SyntaxHighlighter

Monday 19 March 2012

How To Dial a Phone Number From a Webpage on an iPhone or Android Device

I always find it a ball ache when I am on a mobile device, see a telephone number on a webpage but it's not clickable to automatically dial the number for me. So if you need to do this on your websites, set up the anchor element as such:

<a href="tel:01234 567 8910">01234 567 8910</a>

Jobs dones! Nice and simple :)

Friday 9 March 2012

How To Call PHP From a Cron in Plesk

Like a lot of people I needed to run a PHP script from a cron (crontab) via the Plesk server admin tool. Simply putting the path to the file (from root) does not run it. The way to do this is by calling the php processor with some parameters. So do the following:

php -q /var/www/vhosts/mywebsite.com/httpdocs/cron/my-file.php

Obviously use the path that relates to your file.

This seems to work for a lot of people, but as my script had includes in it I was getting failure to open stream errors when it was called. So to get round this, I changed the directory prior to the call. So it now looks like this:

cd /var/www/vhosts/ mywebsite.com /httpdocs/cron; php -q  my-file .php

Hey presto, it all works a treat now!



You may need to set permissions on the script to be executed. By default, the task will email the output of the script to you (click the Settings option on the Scheduled Tasks page to change the address - see image below). This can be turned off by adding 2>&1 to the end of the command. making the it look like this:

cd /var/www/vhosts/ mywebsite.com /httpdocs/cron; php -q  my-file .php /dev/null 2>&1

Credit to http://daipratt.co.uk/crontab-plesk-php/ and http://stackoverflow.com/questions/3140675/php-cron-job-including-file-not-working for helping to work this mess out ;)

Friday 2 March 2012

PHP: Last Modified Date of Folder / Directory

It turns out it's really easy to get the the last modified date of a folder/directory using PHP. You use the filemtime() function. It returns a timestamp for us so we would do something like:

$lastModifed = filemtime($dir);
print "Last modified on ".date("Y-m-d H:i:s", $lastModifed );

Labels

.net (7) ajax (1) android (7) apache (1) asp.net (3) asus (2) blogger (2) blogspot (3) c# (16) compact framework (2) cron (1) css (1) data (1) data recovery (2) dns (1) eclipse (1) encryption (1) excel (1) font (1) ftp (1) gmail (5) google (4) gopro (1) html (1) iis (3) internet explorer IE (1) iphone (1) javascript (3) kinect (1) linux (1) macro (1) mail (9) mercurial (1) microsoft (3) microsoft office (3) monitoring (1) mootools (1) ms access (1) mssql (13) mysql (2) open source (1) openvpn (1) pear (2) permissions (1) php (12) plesk (4) proxy (1) qr codes (1) rant (4) reflection (3) regex (1) replication (1) reporting services (5) security (2) signalr (1) sql (11) sqlce (1) sqlexpress (1) ssis (1) ssl (1) stuff (1) svn (2) syntax (1) tablet (2) telnet (3) tools (1) twitter (1) unix (3) vb script (3) vb.net (9) vba (1) visual studio (2) vpc (2) vpn (1) windows (4) woff (1) xbox 360 (1)