<?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>Leading Edge Scripts &#187; Server Administration</title>
	<atom:link href="http://leadingedgescripts.co.uk/category/server-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://leadingedgescripts.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 16 Oct 2009 09:14:32 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Recalculate disk space for a single domain in Plesk</title>
		<link>http://leadingedgescripts.co.uk/server-administration/recalculate-disk-space-for-a-single-domain-in-plesk/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/recalculate-disk-space-for-a-single-domain-in-plesk/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 10:57:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[plesk]]></category>
		<category><![CDATA[quota exceeded]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/?p=241</guid>
		<description><![CDATA[This is a pretty easy one, it&#8217;s useful if a client has gone over their allocated disk space. Occasionally even if they delete everything Plesk still thinks they are over until the nightly cron jobs are re-run.
This command just forces the job to re-run on  a single domain:
/usr/local/psa/admin/sbin/statistics &#8211;calculate-one &#8211;domain-name=Domain_name.com
]]></description>
			<content:encoded><![CDATA[<p>This is a pretty easy one, it&#8217;s useful if a client has gone over their allocated disk space. Occasionally even if they delete everything Plesk still thinks they are over until the nightly cron jobs are re-run.</p>
<p>This command just forces the job to re-run on  a single domain:</p>
<p style="padding-left: 30px;">/usr/local/psa/admin/sbin/statistics &#8211;calculate-one &#8211;domain-name=Domain_name.com</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/recalculate-disk-space-for-a-single-domain-in-plesk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Whitelabel your Plesk web hosts nameservers</title>
		<link>http://leadingedgescripts.co.uk/server-administration/whitelabel-your-plesk-web-hosts-nameservers/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/whitelabel-your-plesk-web-hosts-nameservers/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 17:49:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[hide nameservers]]></category>
		<category><![CDATA[whitelabel nameservers]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/?p=237</guid>
		<description><![CDATA[This post is all about how you can hide your hosting companies name servers. I run a web hosting company, and many of our clients are re-sellers, as you might expect, they don&#8217;t want people knowing who we are, so they want to hide our nameservers.
Incidentally, our nameservers are ns1.leadingedgehosting.co.uk &#38; ns2.leadingedgehosting.co.uk
This post will show [...]]]></description>
			<content:encoded><![CDATA[<p>This post is all about how you can hide your hosting companies name servers. I run a web hosting company, and many of our clients are re-sellers, as you might expect, they don&#8217;t want people knowing who we are, so they want to hide our nameservers.</p>
<p>Incidentally, our nameservers are ns1.leadingedgehosting.co.uk &amp; ns2.leadingedgehosting.co.uk</p>
<p>This post will show you how to set up your DNS so you can have ns1.yourdomain.com &amp; ns2.yourdomain.com whatever your web hosts nameservers are.</p>
<p>We use the <a href="http://www.parallels.com/plesk/">Plesk control panel</a> so I&#8217;m going to demonstrate how to do this using that, but in principle, as long as you have access to your own DNS records you should be able to do this using any control panel.</p>
<h2>Step 1.</h2>
<p>Create two new A-records on your nameservers for your domain as follows:</p>
<p><a href="http://www.leadingedgescripts.co.uk/wp-content/2008/11/nameservers.gif"><img class="alignnone size-medium wp-image-238" title="nameservers" src="http://www.leadingedgescripts.co.uk/wp-content/2008/11/nameservers-300x24.gif" alt="" width="300" height="24" /></a></p>
<p>These should point to your nameserver IPs.</p>
<h2>Step 2.</h2>
<p>Register your Glue records with your domain registrar. They will ask you for the IP addresses of your nameservers, these should match your IPs as set up above, and that&#8217;s it.</p>
<p>Your domain registrar may have the facility to register Glue records via their control panel, but many don&#8217;t, so you may have to email them.</p>
<p>Now you should be able to have ns1.yourdomain.com and ns2.yourdomain.com and use your web hosting companies nameservers as if they were your own!</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/whitelabel-your-plesk-web-hosts-nameservers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Full Path To A Virtual Host Directory</title>
		<link>http://leadingedgescripts.co.uk/server-administration/find-the-full-path-to-a-virtual-host-directory/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/find-the-full-path-to-a-virtual-host-directory/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 09:17:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[getcwd()]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/?p=167</guid>
		<description><![CDATA[This is a quick one, but hopefully some people will find it useful!
This simple script normally returns the full Linux path to your files, e.g.
/var/www/vhosts/leadingedgescripts.co.uk/httpdocs/
Simply create a PHP file with the following contents:
&#60;?php
echo getcwd();
?&#62;
Copy it to your PHP enabled server (using FTP/SFTP etc) and visit it in your web browser.
This tidbit of information can be [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick one, but hopefully some people will find it useful!</p>
<p>This simple script normally returns the full Linux path to your files, e.g.</p>
<p style="padding-left: 30px;">/var/www/vhosts/leadingedgescripts.co.uk/httpdocs/</p>
<p>Simply create a PHP file with the following contents:</p>
<p style="padding-left: 30px;">&lt;?php</p>
<p style="padding-left: 30px;">echo getcwd();</p>
<p style="padding-left: 30px;">?&gt;</p>
<p>Copy it to your PHP enabled server (using FTP/SFTP etc) and visit it in your web browser.</p>
<p>This tidbit of information can be very useful when configuring a website on a new server.</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/find-the-full-path-to-a-virtual-host-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scary PHP Functions You Should Disable</title>
		<link>http://leadingedgescripts.co.uk/server-administration/scary-php-functions-you-should-disable/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/scary-php-functions-you-should-disable/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:49:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[disable functions]]></category>
		<category><![CDATA[php functions]]></category>
		<category><![CDATA[php security]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/?p=143</guid>
		<description><![CDATA[A few months back we completed a security update on one of our main servers and whilst we were performing the update we realised that there is a distinct lack of information out there concerning the security of PHP functions, and no good lists of functions that should be banned or switched off.
When you install PHP, it [...]]]></description>
			<content:encoded><![CDATA[<p>A few months back we completed a security update on one of our main servers and whilst we were performing the update we realised that there is a distinct lack of information out there concerning the security of PHP functions, and no good lists of functions that should be banned or switched off.</p>
<p>When you install PHP, it doesn&#8217;t make a huge amount of recommendations about which functions you should ban on your servers. Although it basically does come out of the box in safe mode, which is great, as a web host trying to offer the best service possible, we like to offer our customers the choice of using PHP&#8217;s safe mode or not. I know that as a developer it&#8217;s a real pain to be forced to deal with things like magic quotes when you already have tight methods of blocking SQL injection, XSS attacks etc.</p>
<p>So, as a hosting company, we want to leave things as flexible as possible for developers, it&#8217;s critical for us to know that our customers can&#8217;t write PHP code that could lead to our server being left wide open to attack.</p>
<p>
<!-- Begin Google Adsense code -->
<script type="text/javascript"><!--
google_ad_client = "pub-4904188713812219";
/* 468x60, created 02/11/08 */
google_ad_slot = "9286450703";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Google Adsense code -->
</p>
<p>So, being diligent web hosts we searched high and low for a decent list of PHP functions that we ought to ban, and surprisingly couldn&#8217;t really find any decent lists.</p>
<p>So, for anyone wondering what functions to ban, here is our list of PHP functions you should definitely not allow your customers to use!</p>
<p>exec, system, passthru, readfile, shell_exec, escapeshellarg, proc_close, proc_open, ini_alter, dl, parse_ini_file, show_source, popen, pclose, pcntl_exec, proc_get_status, proc_nice, proc_terminate, pfsockopen, posix_kill, posix_mkfifo, openlog, syslog, escapeshellcmd, apache_child_terminate, apache_get_env, apache_set_env, apache_note, virtual, error_log, openlog, syslog, readlink, symlink, link, highlight_file, closelog, ftp_exec, posix_setpgid, posix_setuid, posix_setsid, posix_setegid, posix_seteuid, posix_getpwnam, posix_ctermid, posix_uname, posix_getegid, posix_geteuid, posix_getpid, posix_getppid, posix_getpwuid</p>
<p>I&#8217;m not going to go into details here, but if you&#8217;re in for a fright, look these functions up (especially the posix ones) on the www.php.net website, you&#8217;ll be very scared!</p>
<p>This list may be overkill, but keep in mind, we&#8217;re aiming this at the shared server market. If anyone has any other functions they think should be banned, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/scary-php-functions-you-should-disable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating A New Subversion User on Windows</title>
		<link>http://leadingedgescripts.co.uk/server-administration/creating-a-new-subversion-user-on-windows/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/creating-a-new-subversion-user-on-windows/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:37:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/?p=137</guid>
		<description><![CDATA[This post assumes that you&#8217;ve installed Subversion on a Windows server, if you haven&#8217;t I&#8217;m planning on writing a detailed post about how to install Subversion and get it all up and running so I&#8217;ll try and get that done asap. It also pretty much assumes that you are using the Wonderful (yes that&#8217;s a capital [...]]]></description>
			<content:encoded><![CDATA[<p>This post assumes that you&#8217;ve installed Subversion on a Windows server, if you haven&#8217;t I&#8217;m planning on writing a detailed post about how to install Subversion and get it all up and running so I&#8217;ll try and get that done asap. It also pretty much assumes that you are using the Wonderful (yes that&#8217;s a capital W) <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> Anyway, here&#8217;s how to add a Subversion user:</p>
<p>Go to the command prompt and find your Apache installation, and the find the Apache binary files &#8211; on my Windows server it&#8217;s here:</p>
<p style="padding-left: 30px;"><span style="white-space:pre"> </span>C:\Program Files\xampp\apache\bin\</p>
<p>
<!-- Begin Google Adsense code -->
<script type="text/javascript"><!--
google_ad_client = "pub-4904188713812219";
/* 468x60, created 02/11/08 */
google_ad_slot = "9286450703";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Google Adsense code -->
</p>
<p>If you look in this folder, you should be able to see a file called: htpasswd.exe . That&#8217;s the file we&#8217;re going to use to generate our Subversion username / password combo. Now, assuming that your XAMPP install is similar to mine, you should have a \conf\ folder located at the same level as the \bin\ folder :</p>
<p style="padding-left: 30px;"><span style="white-space:pre"> </span>C:\Program Files\xampp\apache\bin\</p>
<p style="padding-left: 30px;"><span style="white-space:pre"> </span>C:\Program Files\xampp\apache\conf\</p>
<p>If you look in this folder, you &#8220;may&#8221; have a file called svnusers.conf &#8211; this is where the Subversion usernames / passwords are stored.</p>
<p>Assuming that&#8217;s the case, and you are still in your \bin\ folder, issue the following command:</p>
<p style="padding-left: 30px;"><span style="white-space:pre"> </span>htpasswd -m ..\conf\svnusers.conf username </p>
<p>(replacing username with your desired username of course&#8230;)</p>
<p>You will be asked to enter a password twice, do this and your Subversion user should be added into svnusers.conf for you. Now, assuming that that was successful, you need to edit svnaccess.conf to give the correct permissions to your new user.</p>
<p>For those of you wondering where svnaccess.conf is located &#8211; it should be in the same folder as svnusers.conf. Edit svnaccess.conf using a text editor (<a href="http://notepad-plus.sourceforge.net/">Notepad++</a> or <a href="http://www.textpad.com/">Textpad</a> are great editors that I highly recommend!)</p>
<p>You should see something looking a bit like this:</p>
<p style="padding-left: 30px; ">[groups]<br />
admins = User1, User2<br />
ourdevelopers = User3, User4</p>
<p style="padding-left: 30px; ">[/]<br />
#give admins read / write access to all repositories<br />
@admins = rw<br />
@ourdevelopers = r </p>
<p>This should be fairly self explanatory, but just for completeness, you need to add your user to a group, and then give that group appropriate permissions to your repositories &#8211; such as rw (read write).</p>
<p>That&#8217;s it! Your new user should be added to your Windows Subversion server.</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/creating-a-new-subversion-user-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install HSBC CPI credit card processing on Linux</title>
		<link>http://leadingedgescripts.co.uk/server-administration/install-hsbc-cpi-credit-card-processing-on-linux/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/install-hsbc-cpi-credit-card-processing-on-linux/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 17:46:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HSBC CPI]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[CPI]]></category>
		<category><![CDATA[HSBC]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/wp/?p=13</guid>
		<description><![CDATA[UPDATE: I have written some more information about setting up the HSBC CPI using the Java method rather than the C method outlined below.
I ran into a problem recently where a client of mine could not install the HSBC credit card payments, despite his best efforts at following the CPI specification document HSBC provided.
To cut [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: I have written some <a href="http://www.leadingedgescripts.co.uk/hsbc-cpi/how-to-set-up-the-hsbc-cpi-integration-part-two-the-java-method/">more information about setting up the HSBC CPI</a> using the Java method rather than the C method outlined below.</p>
<p>I ran into a problem recently where a client of mine could not install the HSBC credit card payments, despite his best efforts at following the CPI specification document HSBC provided.</p>
<p>To cut a long(ish) story short, he ended up asking me to take a look at it. Since I managed to figure out the problem, and noticed that the HSBC documentation is somewhat lacking to say the least&#8230; (and the HSBC support staff don’t seem to know this either!) I thought I’d give something back by letting you know how to get this thing working on a Linux server. Sorry, anyone using any other type of server, I can’t help.</p>
<p>
<!-- Begin Google Adsense code -->
<script type="text/javascript"><!--
google_ad_client = "pub-4904188713812219";
/* 468x60, created 02/11/08 */
google_ad_slot = "9286450703";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Google Adsense code -->
</p>
<p>Right, to begin with you need to get all the files that HSBC send you. For completeness I’ve copied the text right out of the CPI Specification document below:</p>
<p><q></q></p>
<h4>Linux</h4>
<ul>
<li>Copy sample.html to a web enabled directory.</li>
<li>Copy OrderHash.e to a web enabled directory with execute permissions and without &#8220;directory browse&#8221; permissions (the pages will need to be able to read from and write to a file in the local directory).</li>
<li>Copy results.e to a secure (https) web enabled directory with execute permissions and without &#8220;directory browse&#8221; permissions (the pages will need to be able to read from and write to a file in the local directory).</li>
<li>Add the path to libCcCpiTools.so to the LD_LIBRARY_PATH environment variable (either by suitable file location, or direct addition). It may be necessary for a merchant to speak to their host regarding suitable location / installation of this file.</li>
<li>The executable sample files look for the shared secret in a file called ss.txt within the same folder.</li>
</ul>
<p>Lets take this one step at a time.</p>
<p>• Copy sample.html to a web enabled directory.</p>
<p>Ok, why this is the first step, I don&#8217;t know, but it’s quite correct, just create a folder in your web space (or put it into the root of the website) and copy this file over. You don’t need to do anything special with this file just yet.</p>
<p>• Copy OrderHash.e to a web enabled directory with execute permissions and without &#8220;directory browse&#8221; permissions (the pages will need to be able to read from and write to a file in the local directory).</p>
<p>Ok, again, this is strange thing to ask for at the beginning of the document in my opinion, but that doesn’t matter too much. What REALLY DOES MATTER is the essential information that is missing here!!!</p>
<p><strong>Copy this file into your CGI-BIN folder!</strong> I could not get this to work in any other folder, it needs to be located in your CGI-BIN (yes I know I’ve repeated myself).</p>
<p>Several people seem to have had problems with the CGI-BIN, I should explain, you don’t just create a folder on your server called /CGI-BIN/ you need to tell your Apache web server to use CGI scripts, instructions on this can be found here: <a href="http://httpd.apache.org/docs/1.3/howto/cgi.html">http://httpd.apache.org/docs/1.3/howto/cgi.html</a> – If your server already has a folder called /CGI-BIN/ then it probably already knows how to execute CGI scripts.</p>
<p>Then <strong>set the permissions for this file to 755</strong></p>
<p>That information alone should be enough to help to figure out this (in my opinion) poorly documented system. Anyway, on with the rest:</p>
<p>• Copy results.e to a secure (https) web enabled directory with execute permissions and without &#8220;directory browse&#8221; permissions (the pages will need to be able to read from and write to a file in the local directory).</p>
<p>Again, this file <strong>must be placed in the CGI-BIN</strong> folder in your web space, <strong>and have 755 permissions.</strong></p>
<p>• Add the path to libCcCpiTools.so to the LD_LIBRARY_PATH environment variable (either by suitable file location, or direct addition). It may be necessary for a merchant to speak to their host regarding suitable location / installation of this file.</p>
<p>What? I hear you asking. Well, don’t worry all they want you to do is ask your web host to install the libCcCpiTools.so binary file on your web hosts server &#8230; Not asking much then! anyone using a normal web host won&#8217;t be allowed to use this. Make sure your host will allow you to install this file.  The server administrator should be able to install this and setup the LD_LIBRARY_PATH for you. If they can, you can also get them to test that the libCcCpiTools.so file is working using the ‘testhash.e’ file that HSBC kindly supply. If that works, then we’re in business.</p>
<p>• The executable sample files look for the shared secret in a file called ss.txt within the same folder.</p>
<p>What? the same folder as what? What they hell are they talking about??? Well, the missing text is &#8230; within the same folder as the OrderHash.e file (your CGI-BIN, if you hadn’t figured that out.) You need to copy your shared secret into this SS.txt file.</p>
<h4>So you think that’s it?</h4>
<p>We’re almost there now, just some more missing information to fill you in on.</p>
<p>This one isn’t even covered in the <a href="http://www.leadingedgescripts.co.uk/downloads/CPI%20Specification.pdf">CPI specification</a> at all.</p>
<p><strong>Now you have to edit the sample.html file.</strong></p>
<p>Open up the sample.html using your favourite HTML editor, you should see something similar to the following:</p>
<pre>&lt;FORM name="cpiForm" action="http://www.yourdomain.com/cgi-bin/OrderHash.e" method="POST" onSubmit="singleSubmit(this)"&gt;
	&lt;INPUT TYPE="submit" NAME= "submitButton" VALUE="Submit"&gt;

	&lt;INPUT TYPE="button" NAME= "resetButton" VALUE="Reset" onClick="this.form.reset();resetDynamicFields();"&gt;

	&lt;!-- Fill in the VALUE attribute below with the URL to the CPI. --&gt;
	&lt;INPUT type="hidden" name="CpiUrl" value="https://www.cpi.hsbc.com/servlet"&gt;
	&lt;BR&gt;
	&lt;TABLE&gt;
	&lt;TR&gt;&lt;TD&gt;OrderId:&lt;/TD&gt;&lt;TD&gt;&lt;INPUT type="text" name="OrderId" value=""&gt;&lt;/TD&gt;&lt;/TR&gt;

	&lt;TR&gt;&lt;TD&gt;TimeStamp:&lt;/TD&gt;&lt;TD&gt;&lt;INPUT type="text" name="TimeStamp" value=""&gt;&lt;/TD&gt;&lt;/TR&gt;
	&lt;TR&gt;&lt;TD&gt; &lt;/TD&gt;&lt;/TR&gt;

	&lt;!-- Fill in the VALUE attribute below with the URL to the Results sample. --&gt;

	&lt;TR&gt;&lt;TD&gt;CpiReturnUrl:&lt;/TD&gt;&lt;TD&gt;&lt;INPUT type="text" name="CpiReturnUrl" value="https://www.yourdomain.com/cgi-bin/Results.e"&gt;&lt;/TD&gt;&lt;/TR&gt;</pre>
<p style="text-align: left;">Edit the bits I have highlighted in red so that they point to the files in your CGI-BIN. (Like I have done above.)</p>
<h4>Now you’re nearly done!</h4>
<p>Now, if you open up the sample.html file in your browser, you should be able to click submit, open OrderHash.e, click on Submit again and be taken through to the HSBC online ordering service.</p>
<p><strong>OK great, but my web host won&#8217;t allow me to use exec().</strong></p>
<p>If you’re on a shared server, for one thing, you’ve been lucky to get this far, most web hosts who run shared servers will not install the libCcCpiTools.so shared object. If yours did, you may not need this next bit of information. For those who do, now you’ll be starting to think to yourself, well yeah that&#8217;s great but how the hell do I customise these pages? I don’t want my customers looking at pages that say &#8216;Sample Order Hash Page&#8217; (or whatever it says). So how am I meant to get a valid order hash from OrderHash.e, without sending my customers via the OrderHash.e file?</p>
<p>Well, now you’re expected to be able to execute the OrderHash.e file. <strong>Nice System &#8230;</strong></p>
<p>Excuse me HSBC, but most shared hosts don&#8217;t allow me execute random binary files on their server &#8230;</p>
<p>I run a small shared hosting server with a colleague, for security reasons (good reasons) we don’t allow use of the PHP exec() function, it&#8217;s simply too dangerous</p>
<p>So when I was asked to find a way around this using PHP on my server without using the exec() function, at first I was stumped. But here’s how I got around the issue (there is possibly another way using curl, but I don’t know it, so this was my solution &#8230;)</p>
<p><strong>PHP Code:</strong></p>
<pre><code>$postdata = array2String($_POST);

$fp = fsockopen("www.yourdomain.com", 80);

if (!$fp)
{
	echo "Couldn't open the connection to OrderHash.e file";
}
else
{
	/***************************
	|lets build our post request
	***************************/
	$out = "POST /cgi-bin/OrderHash.e HTTP/1.1\r\n";
	$out .= "Host: www.yourdomain.com\r\n";
	$out .= "Accept:text/xml,application/xml,application/zhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
	$out .= "Accept-Language: en\r\n";
	$out .= "Accept-Encoding: gzip,deflate\r\n";
	$out .= "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
	$out .= "Keep-Alive: 300\r\n";
	//$out .= "Referer: http://www.yourdomain.com/hsbc/sample.html\r\n";
	$out .= "Content-Type:application/x-www-form-urlencoded\r\n";
	$out .= "Content-Length: ". strlen($postdata) ."\r\n";
	$out .= "Connection: close\r\n\r\n";
	$out .= $postdata;

	/*****************************
	|This passes our POST headers
	|to the OrderHash.e form
	*****************************/
	fwrite($fp, $out);
	...

			</code></pre>
<p>Here is a copy of the <a href="http://www.leadingedgescripts.co.uk/downloads/hsbc_php.zip">full PHP script</a>.</p>
<p>All credit to Ed Fowler, who ran up against the same problem as I did and came up with this version using Perl. It&#8217;s based on the same concept as my PHP script, and has the same pre-requisite (that you can generate a valid order hash). But I&#8217;m pleased to be able to offer the Perl version as well (Thanks Ed!) <a href="http://www.leadingedgescripts.co.uk/downloads/hsbc_perl.zip">full Perl script</a></p>
<p>Why not take a look at Eds site: <a href="http://www.abodeHIP.co.uk/">www.abodeHIP.co.uk</a></p>
<hr /><em>Ok</em>, I&#8217;ve noticed that some of you who&#8217;ve emailed me have had problems understanding the array2String() function that I&#8217;ve mentioned in the code above. I probably should have added this in when I first wrote this page. What this function does is take all the post variables and concatenate them into a string. POST requests (if you could see them (which you can using <a href="http://livehttpheaders.mozdev.org/">LiveHTTPHeaders</a>)) look exactly like GET requests. So if you just turn your $_POST array into a URL safe string, that is what we pass within our HTTP header to the OrderHash.e file.</p>
<p>Our variable $postdata should contain a string looking something like this (cut down) version:</p>
<p>CpiUrl=https%3A%2F%2Fwww.cpi.hsbc.com%2Fservlet&amp;OrderId=123456789&amp;TimeStamp=123456789&amp;CpiReturnUrl=https%3A%2F%2Fwww.yourdomain.com%2Fthanks.php&amp;CpiDirectResultUrl=https%3A%2F%2Fwww.yourdomain.com%2Fcgi-bin%2FResults.e&amp;StorefrontId=UK123456789GBP&amp;</p>
<p>I&#8217;ve also been asked &#8220;what next?&#8221;, well $fp can be treated like a file and read back into your script, if you read it into a string you will have an exact copy of the HTML output of the OrderHash.e file to play with, all you need to do then is strip out the stuff you don&#8217;t want and output the stuff you do. Hope that helps.</p>
<h4>Other sources of helpful stuff to look at</h4>
<ul>
<li>This doesn&#8217;t relate to anything I have written, but someone might find this useful. <a href="http://www.angryrooster.co.uk/software/hsbccpi.php">a tiny Php Module that sits between the HSBC library for generating Order Hash Codes, and PHP.</a></li>
<li>CPI support telephone number: 08456 022880</li>
<li>If you don&#8217;t already have a CGI-BIN or your server isn&#8217;t processing the OrderHash.e as an executable, you probably need to set Apache up to use CGI scripts, instructions on this can be found here:<a href="http://httpd.apache.org/docs/1.3/howto/cgi.html">http://httpd.apache.org/docs/1.3/howto/cgi.html</a></li>
<li>I haven&#8217;t tried this, but you might be able to execute the OrderHash.e file using the PHP backtick operator -&gt; ` (look up how to do this)</li>
</ul>
<p>You can see roughly what I did; open a connection to the OrderHash.e file in the CGI-Bin &amp; send it some POST data via HTTP headers using my fsockopen() connection. Then I retrieve the result, which contains a valid order hash. Then I can do whatever I want with the returned result, which contains, among other things my <strong>valid Order Hash</strong></p>
<p><sub>In order to use this code, you need to have already got your libCcCpiTools.so file installed and have CGI and PHP scripting working. If you do already have the libCcCpiTools.so file installed and a working cgi-bin and PHP, then you should only need my code to get the project finished. You should be able to slot it into any html/css layout with relative ease.</sub></p>
<p>Disclaimer</p>
<p>I never said this would definitely work for you, I&#8217;m just trying to help. This worked for me, using my server, hopefully it&#8217;ll work for you, but I&#8217;m in no way responsible if you mess up your server or your website. I don&#8217;t work for HSBC, and don&#8217;t have any knowledge of their systems. I have reproduced their documents in this file, and am making their CPI specification document freely available. I&#8217;m not sure if that&#8217;s ok, but it remains HSBC&#8217;s property and if they want me to take it off this site, then please email me before you sue me.<br />
Chris Cook</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/install-hsbc-cpi-credit-card-processing-on-linux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How To Convert Your Putty .ppk Private Key To A Normal SSH Key You Can Use On An Apple Mac</title>
		<link>http://leadingedgescripts.co.uk/server-administration/how-to-convert-your-putty-ppk-private-key-to-a-normal-ssh-key-you-can-use-on-an-apple-mac/</link>
		<comments>http://leadingedgescripts.co.uk/server-administration/how-to-convert-your-putty-ppk-private-key-to-a-normal-ssh-key-you-can-use-on-an-apple-mac/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 17:25:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Macs]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[keys]]></category>
		<category><![CDATA[ppk]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.leadingedgescripts.co.uk/wp/?p=3</guid>
		<description><![CDATA[Also, how to connect to a server using SSH on a Mac
I spent ages trying to figure this out so that I could SSH onto my production hosting server from my iBook. Now that I know what was wrong, I can’t believe how long it took me to solve, because the answer is so simple [...]]]></description>
			<content:encoded><![CDATA[<h2>Also, how to connect to a server using SSH on a Mac</h2>
<p>I spent ages trying to figure this out so that I could SSH onto my production hosting server from my iBook. Now that I know what was wrong, I can’t believe how long it took me to solve, because the answer is so simple – but unfortunately I never found anything in Google that helped me, it was only pure luck and dogged perseverance that helped me figure this one out.</p>
<p>
<!-- Begin Google Adsense code -->
<script type="text/javascript"><!--
google_ad_client = "pub-4904188713812219";
/* 468x60, created 02/11/08 */
google_ad_slot = "9286450703";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Google Adsense code -->
</p>
<p>I already knew that I could open an SSH connection on my Mac using Terminal, and I could SSH onto my production server from my XP pc using Putty with no problems.</p>
<p>So when I copied my .ppk Putty key from my PC to my Mac I expected to be able to type:</p>
<p><code>ssh -2 username@123.123.123.123 –i yourkey.ppk</code></p>
<p>from within Terminal and get straight onto my server with no questions asked.</p>
<p>But oh no! it’s not quite as easy as that – well these things never are, are they?</p>
<p>Let start with the very basics, you can find the Terminal program on your Macintosh in Applications -&gt; Utilities.</p>
<p>Open it and you have something resembling a Windows DOS prompt.</p>
<p>Now if you already have a .ppk file from your PC that you want to convert to use on your Mac you need to visit the Putty Website <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">www.chiark.greenend.org.uk/~sgtatham/putty/download.html</a> and download puttygen.exe (on your PC) now open it, and using the File menu, load your .ppk that you already use, and type in your pass phrase.</p>
<p>Now go to the Conversions menu and export the key as an OpenSSH key – hey presto – you now have a key file that will work on your Mac! Such a simple solution, yet that took me so long to figure out &#8230;</p>
<p>Anyway, now you just need to copy your new .ssh keyfile over to your home (~) directory on your Mac and set the permissions to 700 (chmod 700 yourkey.ssh).</p>
<p>Once you’ve done all that you can use the ssh command.</p>
<pre>				<code>
ssh -2 username@123.123.123.123 –i yourkey.ssh
				</code></pre>
<p>and you should be able to SSH onto your box as you would from your PC – amazing!</p>
]]></content:encoded>
			<wfw:commentRss>http://leadingedgescripts.co.uk/server-administration/how-to-convert-your-putty-ppk-private-key-to-a-normal-ssh-key-you-can-use-on-an-apple-mac/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>
