<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>David Pratt</title> <atom:link href="http://daipratt.co.uk/feed/" rel="self" type="application/rss+xml" /><link>http://daipratt.co.uk</link> <description>Concerned about Website Construction &#38; SEO</description> <lastBuildDate>Thu, 17 May 2012 19:14:00 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Exporting data from SQL Server Express 2005 to CSV using PHP</title><link>http://daipratt.co.uk/exporting-data-sql-server-2005-express-csv-php-mssql/</link> <comments>http://daipratt.co.uk/exporting-data-sql-server-2005-express-csv-php-mssql/#comments</comments> <pubDate>Fri, 10 Jun 2011 08:55:28 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[db]]></category> <category><![CDATA[php]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1586</guid> <description><![CDATA[A tutorial that explains how to connect to a SQL Server 2005 Express database from a PHP script, and then output a CSV file of a table within that database.]]></description> <content:encoded><![CDATA[<p>Annoyingly, one of the limitations of SQL Server Express 2005 is that it doesn&#8217;t allow you to export data as CSV, or any other format (bar SQL) for that matter. This is fine is you have a small dataset as you can just copy the data out of the results pane, and then paste into a spreadsheet program to save in the format of your choosing. If like me on the other hand whereby you have a massive result set of +100k records then that doesn&#8217;t quite work.</p><p>Googleing around for a solution I came across a couple of different options (using DTS Wizard, another using a 3rd party app etc.), but nothing looked like it could do the job I was after &#8211; basically I wanted a no-fuss phpmyadmin style export to csv option. Dissatisfied with the options out there, I ended up deciding to write a php script that would connect to the db using the mssql php extension, get the required data, and automatically spit out a csv file. Writing the script was the easy part, the difficult bit was getting PHP to talk to the database due to an incompatibility between the SQL Server Express 2005 db driver and the php extension. To get PHP to play nicely with MS SQL Server 2005 Express you need to resolve this driver problem, here&#8217;s how you do it:</p><ol><li>Search your computer for ntwdblib.dll</li><li>If you right click on each occurance of the file (I had one in the php, apache and system32 directories)</li><li>Hit the details tab, and if any of them say a number that ISN&#8217;T <strong>2000.80.194.0</strong> then you need to <a
href="http://www.google.co.uk/search?q=2000.80.194.0+ntwdblib.dll+download">download that version</a> of the file.</li><li>Once you have downloaded the file, you need to replace all of the existing ntwdblib.dll files with the one you have downloaded, or figure out which one your php version is using. Obviously, make back-ups first.</li></ol><p>A more in depth tutorial on how to do this can be found<br
/> <href="http://dba.fyicenter.com/faq/sql_server_2/ntwdblib_dll_SQL_Server_Client_Libarary_DLL.html">here</a>.</p><p>Here&#8217;s the code for connecting to the db, generating a CSV file and outputting to file in the simplest way I could come up with:</p><pre class="brush: php">
//MSSQL connection string details.
$dbhost = "LOCALHOST\SQLEXPRESS";
$dbuser = 'dave';
$dbpass = 'password';
$dbname = 'target_db_name';
$db = mssql_connect($dbhost, $dbuser, $dbpass);
if (!$db) {
	die('Could not connect to mssql - check your connection details &#038; make sure that ntwdblib.dll is the right version!');
}
$db_selected = mssql_select_db($dbname, $db);
if (!$db_selected) {
	die('Could not select mssql db');
}
$sql = "SELECT * FROM target_database_table_name";
$results = mssql_query($sql, $db);
//Generate CSV file - Set as MSSQL_ASSOC as you don't need the numeric values.
while ($l = mssql_fetch_array($results, MSSQL_ASSOC)) {
	foreach($l AS $key => $value){
		//If the character " exists, then escape it, otherwise the csv file will be invalid.
		$pos = strpos($value, '"');
		if ($pos !== false) {
			$value = str_replace('"', '\"', $value);
		}
		$out .= '"'.$value.'",';
	}
	$out .= "\n";
}
mssql_free_result($results);
mssql_close($db);
// Output to browser with the CSV mime type
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=table_dump.csv");
echo $out;
</pre><p><i>For reference, I&#8217;m using PHP 5.2.3 on wamp &#8211; the driver fix mentioned above didn&#8217;t seem to work with 5.3.*</i></p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/exporting-data-sql-server-2005-express-csv-php-mssql/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Wget examples for a Linux newbie</title><link>http://daipratt.co.uk/wget-tricks-tips/</link> <comments>http://daipratt.co.uk/wget-tricks-tips/#comments</comments> <pubDate>Fri, 06 May 2011 07:42:06 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[command line]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[wget]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1481</guid> <description><![CDATA[A collection of wget examples, tips and tricks that showcase some of the interesting things that you can do with it.]]></description> <content:encoded><![CDATA[<p>Having ditched Windows entirety at the start of the year and made the switch to Linux (Ubuntu flavour), I&#8217;ve discovered a range of tools that would have come in very handy in my days as a Windows user. One of those tools is called <a
href="http://www.gnu.org/software/wget/">wget</a>. Wget is basically a bit of software that allows you to download files from webservers via the command line. That in itself doesn&#8217;t sound very exciting, but when you start wielding some of its options, you can do some interesting things with it. To showcase some of the things that wget can do, here is a collection of one-liners that you might find interesting or useful &#8211; I haven&#8217;t come up with them all myself, mostly collected them from around the net from forums and places such as <a
href="http://www.commandlinefu.com">command line fu</a>:</p><p>[To understand what the options after the wget command, you'll need to refer to the <a
href="http://www.gnu.org/software/wget/manual/wget.html">wget documentation</a>]</p><h4>Download a single file</h4><p>Start with an easy one!</p><pre class="brush: plain">
wget http://www.example.com/archive.zip
</pre><h4>Download an entire website</h4><p>If you don&#8217;t want to be courteous, then you can ignore the &#8211;random-wait switch if you don&#8217;t mind running the risk of getting banned. If you only want to download the site to a certain depth, then you can use the switch <i>-l</i> followed by a number to indicate the depth e.g. &#8220;-l 2&#8243; to a depth level of 2. Downloading an entire website can also be achieved using the <i>-mirror</i> parameter.</p><pre class="brush: plain">
wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
</pre><h4>Download an entire ftp directory using wget</h4><p>Handy if you don&#8217;t want to spark up an FTP client.</p><pre class="brush: plain">
wget -r ftp://username:password@ftp.example.com
or
wget --ftp-user=username --ftp-password=password example.com
</pre><h4>Check for broken links using wget as a spider</h4><p>This is the command line equivalent of using a Windows based tool called Xenu Link Sleuth. It will spider an entire website, ignoring the robots.txt and generate a log file of all broken links. Handy.</p><pre class="brush: plain">
wget --spider -o wget.log -e robots=off --wait 1 -r -p http://www.example.com
</pre><h4>Get server information</h4><pre class="brush: plain">
wget -S -q -O - http://www.example.com | grep ^Server
</pre><h4>Diff remote webpages using wget</h4><pre class="brush: plain">
diff <(wget -q -O - http://www.example.com) <(wget -q -O - http://www.example2.com)
</pre><h4>Schedule a download</h4><p>If you've got a big file to download, you could schedule getting it in this manner. Couple this command with a cron job and you could feasibly create a snapshot of a website at given time intervals.</p><pre class="brush: plain">
echo 'wget http://www.example.com' | at 01:00
</pre>]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/wget-tricks-tips/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Using FB.api to make a full post to a users wall</title><link>http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/</link> <comments>http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/#comments</comments> <pubDate>Sat, 25 Sep 2010 22:43:43 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[facebook]]></category> <category><![CDATA[javascript]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1367</guid> <description><![CDATA[The JavaScript snippet you need to make a full wall post (including image) to a users wall using the Facebook JavaScript API.]]></description> <content:encoded><![CDATA[<p>I just thought I&#8217;d make another quick post about the Facebook Graph API seen as there seems to be so little documentation and examples for it.  The below example shows you how to make a full wall post with message, name, description, link, picture and caption to the wall of a Facebook user using JavaScript to call the <a
href="http://developers.facebook.com/docs/reference/javascript/FB.api">Facebook FB.api</a>.</p><p>So, assuming that you have an authenticated session, here&#8217;s what you need to do:</p><pre class="brush: javascript">
var params = {};
params['message'] = 'Message';
params['name'] = 'Name';
params['description'] = 'Description';
params['link'] = 'http://apps.facebook.com/summer-mourning/';
params['picture'] = 'http://summer-mourning.zoocha.com/uploads/thumb.png';
params['caption'] = 'Caption';
&nbsp;
FB.api('/me/feed', 'post', params, function(response) {
  if (!response || response.error) {
	alert('Error occured');
  } else {
	alert('Published to stream - you might want to delete it now!');
  }
});
</pre><p>If you do this right you should get something like this appearing:<br
/> <img
src="http://daipratt.co.uk/wp-content/uploads/2010/09/wall-post.png" alt="Showing a full post to the Facebook wall" title="wall-post" width="536" height="157" class="alignnone size-full wp-image-1375" /></p><p>Spamtastic.</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Create a Facebook page that shows a different version to those that &#8220;like&#8221; it</title><link>http://daipratt.co.uk/facebook-different-page-like/</link> <comments>http://daipratt.co.uk/facebook-different-page-like/#comments</comments> <pubDate>Fri, 17 Sep 2010 07:58:14 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[facebook]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1293</guid> <description><![CDATA[How to show one of version of a Facebook fan/tab page to those people who "like" it, and another to those who are yet to "like" it.]]></description> <content:encoded><![CDATA[<p>Continuing on the Facebook theme from by previous post about how to <a
href="/facebook-api-upload-photo/">create a Facebook photo album and insert photos into it</a> using PHP, I thought I&#8217;d share another Facebook technique that I&#8217;ve used a few times recently.  That is, one of showing one version of a Facebook fan/tab page to those people who &#8220;like&#8221; it, and another to those who are yet to &#8220;like&#8221; it.  I won&#8217;t talk about why you would want to do this here, I&#8217;ll just show you how&#8230;</p><p>Assuming that you have installed the Facebook static FBML application on your fan page, and you are on the page where you enter your source code, drop in the following (but obviously replace <em>yourdomain</em> with your own server address):</p><pre class="brush:php">
&lt;link rel="stylesheet" type="text/css" href="http://yourdomain.com/stylesheet.css?v=1.1" /&gt;
&lt;div id="wrapper"&gt;
	&lt;fb:visible-to-connection&gt;
		&lt;img src="http://yourdomain.com/thanks.jpg" alt="Thanks!" width="520" height="400" /&gt;
		&lt;fb:else&gt;
			&lt;div id="non-like"&gt;&lt;img src="http://yourdomain.com/please-like-this.jpg" alt="Like!" width="520" height="400" /&gt;&lt;/div&gt;
		&lt;/fb:else&gt;
	&lt;/fb:visible-to-connection&gt;
&lt;/div&gt;
</pre><p>Include the following CSS in your stylesheet:</p><pre class="brush:css">
#wrapper{position:relative;}
#non-like{position:absolute; top:0; left:0;}
</pre><p>You can flesh out the above example to make a richer example, but it should be enough to get you started. When you are developing the page, remember that if you make changes to your stylesheet while you are working on the page, increment the stylesheet version number otherwise your changes won&#8217;t be picked up in Facebook due to their aggressive caching policy!  The other gotcha is if your mark-up isn&#8217;t valid &#8211; if that is the case then the mark-up in between the <fb:else> will probably not render. Oh, and if you are the admin of the page then it won&#8217;t work properly either, so be sure to test the page with a Facebook login that doesn&#8217;t have admin privileges for the fan page you are editing.</p><p><a
href="http://www.facebook.com/zoochaonline?v=app_4949752878" target="_blank">Here&#8217;s an example</a>&#8230; don&#8217;t be shy in liking it! ;-)</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/facebook-different-page-like/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Create photo albums and upload photos using the Facebook Graph API</title><link>http://daipratt.co.uk/facebook-api-upload-photo/</link> <comments>http://daipratt.co.uk/facebook-api-upload-photo/#comments</comments> <pubDate>Sat, 11 Sep 2010 16:08:48 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[facebook]]></category> <category><![CDATA[php]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1295</guid> <description><![CDATA[An example using the Facebook Graph API that shows how to create a photo album and insert photos into it. The example uses PHP.]]></description> <content:encoded><![CDATA[<p>UPDATE: Thanks to some of the comments below I have been able to revise the code &#8211; thanks Luke &#038; Guilherme</p><p>I thought I&#8217;d share some recent learning&#8217;s with using the <a
href="http://developers.facebook.com/docs/api">Facebook Graph API</a> as there seems to be so few examples out there about how to utilise various aspects of its functionality.  I will explain how to create a photo album and then insert a photo into it using PHP.</p><p>The code example assumes that you have already generated an authenticated session and have the correct permissions (read_stream, publish_stream, photo_upload, user_photos, user_photo_video_tags). If you haven&#8217;t already done so, then there is a <a
href="http://thinkdiff.net/facebook/graph-api-iframe-base-facebook-application-development/">good example here</a> about how to do so and you can read more about the Facebook permissions on the <a
href="http://developers.facebook.com/docs/authentication/permissions">Facebook dev site</a>.</p><p>The following snippet creates a photo album and then uploads a photo into it:</p><pre class="brush: php">
//At the time of writing it is necessary to enable upload support in the Facebook SDK, you do this with the line:
$facebook->setFileUploadSupport(true);
&nbsp;
//Create an album
$album_details = array(
		'message'=> 'Album desc',
		'name'=> 'Album name'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
&nbsp;
//Get album ID of the album you've just created
$album_uid = $create_album['id'];
&nbsp;
//Upload a photo to album of ID...
$photo_details = array(
	'message'=> 'Photo message'
);
$file='app.jpg'; //Example image file
$photo_details['image'] = '@' . realpath($file);
&nbsp;
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
</pre><p>You can add more detail to the created album and photo than I have in the example by using <a
href="http://developers.facebook.com/docs/reference/api/post">additional parameters</a> within the arguments array.</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/facebook-api-upload-photo/feed/</wfw:commentRss> <slash:comments>63</slash:comments> </item> <item><title>Best way to store IP addresses in MySQL</title><link>http://daipratt.co.uk/mysql-store-ip-address/</link> <comments>http://daipratt.co.uk/mysql-store-ip-address/#comments</comments> <pubDate>Tue, 10 Aug 2010 08:53:35 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[php]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1258</guid> <description><![CDATA[It's tempting to store IP addresses in a database as a varchar of length 15 in the absence of a dedicated IPv4 field type in mysql, but that isn't the most efficient way of doing so...]]></description> <content:encoded><![CDATA[<p>It&#8217;s tempting to store IP addresses in a database as a VARCHAR(15) in the absence of a dedicated IP address field type in mysql, but that isn&#8217;t the most efficient way of doing so. The best way that I&#8217;ve come across to store an IPv4 address is to store it as an unsigned integer.  In phpmyadmin you might set up an ip address field so that it looks something like:<br
/><div
id="attachment_1264" class="wp-caption alignnone" style="width: 363px"><a
href="http://daipratt.co.uk/wp-content/uploads/2010/08/phpmyadmin-ip-address-setup.png"><img
src="http://daipratt.co.uk/wp-content/uploads/2010/08/phpmyadmin-ip-address-setup.png" alt="Screenshot of the PHPMyAdmin field setup for an IP address field" title="PHPMyAdmin field setup for IP address field" width="353" height="243" class="size-full wp-image-1264" /></a><p
class="wp-caption-text">Screenshot of the PHPMyAdmin field setup for an IP address field</p></div></p><p>You&#8217;ll realise I&#8217;m sure that you can&#8217;t just add the dotted IP address straight into an INT field without first converting it into a valid format.  For that you&#8217;ll need a PHP function called <a
href="http://php.net/manual/en/function.ip2long.php">ip2long</a> which will convert a string containing an IP dotted address into a integer that can be stored in the INT field.</p><p>Here is a quick example of how you might go about getting the real IP address of a client and then storing and retrieving its value from the mysql DB:</p><pre class="brush: php">
//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
  $ip=$_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
  $ip=$_SERVER['REMOTE_ADDR'];
}
//The value of $ip at this point would look something like: "192.0.34.166"
$ip = ip2long($ip);
//The $ip would now look something like: 1073732954
</pre><p>Now that you have the real IP address of the client converted to the INT format, you can write it into the DB as you normally would:</p><pre class="brush: php">
$sql = "INSERT INTO user(ip) VALUES('$ip')";
$dbQuery = mysql_query($sql,$dbLink);
</pre><p>To retrieve the original IP address from the database you can use the mysql function <a
href="http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-ntoa">INET_NTOA</a> like so:</p><pre class="brush: sql">
SELECT INET_NTOA(ip) FROM 'user' WHERE 1
</pre><p>Alternately you could use the PHP function <a
href="http://www.php.net/manual/en/function.long2ip.php">longtoip</a> to convert the returned INT value into the dotted IPv4 address in the PHP code instead, and you could even add the dotted IP address to the INT field in the db using the mysql funtion INET_ATON.</p><p>Storing IP addresses in this manner is beneficial because it takes less space than storing it as a string.  The other benefit is that lookups are faster because integer comparisons are quicker than string comparisons.</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/mysql-store-ip-address/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Non-standard page size&#8217;s in TCPDF</title><link>http://daipratt.co.uk/tcpdf-page-sizes/</link> <comments>http://daipratt.co.uk/tcpdf-page-sizes/#comments</comments> <pubDate>Wed, 23 Jun 2010 18:11:12 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[php]]></category> <category><![CDATA[tcpdf]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1249</guid> <description><![CDATA[If you need to create a PDF using TCPDF that isn't a standard size (A4, A5, B1, LETTER etc.) then this snippet might help you out: $resolution= array(100, 100);  $pdf->AddPage('P', $resolution);]]></description> <content:encoded><![CDATA[<p>If you need to create a PDF using <a
href="http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf">TCPDF</a> that isn&#8217;t a standard size (A4, A5, B1, LETTER etc.) then it is possible to specify a custom size even though it isn&#8217;t that well documented. To do this you need to pass an array containing the desired width and the height of the PDF instead a formatted parameter such as &#8216;A4&#8242;.  For example:</p><pre class="brush: php">
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
&nbsp;
// add a page
$resolution= array(100, 100);
$pdf->AddPage('P', $resolution);
</pre><p>Make sure you express the height and width in the unit of measurement (pt, px, mm, cm etc.) that you are using as well.</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/tcpdf-page-sizes/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Using Crontab with Plesk to call PHP files</title><link>http://daipratt.co.uk/crontab-plesk-php/</link> <comments>http://daipratt.co.uk/crontab-plesk-php/#comments</comments> <pubDate>Thu, 06 May 2010 18:39:01 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[crontab]]></category> <category><![CDATA[php]]></category> <category><![CDATA[plesk]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1214</guid> <description><![CDATA[How to set up a scheduled job on Plesk that calls a PHP file at an interval of your choosing.]]></description> <content:encoded><![CDATA[<p>Having battled with getting a php file to be called from a scheduled task (a.k.a. a crontab task) using the Plesk interface panel on a Linux box, I thought I&#8217;d share a bit of a how-to on it because I struggled to find anything helpful out there on the topic.</p><p>Here is screen shot of a completed &#8220;Schedule New Task&#8221; form so that you can see what a working configuration looks like:<br
/><div
id="attachment_1219" class="wp-caption alignnone" style="width: 483px"><a
href="http://daipratt.co.uk/wp-content/uploads/2010/05/crontab.png"><img
src="http://daipratt.co.uk/wp-content/uploads/2010/05/crontab.png" alt="Setting up Crontab from within Plesk to load a php file." title="Crontab" width="473" height="389" class="size-full wp-image-1219" /></a><p
class="wp-caption-text">Setting up Crontab from within Plesk to load a php file.</p></div></p><p>The fields on the form look fairly self explanatory to fill out, but the first gotcha for me was how to get it so that the job runs every hour instead of on just one named hour. To get the cron to run every hour you just need to use an asterisk (*), the same technique can be applied for all other time frequencies as well.</p><p>Once you&#8217;ve set the cron to run at the required interval, you will need to tell it what command to call. This isn&#8217;t obvious either.  Firstly what you need to do is call php or state the path to the php folder, then pass it the parameter &#8220;-q&#8221; (to suppress the HTTP header output), and then state the full path of the php file that you want to run e.g.</p><pre class="brush: plain">
php -q httpdocs/cron.php
</pre><p>If you just put the path to the name of the php file that you want to run, then the cron will throw an error.</p><p><em>For reference, I&#8217;m using Plesk 9.5.1 &amp; PHP 5.3</em></p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/crontab-plesk-php/feed/</wfw:commentRss> <slash:comments>31</slash:comments> </item> <item><title>Calculate text width and height with JavaScript</title><link>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/</link> <comments>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/#comments</comments> <pubDate>Thu, 22 Apr 2010 08:43:06 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[css]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[ui]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1123</guid> <description><![CDATA[A tutorial that shows you how to measure the height and width of a text element using JavaScript.]]></description> <content:encoded><![CDATA[<p>Occasionally when putting together an advanced layout it&#8217;s necessary to have a level of control over the UI that can&#8217;t be achieved with CSS alone.</p><p>One situation might be in displaying a place name. Say for instance that place name had to be rendered in block that has a width of 200px, with a height that can flex as necessary to accomodate the content. This won&#8217;t be a problem in 99.9% of situations, but what happens if the place name is Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?! Yes this place <a
href="http://maps.google.co.uk/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch&#038;sll=53.800651,-4.064941&#038;sspn=22.383401,67.631836&#038;ie=UTF8&#038;hq=&#038;hnear=Llanfair+Pwllgwyngyll,+Gwynedd,+United+Kingdom&#038;ll=53.223096,-4.206047&#038;spn=0.17636,0.528374&#038;z=12" target="_blank">does exist</a>! In cases like this you might want to apply a special class name, or maybe dynamically adjust the font-size so that it fits within the allowed container. The consequences of not defending against this situation might be that the layout behaves unpredicatably, breaks, or perhaps some of the word could be hidden by the overflow property in the CSS being set to hidden or something.</p><p>So, should you find yourself in a situation where you need to measure the height and width of a text element, this code might help you:</p><h5>HTML</h5><pre class="brush:php">
&lt;p id="place-name"&gt; Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch&lt;/p&gt;
</pre><h5>CSS</h5><pre class="brush:css">
#place-name{
    position: absolute;
    height: auto;
    width: auto;
}
</pre><h5>JavaScript</h5><pre class="brush:javascript">
var oPlaceName = document.getElementById("place-name");
if (oPlaceName){
	var iHeight = oPlaceName.clientHeight + 1;
	var iWidth = oPlaceName.clientWidth + 1;
	if (iWidth &gt; 200){
		//Deal with the long text.
	}
}
</pre><p>I have prepared a <a
href="/examples/text-width.html" target="_blank">quick standalone example</a> should you want to see this in action.</p><p>A place name might have been a bad example, but it could have quite easily have been any other type of field who&#8217;s length or height you might want explicit control over. Other applications of this that I can think of quickly could be adjusting the font-size of headings so that they never wrap, perhaps adjusting letter spacings so that they have aligned edges, or whatever else the designers .psd file shocks you with! With a clever implementation, this sort of thing could be achieved without the user even noticing, but that&#8217;s a job for someone else!</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>A few things to consider when developing on a public domain</title><link>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/</link> <comments>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/#comments</comments> <pubDate>Sun, 14 Mar 2010 17:07:21 +0000</pubDate> <dc:creator>David Pratt</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[seo]]></category> <guid
isPermaLink="false">http://daipratt.co.uk/?p=1098</guid> <description><![CDATA[To prevent a site being indexed by Google before it is ready for public consumption, there are a couple things that you can do.]]></description> <content:encoded><![CDATA[<p>If you ever find yourself developing a site on a public facing domain, it is always a good idea to have measures in place to prevent search engines indexing it in the event that a stray link enables a search engine spider to find it. A few of the things that you can do are&#8230;</p><p>Ensure the document head of each page has the &#8220;noindex&#8221; meta tag. This statement tells search engine spiders to not index any of the content on the current page.</p><pre class="brush: php">
&lt;meta name="robots" content="noindex" /&gt;
</pre><p>Ensure the document head of each page has the &#8220;nofollow&#8221; meta tag. This statement tells search engine spiders to not follow any links on the page.</p><pre class="brush: php">
&lt;meta name="robots" content="nofollow" /&gt;
</pre><p>Add a rule to the robots.txt file that prevents search engine spiders from accessing the site.</p><pre class="brush:plain">
User-agent: *
Disallow: /
</pre><p>Just remember to remove these measures when you launch the site!</p> ]]></content:encoded> <wfw:commentRss>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
