<?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>bgallz.org &#124; Web coding &#38; design tutorials, scripts, resources and more. &#187; Scripts</title>
	<atom:link href="http://bgallz.org/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://bgallz.org</link>
	<description>Web coding &#38; design tutorials, scripts, resources and more.</description>
	<lastBuildDate>Tue, 10 Jan 2012 00:58:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Javascript &amp; PHP Star Rating Script</title>
		<link>http://bgallz.org/988/javascript-php-star-rating-script/</link>
		<comments>http://bgallz.org/988/javascript-php-star-rating-script/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 00:15:42 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rater]]></category>
		<category><![CDATA[rating]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[star]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=988</guid>
		<description><![CDATA[I&#8217;ve searched around the interwebs for an ajax star rater and I came across a few different possibilities, all of which looked very good. The top result from google was Nick Stakenburg&#8217;s &#8220;Starbox&#8221; for &#8220;ajax star rater&#8221;. I also found Masuga Web Design&#8217;s Ajax Star Rater and a script from MySandbox to be popular results. However I couldn&#8217;t really seem ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve searched around the interwebs for an ajax star rater and I came across a few different possibilities, all of which looked very good. The top result from google was <a href="http://www.nickstakenburg.com/projects/starbox/">Nick Stakenburg&#8217;s &#8220;Starbox&#8221;</a> for &#8220;ajax star rater&#8221;. I also found <a href="http://masugadesign.com/software/unobtrusive-ajax-star-rating-bar/">Masuga Web Design&#8217;s Ajax Star Rater</a> and a script from <a href="http://sandbox.ronggur.com/2009/05/30/jquery-tutorial-simple-ajax-star-rating-with-php/">MySandbox</a> to be popular results. However I couldn&#8217;t really seem to find a PHP / Mysql script that used Javascript for the rater effects. So I decided to make one based off of a script I found:</p>
<p><a href="http://www.reignwaterdesigns.com/ad/tidbits/rateme/">Reign Water Design&#8217;s 5 Star Rating System</a></p>
<p>This was a very nice easy to use Javascript 5 star rating script. All I had to do was make some tweaks to my preference and add on some PHP/Mysql code to submit the rating.</p>
<p><a href="http://bfgamerz.com/resource.php?g=bf-bad-company-2" target="_blank"><strong>See the demo</strong></a> or <a href="http://bgallz.org/scripts/bgallz.org-php-star-rater.rar"><strong>download this script</strong></a>.</p>
<p>To view the PHP source code, images, and everything together you must download this script.</p>
<h2>Javascript:</h2>
<p><strong>Insert the following in the &lt;<em>head</em>&gt; tags of your page:</strong><br />
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Javascript Source Code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span>&gt;</span>
function insertParam(key, value)
{
    key = escape(key); value = escape(value);
    var kvp = document.location.search.substr(1).split(&quot;<span class="sc1">&amp;&quot;);</span>
    var i=kvp.length; var x; while(i--)
    {
        x = kvp[i].split(&quot;=&quot;);
        if (x[0]==key)
        {
                x[1] = value;
                kvp[i] = x.join(&quot;=&quot;);
                break;
        }
    }
    if(i<span class="sc2">&lt;0<span class="br0">&#41;</span> <span class="br0">&#123;</span>kvp<span class="br0">&#91;</span>kvp.length<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span>key,<span class="kw3">value</span><span class="br0">&#93;</span>.join<span class="br0">&#40;</span><span class="st0">&quot;=&quot;</span><span class="br0">&#41;</span>;<span class="br0">&#125;</span></span>
<span class="sc2">    <span class="sy0">//</span>this will reload the page, it<span class="st0">'s likely better to store this until finished</span>
<span class="sc2">    document.location.search = kvp.join(&quot;&amp;&quot;);</span>
<span class="sc2">}</span>
<span class="sc2">function alterDisplay(id){</span>
<span class="sc2">	var dropdown = document.getElementById(id);</span>
<span class="sc2">	if(dropdown.style.display == &quot;none&quot;){</span>
<span class="sc2">		dropdown.style.display = &quot;&quot;;</span>
<span class="sc2">	} else {</span>
<span class="sc2">		dropdown.style.display = &quot;none&quot;;</span>
<span class="sc2">	}</span>
<span class="sc2">}</span>
<span class="sc2">&lt;/script&gt;</span></span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span> <span class="kw3">language</span><span class="sy0">=</span><span class="st0">&quot;javascript&quot;</span> <span class="kw3">src</span><span class="sy0">=</span><span class="st0">&quot;./scripts/ratingsys.js&quot;</span>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a>&gt;</span></pre></div></div></p>
<h2>CSS</h2>
<p>You will need to include this in the &lt;<em>head</em>&gt; tags as well either in &lt;<em>style</em>&gt; tags or by &lt;<em>link</em>&gt;:<br />
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">CSS Styles</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="css" style="font-family:monospace;"><span class="re0">#rateMe</span> <span class="re0">#rate_overlay</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span><span class="kw2">absolute</span><span class="sy0">;</span>
	<span class="kw1">display</span><span class="sy0">:</span><span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span>
	<span class="kw1">margin</span><span class="sy0">:</span><span class="nu0">0</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span><span class="nu0">0</span><span class="sy0">;</span>
	<span class="kw1">height</span><span class="sy0">:</span><span class="re3">30px</span><span class="sy0">;</span>
	<span class="kw1">width</span><span class="sy0">:</span><span class="kw2">auto</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span><span class="re0">#eee</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">./images/star_overlay.gif</span><span class="br0">&#41;</span> <span class="kw2">repeat-x</span><span class="sy0">;</span>
	<span class="kw1">z-index</span><span class="sy0">:</span><span class="nu0">2</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re0">#rateStatus</span><span class="br0">&#123;</span><span class="kw1">width</span><span class="sy0">:</span><span class="re3">100px</span><span class="sy0">;</span> <span class="kw1">height</span><span class="sy0">:</span><span class="re3">20px</span><span class="sy0">;</span>margin<span class="sy0">:</span><span class="re3">2px</span> 0 0 <span class="re3">5px</span><span class="sy0">;</span>font<span class="sy0">:</span> <span class="re3">12px</span> <span class="st0">&quot;Trebuchet MS&quot;</span><span class="sy0">,</span> Arial<span class="sy0">,</span> Helvetica<span class="sy0">,</span> <span class="kw2">sans-serif</span><span class="sy0">;</span> <span class="kw1">font-weight</span><span class="sy0">:</span> <span class="kw2">bold</span><span class="br0">&#125;</span>
<span class="re0">#rateMe</span><span class="br0">&#123;</span><span class="kw1">width</span><span class="sy0">:</span><span class="re3">152px</span><span class="sy0">;</span> <span class="kw1">height</span><span class="sy0">:</span><span class="re3">50px</span><span class="sy0">;</span> <span class="kw1">padding</span><span class="sy0">:</span><span class="re3">0px</span><span class="sy0">;</span> <span class="kw1">margin</span><span class="sy0">:</span><span class="re3">0px</span><span class="sy0">;</span> <span class="kw1">vertical-align</span><span class="sy0">:</span><span class="kw1">top</span><span class="sy0">;</span> <span class="kw1">z-index</span><span class="sy0">:</span><span class="kw2">auto</span><span class="br0">&#125;</span>
<span class="re0">#rateMe</span> li<span class="br0">&#123;</span><span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span>list-style<span class="sy0">:</span><span class="kw2">none</span><span class="sy0">;</span><span class="br0">&#125;</span>
<span class="re0">#rateMe</span> li a<span class="re2">:hover</span><span class="sy0">,</span>
<span class="re0">#rateMe</span> <span class="re1">.on</span><span class="br0">&#123;</span><span class="kw1">background</span><span class="sy0">:</span><span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">./images/star_on.gif</span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span><span class="sy0">;</span><span class="br0">&#125;</span>
<span class="re0">#rateMe</span> a<span class="br0">&#123;</span><span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span>background<span class="sy0">:</span><span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">./images/star_off.gif</span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span><span class="sy0">;</span>width<span class="sy0">:</span><span class="re3">30px</span><span class="sy0">;</span> <span class="kw1">height</span><span class="sy0">:</span><span class="re3">30px</span><span class="sy0">;</span>cursor<span class="sy0">:</span><span class="kw2">pointer</span><span class="sy0">;</span><span class="br0">&#125;</span>
<span class="re0">#rateMe</span> a<span class="re2">:hover</span><span class="br0">&#123;</span><span class="kw1">background</span><span class="sy0">:</span><span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">./images/star_on.gif</span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span><span class="sy0">;</span><span class="br0">&#125;</span>
<span class="re0">#ratingSaved</span><span class="br0">&#123;</span><span class="kw1">display</span><span class="sy0">:</span><span class="kw2">none</span><span class="sy0">;</span><span class="br0">&#125;</span>
<span class="re1">.saved</span><span class="br0">&#123;</span><span class="kw1">color</span><span class="sy0">:</span><span class="kw2">red</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></p>
<p>Basically I took the script that Water&#8217;s made and changed a few things to the css styles, added an overlay for the current rating, and wrote a php script to insert rates and determine the current rating, etc. I also added the Javascript functions <strong>insertParam()</strong> and <strong>alterDisplay()</strong>. You do not need to use this function insertParam() to create the url, you can simply set the &lt;<em>a</em>&gt; tags to something like this:</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a> <span class="kw3">href</span><span class="sy0">=</span><span class="st0">&quot;./index.php?r=1&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;_1&quot;</span> <span class="kw3">title</span><span class="sy0">=</span><span class="st0">&quot;Terrible&quot;</span> <span class="kw3">onmouseover</span><span class="sy0">=</span><span class="st0">&quot;rating(this)&quot;</span> <span class="kw3">onmouseout</span><span class="sy0">=</span><span class="st0">&quot;off(this)&quot;</span>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a>&gt;</span></pre></div></div>
<p>The Javascript function <strong>alterDisplay()</strong> is used to hide and show the overlay &lt;div&gt; that holds the current rating (if there is one). So when you mouse over the rating bar holder it hides the overlay so you can rate.</p>
<p>The PHP script grabs the information from the Mysql table that you specify in the function. You will need to adjust the following values:</p>
<ul>
<li><strong>$var</strong> &#8211; The column to base your mysql selection off of. Grab all rows where this column equals $id.</li>
<li><strong>$table</strong> &#8211; The table where the ratings are being held.</li>
<li><strong>$star_width</strong> &#8211; Width of the stars, default is 30px.</li>
</ul>
<p><strong><font color="red">You will need to be connected to a MYSQL database before calling the rating bar function.</font></strong></p>
<p>Since the syntax of the function is the following:</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Rating Bar Syntax</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span class="kw2">function</span> rating_bar<span class="br0">&#40;</span><span class="re0">$id</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
<p>You will need to supply the identifier (<strong>$id</strong>) which tells the PHP script which row to grab from the Mysql table.</p>
<p>To display the current rating after it has been rated on &#8211; because Javascript alone is not enough &#8211; I added an overlay &lt;<em>div</em>&gt; which will hold the current rating. This is done by setting the css style of this overlay div to the following:</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Rate Overlay CSS Style</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="css" style="font-family:monospace;"><span class="re0">#rateMe</span> <span class="re0">#rate_overlay</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span><span class="kw2">absolute</span><span class="sy0">;</span>
	<span class="kw1">display</span><span class="sy0">:</span><span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span>
	<span class="kw1">margin</span><span class="sy0">:</span><span class="nu0">0</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span><span class="nu0">0</span><span class="sy0">;</span>
	<span class="kw1">height</span><span class="sy0">:</span><span class="re3">30px</span><span class="sy0">;</span>
	<span class="kw1">width</span><span class="sy0">:</span><span class="kw2">auto</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span><span class="re0">#eee</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">./images/star_overlay.gif</span><span class="br0">&#41;</span> <span class="kw2">repeat-x</span><span class="sy0">;</span>
	<span class="kw1">z-index</span><span class="sy0">:</span><span class="nu0">2</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
<h3>The <strong>position: aboslute </strong>and <strong>z-index: 2</strong> style attributes make the div lay over top of the <strong><span style="text-decoration: underline;">rateMe</span></strong> div which holds the rater and has a <strong>z-index: 1</strong>.</h3>
<img src="http://bgallz.org/?ak_action=api_record_view&id=988&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/988/javascript-php-star-rating-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gaming Website Script</title>
		<link>http://bgallz.org/875/gaming-website-script/</link>
		<comments>http://bgallz.org/875/gaming-website-script/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 16:43:19 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=875</guid>
		<description><![CDATA[Want to run a gaming website full of screenshots, videos, reviews, downloads and everything else on the games you wish to run? Easily upload and manage all data for the games you include on your website through the admin panel and control the entire site. The BFGamerz Gaming Script comes with vBulletin announcement thread viewer custom installed so you can ...]]></description>
			<content:encoded><![CDATA[<p>Want to run a gaming website full of screenshots, videos, reviews, downloads and everything else on the games you wish to run? Easily upload and manage all data for the games you include on your website through the admin panel and control the entire site. The BFGamerz Gaming Script comes with vBulletin announcement thread viewer custom installed so you can share your forum announcements on your homepage.</p>
<p>The BFGamerz Gaming Script allows you to easily add/edit/remove:</p>
<ul>
<li>Screenshots</li>
<li>Videos</li>
<li>Downloads</li>
<li>Reviews</li>
<li>Maps</li>
<li>Resources</li>
</ul>
<p>for every game you include on your website. Viewers will easily obtain all the information they need for your games. Create categories and sub-categories for your games as far as expansions, mods, etc. Members can use private messaging, add games to their profile with their in-game names, comment on nearly everything, and share videos and so much more.</p>
<p>Login to the BFGamerz Gaming Script using the following demo details:</p>
<p><strong>Username:</strong> Demo11<strong><br />
Password:</strong> demopass</p>
<p><a href="http://bfgamerz.com/" target="_blank">Try the BFGamerz Gaming Script here!</a></p>
<p>The BFGamerz Gaming Script is regularly $80.00 and is currently on sale for <span style="text-decoration: underline;"><strong>50%</strong><strong> OFF</strong></span>!</p>
<h3>Act now and get this script for just $40.00!</h3>
<p><span style="font-size: 11pt;"><del datetime="2010-12-30T15:10:45+00:00">Regular Price: $80.00</del>.</span><br />
<span style="font-size: 15pt; color: green;">Sale Price: $40.00!</span></p>
<p><button onclick="window.location = 'http://bgallz.org/whmcs/cart.php?gid=3';" name="Order Gaming Script" style="font:13pt verdana;font-weight:bold">Order Now</button></p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=875&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/875/gaming-website-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Prime Number Script</title>
		<link>http://bgallz.org/657/php-prime-number-script/</link>
		<comments>http://bgallz.org/657/php-prime-number-script/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 05:38:58 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[prime]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=657</guid>
		<description><![CDATA[Here is a simple little script that will determine if a number is prime or not. Just submit the function through with the parameter number as the integer you want to determine &#8211; is prime or not.
Syntax

is_prime(number);

Here is the function&#8217;s definition:

function is_prime($num=0)
{

$num = (int)$num; // Make sure it&#039;s an integer.
if($num &#62; 0)
{
	$count = 0;
	$half = round($num / 2);

	for($i=2;$i&#60;=$half;$i++)
	// Check the ...]]></description>
			<content:encoded><![CDATA[<p>Here is a simple little script that will determine if a number is prime or not. Just submit the function through with the parameter <em>number</em> as the integer you want to determine &#8211; is prime or not.</p>
<h1>Syntax</h1>
<pre>
is_prime(number);
</pre>
<p>Here is the function&#8217;s definition:</p>
<pre>
function is_prime($num=0)
{

$num = (int)$num; // Make sure it&#039;s an integer.
if($num &gt; 0)
{
	$count = 0;
	$half = round($num / 2);

	for($i=2;$i&lt;=$half;$i++)
	// Check the remainder from 2 to the half point.
	{
		if(($num % $i) == 0)
		// Remainder is 0, it is divisible. Not a prime number.
		{
			$count++;
			// Increase count of divisible numbers.
		}
	}
	if($count &gt; 0)
	{
		return false;
	} else {
		return true;
	}
} else {

return false;

}

}
</pre>
<p>Examples:</p>
<pre>
is_prime(10);
is_prime(3);
is_prime(109);
</pre>
<pre>
false
true
true
</pre>
<p>Basically our script here takes a parameter, makes sure it is an integer greater  than 0, then divides it by each number from 2 to half way to that number. So if our number was 7 the script would divide 7 by 2, 3, 4. The half mark is rounded to the nearest whole number. Since a remainder exists from each of these divisions, the number is declared as prime.</p>
<p><a title="PHP Prime Numbers" href="http://bgallz.org/scripts/is_prime.php" target="_blank">Click here to demo the script!</a></p>
<p><a href="http://bgallz.org/is_prime.rar" target="_blank">Click here to download this script!</a></p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=657&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/657/php-prime-number-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Upload and Resize Image</title>
		<link>http://bgallz.org/502/php-upload-resize-image/</link>
		<comments>http://bgallz.org/502/php-upload-resize-image/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 17:21:42 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=502</guid>
		<description><![CDATA[Many times when you upload a image somewhere you want to resize it to different dimensions based off of a maximum width or height. Here is a simple script that does this for you, using a HTML form and a PHP script. We start with the PHP script that will run if our $_GET['do'] is set to &#8220;upload.&#8221; Then we ...]]></description>
			<content:encoded><![CDATA[<p>Many times when you upload a image somewhere you want to resize it to different dimensions based off of a maximum width or height. Here is a simple script that does this for you, using a HTML form and a PHP script. We start with the PHP script that will run if our <em>$_GET['do']</em> is set to &#8220;upload.&#8221; Then we include the HTML form that has three inputs (max width, max height, image file).</p>
<p><a title="Upload and Resize Demo" href="http://bgallz.org/scripts/upload-resize-image/" target="_blank"><strong>Use the Upload and Resize Demo Here!</strong></a></p>
<p><a href="http://bgallz.org/scripts/upload-resize-image/bgallz.org-Upload-and-Resize-Image-Script.rar"><strong>Download This Script!</strong></a></p>
<p>Here is the PHP:</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Upload and Resize PHP Code</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span class="kw2">&lt;?php</span>
<span class="co1">// index.php</span>
<span class="kw2">function</span> generate_resized_image<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$max_dimension</span> <span class="sy0">=</span> <span class="nu0">800</span><span class="sy0">;</span> <span class="co1">// Max new width or height, can not exceed this value.</span>
<span class="re0">$dir</span> <span class="sy0">=</span> <span class="st0">&quot;./images/&quot;</span><span class="sy0">;</span> <span class="co1">// Directory to save resized image. (Include a trailing slash - /)</span>
<span class="co1">// Collect the post variables.</span>
<span class="re0">$postvars</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>
<span class="st0">&quot;image&quot;</span>    <span class="sy0">=&gt;</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;name&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">,</span>
<span class="st0">&quot;image_tmp&quot;</span>    <span class="sy0">=&gt;</span> <span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;tmp_name&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;image_size&quot;</span>    <span class="sy0">=&gt;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;size&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;image_max_width&quot;</span>    <span class="sy0">=&gt;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_width&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;image_max_height&quot;</span>   <span class="sy0">=&gt;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_height&quot;</span><span class="br0">&#93;</span>
<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Array of valid extensions.</span>
<span class="re0">$valid_exts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;jpg&quot;</span><span class="sy0">,</span><span class="st0">&quot;jpeg&quot;</span><span class="sy0">,</span><span class="st0">&quot;gif&quot;</span><span class="sy0">,</span><span class="st0">&quot;png&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Select the extension from the file.</span>
<span class="re0">$ext</span> <span class="sy0">=</span> <a href="http://www.php.net/end"><span class="kw3">end</span></a><span class="br0">&#40;</span><a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="sy0">,</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;name&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Check not larger than 175kb.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_size&quot;</span><span class="br0">&#93;</span> <span class="sy0">&lt;=</span> <span class="nu0">179200</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="co1">// Check is valid extension.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$ext</span><span class="sy0">,</span><span class="re0">$valid_exts</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;jpg&quot;</span> <span class="sy0">||</span> <span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;jpeg&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span class="kw3">imagecreatefromjpeg</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;gif&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefromgif"><span class="kw3">imagecreatefromgif</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;png&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefrompng"><span class="kw3">imagecreatefrompng</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="co1">// Grab the width and height of the image.</span>
<a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span><span class="sy0">,</span><span class="re0">$height</span><span class="br0">&#41;</span> <span class="sy0">=</span> <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// If the max width input is greater than max height we base the new image off of that, otherwise we</span>
<span class="co1">// use the max height input.</span>
<span class="co1">// We get the other dimension by multiplying the quotient of the new width or height divided by</span>
<span class="co1">// the old width or height.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_width&quot;</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> <span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_height&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_width&quot;</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> <span class="re0">$max_dimension</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$newwidth</span> <span class="sy0">=</span> <span class="re0">$max_dimension</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="re0">$newwidth</span> <span class="sy0">=</span> <span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_width&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re0">$newheight</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="re0">$newwidth</span> <span class="sy0">/</span> <span class="re0">$width</span><span class="br0">&#41;</span> <span class="sy0">*</span> <span class="re0">$height</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_height&quot;</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> <span class="re0">$max_dimension</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$newheight</span> <span class="sy0">=</span> <span class="re0">$max_dimension</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="re0">$newheight</span> <span class="sy0">=</span> <span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_max_height&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re0">$newwidth</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="re0">$newheight</span> <span class="sy0">/</span> <span class="re0">$height</span><span class="br0">&#41;</span> <span class="sy0">*</span> <span class="re0">$width</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="co1">// Create temporary image file.</span>
<span class="re0">$tmp</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatetruecolor"><span class="kw3">imagecreatetruecolor</span></a><span class="br0">&#40;</span><span class="re0">$newwidth</span><span class="sy0">,</span><span class="re0">$newheight</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Copy the image to one with the new width and height.</span>
<a href="http://www.php.net/imagecopyresampled"><span class="kw3">imagecopyresampled</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="sy0">,</span><span class="re0">$image</span><span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span><span class="re0">$newwidth</span><span class="sy0">,</span><span class="re0">$newheight</span><span class="sy0">,</span><span class="re0">$width</span><span class="sy0">,</span><span class="re0">$height</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Create random 4 digit number for filename.</span>
<span class="re0">$rand</span> <span class="sy0">=</span> <a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span>1000<span class="sy0">,</span>9999<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$filename</span> <span class="sy0">=</span> <span class="re0">$dir</span><span class="sy0">.</span><span class="re0">$rand</span><span class="sy0">.</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="co1">// Create image file with 100% quality.</span>
<a href="http://www.php.net/imagejpeg"><span class="kw3">imagejpeg</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="sy0">,</span><span class="re0">$filename</span><span class="sy0">,</span>100<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw1">return</span> <span class="st0">&quot;&lt;strong&gt;Image Preview:&lt;/strong&gt;&lt;br/&gt;
&lt;img src=<span class="es1">\&quot;</span>&quot;</span><span class="sy0">.</span><span class="re0">$filename</span><span class="sy0">.</span><span class="st0">&quot;<span class="es1">\&quot;</span> border=<span class="es1">\&quot;</span>0<span class="es1">\&quot;</span> title=<span class="es1">\&quot;</span>Resized  Image Preview<span class="es1">\&quot;</span> style=<span class="es1">\&quot;</span>padding: 4px 0px 4px 0px;background-color:#e0e0e0<span class="es1">\&quot;</span> /&gt;&lt;br/&gt;
Resized image successfully generated. &lt;a href=<span class="es1">\&quot;</span>&quot;</span><span class="sy0">.</span><span class="re0">$filename</span><span class="sy0">.</span><span class="st0">&quot;<span class="es1">\&quot;</span> target=<span class="es1">\&quot;</span>_blank<span class="es1">\&quot;</span> name=<span class="es1">\&quot;</span>Download your resized image now!<span class="es1">\&quot;</span>&gt;Click here to download your image.&lt;/a&gt;&quot;</span><span class="sy0">;</span>
<a href="http://www.php.net/imagedestroy"><span class="kw3">imagedestroy</span></a><span class="br0">&#40;</span><span class="re0">$image</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://www.php.net/imagedestroy"><span class="kw3">imagedestroy</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">return</span> <span class="st0">&quot;File size too large. Max allowed file size is 175kb.&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">return</span> <span class="st0">&quot;Invalid file type. You must upload an image file. (jpg, jpeg, gif, png).&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&quot;do&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&quot;do&quot;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st0">&quot;upload&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$upload_and_resize</span> <span class="sy0">=</span> generate_resized_image<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="re0">$upload_and_resize</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="re0">$upload_and_resize</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="sy1">?&gt;</span></pre></div></div>
<p>Here is the HTML:</p>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">HTML Form</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a> <span class="kw3">action</span><span class="sy0">=</span><span class="st0">&quot;./index.php?do=upload&quot;</span> <span class="kw3">method</span><span class="sy0">=</span><span class="st0">&quot;post&quot;</span> <span class="kw3">enctype</span><span class="sy0">=</span><span class="st0">&quot;multipart/form-data&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/table.html"><span class="kw2">table</span></a> <span class="kw3">width</span><span class="sy0">=</span><span class="st0">&quot;100%&quot;</span> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;center&quot;</span> <span class="kw3">border</span><span class="sy0">=</span><span class="st0">&quot;0&quot;</span> <span class="kw3">cellpadding</span><span class="sy0">=</span><span class="st0">&quot;2&quot;</span> <span class="kw3">cellspacing</span><span class="sy0">=</span><span class="st0">&quot;0&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span> <span class="kw3">width</span><span class="sy0">=</span><span class="st0">&quot;100&quot;</span>&gt;</span>
Max Width:<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;image_max_width&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;width: 120px&quot;</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">maxlength</span><span class="sy0">=</span><span class="st0">&quot;4&quot;</span> <span class="sy0">/</span>&gt;</span> px.<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span>&gt;</span>
Max Height:<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;image_max_height&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;width: 120px&quot;</span> <span class="kw3">maxlength</span><span class="sy0">=</span><span class="st0">&quot;4&quot;</span> <span class="sy0">/</span>&gt;</span> px.<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span>&gt;</span>
Image:<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;file&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;image&quot;</span> <span class="kw3">size</span><span class="sy0">=</span><span class="st0">&quot;40&quot;</span> <span class="sy0">/</span>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span> <span class="kw3">colspan</span><span class="sy0">=</span><span class="st0">&quot;2&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/ol.html"><span class="kw2">ol</span></a> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;margin:0;padding:3px 0px 3px 15px&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>Max file size: 175 KB.<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>Allowed extensions: jpg, jpeg, gif, png.<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>Max Dimension: <span class="sc2">&lt;<a href="http://december.com/html/4/element/em.html"><span class="kw2">em</span></a>&gt;</span>800<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/em.html"><span class="kw2">em</span></a>&gt;</span>px.<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/li.html"><span class="kw2">li</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/ol.html"><span class="kw2">ol</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a> <span class="kw3">align</span><span class="sy0">=</span><span class="st0">&quot;left&quot;</span> <span class="kw3">colspan</span><span class="sy0">=</span><span class="st0">&quot;2&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Submit!&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;font: 14pt verdana&quot;</span> <span class="sy0">/</span>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/td.html"><span class="kw2">td</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/tr.html"><span class="kw2">tr</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/table.html"><span class="kw2">table</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a>&gt;</span></pre></div></div>
<p><strong>This will create a form that looks like this:</strong></p>
<p><a name="form"></a></p>
<form action="#form" enctype="multipart/form-data" method="post">
<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center">
<tbody>
<tr>
<td width="100" align="left">Max Width:</td>
<td align="left">
<input style="width: 120px;" maxlength="4" name="image_max_width" type="text" /> px.</td>
</tr>
<tr>
<td align="left">Max Height:</td>
<td align="left">
<input style="width: 120px;" maxlength="4" name="image_max_height" type="text" /> px.</td>
</tr>
<tr>
<td align="left">Image:</td>
<td align="left">
<input name="image" size="40" type="file" /></td>
</tr>
<tr>
<td colspan="2" align="left">
<ol style="margin: 0; padding: 3px 0px 3px 15px;">
<li>Max file size: 175 KB</li>
<li>Allowed extensions: jpg, jpeg, gif, png.</li>
<li>Max Dimension: <em>800</em>px.</li>
</ol>
</td>
</tr>
<tr>
<td align="left colspa=">
<input style="font: 14pt verdana;" name="submit" type="submit" value="Submit!" /></td>
</tr>
</tbody>
</table>
</form>
<p>Then we just have to call the functions returned value (<em>$upload_and_resize</em>).</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Show Upload and Resize</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;upload&quot;&gt;
<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$upload_and_resize</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
&lt;/div&gt;</pre></div></div>
<input id="gwProxy" type="hidden" />
<p><!--Session data--></p>
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<img src="http://bgallz.org/?ak_action=api_record_view&id=502&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/502/php-upload-resize-image/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>PHP Favicon Generator Script</title>
		<link>http://bgallz.org/488/php-favicon-generator-script/</link>
		<comments>http://bgallz.org/488/php-favicon-generator-script/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 18:12:40 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=488</guid>
		<description><![CDATA[I decided to make a free easy to use favicon generating script that uses PHP. The script has a few features and requirements when uploading your image to be converted to a favicon. First the script checks for a few things such as file type, file size, if the directory is writable, and the specified dimensions. You can create a ...]]></description>
			<content:encoded><![CDATA[<p>I decided to make a free easy to use favicon generating script that uses PHP. The script has a few features and requirements when uploading your image to be converted to a favicon. First the script checks for a few things such as file type, file size, if the directory is writable, and the specified dimensions. You can create a 16&#215;16 icon or a 32&#215;32 icon.</p>
<p><a title="Favicon Generator Script" href="http://bgallz.org/favicon-generator/" target="_blank"><strong>Click here to check out the demo for this script!</strong></a></p>
<p>Just select the image file you want converted to a 16&#215;16 or 32&#215;32 icon and hit submit! It&#8217;s that easy. Here is how it works:</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Favicon Generator Script</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span class="kw2">&lt;?php</span>
<span class="co1">// bgallz.org - Web coding and design tutorials, scripts, resources and more.</span>
<span class="co1">// favicon Generator Script</span>
<span class="kw2">function</span> generate_favicon<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="co1">// Create favicon.</span>
<span class="re0">$postvars</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;image&quot;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;name&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">,</span>
<span class="st0">&quot;image_tmp&quot;</span>        <span class="sy0">=&gt;</span> <span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;tmp_name&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;image_size&quot;</span>    <span class="sy0">=&gt;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;size&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;image_dimensions&quot;</span>    <span class="sy0">=&gt;</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&quot;image_dimensions&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$valid_exts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;jpg&quot;</span><span class="sy0">,</span><span class="st0">&quot;jpeg&quot;</span><span class="sy0">,</span><span class="st0">&quot;gif&quot;</span><span class="sy0">,</span><span class="st0">&quot;png&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$ext</span> <span class="sy0">=</span> <a href="http://www.php.net/end"><span class="kw3">end</span></a><span class="br0">&#40;</span><a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="sy0">,</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;name&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$directory</span> <span class="sy0">=</span> <span class="st0">&quot;favicon/&quot;</span><span class="sy0">;</span> <span class="co1">// Directory to save favicons. Include trailing slash.</span>
<span class="co1">// Check not larger than 175kb.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_size&quot;</span><span class="br0">&#93;</span> <span class="sy0">&lt;=</span> <span class="nu0">179200</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="co1">// Check is valid extension.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$ext</span><span class="sy0">,</span><span class="re0">$valid_exts</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;jpg&quot;</span> <span class="sy0">||</span> <span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;jpeg&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span class="kw3">imagecreatefromjpeg</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;gif&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefromgif"><span class="kw3">imagecreatefromgif</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ext</span> <span class="sy0">==</span> <span class="st0">&quot;png&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$image</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatefrompng"><span class="kw3">imagecreatefrompng</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span><span class="sy0">,</span><span class="re0">$height</span><span class="br0">&#41;</span> <span class="sy0">=</span> <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_tmp&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$newwidth</span> <span class="sy0">=</span> <span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_dimensions&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$newheight</span> <span class="sy0">=</span> <span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image_dimensions&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$tmp</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecreatetruecolor"><span class="kw3">imagecreatetruecolor</span></a><span class="br0">&#40;</span><span class="re0">$newwidth</span><span class="sy0">,</span><span class="re0">$newheight</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Copy the image to one with the new width and height.</span>
<a href="http://www.php.net/imagecopyresampled"><span class="kw3">imagecopyresampled</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="sy0">,</span><span class="re0">$image</span><span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span>0<span class="sy0">,</span><span class="re0">$newwidth</span><span class="sy0">,</span><span class="re0">$newheight</span><span class="sy0">,</span><span class="re0">$width</span><span class="sy0">,</span><span class="re0">$height</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$rand</span> <span class="sy0">=</span> <a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span>1000<span class="sy0">,</span>9999<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$filename</span> <span class="sy0">=</span> <span class="st0">&quot;./&quot;</span><span class="sy0">.</span><span class="re0">$directory</span><span class="sy0">.</span><span class="re0">$rand</span><span class="sy0">.</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="co1">// Create image file with 100% quality.</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/is_writable"><span class="kw3">is_writable</span></a><span class="br0">&#40;</span><span class="re0">$directory</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<a href="http://www.php.net/imagejpeg"><span class="kw3">imagejpeg</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="sy0">,</span><span class="re0">$filename</span><span class="sy0">,</span>100<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Image created, now rename it to its</span>
<span class="re0">$ext_pos</span> <span class="sy0">=</span> <a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span><span class="st0">&quot;.&quot;</span> <span class="sy0">.</span> <span class="re0">$ext</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$strip_ext</span> <span class="sy0">=</span> <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$postvars</span><span class="br0">&#91;</span><span class="st0">&quot;image&quot;</span><span class="br0">&#93;</span><span class="sy0">,</span>0<span class="sy0">,</span><span class="re0">$ext_pos</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// Rename image to .ico file</span>
<a href="http://www.php.net/rename"><span class="kw3">rename</span></a><span class="br0">&#40;</span><span class="re0">$filename</span><span class="sy0">,</span><span class="st0">&quot;./favicon/&quot;</span><span class="sy0">.</span><span class="re0">$strip_ext</span><span class="sy0">.</span><span class="st0">&quot;.ico&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw1">return</span> <span class="st0">&quot;&lt;strong&gt;Icon Preview:&lt;/stong&gt;
&lt;p&gt;&lt;img title=&quot;</span>\Favicon Preview\<span class="st0">&quot; src=&quot;</span>\<span class="st0">&quot;.<span class="es4">$filename</span>.&quot;</span>\<span class="st0">&quot; border=&quot;</span>\<span class="nu0">0</span>\<span class="st0">&quot; alt=<span class="es1">\&quot;</span>Favicon<span class="es1">\&quot;</span> /&gt;&lt;/p&gt;
&lt;p&gt;Favicon successfully generated. &lt;a name=&quot;</span>\Download Favicon\<span class="st0">&quot; href=<span class="es1">\&quot;</span>&quot;</span><span class="sy0">.</span><span class="re0">$filename</span><span class="sy0">.</span><span class="st0">&quot;<span class="es1">\&quot;</span> target=<span class="es1">\&quot;</span>_blank<span class="es1">\&quot;</span>&gt;Click here to download your favicon.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If favicon doesn't download, right click the link above. Click SAVE AS to download .ico.&lt;/strong&gt;&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">return</span> <span class="st0">&quot;The directory: <span class="es1">\&quot;</span>&quot;</span><span class="sy0">.</span><span class="re0">$directory</span><span class="sy0">.</span><span class="st0">&quot;<span class="es1">\&quot;</span> is not writable.&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<a href="http://www.php.net/imagedestroy"><span class="kw3">imagedestroy</span></a><span class="br0">&#40;</span><span class="re0">$image</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://www.php.net/imagedestroy"><span class="kw3">imagedestroy</span></a><span class="br0">&#40;</span><span class="re0">$tmp</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">return</span> <span class="st0">&quot;File size too large. Max allowed file size is 175kb.&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">return</span> <span class="st0">&quot;Invalid file type. You must upload an image file. (jpg, jpeg, gif, png).&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&quot;do&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&quot;do&quot;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st0">&quot;create&quot;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&quot;submit&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
<span class="re0">$generate_favicon</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">.</span>generate_favicon<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;&quot;</span><span class="sy0">;</span>
<span class="re0">$generate_favicon</span> <span class="sy0">.=</span> <span class="st0">&quot;Place your download instructions and anything else you want here to follow the download link after upload.&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="re0">$generate_favicon</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="sy1">?&gt;</span></pre></div></div>
<p>Then we must include the HTML form that will submit the image and dimensions to PHP:</p>
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://bgallz.org/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://bgallz.org/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a> <span class="kw3">action</span><span class="sy0">=</span><span class="st0">&quot;index.php?do=create&quot;</span>  <span class="kw3">enctype</span><span class="sy0">=</span><span class="st0">&quot;multipart/form-data&quot;</span> <span class="kw3">method</span><span class="sy0">=</span><span class="st0">&quot;post&quot;</span>&gt;</span>Image Dimensions:<span class="sc2">&lt;<a href="http://december.com/html/4/element/br.html"><span class="kw2">br</span></a> <span class="sy0">/</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/select.html"><span class="kw2">select</span></a> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;width: 170px;&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;image_dimensions&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/option.html"><span class="kw2">option</span></a> <span class="kw3">selected</span><span class="sy0">=</span><span class="st0">&quot;selected&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;16&quot;</span>&gt;</span>16px x 16px<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html"><span class="kw2">option</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/option.html"><span class="kw2">option</span></a> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;32&quot;</span>&gt;</span>32px x 32px<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html"><span class="kw2">option</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/select.html"><span class="kw2">select</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/p.html"><span class="kw2">p</span></a>&gt;&lt;<a href="http://december.com/html/4/element/span.html"><span class="kw2">span</span></a> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;font-size: 14pt;&quot;</span>&gt;</span>Favicon Image:<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/span.html"><span class="kw2">span</span></a>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/p.html"><span class="kw2">p</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;image&quot;</span> <span class="kw3">size</span><span class="sy0">=</span><span class="st0">&quot;40&quot;</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;file&quot;</span> <span class="sy0">/</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;font: 14pt verdana;&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Submit!&quot;</span> <span class="sy0">/</span>&gt;</span></pre></div></div>
<p>Be sure to include the HTML head tags in your HTML pages that use the favicon. These are given on the script&#8217;s index and on the demo.</p>
<p><a href="http://bgallz.org/bgallz.org-favicon-generator.rar" target="_blank"><strong>Click here to download the script!</strong></a></p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=488&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/488/php-favicon-generator-script/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CSS Drop-Down Menu</title>
		<link>http://bgallz.org/392/css-drop-down-menu/</link>
		<comments>http://bgallz.org/392/css-drop-down-menu/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 04:32:42 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[dropdown]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=392</guid>
		<description><![CDATA[Drop down menus are very useful for navigation on websites and for holding many links to pages on your site without taking up much space on your web pages. Using just CSS and Javascript we can make a nice simple drop down menu you can put on your web page. To do this we&#8217;ll have three files: dropdown.css, dropdown.js, and ...]]></description>
			<content:encoded><![CDATA[<p>Drop down menus are very useful for navigation on websites and for holding many links to pages on your site without taking up much space on your web pages. Using just CSS and Javascript we can make a nice simple drop down menu you can put on your web page. To do this we&#8217;ll have three files: <strong>dropdown.css</strong>, <strong>dropdown.js</strong>, and <strong>index.html</strong>. Our index.html page will display the drop down menu and our stylesheet &#8211; dropdown.css &#8211; will hold the styles for the drop down menu.</p>
<p>Here is a preview of what our drop down menu will look like:</p>
<ul id="css_dropdown">
<li class="li"><a href="#">Homepage</a></li>
<li class="li"><a onmouseover="mopen('list1')" onmouseout="mclosetime()" href="#">Drop Down Menu #1</a>
<div id="list1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"><a href="#">Drop Down Link #1</a><br />
<a href="#">Drop Down Link #2</a><br />
<a href="#">Drop Down Link #3</a></div>
</li>
<li class="li"><a onmouseover="mopen('list2')" onmouseout="mclosetime()" href="#">Drop Down Menu #2</a>
<div id="list2" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"><a href="#">Drop Down Link #1</a><br />
<a href="#">Drop Down Link #2</a><br />
<a href="#">Drop Down Link #3</a></div>
</li>
<li class="li"><a href="#">Link #1</a></li>
<li class="li"><a href="#">Link #2</a></li>
</ul>
<p><br/><br/></p>
<h1>Dropdown.css</h1>
<pre>
@charset "utf-8";
#dropdown {
margin: 0px;
padding: 0px;
list-style-type: none;
text-align: left;
font: 11px Arial, Helvetica, sans-serif;
}
#dropdown li {
float: left;
margin: 0px;
padding: 5px;
list-style-type: none;
border-bottom: 2px solid #cccccc;
border-right: 1px solid #eeeeee;
}
#dropdown li a {
display: block;
margin: 0;
text-decoration: none;
}

#dropdown div {
position: absolute;
visibility: hidden;
margin: 7px 0px 0px 0px;
padding: 0;
background-color: #e8e8e8;
border-right: 1px solid #c5c5c5;
border-bottom: 1px solid #c5c5c5;
}
#dropdown div a {
position: relative;
display: block;
margin: 0;
padding: 3px 6px;
width: auto;
white-space: nowrap;
text-align: left;
text-decoration: none;
font: 11px Verdana, Arial, Helvetica, sans-serif;
color: #333;
border-top: 1px solid #f1f1f1;
border-bottom: 1px solid #e2e2e2;
}
#dropdown div a:hover {
background-color: #f1f1f1;
color: #000;
}
</pre>
<h1>Dropdown.js</h1>
<pre>
// Dropdown menu javascript
var timeout    = 500;
var closetimer    = 0;
var ddmenuitem    = 0;

// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();

// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}

// close layer when click-out
document.onclick = mclose;
</pre>
<h1>Index.html</h1>
<pre>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;link href=&quot;./dropdown.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;./dropdown.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;ul id=&quot;dropdown&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; onmouseover=&quot;mopen(&#039;list1&#039;)&quot; onmouseout=&quot;mclosetime()&quot;&gt;Drop Down Menu #1&lt;/a&gt;
&lt;div id=&quot;list1&quot; onmouseover=&quot;mcancelclosetime()&quot; onmouseout=&quot;mclosetime()&quot;&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #1&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #2&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #3&lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; onmouseover=&quot;mopen(&#039;list2&#039;)&quot; onmouseout=&quot;mclosetime()&quot;&gt;Drop Down Menu #2&lt;/a&gt;
&lt;div id=&quot;list2&quot; onmouseover=&quot;mcancelclosetime()&quot; onmouseout=&quot;mclosetime()&quot;&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #1&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #2&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #3&lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Link #1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Link #2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; onmouseover=&quot;mopen(&#039;list3&#039;)&quot; onmouseout=&quot;mclosetime()&quot;&gt;Drop Down Menu #3&lt;/a&gt;
&lt;div id=&quot;list3&quot; onmouseover=&quot;mcancelclosetime()&quot; onmouseout=&quot;mclosetime()&quot;&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #1&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #2&lt;/a&gt;
&lt;a href=&quot;#&quot;&gt;Drop Down Link #3&lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><a title="Download CSS Drop Down Menu Script" href="http://bgallz.org/css-drop-down-menu.rar" target="_blank">Click here to download this drop down menu script!</a></p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=392&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/392/css-drop-down-menu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Create Thumbnail Images</title>
		<link>http://bgallz.org/270/php-create-thumbnail-images/</link>
		<comments>http://bgallz.org/270/php-create-thumbnail-images/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 15:54:54 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=270</guid>
		<description><![CDATA[Here we are going to observe how to use PHP to generate thumbnails for us. A thumbnail is a smaller size and usually smaller quality of an image shown as preview or link to the original image. Thumbnails can be very useful for faster loading times and quicker display of images on your web pages and a few other reasons. ...]]></description>
			<content:encoded><![CDATA[<p>Here we are going to observe how to use PHP to generate thumbnails for us. A thumbnail is a smaller size and usually smaller quality of an image shown as preview or link to the original image. Thumbnails can be very useful for faster loading times and quicker display of images on your web pages and a few other reasons. This script will allow us to use a directory on our server and convert all image files in it to a new thumbnail, with dimensions we want, and save it on a new thumbnails directory.</p>
<p>We do this using some PHP functions. First we have to open the directory that we specify as the directory to the images we want to convert to thumbnails. We use the function <em>opendir()</em>.</p>
<p>The next part:</p>
<pre>
while (false !== ($fname = readdir($dir))) {
</pre>
<p>This loops through the directory until it reaches the end of the files stored in the directory.</p>
<p>Then we make sure it is an image file type by checking its extension:</p>
<pre>
$valid_extensions = array("jpg","gif","png","jpeg");
if(in_array(strtolower($info['extension']),$valid_extensions)){
</pre>
<p>We use the function <em>imagecreatefromjpeg()</em> to make an image out of the file with the image extension. With this we grab the image&#8217;s width and height to calculate the new height of the thumbnail based off of the <em>$thumbWidth</em> specified in the beginning of the function (200).</p>
<p>We then use the function<em> imagecreatetruecolor()</em> to make a temporary image for the new thumbnail. With it we transfer it to a new image file in our thumbnails directory with the following code:</p>
<pre>
$genThumb = imagejpeg($tempImage,$pathToThumbs . rand(100,999) .  $fname);
</pre>
<p>The <em>rand(100,900)</em> make a random 3 digit number in front of the file name. Remove it if you wish.</p>
<p>Here is our function:</p>
<pre>

function generateThumbs(){
$pathToScreens = "../screenshots/"; // Directory to your images you want converted to thumbnails.
$pathToThumbs = "../screenshots/thumbs/"; // Directory to your thumbnails.
$thumbWidth = 200; // Width of the thumbnails generated.

$dir = opendir($pathToScreens) or die("Could not open directory");
$counter = 0;

while(($fname = readdir($dir)) !== false){
if($fname != "." &#038;&#038; $fname != ".."){
// Remove folders.
$valid_extensions = array("jpg","jpeg"); // Only jpeg images allowed.
$info = pathinfo($pathToScreens . $fname);
if(in_array(strtolower($info["extension"]),$valid_extensions)){
// Make sure the file is an image file by checking its extension to the array of image extensions.
$img = imagecreatefromjpeg($pathToScreens . $fname); // Select the file as an image from the directory.
$width = imagesx($img);
$height = imagesy($img);
// Collect its width and height.

$newHeight = floor($height * ($thumbWidth / $width)); // Calculate new height for thumbnail.

$tempImage = imagecreatetruecolor($thumbWidth,$newHeight); // Create a temporary image of the thumbnail.
// Copy and resize old image into new image.
imagecopyresized($tempImage,$img, 0, 0, 0, 0, $thumbWidth,$newHeight,$width,$height);

$genThumb = imagejpeg($tempImage,$pathToThumbs . rand(100,999) . $fname);
// Create the thumbnail with the new width and height in the thumbnails directory.
// I added a rand 3 digit number in front of the file name to avoid overwrite.
$counter++; // Increment.
}
}
}
if($counter > 0){
return $counter . " thumbnails generated from the directory \"".$pathToScreens."\".";
} else {
return "No image files could be processed.";
}
closedir($dir); // Close the directory.
}

?>
</pre>
<p>Then we can just call it like so:</p>
<pre>
echo generateThumbs();
</pre>
<img src="http://bgallz.org/?ak_action=api_record_view&id=270&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/270/php-create-thumbnail-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Snowing Effect Script</title>
		<link>http://bgallz.org/244/javascript-snowing-effect-script/</link>
		<comments>http://bgallz.org/244/javascript-snowing-effect-script/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 17:06:00 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[snowing]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=244</guid>
		<description><![CDATA[
Here is a nice feature to add to your web pages during the holiday season. Falling snowflakes are very simple and yet a great eye catcher to new visitors to your website.
Here is the snowflake gif I made for this:

Now, to make  the effect of the snowflake falling on the webpage we will just use javascript. You want to place ...]]></description>
			<content:encoded><![CDATA[<p><script src="http://bgallz.org/snowing.js" type="text/javascript"></script></p>
<p>Here is a nice feature to add to your web pages during the holiday season. Falling snowflakes are very simple and yet a great eye catcher to new visitors to your website.</p>
<p>Here is the snowflake gif I made for this:</p>
<p><img class="alignnone" title="Snowflake.gif" src="http://uber-warez.com/images/snowflake.gif" alt="Falling Snowflake" width="15" height="16" /></p>
<p>Now, to make  the effect of the snowflake falling on the webpage we will just use javascript. You want to place this code in the &lt;head&gt; tags of your webpage and it will give you the pretty effect that it is snowing! You can do this with other seasons as well like autumn, you would want to use a leaf of some kind. Here is the code:</p>
<pre>
&lt;script type=&quot;text/javascript&quot;&gt;

// Path to your snowflake image. If in same folder just the title of the image, otherwise put &#039;./folder/imagetitle.ext&#039; ex: ./images/snowflake.gif.
var snowimg = &quot;snowflake.gif&quot;;
// Number of snowflakes you want to render on the page.
var num = 12;

var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&amp;amp;amp;&amp;amp;amp;!document.all) ? 1 : 0;

function iecom(){
return (document.compatMode &amp;amp;amp;&amp;amp;amp; document.compatMode!=&quot;BackCompat&quot;)? document.documentElement : document.body
}

var dx, xp, yp;&nbsp;&nbsp;&nbsp; // coordinate, positions
var am, stx, sty;&nbsp; // amplitude, steps
var i;
var doc_width = 800;
doc_height = 600;

if (ns6up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = iecom().clientWidth;
doc_height = iecom().clientHeight;
}

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();

for (i = 0; i &lt; num; ++ i) {
dx[i] = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // set coordinate variables
xp[i] = Math.random()*(doc_width-50);&nbsp; // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random();&nbsp;&nbsp;&nbsp;&nbsp; // set step variables
if (ie4up||ns6up) {
document.write(&quot;&lt;div id=\&quot;dot&quot;+ i +&quot;\&quot; style=\&quot;POSITION: absolute; Z-INDEX: &quot;+ i +&quot;; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\&quot;&gt;&lt;img src=&#039;&quot;+snowsrc+&quot;&#039; border=\&quot;0\&quot;&gt;&lt;\/div&gt;&quot;);
}
}

function snowIE_NS6() {  // IE and NS6 main animation function
doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
doc_height=(window.innerHeight &amp;amp;amp;&amp;amp;amp; snowdistance==&quot;windowheight&quot;)? window.innerHeight : (ie4up &amp;amp;amp;&amp;amp;amp; snowdistance==&quot;windowheight&quot;)?  iecompattest().clientHeight : (ie4up &amp;amp;amp;&amp;amp;amp; !window.opera &amp;amp;amp;&amp;amp;amp; snowdistance==&quot;pageheight&quot;)? iecompattest().scrollHeight : iecompattest().offsetHeight;
for (i = 0; i &lt; no; ++ i) {  // iterate for every dot
yp[i] += sty[i];
if (yp[i] &gt; doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
dx[i] += stx[i];
document.getElementById(&quot;dot&quot;+i).style.top=yp[i]+&quot;px&quot;;
document.getElementById(&quot;dot&quot;+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+&quot;px&quot;;
}
snowtimer=setTimeout(&quot;snowIE_NS6()&quot;, 10);
}

function hidesnow(){
if (window.snowtimer) clearTimeout(snowtimer)
for (i=0; i&lt;no; i++) document.getElementById(&quot;dot&quot;+i).style.visibility=&quot;hidden&quot;
}

if (ie4up||ns6up){
snowIE_NS6();
if (hidesnowtime&gt;0)
setTimeout(&quot;hidesnow()&quot;, hidesnowtime*1000)
}

&lt;/script&gt;
</pre>
<p>Enjoy!</p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=244&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/244/javascript-snowing-effect-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple File Hosting Script</title>
		<link>http://bgallz.org/186/simple-file-hosting-script/</link>
		<comments>http://bgallz.org/186/simple-file-hosting-script/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 04:15:55 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=186</guid>
		<description><![CDATA[I&#8217;ve made an easy to use file hosting script that is free for download.
It has some nice features such as:

Allowed file extensions.
File size limit.
Generated file names.
BBcode, IMG code, Url, etc.
Terms of Conditions

Generated file names on the server are created using the functions rand() and the md5() hash generator. Here is the code:

&#60;?php
$ext = end(explode(&#34;.&#34;,strtolower(basename($_FILES[&#34;file&#34;][&#34;name&#34;]))));
$rand = rand(1000,9999);
$filename = strtolower(basename($_FILES[&#34;file&#34;][&#34;name&#34;]));
$filename = md5($rand.$filename);
$md5_name ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made an easy to use file hosting script that is free for download.</p>
<p>It has some nice features such as:</p>
<ul>
<li>Allowed file extensions.</li>
<li>File size limit.</li>
<li>Generated file names.</li>
<li>BBcode, IMG code, Url, etc.</li>
<li>Terms of Conditions</li>
</ul>
<p>Generated file names on the server are created using the functions <em>rand() </em>and the <em>md5()</em> hash generator. Here is the code:</p>
<pre>
&lt;?php
$ext = end(explode(&quot;.&quot;,strtolower(basename($_FILES[&quot;file&quot;][&quot;name&quot;]))));
$rand = rand(1000,9999);
$filename = strtolower(basename($_FILES[&quot;file&quot;][&quot;name&quot;]));
$filename = md5($rand.$filename);
$md5_name = $filename. &quot;.&quot; .$ext;
?&gt;
</pre>
<p>The script also uses javascript to check for the Terms and Conditions checkbox being checked to make the submit button enabled.</p>
<p>I will be updating this script with more features, but this is meant to be a simple file hosting script. I will later include a download file page.</p>
<p>Here is what the upload form looks like:</p>
<p><img class="alignnone size-medium wp-image-190" title="filehostingscript" src="http://bgallz.org/wp-content/uploads/2009/11/filehostingscript-300x132.jpg" alt="filehostingscript" width="300" height="132" /></p>
<p><strong><a href="http://bgallz.org/file-hosting/" target="_blank">Check out the demo here!</a></strong></p>
<p><strong><a href="http://bgallz.org/bgallz.org-Simple-File-Hosting-Script.rar" target="_blank">Click here to download the script!</a></strong></p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=186&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/186/simple-file-hosting-script/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>PHP Cookies with Login – setcookie()</title>
		<link>http://bgallz.org/157/php-cookies-with-login-setcookie/</link>
		<comments>http://bgallz.org/157/php-cookies-with-login-setcookie/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 04:48:27 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP Functions]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[setcookie]]></category>

		<guid isPermaLink="false">http://bgallz.org/?p=157</guid>
		<description><![CDATA[A cookie is a small file that the server embeds on the user&#8217;s computer. This data is sent and recieved with each browser that is used to view a page using cookies.
To create a cookie in PHP use the setcookie() function. Here is its syntax:

setcookie($name, $value, $expire, $path, $domain);

So if you want to create a cookie for someone&#8217;s status that ...]]></description>
			<content:encoded><![CDATA[<p>A cookie is a small file that the server embeds on the user&#8217;s computer. This data is sent and recieved with each browser that is used to view a page using cookies.</p>
<p>To create a cookie in PHP use the <em>setcookie()</em> function. Here is its syntax:</p>
<pre>
setcookie($name, $value, $expire, $path, $domain);
</pre>
<p>So if you want to create a cookie for someone&#8217;s status that will last one day, the code would look something like this:</p>
<pre>
// name = status
// expire = current timestamp plus 24 hours
// path = current path "/"
setcookie("status","user status here",time()+(3600*24),"/");
</pre>
<p>So let&#8217;s say we want to create a cookie for every user that logs in and have it last for 12 hours. We need to run a login form and validate the login details to match someone on our database, and then create the cookies and set them to a specific time interval. Let&#8217;s make a function for this on <strong>function.php</strong>:</p>
<h1>function.php</h1>
<pre>
&lt;?php
// function.php

function run_login_form($username,$password){
$username = trim(addslashes($username));
$password = md5(trim($password));

$sql = mysql_query(&quot;SELECT userid FROM users WHERE username = &#039;$username&#039; AND password = &#039;$password&#039; LIMIT 1&quot;);
if(mysql_num_rows($sql) &gt; 0){
$row = mysql_fetch_assoc($sql);
// User found, now let&#039;s create the cookies for the user!
if(!$_COOKIE[&quot;userid&quot;] &amp;&amp; !$_COOKIE[&quot;username&quot;]) {
setcookie(&quot;userid&quot;,$row[&quot;userid&quot;],time()+(3600*12),&quot;/&quot;);
setcookie(&quot;username&quot;,$username,time()+(3600*12),&quot;/&quot;);
}
return true;
} else {
return false;
}

}
?&gt;
</pre>
<p>Now if you have a simple form with two inputs, one for username and password, you can send these to a login page which will run the above function to validate and check the login. We&#8217;ll put this form on our <strong>index.php</strong>:</p>
<h1>index.php</h1>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;PHP Login / Logout&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;login.php&quot; method=&quot;post&quot;&gt;
Username: &lt;input type=&quot;text&quot; name=&quot;username&quot; maxlength=&quot;25&quot; /&gt;&lt;br/&gt;
Password: &lt;input type=&quot;password&quot; name=&quot;password&quot; maxlength=&quot;40&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now on <strong>login.php</strong> we include that function and run it with the submitted username and password.</p>
<h1>login.php</h1>
<pre>
&lt;?php
// login.php

include(&quot;function.php&quot;);

if($_POST[&quot;submit&quot;]){

$login = run_login_form($_POST[&quot;username&quot;],$_POST[&quot;password&quot;]);
if($login){
echo &quot;Login successful! Welcome back!&quot;;
} else {
echo &quot;Login unsuccessful! Please try again.&quot;;
}

}

?&gt;
</pre>
<p>Now we&#8217;ve made the user logged in. Basically we checked the mysql database for a user with those login details and upon finding a match, we created two cookies for that user. One being their userid (an ID we keep in our database for each user) and the other being their username.</p>
<p>So what if the user wants to log out? This is very easy when dealing with simply erasing the cookies we made. We place the following code on our <strong>index.php </strong>page<strong>.</strong></p>
<pre>
&lt;?php
// index.php continued

if($_GET[&quot;do&quot;] == &quot;logout&quot;){

if($_COOKIE[&quot;userid&quot;] &amp;&amp; $_COOKIE[&quot;username&quot;]){
// user is logged in, now log them out!

// set the cookies to a time less than the current timestamp
setcookie(&quot;userid&quot;,&quot;&quot;,time()-3600,&quot;/&quot;);
setcookie(&quot;username&quot;,&quot;&quot;,time()-3600,&quot;/&quot;);
}

}

?&gt;
</pre>
<p>Now when the user visits <strong>index.php?do=logout</strong> it will run this logout code. If the cookies are found, it erases them and they will be treated as a guest based on how your script treats users without these cookies. This way we can check each user on every page they visit for these cookies to tell if they are a registered and logged in user or a guest.</p>
<img src="http://bgallz.org/?ak_action=api_record_view&id=157&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bgallz.org/157/php-cookies-with-login-setcookie/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

