<?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"
	>

<channel>
	<title>Dodit Suprianto</title>
	<atom:link href="http://dodit.net23.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dodit.net23.net</link>
	<description>My PHP classes repository</description>
	<pubDate>Thu, 12 Mar 2009 04:47:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>CSS Pagination</title>
		<link>http://dodit.net23.net/?p=20</link>
		<comments>http://dodit.net23.net/?p=20#comments</comments>
		<pubDate>Sun, 26 Oct 2008 14:45:19 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
		
		<category><![CDATA[PHP Classes]]></category>

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

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

		<guid isPermaLink="false">http://dodit.net23.net/?p=20</guid>
		<description><![CDATA[A Pagination is process to split a large number of records to be several records per page which you can determine how much number of records per page by your self. For example, you will be load 1000 records into your web page in one page, that is disadvantage performance for your server because it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div>A Pagination is process to split a large number of records to be several records per page which you can determine how much number of records per page by your self. For example, you will be load 1000 records into your web page in one page, that is disadvantage performance for your server because it&#8217;s to hard and slowly process. To be wise if you use pagination mechanism.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4968797830346325";
/* 468x60, created 2/12/08 */
google_ad_slot = "7846766812";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>How it can be? for load 1000 records, you can splitting to be 10 records per page. it means that you have 100 pages. So we need to make page index, also previous and next page navigation to cover all records.</p>
<p>Screenshoot:<br />
<img class="aligncenter" src="http://dodit.net23.net/phpclasses/pagination/pagination.gif" alt="" width="314" height="28" /></p>
<p><a href="http://dodit.net23.net/phpclasses/pagination/pagination.zip"><strong>Download CSSPagination</strong></a></p>
<p><strong>CSSPagination.class.php code files is:</strong></p>
<p>&lt;code&gt;</p>
<p>&lt;?php</p>
<p>/**<br />
* @author Dodit Suprianto<br />
* Email: d0dit@yahoo.com<br />
* Website: http://doditsuprianto.com, http://goiklan.co.nr<br />
* Website: http://www.meozit.com, http://easyads.co.nr<br />
*<br />
* CSSPagination is a pagination class which combines with Cascading Style Sheet for good looking style;<br />
* CSSPagination has main function to split all records before they will be loaded into one website,<br />
* to be several records in one page (you can determine how many records in one page).<br />
* So, if you want to jump at the other page, you can choose once of them.<br />
* CSSPagination is easy to use and good looking. I try to throw the complexity code.<br />
* The most important is, that you can change the CSS code to make it suitable with your own page style.<br />
*/</p>
<p>class CSSPagination<br />
{<br />
private $totalrows;<br />
private $rowsperpage;<br />
private $website;<br />
private $page;<br />
private $sql;</p>
<p>public function __construct($sql, $rowsperpage, $website)<br />
{<br />
$this-&gt;sql = $sql;<br />
$this-&gt;website = $website;<br />
$this-&gt;rowsperpage = $rowsperpage;<br />
}</p>
<p>public function setPage($page)<br />
{<br />
if (!$page) { $this-&gt;page=1; } else  { $this-&gt;page = $page; }<br />
}</p>
<p>public function getLimit()<br />
{<br />
return ($this-&gt;page - 1) * $this-&gt;rowsperpage;<br />
}</p>
<p>private function getTotalRows()<br />
{<br />
$result = @mysql_query($this-&gt;sql) or die (&#8221;query failed!&#8221;);<br />
$this-&gt;totalrows = mysql_num_rows($result);<br />
}</p>
<p>private function getLastPage()<br />
{<br />
return ceil($this-&gt;totalrows / $this-&gt;rowsperpage);<br />
}</p>
<p>public function showPage()<br />
{<br />
$this-&gt;getTotalRows();</p>
<p>$pagination = &#8220;&#8221;;<br />
$lpm1 = $this-&gt;getLastPage() - 1;<br />
$page = $this-&gt;page;<br />
$prev = $this-&gt;page - 1;<br />
$next = $this-&gt;page + 1;</p>
<p>$pagination .= &#8220;&lt;div class=\&#8221;pagination\&#8221;";<br />
if($margin || $padding)<br />
{<br />
$pagination .= &#8221; style=\&#8221;";<br />
if($margin)<br />
$pagination .= &#8220;margin: $margin;&#8221;;<br />
if($padding)<br />
$pagination .= &#8220;padding: $padding;&#8221;;<br />
$pagination .= &#8220;\&#8221;";<br />
}<br />
$pagination .= &#8220;&gt;&#8221;;</p>
<p>if ($this-&gt;getLastPage() &gt; 1)<br />
{<br />
if ($page &gt; 1)<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$prev&gt;« prev&lt;/a&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;span class=\&#8221;disabled\&#8221;&gt;« prev&lt;/span&gt;&#8221;;</p>
<p>if ($this-&gt;getLastPage() &lt; 9)<br />
{<br />
for ($counter = 1; $counter &lt;= $this-&gt;getLastPage(); $counter++)<br />
{<br />
if ($counter == $page)<br />
$pagination .= &#8220;&lt;span class=\&#8221;current\&#8221;&gt;&#8221;.$counter.&#8221;&lt;/span&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$counter&gt;&#8221;.$counter.&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
}</p>
<p>elseif($this-&gt;getLastPage() &gt;= 9)<br />
{<br />
if($page &lt; 4)<br />
{<br />
for ($counter = 1; $counter &lt; 6; $counter++)<br />
{<br />
if ($counter == $page)<br />
$pagination .= &#8220;&lt;span class=\&#8221;current\&#8221;&gt;&#8221;.$counter.&#8221;&lt;/span&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$counter/&gt;&#8221;.$counter.&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
$pagination .= &#8220;&#8230;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$lpm1&gt;&#8221;.$lpm1.&#8221;&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=&#8221;.$this-&gt;getLastPage().&#8221;&gt;&#8221;.$this-&gt;getLastPage().&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
elseif($this-&gt;getLastPage() - 3 &gt; $page &amp;&amp; $page &gt; 1)<br />
{<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=1&gt;1&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=2&gt;2&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&#8230;&#8221;;<br />
for ($counter = $page - 1; $counter &lt;= $page + 1; $counter++)<br />
{<br />
if ($counter == $page)<br />
$pagination .= &#8220;&lt;span class=\&#8221;current\&#8221;&gt;&#8221;.$counter.&#8221;&lt;/span&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$counter&gt;&#8221;.$counter.&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
$pagination .= &#8220;&#8230;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$lpm1&gt;$lpm1&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=&#8221;.$this-&gt;getLastPage().&#8221;&gt;&#8221;.$this-&gt;getLastPage().&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
else<br />
{<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=1&gt;1&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=2&gt;2&lt;/a&gt;&#8221;;<br />
$pagination .= &#8220;&#8230;&#8221;;<br />
for ($counter = $this-&gt;getLastPage() - 4; $counter &lt;= $this-&gt;getLastPage(); $counter++)<br />
{<br />
if ($counter == $page)<br />
$pagination .= &#8220;&lt;span class=\&#8221;current\&#8221;&gt;&#8221;.$counter.&#8221;&lt;/span&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$counter&gt;&#8221;.$counter.&#8221;&lt;/a&gt;&#8221;;<br />
}<br />
}<br />
}</p>
<p>if ($page &lt; $counter - 1)<br />
$pagination .= &#8220;&lt;a href=$this-&gt;website&amp;page=$next&gt;next »&lt;/a&gt;&#8221;;<br />
else<br />
$pagination .= &#8220;&lt;span class=\&#8221;disabled\&#8221;&gt;next »&lt;/span&gt;&#8221;;<br />
$pagination .= &#8220;&lt;/div&gt;\n&#8221;;<br />
}</p>
<p>return $pagination;<br />
}<br />
}<br />
?&gt;</p>
<p>&lt;/code&gt;</p></div>
]]></content:encoded>
			<wfw:commentRss>http://dodit.net23.net/?feed=rss2&amp;p=20</wfw:commentRss>
		</item>
		<item>
		<title>Image Resizer</title>
		<link>http://dodit.net23.net/?p=18</link>
		<comments>http://dodit.net23.net/?p=18#comments</comments>
		<pubDate>Sun, 26 Oct 2008 14:38:27 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
		
		<category><![CDATA[PHP Classes]]></category>

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

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

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

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

		<guid isPermaLink="false">http://dodit.net23.net/?p=18</guid>
		<description><![CDATA[
The Simple Image Resizer class is useful when you would upload a large image file to the server. Suppose that we do not really need to upload the exactly size. And the fact is we want to upload and save those files into smaller size.




This class can be used to resize images of different formats. [...]]]></description>
			<content:encoded><![CDATA[<div align="justify">
The Simple Image Resizer class is useful when you would upload a large image file to the server. Suppose that we do not really need to upload the exactly size. And the fact is we want to upload and save those files into smaller size.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4968797830346325";
/* 468x60, created 2/12/08 */
google_ad_slot = "7846766812";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>This class can be used to resize images of different formats. It can take an image file in a GIF, JPEG or PNG format and resize it to a given size. The resized image may keep the proportion between the width and height of the original image, The resulting image is saved to a file in the same format as the original image.</p>
<p>You can see the original image size like this one:<br />
<img alt="" src="http://dodit.net23.net/phpclasses/ImageResizer/besar.jpg" class="aligncenter" width="400" height="300" /></p>
<p>And the result after the image resizing by Simple Image Resizer class is:<br />
<img alt="" src="http://dodit.net23.net/phpclasses/ImageResizer/kecil.jpg" class="aligncenter" width="200" height="150" /></p>
<p><a href="http://dodit.net23.net/phpclasses/ImageResizer/ImageResizer.zip"><strong>Download Image Resizer</strong></a>
</div>
<p><strong>Code ImageResize.inc Class File:</strong></p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>&#60;?php
/**
 * @author Dodit Suprianto
 * Email: d0dit@yahoo.com
 * Website: http://doditsuprianto.com
 *
 * Nama file: ImageResize.inc
 *
 * This class to resize an image from bigger to smaller size.
 * Supporting PNG, JPG, and GIF image format.
 *
 * if you chose $proportional=true, it means that width or height image is proportional, example:
 * $r = new Resize("test.jpg", 0, 500, true); height image will be 500 pixel and width will be proportional
 * $r = new Resize("test.jpg", 500, 0, true); width image will be 500 pixel and height will be proportional
 *
 * if you chose $proportional=false, it means the width and height image will be customizable, example:
 * $r = new Resize("test.jpg", 500, 500, true); it forces the image size will be 500 pixel width and 500 pixel height
 *
 */

	class Resize
	{
		private $file_source;
		private $width_resize;
		private $height_resize;
		private $proportional;

		public function __construct($file_source, $width_resize, $height_resize, $proportional)
		{
			$this->file_source = $file_source;
			$this->width_resize = $width_resize;
			$this->height_resize = $height_resize;
			$this->proportional = $proportional;
		}

		public function setProportional($proportional)
		{
			$this->proportional = $proportional;
		}

		public function setFileSource($file_source)
		{
			$this->file_source = $file_source;
		}

		public function setHeightResize($height_resize)
		{
			$this->height_resize = $height_resize;
		}

		public function setWidthResize($width_resize)
		{
			$this->width_resize = $width_resize;
		}

		private function MemoryUsage()
		{
			$imageInfo    = getimagesize($this->file_source);
			$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65);

			$memoryLimit = (int) ini_get('memory_limit')*1048576;
			if ((memory_get_usage() + $memoryNeeded) > $memoryLimit)
			ini_set('memory_limit', ceil((memory_get_usage() + $memoryNeeded + $memoryLimit)/1048576).'M');
		}

		public function ImageResize()
		{
			$this->MemoryUsage();
			if ( $this->height_resize &#60;= 0 &#038;&#038; $this->width_resize &#60;= 0 ) return false;

			$info = getimagesize($this->file_source);
		    $image = '';

			$final_width = 0;
			$final_height = 0;
			list($width_old, $height_old) = $info;

			if ($this->proportional)
			{
				$proportion = $width_old / $height_old;

				if ( $this->width_resize > $this->height_resize &#038;&#038; $this->height_resize != 0)
				{
					$final_height = $this->height_resize;
					$final_width = $final_height * $proportion;
				}
				elseif ( $this->width_resize &#60; $this->height_resize &#038;&#038; $this->width_resize != 0)
				{
					$final_width = $this->width_resize;
					$final_height = $final_width / $proportion;
				}
				elseif ( $this->width_resize == 0 )
				{
					$final_height = $this->height_resize;
					$final_width = $final_height * $proportion;
				}
				elseif ( $this->height_resize == 0)
		        {
					$final_width = $this->width_resize;
					$final_height = $final_width / $proportion;
				}
				else
				{
					$final_width = $this->width_resize;
					$final_height = $this->height_resize;
				}
			}
			else
			{
				$final_width = ($this->width_resize &#60;= 0) ? $this->width_resize_old : $this->width_resize;
				$final_height = ($this->height_resize &#60;= 0) ? $this->height_resize_old : $this->height_resize;
			}

			switch ( $info[2] )
			{
				case IMAGETYPE_GIF:
					$image = imagecreatefromgif($this->file_source);
				break;
				case IMAGETYPE_JPEG:
					$image = imagecreatefromjpeg($this->file_source);
				break;
				case IMAGETYPE_PNG:
					$image = imagecreatefrompng($this->file_source);
				break;
				default:
					return false;
			}

			$image_resized = imagecreatetruecolor( $final_width, $final_height );
			imagecolortransparent($image_resized, imagecolorallocate($image_resized, 0, 0, 0) );
			imagealphablending($image_resized, false);
			imagesavealpha($image_resized, true);

			imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);

			switch ( $info[2] )
			{
				case IMAGETYPE_GIF:
					imagegif($image_resized, time().".gif", 100);
				break;
				case IMAGETYPE_JPEG:
					imagejpeg($image_resized, time().".jpg", 100);
				break;
				case IMAGETYPE_PNG:
					imagepng($image_resized, time().".png", 100);
				break;
				default:
					return false;
			}
			return true;
		}
	}
?></pre>
</div>
<p></code></div>
</div>
<p><strong>Test File Code:</strong></p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>&#60;html>

&#60;head>
&#60;title>Image Resize&#60;/title>
&#60;/head>

&#60;body>

&#60;form enctype="multipart/form-data" method="POST" action="&#60;?php echo $_SERVER['SELF'];?>">
	Photo: &#60;input type=file name=photo size="20">&#60;br>
	Proportional: &#60;input type="radio" value="yes" checked name="R1"> &#60;input type="radio" value="no" name="R1">&#60;br>
	Width: &#60;input type="text" name="width" size="20">&#60;br>
	Height: &#60;input type="text" name="height" size="20">&#60;br>
	&#60;input type="submit" name="submit" value="Resize">
&#60;/form>

&#60;?php
	if ($_POST['submit'])
	{
		require_once("ImageResize.inc");

		if ($_POST['R1'] == "yes")
		{
			// proportional
			$r = new Resize($_FILES['photo']['tmp_name'], $_POST['width'], 0, true);
			// or $r = new Resize($_FILE['photo']['tmp_name'], 0, $_POST['height'], true);
		} else
		{
			// Force the image size
			$r = new Resize($_FILES[photo][tmp_name], $_POST[width], $_POST[height], false);
		}
		$r->ImageResize();
	}
?>

&#60;/body>

&#60;/html></pre>
</div>
<p></code></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dodit.net23.net/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
		<item>
		<title>Custom Pie Chart</title>
		<link>http://dodit.net23.net/?p=13</link>
		<comments>http://dodit.net23.net/?p=13#comments</comments>
		<pubDate>Sun, 26 Oct 2008 14:27:31 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
		
		<category><![CDATA[PHP Classes]]></category>

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

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

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

		<guid isPermaLink="false">http://dodit.net23.net/?p=13</guid>
		<description><![CDATA[Custom pie chart is a class to generate your own pie chart. Easy to use and very simple. You don&#8217;t need to configure it very much. Just set a canvas area, set a value, label description for each slice, of course you could add the other slices as you like, and finally you can determine [...]]]></description>
			<content:encoded><![CDATA[<div>Custom pie chart is a class to generate your own pie chart. Easy to use and very simple. You don&#8217;t need to configure it very much. Just set a canvas area, set a value, label description for each slice, of course you could add the other slices as you like, and finally you can determine of the pie tickness.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4968797830346325";
/* 468x60, created 2/12/08 */
google_ad_slot = "7846766812";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>This pie chart will calculate and generate automatically for you. If need it you can also change the font style, color background and font color. This pie chart could be bind with your data to present a statistic data such as voote, data visitor, and any purpose.</p>
<p>Screenshot of the Custom Pie Result:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://dodit.net23.net/phpclasses/chart/example.png" alt="" width="298" height="393" /></p>
<p><strong><a href="http://dodit.net23.net/phpclasses/chart/pieChart.zip">Download Custom Pie Chart</a></strong></p>
<p><strong>The pieChart.class.php code:</strong>
</div>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>&#60;?php
/**
 * @author Dodit Suprianto
 * Email: d0dit@yahoo.com
 * Website: http://www.meozit.com, http://doditsuprianto.com
 *
 * File name: pieChart.class.php
 *
 * Description:
 * Custom pie chart is a class to generate your own pie chart. Easy to use and very simple.
 * You don't need to configure very much. Just set a canvas area, set a value and description for an each pie slice,
 * of course you should add other slices as you like. This pie chart will calculate and generate automatically for you.
 * If need it you can also change the font style, color background and font color.
 * This pie chart could be bind with your data for present a static data such as vooting, data visitor, and other purpose.
 *
 */

class pieChart
{
	private $canvasWidth;
	private $canvasHeight;
	private $tickness;
	private $color = array();
	private $image;
	private $degree = array();
	private $value = array();
	private $description = array();
	private $font;
	private $fontcolor;
	private $bgcolor;
	private $bgR;
	private $bgG;
	private $bgB;
	private $fontR;
	private $fontG;
	private $fontB;
	private $title = array();

	public function __construct($canvasWidth, $canvasHeight, $tickness)
	{
		$this->canvasWidth = $canvasWidth;
		$this->canvasHeight = $canvasHeight;
		$this->image = imagecreatetruecolor($this->canvasWidth, $this->canvasHeight);
		$this->tickness = $tickness;
	}

	public function setTitle($title)
	{
		$this->title[] = $title;
	}

	public function setFontColor($fontcolor)
	{
		if ($fontcolor)
		{
			$this->fontcolor = imagecolorallocate($this->image, hexdec(substr(trim($fontcolor),1,2)), hexdec(substr(trim($fontcolor),3,2)), hexdec(substr(trim($fontcolor),5,2)));
		} else {$this->fontcolor = imagecolorallocate($this->image, 0, 0, 0);}
	}

	public function setBGColor($bgcolor)
	{
		if ($bgcolor)
		{
			$this->bgR = hexdec(substr(trim($bgcolor), 1, 2));
			$this->bgG = hexdec(substr(trim($bgcolor), 3, 2));
			$this->bgB = hexdec(substr(trim($bgcolor), 5, 2));
			$this->bgcolor = imagecolorallocate($this->image, hexdec(substr(trim($bgcolor),1,2)), hexdec(substr(trim($bgcolor),3,2)), hexdec(substr(trim($bgcolor),5,2)));
		} else {$this->bgcolor = imagecolorallocate($this->image, 0, 0, 0);}
	}

	public function setFont($font)
	{
		$this->font = $font;
	}

	public function Tickness($tickness)
	{
		$this->tickness = $tickness;
	}

	private function pieSlice()
	{
		$total = 0;
		for ($i=0; $i &#60; count($this->value); $i++)
		{
			$total += $this->value[$i];
		}

		for ($i=0; $i &#60; count($this->value); $i++)
		{
			$this->degree[$i] = $this->value[$i] / $total * 360;
			$R = mt_rand(25,250);
			$G = mt_rand(25,250);
			$B = mt_rand(25,250);
			$this->color["light"][$i] = imagecolorallocate($this->image, $R, $G, $B);
			$this->color["dark"][$i] = imagecolorallocate($this->image, $R - 20, $G - 20, $B - 20);
		}
	}

	public function setValue($description, $value)
	{
		$this->value[] = $value;
		$this->description[] = $description;
	}

	public function showPie()
	{
		imagefill($this->image, 0, 0, imagecolorallocate($this->image, $this->bgR, $this->bgG, $this->bgB));

		$pieX = ceil($this->canvasWidth / 2);
		$pieY = ceil($this->canvasHeight / 2) - 60;

		$this->pieSlice();		

		for ($i = $this->tickness + $pieY; $i > $pieY; $i--)
		{
			$start = 0;
			for ($iterate=0; $iterate &#60; count($this->value); $iterate++)
			{
				imagefilledarc($this->image, $pieX, $i, $this->canvasWidth - 50, ($this->canvasWidth - 50)/2, $start, $start + $this->degree[$iterate], $this->color["dark"][$iterate], IMG_ARC_PIE);
			  	$start += $this->degree[$iterate];
			}
		}

		$start = 0;
		$x1 = 20;
		$y1 = 0 + $this->canvasHeight * 2 / 3;
		$x2 = 30;
		$y2 = 10 + $this->canvasHeight * 2 / 3;

		for ($iterate=0; $iterate &#60; count($this->value); $iterate++)
		{
			imagefilledarc($this->image, $pieX, $pieY, $this->canvasWidth - 50, ($this->canvasWidth - 50)/2, $start, $start + $this->degree[$iterate], $this->color["light"][$iterate], IMG_ARC_PIE);
			imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $this->color["light"][$iterate]);
			imagettftext($this->image, 9, 0, $x2 + 5, $y2, $this->fontcolor, $this->font, $this->description[$iterate] . " = " . $this->value[$iterate]);
			$start += $this->degree[$iterate];
			$y1 += 15;
			$y2 += 15;
		}

		$py = 30;
		for ($i=0; $i&#60;count($this->title); $i++)
		{
			$textbox = imagettfbbox(12, 0, $this->font, $this->title[$i]);
			$px = ($this->canvasWidth - $textbox[4])/2;
			$py = 30 + $i * 30;

			imagettftext($this->image, 12, 0, $px, $py, $this->fontcolor, $this->font, $this->title[$i]);
		}

		header('Content-type: image/png');
		imagepng($this->image);
		simagedestroy($this->image);
	}
}

$img = new pieChart(300, 430, 26);
$img->setFont("lsans.ttf");
$img->setValue("http://www.doditsuprianto.com", 56);
$img->setValue("http://www.meozit.com", 100);
$img->setValue("http://www.goiklan.com", 78);
$img->setValue("http://www.phpclasses.org", 190);
$img->setValue("http://www.hotscripts.com",120);
$img->setValue("http://www.google.com", 45);
$img->setBGColor("#001122");
$img->setFontColor("#FFFFFF");
$img->setTitle("FIRST TITLE ON THE FIRST LINE");
$img->setTitle("SECOND TITLE ON THE SECOND LINE");
$img->showPie();
?></pre>
</div>
<p></code></div>
</div>
<p><strong>Using Pie Chart Code:</strong></p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre> 
&#60;html>

&#60;head>
&#60;title>Custom Pie Chart&#60;/title>
&#60;/head>

&#60;body>

&#60;table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="295">
  &#60;tr>
    &#60;td width="100%" height="295">
    &#60;p align="center">&#60;img src=pieChart.class.php>&#60;/td>
  &#60;/tr>
&#60;/table>

&#60;/body>

&#60;/html></pre>
</div>
<p></code></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dodit.net23.net/?feed=rss2&amp;p=13</wfw:commentRss>
		</item>
		<item>
		<title>Custom CAPTCHA</title>
		<link>http://dodit.net23.net/?p=5</link>
		<comments>http://dodit.net23.net/?p=5#comments</comments>
		<pubDate>Sun, 26 Oct 2008 11:28:58 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
		
		<category><![CDATA[PHP Classes]]></category>

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

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

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

		<guid isPermaLink="false">http://dodit.net23.net/?p=5</guid>
		<description><![CDATA[
A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can&#8217;t:

The term CAPTCHA (for Completely Automated Turing Test To Tell Computers and Humans Apart) was [...]]]></description>
			<content:encoded><![CDATA[<div align="justify">
<p>A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can&#8217;t:</p>
<p><img alt="Custom CAPTCHA Screenshot" src="http://dodit.net23.net/phpclasses/captcha/captcha.class.php.gif" class="aligncenter" width="172" height="47" /></p>
<p>The term CAPTCHA (for Completely Automated Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University. At the time, they developed the first CAPTCHA to be used by Yahoo.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4968797830346325";
/* 300x250, created 4/20/08 */
google_ad_slot = "5068686902";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> </p>
<p>CSSPagination is a pagination class which combines with Cascading Style Sheet for good looking style; CSSPagination has main function to split all records before they will be loaded into one website, to be several records in one page (you can determine how many records in one page). So, if you want to jump at the other page, you can choose once of them. CSSPagination is easy to use and good looking. I try to throw the complexity code. The most important is, that you can change the CSS code (style.css) to make it suitable with your own page style.</p>
<p><strong><a href="http://dodit.net23.net/phpclasses/captcha/captcha.zip">Download Cusutom CAPTCHA</a></strong></p>
<p><strong>The code of captcha.class.php:</strong></p>
</div>
<p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>&#60;br />
&#60;?php&#60;br />
/**&#60;br />
* @author Dodit Suprianto&#60;br />
* Email: d0dit@yahoo.com&#60;br />
* Website: http://doditsuprianto.com, http://goiklan.co.nr&#60;br />
* Website: http://www.meozit.com, http://easyads.co.nr&#60;br />
*&#60;br />
* call captcha code &#60;img src=captcha.class.php?length=&#038;font=&#038;size=&#038;angel=&#038;file=>&#60;br />
*&#60;br />
* You can enter the parameter or not. Explaination:&#60;br />
*&#60;br />
* length : how much character will be shown. 4 character by default.&#60;br />
* font : Type of font (ex. Arial.ttf). Georgia font by default&#60;br />
* size : Size of font character. 20 by default&#60;br />
* angel : angel of font character. 0 by default, it means horizontal position&#60;br />
* file : if you want subtitute the background image. "eyes.gif" by default.&#60;br />
*&#60;br />
* You must copy several file to current directory&#60;br />
* if you want to subtitute the default setting.&#60;br />
* such as font file, background file&#60;br />
*&#60;br />
*/&#60;/p>
&#60;p>session_start();&#60;/p>
&#60;p>class captcha&#60;br />
{&#60;br />
private $length;&#60;br />
private $font;&#60;br />
private $size;&#60;br />
private $angel;&#60;br />
private $file;&#60;/p>
&#60;p>public function __construct()&#60;br />
{&#60;br />
$this->length = 4;&#60;br />
$this->font = "georgia.ttf";&#60;br />
$this->size = 20;&#60;br />
$this->angel = 0;&#60;br />
$this->file = "eyes.gif";&#60;br />
}&#60;/p>
&#60;p>public function setFile($file)&#60;br />
{&#60;br />
$this->file = $file;&#60;br />
}&#60;/p>
&#60;p>public function setLength($length)&#60;br />
{&#60;br />
$this->length = $length;&#60;br />
}&#60;/p>
&#60;p>public function setFont($font)&#60;br />
{&#60;br />
$this->font = $font;&#60;br />
}&#60;/p>
&#60;p>public function setSize($size)&#60;br />
{&#60;br />
$this->size = $size;&#60;br />
}&#60;/p>
&#60;p>public function setAngel($angel)&#60;br />
{&#60;br />
$this->angel = $angel;&#60;br />
}&#60;/p>
&#60;p>private function RandomText()&#60;br />
{&#60;br />
$output = "";&#60;br />
$input = array('A','B','C','D','E','F','G','H','I','J','K','L',&#60;br />
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2',&#60;br />
'3','4','5','6','7','8','9');&#60;br />
srand((float) microtime() * 10000000);&#60;br />
$rand_keys = array_rand($input, count($input)); &#60;/p>
&#60;p>for ($i=0; $i &#60; count($input)-1; $i++)&#60;br />
{&#60;br />
$output .= $input[$rand_keys[$i]];&#60;br />
}&#60;br />
return substr($output, 0, $this->length);&#60;br />
}&#60;/p>
&#60;p>public function ConvertFontToImage()&#60;br />
{&#60;br />
$type = getimagesize($this->file);&#60;br />
$random = $this->RandomText();&#60;br />
switch ($type[2])&#60;br />
{&#60;br />
case IMAGETYPE_GIF:&#60;br />
header("Content-type: image/gif");&#60;br />
$im = imagecreatefromgif($this->file);&#60;br />
$white = imagecolorallocate($im, 255, 255, 255);&#60;br />
$textbox = imagettfbbox($this->size, 0, $this->font, $this->RandomText());&#60;br />
$px = ($type[0] - $textbox[4])/2;&#60;br />
$py = ($type[1] - $textbox[5])/2;&#60;br />
imagettftext($im, $this->size, $this->angel, $px, $py, $white, $this->font, $random);&#60;br />
imagegif($im);&#60;br />
imagedestroy($im);&#60;br />
break;&#60;br />
case IMAGETYPE_JPEG:&#60;br />
header("Content-type: image/jpeg");&#60;br />
$im = imagecreatefromjpeg($this->file);&#60;br />
$white = imagecolorallocate($im, 255, 255, 255);&#60;br />
$textbox = imagettfbbox($this->size, 0, $this->font, $this->RandomText());&#60;br />
$px = ($type[0] - $textbox[4])/2;&#60;br />
$py = ($type[1] - $textbox[5])/2;&#60;br />
imagettftext($im, $this->size, $this->angel, $px, $py, $white, $this->font, $random);&#60;br />
imagejpeg($im);&#60;br />
imagedestroy($im);&#60;br />
break;&#60;br />
case IMAGETYPE_PNG:&#60;br />
header("Content-type: image/png");&#60;br />
$im = imagecreatefrompng($this->file);&#60;br />
$white = imagecolorallocate($im, 255, 255, 255);&#60;br />
$textbox = imagettfbbox($this->size, 0, $this->font, $this->RandomText());&#60;br />
$px = ($type[0] - $textbox[4])/2;&#60;br />
$py = ($type[1] - $textbox[5])/2;&#60;br />
imagettftext($im, $this->size, $this->angel, $px, $py, $white, $this->font, $random);&#60;br />
imagepng($im);&#60;br />
imagedestroy($im);&#60;br />
break;&#60;br />
}&#60;br />
$_SESSION['code'] = $random;&#60;br />
}&#60;br />
} &#60;/p>
&#60;p>$handle = new captcha();&#60;br />
if (!empty($_GET['length'])) $handle->setLength($_GET['length']);&#60;br />
if (!empty($_GET['font'])) $handle->setFont($_GET['font']);&#60;br />
if (!empty($_GET['size'])) $handle->setSize($_GET['size']);&#60;br />
if (!empty($_GET['angel'])) $handle->setAngel($_GET['angel']);&#60;br />
if (!empty($_GET['file'])) $handle->setFile($_GET['file']);&#60;br />
$handle->ConvertFontToImage();&#60;br />
?>&#60;br /></pre>
</div>
<p></code></div>
</div>
<p><strong>Testing file code:</strong></p>
<p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>&#60;br />
&#60;?php&#60;br />
/**&#60;br />
* @author Dodit Suprianto&#60;br />
* Email: d0dit@yahoo.com&#60;br />
* Website: http://doditsuprianto.com, http://goiklan.co.nr&#60;br />
* Website: http://www.meozit.com, http://easyads.co.nr&#60;br />
*&#60;br />
* call captcha code &#60;img src=captcha.class.php?length=&#038;font=&#038;size=&#038;angel=&#038;file=>&#60;br />
*&#60;br />
* You can enter the parameter or not. Explaination:&#60;br />
*&#60;br />
* length : how much character will be shown. 4 character by default.&#60;br />
* font : Type of font (ex. Arial.ttf). Georgia font by default&#60;br />
* size : Size of font character. 20 by default&#60;br />
* angel : angel of font character. 0 by default, it means horizontal position&#60;br />
* file : if you want subtitute the background image. "eyes.gif" by default.&#60;br />
*&#60;br />
* You must copy several file to current directory&#60;br />
* if you want to subtitute the default setting.&#60;br />
* such as font file, background file&#60;br />
*&#60;br />
*/&#60;br />
session_start();&#60;br />
?>&#60;br />
&#60;html>&#60;br />
&#60;head>&#60;/p>
&#60;p>&#60;/head>&#60;br />
&#60;body>&#60;br />
&#60;?php&#60;br />
if ($_POST['submit'])&#60;br />
{&#60;br />
if ($_SESSION['code'] == $_POST['code'] &#038;&#038; !empty($_SESSION['code']))&#60;br />
{&#60;br />
/**&#60;br />
* you should add other codes in here&#60;br />
* in this section, means that the captcha and code are match&#60;br />
*/&#60;/p>
&#60;p>echo "captcha is correct";&#60;br />
unset($_SESSION['code']);&#60;br />
}&#60;br />
else&#60;br />
{&#60;br />
echo "captcha is wrong";&#60;br />
}&#60;br />
}&#60;br />
echo "&#60;br />
&#60;form action='$_SERVER[SELF]' method=POST>";&#60;br />
echo "Security code: &#60;img src=captcha.class.php?length=4&#038;font=&#038;size=24&#038;angel=5&#038;file=>
&#60;p>";&#60;br />
echo "Input code:&#60;br />
&#60;input type=text name=code>";&#60;br />
echo "&#60;br />
&#60;input type='submit' name='submit' value='Submit'>";&#60;br />
echo "&#60;/form>
&#60;p>";&#60;br />
?>&#60;br />
&#60;/body>&#60;br />
&#60;/html>&#60;br /></pre>
</div>
<p></code></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dodit.net23.net/?feed=rss2&amp;p=5</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Code -->
