Friday, October 17, 2014

Contact form 7 telephone number digits restriction modification

If you use the contact form 7 plugin (version 4.0) for contact information gathering on your wordpress site and want to restrict the minimum and maximum digits a user enters but without sacrificing the brackets, spaces or plus sign here's how I found out to do this.

In the file: formatting.php line 153 (found under /your/host/wordpressdir/wp-content/plugins/contact-form-7/includes )
comment out the original line like so (in case you want to revert the changes):
//$result = preg_match( '/^[+]?[0-9() -]*$/', $tel );

and add the following:
$pattrn = array( " ", "\r", "\n", "-", ".", "(", ")", "_", "'", "`", "+");
$newphone = str_replace( $pattrn , '' , $tel );
if( strlen( $newphone ) == 10 && preg_match( '/^[0-9]*$/', $newphone )) $result = true;
else $result = false;

Now the user must enter 10 digits no matter if the formatting is +(123) 123 - 1231 with or without spacing and brackets and even underscore or plus sign.

In case anyone is wondering why this is required is because sometimes users might omit their area code (the first three digits) and it becomes very hard to guess what it might be to dial it.

I'm sure this part can be improved because the digits are hard coded and there might be other countries that require more or less so if this was setup from admin and input it there but I don't know how to do this yet and don't require so if someone wants to improve or any feedback let me know in the comments below.

Also check out my previous article if you need to send the data to a database of your own here.

Thanks for visiting.

Wednesday, August 20, 2014

script to copy user files to flash usb drive silently and automatically

Came across an interesting request recently and though I'd have to do my own batch scripting but quick search found me this site: http://www.instructables.com/id/How-to-make-flash-drive-that-copys-users-files-si/ so there's really not much more to explain, they did an excellent job I will just provide you with the files.

download this: archive.zip , extract and place all the files at the root (right at the top) of the USB flash or hard drive you want to use to gather your data. As an added bonus you can easily rename instead of the default name (usually the drive's manufacturer's name) to something like MARIO.

Now all you have to do is run launch.bat if the auto run doesn't do it's job (windows 7 and 8 probably don't do it automatically any more)

Of course as the site warns you shouldn't use this for anything illegal, this is informational use only and goes to show that you should have good physical security of your hardware at all times if you have important data on your computer or disable the USB connections on your computer.

Leave comments about any feedback.

Thank you for visiting!

Thursday, May 29, 2014

Questions about Google self driving car

As all the fuss is about the new two passenger Google driver-less car there are many questions yet to be answered.

I thought I'd ask them now and search for answers later:

  • Who will get the first one hundred cars? 
  • What are the specs? I.e horsepower, range on battery, any air bags or other safety? Etc 
  • How does calling and setting locations work? Is Google maps involved? Maybe the new ubr integration? where can the car go? i.e. drivethrough? 
  • Is there going to be more apps connected? i.e. can you listen to music or watch youtube or netflix, etc
  • How does payment work? And pretty important how much does it cost? Assuming less than traditional taxis would be good competitive edge. 
  • Payment methods? maybe cryptocurrencies like bitcoin, etc
  • What kind of regulation is there or will there be? Does it simply pass a driver license to say it works? 
  • How many rides or how long can a customers retain the car? for example if I want to run errands could I stop and go in to the store and the car will wait? etc

Any more questions that should be interesting?