<?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>Some PHP &#124; Wordpress Tips &#187; PHP Tutorial</title>
	<atom:link href="http://worth2read.org/blog/category/php-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://worth2read.org/blog</link>
	<description>Wordpress &#124; PHP Tips</description>
	<lastBuildDate>Tue, 20 Jul 2010 14:31:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to install ioncube in your server</title>
		<link>http://worth2read.org/blog/2010/06/20/install-ioncube-in-your-server/</link>
		<comments>http://worth2read.org/blog/2010/06/20/install-ioncube-in-your-server/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 04:58:10 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=195</guid>
		<description><![CDATA[Some scripts are encoded with ioncube. So to run the script, you need ioncube installed at your server. To install ioncube at your server, use the following instructions: Go to this page http://www.ioncube.com/loaders.php and download the package suitable for your operating system Unpack it and upload it to your server in the directory ioncube. The <a href='http://worth2read.org/blog/2010/06/20/install-ioncube-in-your-server/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2010%2F06%2F20%2Finstall-ioncube-in-your-server%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2010%2F06%2F20%2Finstall-ioncube-in-your-server%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Some scripts are encoded with ioncube. So to run the script, you need ioncube installed at your server. To install ioncube at your server, use the following instructions:</p>
<ol>
<li>Go to this page http://www.ioncube.com/loaders.php and download the package suitable for your operating system</li>
<li>Unpack it and upload it to your server in the directory ioncube. The package contains the directory ioncube with loaders for different versions of operating system</li>
<li>Launch the Loader Wizard script in your browser. For example: http://yourdomain/ioncube/loader-wizard.php</li>
<li>Select for run time installation, if your server is Shared ( not dedicated ).</li>
<li>Follow the instructions there and the installation will be done successfully.</li>
<li>Contact the script provider if you do experience any problems  running encoded files.<strong><br />
</strong></li>
<li>For security reasons it is strongly advised to remove the Wizard script ( loader-wizard.php )  from your server after the installation of the ionCube  Loader</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2010/06/20/install-ioncube-in-your-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to integrate Cyberbit payment gateway to a PHP Website</title>
		<link>http://worth2read.org/blog/2010/06/15/integrating-cyberbit-payment-gateway-to-a-php-website/</link>
		<comments>http://worth2read.org/blog/2010/06/15/integrating-cyberbit-payment-gateway-to-a-php-website/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 04:03:26 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=162</guid>
		<description><![CDATA[I could not find a guide to integrate cyberbit payment gateway to a website. So I thought to write one. First you need a merchant account with cybernet . When you start an account you will receive a test account with user name and password. Also you will receive some documents. It explains almost everything <a href='http://worth2read.org/blog/2010/06/15/integrating-cyberbit-payment-gateway-to-a-php-website/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2010%2F06%2F15%2Fintegrating-cyberbit-payment-gateway-to-a-php-website%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2010%2F06%2F15%2Fintegrating-cyberbit-payment-gateway-to-a-php-website%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I could not find a guide to integrate cyberbit payment gateway to a website. So I thought to write one.</p>
<p>First you need a merchant account with <a href="http://www.cyberbit.eu/" target="_blank">cybernet</a> . When you start an account you will receive a test account with user name and password. Also you will receive some documents. It explains almost everything &#8211; how to integrate it. They also give you hash key for you to use in the code.</p>
<p>On the programming side, you have to create a form, so that the customers can enter  card holder details and shipping details. Then POST the data to cyberbit payment gateway.</p>
<p>Following is an example of Form  (taken from the document provided by Cyberbit)</p>
<p>&lt;form method=&#8221;POST&#8221; action=&#8221;https://test.xxxxx.xx/xxxx.php&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;1&#8243; name=&#8221;transtype&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;sdf6a6yr3f3df33&#8243; name=&#8221;secret&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;https://www.cyberbit.eu/bjarne_test/accept.php&#8221;<br />
name=&#8221;accepturl&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;CyberTest&#8221; name=&#8221;merchantid&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;test3&#8243; name=&#8221;InternalorderId&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;978&#8243; name=&#8221;currencycode&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;100&#8243; name=&#8221;amountcleared&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;28006f49d5ffc3a60adbe4898594e749ee34b055&#8243;<br />
name=&#8221;hash&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;cardholder@email.com&#8221; name=&#8221;owneremail&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;some street&#8221; name=&#8221;owneraddress&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;123&#8243; name=&#8221;owneraddressnumber&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;London&#8221; name=&#8221;ownercity&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;OO&#8221; name=&#8221;ownerstate&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;GB&#8221; name=&#8221;ownercountry&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;Larry&#8221; name=&#8221;ownerfirstname&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;Smith&#8221; name=&#8221;ownerlastname&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;123456&#8243; name=&#8221;ownerzip&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8221;xxxx&#8221; name=&#8221;ownerphone&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8217;&#8221;Item Number&#8221;;&#8221;Item Description&#8221;;&#8221;Amount&#8221;;&#8221;Price&#8221;&#8216;<br />
name=&#8221;header&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8217;&#8221;1&#8243;;&#8221;Blue car&#8221;;&#8221;1&#8243;;&#8221;1.000,00&#8243;&#8216; name=&#8221;orderline1&#8243;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8217;&#8221;2&#8243;;&#8221;Red bike&#8221;;&#8221;2&#8243;;&#8221;250,00&#8243;&#8216; name=&#8221;orderline2&#8243;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8217;&#8221;Shipping&#8221;;&#8221;150,00&#8243;&#8216; name=&#8221;shipping&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; value=&#8217;&#8221;Total&#8221;;&#8221;1.650,00&#8243;&#8216; name=&#8221;total&#8221;&gt;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;Make Payment&#8221;&gt;<br />
&lt;/form&gt;</p>
<p>All the variables are well defined in cyberbit document. In the above example all the values are defined. In real situation you have to take the input values.</p>
<p>Once the transaction is made cyberbit sends some data back to merchant&#8217;s server.  To receive that data we need to create a file. The URL of that file is called callback URL.</p>
<p>For safety ( I guess) in the test account, we don&#8217;t have the option to set callback URL. If we send the callback URL to cyberbit, they will update the callback URL info.</p>
<p>The server sends an xml file with all the relevant details of transaction  held. It also sends a fingerprint. we can calculate the fingerprint on our side and can match both fingerprints.</p>
<p>Some web servers, like Apache, will add slashes to all characters that could break communication. These are characters like &#8220;, &#8216;, `, etc. And since the XML sent in the xml post parameter does contain double-quotes it is possible that your web server added an escape character to the double-quote to  sanitize the string, so it would look like this \&#8221; instead of just &#8220;. This would result in a totally different SHA1 hash result as your XML string is slightly different than the one cyberbit used when they calculated the SHA1 code.</p>
<p>To avoid this, you can try stripping slashes form the XML string before you try an calculate the hash. In PHP this is very simply, simply do stripslashes($_POST['xml']);</p>
<p>If both matches, we can parse the xml and take the data we need and use it.</p>
<p>There are 2 other pages, called Accept URL and Decline URL.</p>
<p>Accept URL is the URL of the file we create to direct the customer upon successful completion of payment.</p>
<p>Decline URl is the URL of the file we create to direct the customer if the payment is declined.</p>
<p>We can set both Accept URL and Decline URL in cyberbet account.</p>
<p>An interesting thing is the shipping &#8211;&gt; name, phone and email is not yet used for the payment form, so we can&#8217;t send those data. They said they have plans to add them to the payment form.</p>
<p>I will try to add some more notes, when I get time.</p>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2010/06/15/integrating-cyberbit-payment-gateway-to-a-php-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Detemine The Number Of Fridays In A Month</title>
		<link>http://worth2read.org/blog/2009/08/01/how-to-detemine-the-number-of-fridays-in-a-month/</link>
		<comments>http://worth2read.org/blog/2009/08/01/how-to-detemine-the-number-of-fridays-in-a-month/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 01:40:38 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[How to Detemine The Number Of Fridays In A Month]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=73</guid>
		<description><![CDATA[The following code determines the number of Fridays in a month : $year = 2008; $month = 1; //Aug $day = 1; $startDate = mktime(0, 0, 0, $month, $day, $year); $NoD = date( &#8220;t&#8221;, $startDate); While(date( &#8220;D&#8221;, $startDate) != &#8220;Fri&#8221;) //find first Friday { $day++; $startDate = mktime(0, 0, 0, $month, $day, $year); } $day&#8211;; <a href='http://worth2read.org/blog/2009/08/01/how-to-detemine-the-number-of-fridays-in-a-month/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Fhow-to-detemine-the-number-of-fridays-in-a-month%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Fhow-to-detemine-the-number-of-fridays-in-a-month%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>The following code determines the number of Fridays in a month :</strong></p>
<p>$year = 2008;<br />
$month = 1; //Aug<br />
$day = 1;<br />
$startDate = mktime(0, 0, 0, $month, $day, $year);<br />
$NoD = date( &#8220;t&#8221;, $startDate);</p>
<p>While(date( &#8220;D&#8221;, $startDate) != &#8220;Fri&#8221;) //find first Friday<br />
{<br />
$day++;<br />
$startDate = mktime(0, 0, 0, $month, $day, $year);<br />
}<br />
$day&#8211;;<br />
$days = ceil(($NoD-$day)/7);<br />
echo &#8220;$days Fridays&#8221;;</p>
<p>Replace the $month=1; to the number of the month you want. </p>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2009/08/01/how-to-detemine-the-number-of-fridays-in-a-month/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function to Get the variable name</title>
		<link>http://worth2read.org/blog/2009/08/01/function-to-get-the-variable-name/</link>
		<comments>http://worth2read.org/blog/2009/08/01/function-to-get-the-variable-name/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 01:38:49 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[Function to Get the variable name]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=71</guid>
		<description><![CDATA[This is a PHP Function to get the name of the variable (not the value) : function getvarname(&#038;$var) { $ret = &#8221;; $tmp = $var; $var = md5(uniqid(rand(), TRUE)); $key = array_keys($GLOBALS); foreach ( $key as $k ) if ( $GLOBALS[$k] === $var ) { $ret = $k; break; } $var = $tmp; return $ret; <a href='http://worth2read.org/blog/2009/08/01/function-to-get-the-variable-name/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Ffunction-to-get-the-variable-name%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Ffunction-to-get-the-variable-name%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>This is a PHP Function to get the name of the variable (not the value) :</strong></p>
<p>function getvarname(&#038;$var)<br />
{<br />
$ret = &#8221;;<br />
$tmp = $var;<br />
$var = md5(uniqid(rand(), TRUE));</p>
<p>$key = array_keys($GLOBALS);<br />
foreach ( $key as $k )<br />
if ( $GLOBALS[$k] === $var )<br />
{<br />
$ret = $k;<br />
break;<br />
}</p>
<p>$var = $tmp;<br />
return $ret;<br />
}</p>
<p>$another = &#8216;test&#8217;;<br />
$testvar = &#8216;test&#8217;;<br />
echo getvarname($testvar); //echoes &#8216;testvar&#8217;<br />
?></p>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2009/08/01/function-to-get-the-variable-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to display how many weeks and days left when a start date and an end date is given?</title>
		<link>http://worth2read.org/blog/2009/08/01/how-to-display-how-many-weeks-and-days-left-when-a-start-date-and-an-end-date-is-given/</link>
		<comments>http://worth2read.org/blog/2009/08/01/how-to-display-how-many-weeks-and-days-left-when-a-start-date-and-an-end-date-is-given/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 01:36:36 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[How to display how many weeks and days left when a start date and an end date is given?]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=69</guid>
		<description><![CDATA[Following code in php displays how many weeks and days left when a start date and an end date is given: function daysWeeks($start,$end) { $days_left=$end-$start; $weeks = (int) ($days_left / 7) ; $days = $days_left % 7; echo &#8220;$weeks weeks and $days days left!&#8221;; } $start=&#8221;05/08/2008&#8243;; $end=&#8221;25/08/2008&#8243;; daysWeeks($start,$end);]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Fhow-to-display-how-many-weeks-and-days-left-when-a-start-date-and-an-end-date-is-given%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F08%2F01%2Fhow-to-display-how-many-weeks-and-days-left-when-a-start-date-and-an-end-date-is-given%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Following code in php displays how many weeks and days left when a start date and an end date is given:</strong><br />
function daysWeeks($start,$end)<br />
{<br />
$days_left=$end-$start;<br />
$weeks = (int) ($days_left / 7) ;<br />
$days = $days_left % 7;<br />
echo &#8220;$weeks weeks and $days days left!&#8221;;<br />
}<br />
$start=&#8221;05/08/2008&#8243;;<br />
$end=&#8221;25/08/2008&#8243;;<br />
daysWeeks($start,$end);</p>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2009/08/01/how-to-display-how-many-weeks-and-days-left-when-a-start-date-and-an-end-date-is-given/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code To determine the number of hits in your website :</title>
		<link>http://worth2read.org/blog/2009/07/31/code-to-determine-the-number-of-hits-in-your-website/</link>
		<comments>http://worth2read.org/blog/2009/07/31/code-to-determine-the-number-of-hits-in-your-website/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 14:55:45 +0000</pubDate>
		<dc:creator>Gisha James</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[Code To determine the number of hits in your website]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://worth2read.org/blog/?p=62</guid>
		<description><![CDATA[1.Create a .txt file, say hit.txt. 2. Enter the value 0 in hit.txt and save. 3. Create a php file, say counter.php with the following code&#8230;]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F07%2F31%2Fcode-to-determine-the-number-of-hits-in-your-website%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fworth2read.org%2Fblog%2F2009%2F07%2F31%2Fcode-to-determine-the-number-of-hits-in-your-website%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>1.Create a .txt file, say hit.txt. </p>
<p>2. Enter the value 0 in hit.txt and save.</p>
<p>3. Create a php file, say counter.php with the following code&#8230;</p>
<p><?php</p>
<p>$filename= "hits.txt" ;</p>
<p>$fd = fopen ($filename , "r") or die ("Can't open $filename") ;</p>
<p>$fstring = fread ($fd , filesize ($filename)) ;</p>
<p>echo "$fstring" ;</p>
<p>fclose($fd) ;</p>
<p>$fd = fopen ($filename , "w") or die ("Can't open $filename") ;</p>
<p>$fhits = $fstring + 1 ;</p>
<p>$fout= fwrite ($fd , $fhits ) ;</p>
<p>fclose($fd) ;</p>
<p>?></p>
<p>4. Include the counter.php file wherever you want to display the number of hits. </p>
]]></content:encoded>
			<wfw:commentRss>http://worth2read.org/blog/2009/07/31/code-to-determine-the-number-of-hits-in-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
