<?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>GimmeSoda &#187; PHP</title>
	<atom:link href="http://www.gimmesoda.com/category/php-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gimmesoda.com</link>
	<description>The Blog of a Programmer</description>
	<lastBuildDate>Mon, 26 Jul 2010 07:54:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Generating Thumbnails from FLV using FFMPEG</title>
		<link>http://www.gimmesoda.com/generating-thumbnails-from-flv-using-ffmpeg/</link>
		<comments>http://www.gimmesoda.com/generating-thumbnails-from-flv-using-ffmpeg/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 10:15:14 +0000</pubDate>
		<dc:creator>JuanJose</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gimmesoda.com/?p=184</guid>
		<description><![CDATA[I had to make some modifications to a zenGallery system which was going to hold a lot of flash video files and I was too lazy to create a thumbnail for each image so for awhile it had the default thumbnail. After a few, &#8220;what&#8217;s with the thumbnails?&#8221; I decided to write a script that]]></description>
			<content:encoded><![CDATA[<p>I had to make some modifications to a zenGallery system which was going to hold a lot of flash video files and I was too lazy to create a thumbnail for each image so for awhile it had the default thumbnail.</p>
<p>After a few, &#8220;what&#8217;s with the thumbnails?&#8221; I decided to write a script that executed ffmpeg to create a thumbnail for each video (from the frame 10 seconds into the video) and write out a jpg image.</p>
<p>The filename currently just replaces .flv with .jpg and my settings for the call are pretty generic. If anyone has questions about this feel free to ask.</p>
<p>Grab the .phps file from here: <a href="http://files.gimmesoda.com/code_samples/generate_thumbs.phps">Generate Thumbnails from FLV files using FFMPEG</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gimmesoda.com/generating-thumbnails-from-flv-using-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>MD5 with Dynamic Salt Class</title>
		<link>http://www.gimmesoda.com/md5-with-dynamic-salt-class/</link>
		<comments>http://www.gimmesoda.com/md5-with-dynamic-salt-class/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 03:28:54 +0000</pubDate>
		<dc:creator>JuanJose</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gimmesoda.com/?p=46</guid>
		<description><![CDATA[Remember my post about MD5 Hashing and Salt? Well I&#8217;ve taken some time to develop a PHP class which helps very easily implement dynamic salt when using MD5. This class can be easily expanded or modified to use a different hash function. Take a look at it and let me know if it becomes useful]]></description>
			<content:encoded><![CDATA[<p>Remember my post about <a target="_blank" href="http://juanjose.blackfalconsolutions.com/2007/09/13/md5-hashing-and-salt/" title="MD5 Hashing and Salt">MD5 Hashing and Salt</a>? Well I&#8217;ve taken some time to develop a PHP class which helps very easily implement dynamic salt when using MD5. This class can be easily expanded or modified to use a different hash function. Take a look at it and let me know if it becomes useful to anyone!</p>
<p>You can <a href="http://juanjose.blackfalconsolutions.com/PasswordWithSalt.class.zip" title="MD5 with Dynamic Salt">download the PasswordWithSalt.class.php file here</a>. Also I setup a <a target="_blank" href="http://juanjose.blackfalconsolutions.com/PasswordWithSalt_Test.php">VERY simple demo</a> of how this works. I&#8217;m still working on developing this but comments and advice will definately be useful here.</p>
<p> The following is the rough text and instructions I&#8217;ve written for my &#8220;readme.txt&#8221; file.</p>
<p><font size="2"></p>
<blockquote>
<p align="left">The only thing you need to do in order to properly configure this class is set the location you want to store your salts at. For example in the class set $storageLocation = &#8220;/home/user/salts/&#8221;; and give permissions for your server to write to that folder  (777 will work). I recommend the folder to be one outside your normal webroot.</p>
<p align="left">The following demonstrates how to store salt for your user, then generate the hash using those salts. Don&#8217;t forget to store the final hash so you can compare against it later!</p>
<p align="left">&lt;?php<br />
require(&#8220;PasswordWithSalt.class.php&#8221;);</p>
<p align="left">//Init the class<br />
$SaltPlease = new PasswordWithSalt();</p>
<p align="left">//Store generated salts for user &#8220;admin&#8221;<br />
$SaltPlease-&gt;storeSalt(&#8220;admin&#8221;);</p>
<p align="left">//Get hash for user admin, password is &#8220;password&#8221;<br />
$hash = $SaltPlease-&gt;createHash(&#8220;admin&#8221;, &#8220;password&#8221;);<br />
?&gt;</p>
<p align="left">&nbsp;</p>
<p align="left">The following demonstrates how to duplicate the hash for a user who already has salt. $dbhash should be filled with the hash you have stored before.</p>
<p align="left">&lt;?php<br />
require(&#8220;PasswordWithSalt.class.php&#8221;);</p>
<p align="left">//Init the class<br />
$SaltPlease = new PasswordWithSalt();</p>
<p align="left">//Get hash for user admin, password is &#8220;password&#8221;<br />
$hash = $SaltPlease-&gt;createHash(&#8220;admin&#8221;, &#8220;password&#8221;);</p>
<p align="left">//Check to see if the generated hash match.<br />
if($dbhash == $hash) {<br />
echo &#8220;Password Hashes Match.&#8221;;<br />
} else {<br />
echo &#8220;Password Hashes DO NOT Match&#8221;;<br />
}<br />
?&gt;</p></blockquote>
<p></font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gimmesoda.com/md5-with-dynamic-salt-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD5 Hashing and Salt</title>
		<link>http://www.gimmesoda.com/md5-hashing-and-salt/</link>
		<comments>http://www.gimmesoda.com/md5-hashing-and-salt/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 18:47:56 +0000</pubDate>
		<dc:creator>JuanJose</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gimmesoda.com/?p=38</guid>
		<description><![CDATA[I just read a great post by Marcel Oelke who runs http://md5.rednoize.com/. He&#8217;s got a great way to access his webservice and then check if a user&#8217;s password is insecure. Even if you are using MD5 before storing the password, I certianly hope people aren&#8217;t storing passwords in cleartext, it may not be secure. I]]></description>
			<content:encoded><![CDATA[<p>I just read a great post by Marcel Oelke who runs <a href="http://md5.rednoize.com/">http://md5.rednoize.com/</a>. He&#8217;s got a great way to access his webservice and then check if a user&#8217;s password is insecure. Even if you are using MD5 before storing the password, I certianly hope people aren&#8217;t storing passwords in cleartext, it may not be secure.<span id="more-38"></span></p>
<p>I know many people don&#8217;t add some salt before storing the password and MD5.rednoize.com really is the perfect example as to why you should be salting all passwords! Even if you have a single sitewide salt - prepending it to a user&#8217;s password before creating the hash is a powerful way to prevent the use of a database like the one which runs MD5.rednoize.com matching against your database. So basically in PHP:</p>
<p>$salt = &#8220;ThisSuperLongStringWillProtectMyUsersAgainstInsecurePasswords&#8221;;<br />
$userpass = $_POST['pass'];<br />
$md5pass = md5($salt . $userpass);</p>
<p>When your user then attempts to login you&#8217;ll duplicate the same process. I personally would keep the $salt in a file outside the normal webroot.</p>
<p>Now the chances of a site having the matching hash to your users password &#8211; even if the pass is &#8221;word&#8221; is MUCH less likely. I hope this explains what it means to salt your passwords.</p>
<p>You can read Marcel&#8217;s post and learn how to call his webservice here:<br />
<a href="http://pure.rednoize.com/2005/11/10/checking-password-strength-using-md5rednoizecom-and-ajax/">http://pure.rednoize.com/2005/11/10/checking-password-strength-using-md5rednoizecom-and-ajax/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gimmesoda.com/md5-hashing-and-salt/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Image Resizing Using PHP and the GD library</title>
		<link>http://www.gimmesoda.com/image-resizing-using-php-and-the-gd-library/</link>
		<comments>http://www.gimmesoda.com/image-resizing-using-php-and-the-gd-library/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 10:48:00 +0000</pubDate>
		<dc:creator>JuanJose</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux Command Line]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gimmesoda.com/?p=15</guid>
		<description><![CDATA[I&#8217;m developing a new system core, can&#8217;t really say what it&#8217;s about but I&#8217;m having some fun doing it. Coding it is interesting, I&#8217;m getting to pull out and update some of my php code. Below is some code for image resizing, I use config files to set some default information like directories to save]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m developing a new system core, can&#8217;t really say what it&#8217;s about but I&#8217;m having some fun doing it. Coding it is interesting, I&#8217;m getting to pull out and update some of my php code. Below is some code for image resizing, I use config files to set some default information like directories to save to and max width/height requirements. Also the entire system uses language files so I don&#8217;t output the text directly either, except for what I&#8217;m going to remove which is the uploaded file information.</p>
<p>Resize JPG images using the GD library and PHP.</p>
<blockquote><p>function get_image_information($key) {<br /> global $thumbnail_dest, $image_dest, $thumb_max_height, $thumb_max_width, $image_max_height, $image_max_width;<br /> $filename = $_FILES[$key]["name"];<br /> $file_type = $_FILES[$key]["type"];<br /> $file_tmpname = $_FILES[$key]["tmp_name"];<br /> $file_error = $_FILES[$key]["error"];<br /> $file_size = $_FILES[$key]["size"];</p>
<p> if($file_error == 0 &&amp; $file_size > 0) {<br />  if($file_type == &#8220;image/pjpeg&#8221;  $file_type == &#8220;image/jpeg&#8221;  $file_type == &#8220;image/jpg&#8221;) {<br />   $image_name = md5(time() . rand(1001,10000)) . &#8220;.jpg&#8221;;<br />   $thumb_dest = $thumbnail_dest . $image_name;<br />   $image_dest = $image_dest . $image_name;<br />   create_image($file_tmpname, $thumb_max_height, $thumb_max_width, $thumb_dest);<br />   create_image($file_tmpname, $image_max_height, $image_max_width, $image_dest);<br />   return &#8220;thumbs/&#8221; . $image_name;<br />  } else {<br />   $success .= file_upload_success_1 . $filename . file_upload_success_2 . &#8220;<br />&#8220;;<br />   $success .= &#8220;We can only accept jpg uploads. Upload Failed.&#8221;;<br />   return $success;<br />  }<br /> } else {<br />  if($file_error == 1) {<br />   echo $file_upload_fail_1;<br />  } elseif($file_error == 2) {<br />   echo $file_upload_fail_2;<br />  } elseif($file_error == 3) {<br />   echo $file_upload_fail_3;<br />  } elseif($file_error == 4) {<br />   echo $file_upload_fail_4;<br />  } elseif($file_error == 6) {<br />   echo $file_upload_fail_6;<br />  }<br />  return false;<br /> }<br />}<br />function create_image($image, $max_width, $max_height, $dest) {<br /> $image = imagecreatefromjpeg($image);<br /> if ($image === false) {<br />  die (&#8216;Unable to open image&#8217;);<br /> }</p>
<p> $width = imagesx($image);<br /> $height = imagesy($image);</p>
<p> if($width < $max_width &#038;&#038; $height < $max_height) {<br />  $new_width = $width;<br />  $new_height = $height;<br /> } else {<br />  $scale = min($max_width/$width, $max_height/$height);<br />  $new_width = floor($scale * $width);<br />  $new_height = floor($scale * $height);<br /> }</p>
<p> $image_resized = imagecreatetruecolor($new_width, $new_height);<br /> imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);<br /> imagejpeg($image_resized, $dest, 90);<br />}</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.gimmesoda.com/image-resizing-using-php-and-the-gd-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
