<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.1" -->
<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/"
	>

<channel>
	<title>PHP Resource</title>
	<link>http://php.trivuz.com</link>
	<description>welcome to php world</description>
	<pubDate>Tue, 03 Jun 2008 18:38:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<item>
		<title>Building services like FriendFeed using PHP - Part2</title>
		<link>http://php.trivuz.com/building-services-like-friendfeed-using-php-part2/</link>
		<comments>http://php.trivuz.com/building-services-like-friendfeed-using-php-part2/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:38:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorial]]></category>

		<category><![CDATA[Web Services]]></category>

		<category><![CDATA[Building]]></category>

		<category><![CDATA[FriendFeed]]></category>

		<category><![CDATA[Hasin]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/building-services-like-friendfeed-using-php-part2/</guid>
		<description><![CDATA[By Hasin Hayder
Following the first installment in this series, here is the second part. In this part I will focus mainly on Bookmarking and News services supported by FriendFeed . Here we go
Supported bookmarking services by FriendFeed
1. Del.icio.us
2. Furl
3. Google shared stuffs
4. Mag.nolia
5. Stumbleupon
Except google shared stufss, all of the rests require just an username [...]]]></description>
			<content:encoded><![CDATA[<p>By <a href="http://hasin.wordpress.com/2008/06/03/building-services-like-friendfeed-using-php-part2/" title="Hasin Hayder" target="_blank">Hasin Hayder</a></p>
<p>Following the <a href="http://hasin.wordpress.com/2008/05/31/building-friendfeed-using-php-part-1/">first installment in this series</a>, here is the second part. In this part I will focus mainly on Bookmarking and News services supported by FriendFeed . Here we go</p>
<p><strong>Supported bookmarking services by FriendFeed</strong><br />
1. Del.icio.us<br />
2. Furl<br />
3. Google shared stuffs<br />
4. Mag.nolia<br />
5. Stumbleupon</p>
<p>Except google shared stufss, all of the rests require just an username to generate the access point for retrieving user’s bookmarked items. And for the google shared stuffs, it requires the fully functional url of the feed available from your google bookmark service.</p>
<p><strong>Access points</strong></p>
<p><strong><a href="http://del.icio.us/">Del.icio.us</a></strong></p>
<p><strong>AP:</strong> http://feeds.delicious.com/rss/&lt;user name&gt;<br />
<strong>example:</strong> http://feeds.delicious.com/rss/anduh</p>
<hr /> <strong><a href="http://www.furl.net/">Furl</a></strong><strong>AP:</strong> http://rss.furl.net/member/&lt;user name&gt;.rss;<br />
<strong>example:</strong> http://rss.furl.net/member/pigge.rss</p>
<hr /> <strong><a href="http://www.furl.net/">Google Shared Stuffs</a></strong><br />
you can find your google shared stuff url from <a href="http://www.google.com/s2/sharing/stuff">http://www.google.com/s2/sharing/stuff</a><strong>example:</strong> http://www.google.com/s2/sharing/stuff?user=110703083499686157981&amp;output=rss</p>
<hr /> <strong><a href="http://www.ma.gnolia.com/">Ma.gnolia</a></strong><strong>AP:</strong> http://ma.gnolia.com/rss/lite/people/&lt;user name&gt;.rss;<br />
<strong>example:</strong> http://ma.gnolia.com/rss/lite/people/gerryquach</p>
<hr /> <strong><a href="http://www.stumbleupon.com/">Stumbleupon</a></strong><br />
Whoops, Double Whoops, Tripple Whoops. It took quite a time for me to find the feed url. I dont know why it is kept so “SECRET” - LOL<strong>AP:</strong> http://www.stumbleupon.com/syndicate.php?stumbler=&lt;user name&gt;.rss;<br />
<strong>example:</strong> http://www.stumbleupon.com/syndicate.php?stumbler=jd001</p>
<hr /><strong>Supported news services by FriendFeed</strong><br />
1. <a href="http://digg.com/">Digg</a><br />
2. <a href="http://reader.google.com/">Google Reader</a><br />
3. <a href="http://www.mixx.com/">Mixx</a><br />
4. <a href="http://www.reddit.com/">Reddit</a></p>
<p>Here are the access points</p>
<hr /> <strong><a href="http://www.digg.com/">Digg</a></strong><strong>AP:</strong> http://digg.com/users/&lt;user name&gt;/history.rss;<br />
<strong>example:</strong> http://digg.com/users/msaleem/history.rss</p>
<hr /> <strong><a href="http://reader.google.com/">Google Reader</a></strong>You can find your shared item’s feed url here <a href="http://www.google.com/reader/view/user/-/state/com.google/broadcast">http://www.google.com/reader/view/user/-/state/com.google/broadcast</a></p>
<hr /> <strong><a href="http://www.mixx.com//">Mixx</a></strong>Unfortunately during the time of writing this article, Mixx was napping - here is the screenshot. Once they are awake, I will update this section <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p><a href="http://hasin.files.wordpress.com/2008/06/mixx.jpg"><img src="http://hasin.files.wordpress.com/2008/06/mixx.jpg?w=500&amp;h=270" class="aligncenter size-full wp-image-300" height="270" width="500" /></a></p>
<hr /> <strong><a href="http://www.digg.com/">Reddit</a></strong><strong>AP:</strong> http://www.reddit.com/user/&lt;user name&gt;/.rss;<br />
<strong>example:</strong> http://www.reddit.com/user/jack_alexander/.rss</p>
<p>In next installation I will focus on scaling such a huge load successfully. Hope that will be interesting to many of you. Following installation will focus again on the access points.</p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/building-services-like-friendfeed-using-php-part2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building services like FriendFeed using PHP - Part 1</title>
		<link>http://php.trivuz.com/building-services-like-friendfeed-using-php-part-1/</link>
		<comments>http://php.trivuz.com/building-services-like-friendfeed-using-php-part-1/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:35:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Web Services]]></category>

		<category><![CDATA[Building]]></category>

		<category><![CDATA[FriendFeed]]></category>

		<category><![CDATA[Hasin]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/building-services-like-friendfeed-using-php-part-1/</guid>
		<description><![CDATA[By Hasin Hayder
Friendfeed is an excellent life streaming service aggregating all your feeds from different service providers, compile them together, build a social network among your known people and finally deliver all these feeds as a mashup. As a result you can immediately track activities of your friends on all the different service they use [...]]]></description>
			<content:encoded><![CDATA[<p class="entry">By <a href="http://hasin.wordpress.com/2008/05/31/building-friendfeed-using-php-part-1/" title="Hasin Hayder" target="_blank">Hasin Hayder</a></p>
<p class="snap_preview"><a href="http://friendfeed.com/">Friendfeed</a> is an excellent life streaming service aggregating all your feeds from different service providers, compile them together, build a social network among your known people and finally deliver all these feeds as a mashup. As a result you can immediately track activities of your friends on all the different service they use (like jaiku, twitter, flickr) and stay up-to-date. Hats off to the developers of FriendFeed for delivering such a nice application to us.</p>
<p>In this blog post I will try to focus on how to develop such a service like Friendfeed using PHP and JS and how to scale such a huge load successfully. Previously I’d also written another article focusing “<a href="http://hasin.wordpress.com/2008/04/27/how-to-make-your-own-springloops-in-php/">How to develop services like SpringLoops using PHP</a>“. The complete article will be delivered in multiple installments and in current installment, I will focus on <strong>Photo sharing services</strong>  used by friendfeed.</p>
<p><strong><u>Area to focus</u></strong><br />
1. Services to be supported<br />
2. Update discovery<br />
3. Parsing the feeds<br />
4. Storing the data<br />
5. Scaling</p>
<p><a href="http://friendfeed.com/">FriendFeed</a> parses feeds from a total of 35 popular services from around the web <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> - lets have a look at them one by one and I will give you idea about the access points of these services. Though Not all of them are feed, so I will try to focus those services as well to give you a basic idea.</p>
<p><strong>Service 1 : <a href="http://flickr.com/">Flickr</a></strong><br />
Usable PHP Library: <a href="http://phpflickr.com/">PHPFlickr</a></p>
<p>Flickr is an excellent photo sharing services under the banner of Yahoo. Friendfeed parses all the photo from a user and also the list of his/her favorite photos. Given an username you can easily find the Flickr ID like (<strong>76536911@N00</strong>)of that user and once you got it, here is the access points for list of public photos and favorites</p>
<p><em><u>List of photos</u></em><br />
<em>http://api.flickr.com/services/feeds/photos_public.gne?id=&lt;user’s flickr id&gt;&amp;lang=en-us&amp;format=rss_200</em><br />
<strong>example:</strong> http://api.flickr.com/services/feeds/photos_public.gne?id=76536911@N00&amp;lang=en-us&amp;format=rss_200</p>
<p><em><u>List of favorites</u></em><br />
<em>http://api.flickr.com/services/feeds/photos_faves.gne?nsid=&lt;user’s flickr id&gt;&amp;lang=en-us&amp;format=rss_200</em><br />
<strong>example:</strong>http://api.flickr.com/services/feeds/photos_faves.gne?nsid=76536911@N00&amp;lang=en-us&amp;format=rss_200</p>
<p><strong>Service 2: <a href="http://picasaweb.google.com/">Picasa Web Album</a></strong><br />
Picasa is another photo sharing service under the banner of the Giant, Google. Given a picasa user name , here are the access point of user’s public photos</p>
<p><em><u>List of public photos</u></em><br />
<em>http://picasaweb.google.com/data/feed/base/user/&lt;picasa user name&gt;?kind=album&amp;alt=rss&amp;hl=en_US&amp;access=public</em><br />
<strong>example:</strong>http://picasaweb.google.com/data/feed/base/user/countdraculla?kind=album&amp;alt=rss&amp;hl=en_US&amp;access=public</p>
<p><strong>Service 3: <a href="http://www.smugmug.com/">Smugmug</a></strong><br />
Here comes another photo sharing service where users can buy and sell their photos. Given a smugmug user name you can find the feed of this user’s photos</p>
<p><em><u>List of public photos</u></em><br />
<em>http://&lt;smugmug user name&gt;.smugmug.com/hack/feed.mg?Type=nickname&amp;Data=Ifocus&amp;format=rss200</em><br />
<strong>example:</strong>http://ifocus.smugmug.com/hack/feed.mg?Type=nickname&amp;Data=Ifocus&amp;format=rss200</p>
<p><strong>Service 4: <a href="http://www.zooomr.com/">Zoomr</a></strong><br />
Zoomr is another photo sharing service started in late 2005 by Kristopher Tate as a place for him to share photos with his friends and later became a public services, is currently supported by FriendFeed. And here we go with the access points <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p><em><u>List of public photos</u></em><br />
<em>http://www.zooomr.com/services/feeds/public_photos/?id=&lt;zoomr user name&gt;&amp;format=rss_200</em><br />
<strong>example:</strong>http://www.zooomr.com/services/feeds/public_photos/?id=wolfmank&amp;format=rss_200</p>
<p>In next part, I will highlight the access points of supported bookmark services and news services supported by FriendFeed <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /> Have a nice weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/building-services-like-friendfeed-using-php-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Unique Hit Counter</title>
		<link>http://php.trivuz.com/php-unique-hit-counter/</link>
		<comments>http://php.trivuz.com/php-unique-hit-counter/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 05:17:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Access Counters]]></category>

		<category><![CDATA[Counter]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/php-unique-hit-counter/</guid>
		<description><![CDATA[ Description
This simple and easy-to-use script logs the number of unique visitors to your web site by logging only one occurence of each IP address. This script is 100% free!
Installation
It&#8217;s a quick 3-step process.
1.
Upload uniquehits.php and uniquehits.log to your web server.
2.
CHMOD 666 (writable) uniquehits.log (skip this step on Windows servers).
3.
Insert this PHP code on every [...]]]></description>
			<content:encoded><![CDATA[<p><strong> Description</strong></p>
<p>This simple and easy-to-use script logs the number of unique visitors to your web site by logging only one occurence of each IP address. This script is 100% free!<br />
Installation</p>
<p>It&#8217;s a quick 3-step process.</p>
<p>1.<br />
Upload uniquehits.php and uniquehits.log to your web server.<br />
2.<br />
CHMOD 666 (writable) uniquehits.log (skip this step on Windows servers).<br />
3.<br />
Insert this PHP code on every page where the counter should appear:</p>
<p align="justify"><font face="Arial, Helvetica, sans-serif"><strong><font face="Courier New, Courier, mono"><font color="#0000ff">&lt;? include &#8216;uniquehits.php&#8217;                ?&gt;</font></font></strong></font></p>
<p>Done!</p>
<p align="justify"><a href="http://www.sizzly.com/uniquehits.zip" target="_blank">DOWNLOAD LINK</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/php-unique-hit-counter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Object Oriented PHP Counter</title>
		<link>http://php.trivuz.com/object-oriented-php-counter/</link>
		<comments>http://php.trivuz.com/object-oriented-php-counter/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 04:21:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Access Counters]]></category>

		<category><![CDATA[Counter]]></category>

		<category><![CDATA[OOP]]></category>

		<category><![CDATA[PHP5]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/object-oriented-php-counter/</guid>
		<description><![CDATA[A more advanced version of our PHP Counter, this script is object oriented and remembers return visitors by setting a cookie. Because it remembers visitors, this counter counts the number of unique visitors that visited your site.
This script is object oriented and written for PHP 5+, which handles object differently than older versions of PHP. [...]]]></description>
			<content:encoded><![CDATA[<p>A more advanced version of our PHP Counter, this script is object oriented and remembers return visitors by setting a cookie. Because it remembers visitors, this counter counts the number of unique visitors that visited your site.</p>
<p>This script is object oriented and written for PHP 5+, which handles object differently than older versions of PHP. Being object oriented allows multiple counters to exists on one page, or on different pages throughout the site. While you can copy this class into each page that you want to use it on, the best way is to include it in its own file at the top of your page. For example:</p>
<p align="justify"><font color="#0000ff">&lt;?php</font></p>
<p><font color="#0000ff">include(&#8217;counter_script.php&#8217;);<br />
$myCounter=new Counter();</font></p>
<p><font color="#0000ff">//NOW START HTML<br />
?&gt;<br />
&lt;html&gt;<br />
</font></p>
<p> <a href="http://php.trivuz.com/object-oriented-php-counter/#more-20" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/object-oriented-php-counter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Login script tutorial</title>
		<link>http://php.trivuz.com/php-login-script-tutorial/</link>
		<comments>http://php.trivuz.com/php-login-script-tutorial/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 03:50:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorial]]></category>

		<category><![CDATA[Login]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/php-login-script-tutorial/</guid>
		<description><![CDATA[Overview
In this tutorial create 3 files
1. main_login.php
2. checklogin.php
3. login_success.php
Step
1. Create table &#8220;members&#8221; in database &#8220;test&#8221;.
2. Create file main_login.php.
3. Create file checklogin.php.
4. Create file login_success.php.
5. Create file logout.php
]]></description>
			<content:encoded><![CDATA[<p>Overview</p>
<p>In this tutorial create 3 files<br />
1. main_login.php<br />
2. checklogin.php<br />
3. login_success.php</p>
<p>Step<br />
1. Create table &#8220;members&#8221; in database &#8220;test&#8221;.<br />
2. Create file main_login.php.<br />
3. Create file checklogin.php.<br />
4. Create file login_success.php.<br />
5. Create file logout.php<br />
 <a href="http://php.trivuz.com/php-login-script-tutorial/#more-19" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/php-login-script-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>server to server file transfar using php script</title>
		<link>http://php.trivuz.com/server-to-server-file-transfar-using-php-script/</link>
		<comments>http://php.trivuz.com/server-to-server-file-transfar-using-php-script/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 00:30:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Clients and Servers]]></category>

		<category><![CDATA[File Management]]></category>

		<category><![CDATA[file transfar]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/server-to-server-file-transfar-using-php-script/</guid>
		<description><![CDATA[ Script: Server-to-Server Transfer using PHP
Server  to  Server  Transfer 2  or SST  is a PHP class that can be used to move
a file from a server to another.
The moving process  occurs by using  HTTP protocol (by  GET request), after  the
data is requested, it will  be [...]]]></description>
			<content:encoded><![CDATA[<p><strong> Script: Server-to-Server Transfer using PHP</strong><br />
Server  to  Server  Transfer 2  or SST  is a PHP class that can be used to move<br />
a file from a server to another.</p>
<p>The moving process  occurs by using  HTTP protocol (by  GET request), after  the<br />
data is requested, it will  be saved in the local  komputer. So to use the  SST,<br />
you have to  install the script  in the target  computer where the  file will be<br />
moved.</p>
<p>The computer where this script will be installed, should meet this requirements:<br />
1.  Using Linux/Windows<br />
2.  Have PHP Interpreter version 4 or higher<br />
3.  PHP was set to allow Remote File Access<br />
(setting &#8220;allow_url_fopen&#8221; = true)</p>
<p>Installation<br />
&#8212;&#8212;&#8212;&#8212;</p>
<p>1. Copy sst.php, downloader.php and script.inc.php to desired directory<br />
2. Call sst.php using your browser.</p>
<p>Notes<br />
&#8212;&#8211;<br />
1. The maximum size of file that will be moved is 5*1048576 (5MB)<br />
2. SST 2 now works with &#8220;redirection&#8221; URL.<br />
3. SST 2 now works with password protected URL.<br />
 <a href="http://php.trivuz.com/server-to-server-file-transfar-using-php-script/#more-10" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/server-to-server-file-transfar-using-php-script/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wordpress Theme GX3 Gray</title>
		<link>http://php.trivuz.com/wordpress-theme-gx3-gray/</link>
		<comments>http://php.trivuz.com/wordpress-theme-gx3-gray/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 10:08:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[Theme]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/wordpress-theme-gx3-gray/</guid>
		<description><![CDATA[
Live Preview
Download Now
]]></description>
			<content:encoded><![CDATA[<p><img src="http://trivuz.com/files/images/gx3gray.png" height="207" width="300" /></p>
<p><a href="http://trivuz.com/books/index.php/2007/10/26/wordpress-complete-by-hasin-hayder/">Live Preview</a></p>
<p><a href="http://trivuz.com/downloads/index.php?file=_GX3_Gray_4_WP.zip">Download Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/wordpress-theme-gx3-gray/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to create a basic rating system</title>
		<link>http://php.trivuz.com/how-to-create-a-basic-rating-system/</link>
		<comments>http://php.trivuz.com/how-to-create-a-basic-rating-system/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 23:23:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Code Snippets]]></category>

		<category><![CDATA[rating system]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/how-to-create-a-basic-rating-system/</guid>
		<description><![CDATA[ &#60;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;
&#8220;DTD/xhtml1-transitional.dtd&#8221;&#62;
&#60;html&#62;
&#60;body&#62;
&#60;?php if ( (!isset($_POST[&#8217;submit&#8217;])) ) { ?&#62;
  &#60;form action=&#8221;&#60;?php echo $_SERVER[&#8216;PHP_SELF&#8217;]; ?&#62;&#8220; method=&#8221;post&#8221;&#62;
&#60;table&#62;
&#60;tr&#62;
&#60;td&#62;Your rating:&#60;/td&#62;
&#60;td&#62;&#60;select name=&#8221;rate&#8221;&#62;
&#60;option value=&#8221;1&#8243;&#62;1&#60;/option&#62;
&#60;option value=&#8221;2&#8243;&#62;2&#60;/option&#62;
&#60;option value=&#8221;3&#8243;&#62;3&#60;/option&#62;
&#60;option value=&#8221;4&#8243;&#62;4&#60;/option&#62;
&#60;option value=&#8221;5&#8243;&#62;5&#60;/option&#62;
&#60;/select&#62;&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;&#60;td colspan=&#8221;2&#8243; align=&#8221;center&#8221;&#62;
&#60;input type=&#8221;submit&#8221; value=&#8221;Rate it!&#8221; name=&#8221;submit&#8221;/&#62;
&#60;/td&#62;&#60;/tr&#62;
&#60;/table&#62;
&#60;/form&#62;
&#60;?php
} else  {
$rate = isset ($_POST[&#8216;rate&#8217;]) ? $_POST[&#8216;rate&#8217;] : 0;
$filename     = &#8220;ratings&#8221;;
$alreadyRated = false;
$totalRates   = 0;
$totalPoints  = 0;
$ip = getenv(&#8216;REMOTE_ADDR&#8217;);
// Read the result file
$oldResults = file(&#8216;results/&#8217;.$filename.&#8216;.txt&#8217;);
// Summarize total points and rates
foreach ($oldResults as $value) {
$oneRate = explode(&#8216;:&#8217;,$value);
// If our IP is in the list then set the falg
if ($ip == $oneRate[0]) $alreadyRated = true;
$totalRates++;
$totalPoints += $oneRate[1];
}
// If our rating is valid then append it to the result file
if ((!$alreadyRated) &#38;&#38; ($rate &#62; 0)){
$f = fopen(&#8216;results/&#8217;.$filename.&#8220;.txt&#8221;,&#8220;a+&#8221;);
fwrite($f,$ip.&#8216;:&#8217;.$rate.&#8220;\n&#8221;);
fclose($f);
$totalRates++;
$totalPoints+=$rate;
}
echo &#8220;Actual rating from $totalRates rates is: &#8221;
.substr(($totalPoints/$totalRates),0,3).&#8220;&#60;br/&#62;&#8221;;
// Display the actual rating
for ($i=0;$i&#60;round(($totalPoints/$totalRates),0);$i++){
echo &#8220;&#60;img src=&#8217;style/star.png&#8217; /&#62;&#8221;;
}
} ?&#62;
&#60;/body&#62;

]]></description>
			<content:encoded><![CDATA[<p><font color="#000000"> &lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />
&#8220;DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
<font color="#0000bb">&lt;?php </font><font color="#007700">if ( (!isset(</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">&#8217;submit&#8217;</font><font color="#007700">])) ) { </font><font color="#0000bb">?&gt;<br />
</font>  &lt;form action=&#8221;<font color="#0000bb">&lt;?php </font><font color="#007700">echo </font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">&#8216;PHP_SELF&#8217;</font><font color="#007700">]; </font><font color="#0000bb">?&gt;</font>&#8220; method=&#8221;post&#8221;&gt;<br />
&lt;table&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Your rating:&lt;/td&gt;<br />
&lt;td&gt;&lt;select name=&#8221;rate&#8221;&gt;<br />
&lt;option value=&#8221;1&#8243;&gt;1&lt;/option&gt;<br />
&lt;option value=&#8221;2&#8243;&gt;2&lt;/option&gt;<br />
&lt;option value=&#8221;3&#8243;&gt;3&lt;/option&gt;<br />
&lt;option value=&#8221;4&#8243;&gt;4&lt;/option&gt;<br />
&lt;option value=&#8221;5&#8243;&gt;5&lt;/option&gt;<br />
&lt;/select&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td colspan=&#8221;2&#8243; align=&#8221;center&#8221;&gt;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;Rate it!&#8221; name=&#8221;submit&#8221;/&gt;<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/form&gt;</p>
<p><font color="#0000bb">&lt;?php<br />
</font><font color="#007700">} else  {<br />
</font><font color="#0000bb">$rate </font><font color="#007700">= isset (</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">&#8216;rate&#8217;</font><font color="#007700">]) ? </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">&#8216;rate&#8217;</font><font color="#007700">] : </font><font color="#0000bb">0</font><font color="#007700">;<br />
</font><font color="#0000bb">$filename     </font><font color="#007700">= </font><font color="#dd0000">&#8220;ratings&#8221;</font><font color="#007700">;<br />
</font><font color="#0000bb">$alreadyRated </font><font color="#007700">= </font><font color="#0000bb">false</font><font color="#007700">;<br />
</font><font color="#0000bb">$totalRates   </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">;<br />
</font><font color="#0000bb">$totalPoints  </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">;</p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">getenv</font><font color="#007700">(</font><font color="#dd0000">&#8216;REMOTE_ADDR&#8217;</font><font color="#007700">);</p>
<p></font><font color="#ff8000">// Read the result file<br />
</font><font color="#0000bb">$oldResults </font><font color="#007700">= </font><font color="#0000bb">file</font><font color="#007700">(</font><font color="#dd0000">&#8216;results/&#8217;</font><font color="#007700">.</font><font color="#0000bb">$filename</font><font color="#007700">.</font><font color="#dd0000">&#8216;.txt&#8217;</font><font color="#007700">);</p>
<p></font><font color="#ff8000">// Summarize total points and rates<br />
</font><font color="#007700">foreach (</font><font color="#0000bb">$oldResults </font><font color="#007700">as </font><font color="#0000bb">$value</font><font color="#007700">) {<br />
</font><font color="#0000bb">$oneRate </font><font color="#007700">= </font><font color="#0000bb">explode</font><font color="#007700">(</font><font color="#dd0000">&#8216;:&#8217;</font><font color="#007700">,</font><font color="#0000bb">$value</font><font color="#007700">);<br />
</font><font color="#ff8000">// If our IP is in the list then set the falg<br />
</font><font color="#007700">if (</font><font color="#0000bb">$ip </font><font color="#007700">== </font><font color="#0000bb">$oneRate</font><font color="#007700">[</font><font color="#0000bb">0</font><font color="#007700">]) </font><font color="#0000bb">$alreadyRated </font><font color="#007700">= </font><font color="#0000bb">true</font><font color="#007700">;<br />
</font><font color="#0000bb">$totalRates</font><font color="#007700">++;<br />
</font><font color="#0000bb">$totalPoints </font><font color="#007700">+= </font><font color="#0000bb">$oneRate</font><font color="#007700">[</font><font color="#0000bb">1</font><font color="#007700">];<br />
}</p>
<p></font><font color="#ff8000">// If our rating is valid then append it to the result file<br />
</font><font color="#007700">if ((!</font><font color="#0000bb">$alreadyRated</font><font color="#007700">) &amp;&amp; (</font><font color="#0000bb">$rate </font><font color="#007700">&gt; </font><font color="#0000bb">0</font><font color="#007700">)){<br />
</font><font color="#0000bb">$f </font><font color="#007700">= </font><font color="#0000bb">fopen</font><font color="#007700">(</font><font color="#dd0000">&#8216;results/&#8217;</font><font color="#007700">.</font><font color="#0000bb">$filename</font><font color="#007700">.</font><font color="#dd0000">&#8220;.txt&#8221;</font><font color="#007700">,</font><font color="#dd0000">&#8220;a+&#8221;</font><font color="#007700">);<br />
</font><font color="#0000bb">fwrite</font><font color="#007700">(</font><font color="#0000bb">$f</font><font color="#007700">,</font><font color="#0000bb">$ip</font><font color="#007700">.</font><font color="#dd0000">&#8216;:&#8217;</font><font color="#007700">.</font><font color="#0000bb">$rate</font><font color="#007700">.</font><font color="#dd0000">&#8220;\n&#8221;</font><font color="#007700">);<br />
</font><font color="#0000bb">fclose</font><font color="#007700">(</font><font color="#0000bb">$f</font><font color="#007700">);<br />
</font><font color="#0000bb">$totalRates</font><font color="#007700">++;<br />
</font><font color="#0000bb">$totalPoints</font><font color="#007700">+=</font><font color="#0000bb">$rate</font><font color="#007700">;<br />
}</p>
<p>echo </font><font color="#dd0000">&#8220;Actual rating from $totalRates rates is: &#8221;<br />
</font><font color="#007700">.</font><font color="#0000bb">substr</font><font color="#007700">((</font><font color="#0000bb">$totalPoints</font><font color="#007700">/</font><font color="#0000bb">$totalRates</font><font color="#007700">),</font><font color="#0000bb">0</font><font color="#007700">,</font><font color="#0000bb">3</font><font color="#007700">).</font><font color="#dd0000">&#8220;&lt;br/&gt;&#8221;</font><font color="#007700">;</p>
<p></font><font color="#ff8000">// Display the actual rating<br />
</font><font color="#007700">for (</font><font color="#0000bb">$i</font><font color="#007700">=</font><font color="#0000bb">0</font><font color="#007700">;</font><font color="#0000bb">$i</font><font color="#007700">&lt;</font><font color="#0000bb">round</font><font color="#007700">((</font><font color="#0000bb">$totalPoints</font><font color="#007700">/</font><font color="#0000bb">$totalRates</font><font color="#007700">),</font><font color="#0000bb">0</font><font color="#007700">);</font><font color="#0000bb">$i</font><font color="#007700">++){<br />
echo </font><font color="#dd0000">&#8220;&lt;img src=&#8217;style/star.png&#8217; /&gt;&#8221;</font><font color="#007700">;<br />
}<br />
} </font><font color="#0000bb">?&gt;</font><br />
&lt;/body&gt;<br />
</font></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/how-to-create-a-basic-rating-system/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Code Snippet: Date converter</title>
		<link>http://php.trivuz.com/code-snippet-date-converter/</link>
		<comments>http://php.trivuz.com/code-snippet-date-converter/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 11:07:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Code Snippets]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/code-snippet-date-converter/</guid>
		<description><![CDATA[Snippet: Date converter
Description:
       										This tiny piece of code takes care that you can display a standard date instead of the mysql date (2005-02-23)
Example:
echo date(&#8221;d m Y&#8221;, &#8220;2005-02-23&#8243;);
Shows:
23 02 2005
Code:
PHP:
]]></description>
			<content:encoded><![CDATA[<p><strong>Snippet: </strong>Date converter</p>
<p><strong>Description:</strong></p>
<p class="jump_in">       										This tiny piece of code takes care that you can display a standard date instead of the mysql date (2005-02-23)</p>
<p>Example:<br />
echo date(&#8221;d m Y&#8221;, &#8220;2005-02-23&#8243;);</p>
<p>Shows:<br />
23 02 2005</p>
<p><strong>Code:</strong><br />
<span class="12px">PHP:</span><br />
 <a href="http://php.trivuz.com/code-snippet-date-converter/#more-17" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/code-snippet-date-converter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Snippet: Are sessions working?</title>
		<link>http://php.trivuz.com/snippet-are-sessions-working/</link>
		<comments>http://php.trivuz.com/snippet-are-sessions-working/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 11:02:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Code Snippets]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://php.trivuz.com/snippet-are-sessions-working/</guid>
		<description><![CDATA[Description:
       										You can use this piece of code to check if it is possible to use sessions for the visitor.
This can come handy for login pages. If you have cookies disabled and try to login, no login session can be used. In such cases it is nice to inform [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Description:</strong></p>
<p class="jump_in">       										You can use this piece of code to check if it is possible to use sessions for the visitor.</p>
<p>This can come handy for login pages. If you have cookies disabled and try to login, no login session can be used. In such cases it is nice to inform your visitors.</p>
<p><strong>Code:</strong><br />
<span class="12px">PHP:</span><br />
<hr noshade="noshade" /><code><font color="#000000"><br />
<font color="#0000bb">&lt;?php</p>
<p>session_start </font><font color="#007700">();<br />
</font><font color="#ff8000">//Check GET request<br />
</font><font color="#007700">if (isset (</font><font color="#0000bb">$_GET</font><font color="#007700">[</font><font color="#dd0000">&#8216;cookie_check&#8217;</font><font color="#007700">])){<br />
</font><font color="#ff8000">//Check session<br />
</font><font color="#007700">if (isset (</font><font color="#0000bb">$_SESSION</font><font color="#007700">[</font><font color="#dd0000">&#8217;session_set&#8217;</font><font color="#007700">])){<br />
</font><font color="#ff8000">//Display working message<br />
</font><font color="#007700">echo </font><font color="#dd0000">&#8220;working&#8230;&#8221;</font><font color="#007700">;<br />
exit;<br />
</font><font color="#ff8000">//Or redirect<br />
//header (&#8221;Location: cookie_working.php&#8221;);<br />
</font><font color="#007700">} else {<br />
</font><font color="#ff8000">//Display failure message<br />
</font><font color="#007700">echo </font><font color="#dd0000">&#8220;failure&#8230;&#8221;</font><font color="#007700">;<br />
exit;<br />
</font><font color="#ff8000">//Or redirect<br />
//header (&#8221;Location: cookie_fail.php&#8221;);<br />
</font><font color="#007700">}<br />
}<br />
</font><font color="#0000bb">session_register </font><font color="#007700">(</font><font color="#dd0000">&#8220;session_set&#8221;</font><font color="#007700">);<br />
</font><font color="#0000bb">$_SESSION</font><font color="#007700">[</font><font color="#dd0000">&#8217;session_set&#8217;</font><font color="#007700">] = </font><font color="#0000bb">true</font><font color="#007700">;<br />
</font><font color="#0000bb">header </font><font color="#007700">(</font><font color="#dd0000">&#8220;Location: cookie_check.php?cookie_check=1&#8243;</font><font color="#007700">);</p>
<p></font><font color="#0000bb">?&gt;</font><br />
</font></code></p>
]]></content:encoded>
			<wfw:commentRss>http://php.trivuz.com/snippet-are-sessions-working/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
