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

<channel>
	<title>Flixey The Blog</title>
	<atom:link href="http://flixey.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://flixey.com</link>
	<description>Randomizing The Web</description>
	<pubDate>Mon, 27 Apr 2009 18:39:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple SQL Injection</title>
		<link>http://flixey.com/2009/04/27/simple-sql-injection/</link>
		<comments>http://flixey.com/2009/04/27/simple-sql-injection/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:39:12 +0000</pubDate>
		<dc:creator>K Park</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[The Internet]]></category>

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

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

		<category><![CDATA[the web]]></category>

		<guid isPermaLink="false">http://flixey.com/?p=42</guid>
		<description><![CDATA[SQL Injection is a technique used to exploit security holes in a system using SQLs such as MySQL. This kind of security hole usually occurs when a programmer doesn&#8217;t filter quotes or other meta-characters properly. The following code is an example of a such a vulnerability.
if(mysql_query("SELECT * FROM member_tables WHERE id = '".$login_id."' and password [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/SQL_Injection">SQL Injection</a> is a technique used to exploit security holes in a system using SQLs such as MySQL. This kind of security hole usually occurs when a programmer doesn&#8217;t filter quotes or other meta-characters properly. The following code is an example of a such a vulnerability.</p>
<blockquote><p><code>if(mysql_query("SELECT * FROM member_tables WHERE id = '".$login_id."' and password = '".$password."'")){<br />
[...code for login...]<br />
</code><code>}</code></p></blockquote>
<p>If quotes aren&#8217;t stripped from the variables $login_id or $password, a malicious user can inject SQL functions. They could login as the first user, in most cases the administrator, by typing in something like this into either of the two variables:</p>
<blockquote><p><code>s' or 1=1 --</code></p></blockquote>
<p>The one line can be catastrophic to a website&#8217;s security. If the quote isn&#8217;t filtered, the script will read the code like this</p>
<blockquote><p><code>if(mysql_query("SELECT * FROM member_tables WHERE id = 's' or 1=1 --' and password = '[password]&#8216;)){<br />
[...code for login...]<br />
}</code></p></blockquote>
<p>The <em>or</em> statement makes it so even if only one condition matches, it will return a <em>true</em> value and execute the script. Since 1=1 is always true, the script will launch no matter what. The rest of the SQL statements are commented out by the two dashes (&#8211;). Is this the end? Nope.. If the security of the site is so weak, some one could easily delete all the members from the database. It&#8217;s just like the one above, but you add a bit of code and do a bit of guesswork.</p>
<blockquote><p><code>s' or 1=1;DROP TABLE member_table; --</code></p></blockquote>
<p>This would render this in the script</p>
<blockquote><p><code>if(mysql_query("SELECT * FROM member_tables WHERE id = 's' or 1=1;DROP TABLES member_table; -- --' and password = '[password]&#8216;)){<br />
[...code for login...]<br />
}</code></p></blockquote>
<p>That just deletes the table. End, unless you have backup.</p>
<p>As devastating as this can be, it&#8217;s also very simple to prevent. You simply escape or remove quotes from a query using a built in function. In the case of PHP, the <em>addslashes()</em> function does the trick. So, the script above should be fixed to</p>
<blockquote><p><code>$login_id = addslashes($login_id);<br />
$password = addslashes($password);<br />
if(mysql_query("SELECT * FROM member_tables WHERE id = '".$login_id."' and password = '".$password."'")){<br />
[...code for login...]<br />
}</code></p></blockquote>
<p>This function adds backslashes (\) before metacharacters which lets the character be treated as just a string and not a special one that affects the acting of the query.</p>
]]></content:encoded>
			<wfw:commentRss>http://flixey.com/2009/04/27/simple-sql-injection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Standards</title>
		<link>http://flixey.com/2009/04/27/web-standards/</link>
		<comments>http://flixey.com/2009/04/27/web-standards/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:35:52 +0000</pubDate>
		<dc:creator>K Park</dc:creator>
		
		<category><![CDATA[The Internet]]></category>

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

		<category><![CDATA[cross-browser]]></category>

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

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

		<category><![CDATA[the web]]></category>

		<guid isPermaLink="false">http://flixey.com/?p=35</guid>
		<description><![CDATA[It has been a while since I started to follow web standards and started cross-browser coding (not to be confused to cross-site scripting). I became aware of the importance when I saw the immense number of visitors using Firefox and IE Explorer along with other browsers like Safari and Opera. I even got visitor using [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a while since I started to follow <a title="Web Standards" href="http://en.wikipedia.org/wiki/Web_standards">web standards</a> and started <a title="Cross Browser" href="http://en.wikipedia.org/wiki/Cross-browser">cross-browser</a> coding (not to be confused to <a title="Cross Site Scripting (XSS)" href="http://en.wikipedia.org/wiki/Cross-site_scripting">cross-site scripting</a>). I became aware of the importance when I saw the immense number of visitors using Firefox and IE Explorer along with other browsers like Safari and Opera. I even got visitor using the Play Station 3 browser. I figured I couldn&#8217;t just ignore people using browsers my site didn&#8217;t support, so I learned about the <a title="W3C Technical Reports" href="http://www.w3.org/TR/">W3C Recommendations</a> and basic cross-browser scripting. I stopped using IE specific functions and properties. A book that helped me is <em>SAMS Teach Yourself JavaScript in 24 Hours</em>. It&#8217;s up-to-date and includes information on cross-browser scripting and web standards.</p>
<p>The first step of following web standards is reading the W3C <a title="XHTML Basic Recommendations" href="http://www.w3.org/TR/2000/REC-xhtml-basic-20001219/">XHTML recommendations</a>. I suggest using the XHTML Transitional DTD since the Strict DTD is literally strict. A DTD is a <a title="Document Type Definition (DTD)" href="http://en.wikipedia.org/wiki/Document_Type_Definition">Document Type Definition</a> and it basically defines the regulations of web standards and is used to validate your <a title="Extensible Hyper Text Markup Language (XHTML)" href="http://en.wikipedia.org/wiki/XHTML">XHTML </a>code. Then you can start validation your websites using the <a title="W3C Validator" href="http://validator.w3.org/">W3C Validator</a> to check whether the document is valid in the DTD you chose.</p>
<p>The second step is to learn how to code your JavasScript to work in all browsers. JavaScript can be scripted to be cross-browser multiple ways, but the most widely used method is by using the <a title="JavaScript Try and Catch" href="http://www.w3schools.com/js/js_try_catch.asp">try and catch</a> method. The following is an example of a cross-browser AJAX object initialization.</p>
<blockquote><p><code>try{<br />
　　// Firefox, Opera 8.0+, Safari, IE7<br />
　　ajaxReq = new XMLHttpRequest();<br />
　　}catch(error){<br />
　　　　// IE5, IE6<br />
　　　　try{<br />
　　　　　　ajaxReq = new ActiveXObject("Msxml2.XMLHTTP");<br />
　　　　　　}catch(error){<br />
　　　　　　　　try{<br />
　　　　　　　　　　ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");<br />
　　　　　　　　　　}catch(error){<br />
　　　　　　　　　　　　return false;<br />
　　　　　　　　　　}<br />
　　　　　　　　}<br />
　　　　　　}<br />
　　　　}<br />
　　}<br />
}</code></p></blockquote>
<p>This script tries a method and if an error occurs it detects it and executes the code within the catch expression. There can be a try expression within a catch expression and thus a cross-browser script can be coded this way.</p>
<p>To successfully code in cross-browser format, you should learn what functions or properties are IE or Firefox specific and avoid using them. Web standards are cross-browser coding are becoming more important by the second, so it iss to your benefit to get used to them as apply them when you&#8217;re coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://flixey.com/2009/04/27/web-standards/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Crazy Windows with JavaScript</title>
		<link>http://flixey.com/2009/04/20/crazy-windows-with-javascript/</link>
		<comments>http://flixey.com/2009/04/20/crazy-windows-with-javascript/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 12:00:29 +0000</pubDate>
		<dc:creator>K Park</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

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

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

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

		<guid isPermaLink="false">http://flixey.com/?p=8</guid>
		<description><![CDATA[Ever seen a browser window shake like crazy? Well here&#8217;s a script for it. You can start annoying all your friends with this simple yet crazy script.
This very simple code can shake browser windows, possible driving people crazy. It tends to stop on Internet Explorer (I have not tested it on Internet Explorer 8) if [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Ever seen a browser window shake like crazy? Well here&#8217;s a script for it. You can start annoying all your friends with this simple yet crazy script.</p>
<p align="justify">This very simple code can shake browser windows, possible driving people crazy. It tends to stop on Internet Explorer (I have not tested it on Internet Explorer 8) if you click on another window, but it works nicely on Firefox and other standard compliant browsers.</p>
<blockquote><p><code>&lt;script type="text/javascript"&gt;<br />
function lol(){<br />
　self.moveTo(Math.random()*100,Math.random()*100);<br />
　window.setTimeout("lol()",50);<br />
}<br />
window.setTimeout("lol()",50);<br />
&lt;/script&gt;<br />
</code></p></blockquote>
<p align="justify">This code first defines a function called <b>lol()</b> which contains the <b>self </b>object connected to the <b>moveTo() </b>function. The notation is:</p>
<blockquote><p><code>moveTo([distance from left],[distance from top])</code></p></blockquote>
<p align="justify">The example above generates a random string which is between 0 and 1(like 0.5487732&#8230;) using the <b>random()</b> function of the <b>Math </b>object and multiplies it by 500 to make a number that&#8217;ll move the window enough.</p>
<p align="justify">We then have the <b>setTimeout()</b> function. The notation of this one is:</p>
<blockquote><p><code>setTimeout("[function]&#8220;,[time(in milliseconds)])</code></p></blockquote>
<p align="justify">So, in this case, the position of the window changes every 50 milliseconds. You can adjust this to make it faster or slower.</p>
<p align="justify">Have fun!</p>
<p><a onclick="window.open('/examples/crazy-windows-with-javascript.php','example','toolbar=no,width=200px,height=100px,resize=no');" href="#">Preview the example (press alt+f4 to close)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flixey.com/2009/04/20/crazy-windows-with-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FLV Downloader Tips</title>
		<link>http://flixey.com/2009/04/19/flv-downloader-tips/</link>
		<comments>http://flixey.com/2009/04/19/flv-downloader-tips/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 14:36:15 +0000</pubDate>
		<dc:creator>K Park</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[flv downloader]]></category>

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

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

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

		<guid isPermaLink="false">http://flixey.com/?p=3</guid>
		<description><![CDATA[The FLV video downloader I designed was written in PHP and some Javascript on the client side. So you&#8217;ll need to know a bit of PHP to understand how this works. It&#8217;s actually very simple, all you do is get the  source from YouTube and then parse it so only the address of the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The <a href="http://video.flixey.com">FLV video downloader</a> I designed was written in PHP and some Javascript on the client side. So you&#8217;ll need to know a bit of PHP to understand how this works. It&#8217;s actually very simple, all you do is get the  source from YouTube and then parse it so only the address of the .flv file is left. The following script locates the download URL and returns it. This is the core to any downloader (it&#8217;s the same concept for even Google Video downloaders and so on).</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>&lt;?php<br />
function get_video_url($id){<br />
　　$url = "http://youtube.com/watch?v=".$id;<br />
　　if ($contents = @file_get_contents($url)) {<br />
　　　　if (preg_match('/video_id=\S+&amp;.+&amp;t=.+&amp;f/i', $contents, $match)) {<br />
　　　　$vars = $match[0];<br />
$url = &#8220;http://www.youtube.com/get_video?&#8221;.$vars;<br />
return $url;<br />
}<br />
}<br />
}<br />
?&gt;</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><strong>Line by Line Analysis</strong></p>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line by line analysis of the code above should help you understand the script better.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>function get_video_url($id){</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line declares a <b>function</b> (a repetitively usable operation) called <b>get_video_url()</b> so we can use it easily and efficiently. The <b>$id</b> is the video id from YouTube and would be a submitted value, something like <em>FzRH3iTQPrk</em>.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>$url = "http://youtube.com/watch?v=".$id;</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line stores the youtube url will the video id in the variable <b>$url</b>.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>if ($contents = @file_get_contents($url)) {</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line of code stored the HTML code of the YouTube page ($url) by using the <b><a title="file_get_contents manual" href="http://www.php.net/file_get_contents" target="_blank">file_get_contents()</a></b><br />
function (note that some hosting services may have disabled the function). The line below it will only be executed if $contents is not empty since the <b><a title="if manual" href="http://www.php.net/manual/en/control-structures.if.php">if()</a></b> operator is controlling it.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>if (preg_match('/video_id=\S+&amp;.+&amp;t=.+&amp;f/i', $contents, $match)) {</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This is the core of the whole thing. It finds the required<br />
information to get the video URL from the source code by searching the HTML code with <a title="Wikipedia - Regular Expressions" href="http://en.wikipedia.org/wiki/Regular_expression" target="_blank">regular expressions</a> using the <b><a title="preg_match manual" href="http://www.php.net/preg-match" target="_blank">preg_match()</a></b> function. This function uses regular expressions to find patterns in a variable (in this case <b>$html</b>) and puts the results as arrays into another variabe (in this case <b>$match</b>).</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>$vars = $match[0];</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line stores the needed information from the array <b>$match[0]</b> (which is the first item) into the $vars variable.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>$url = "http://www.youtube.com/get_video?".$vars;</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line finally puts the information together to get the full video URL. It&#8217;s quite simple, it&#8217;s just combining the found information and <b>http://www.youtube.com/get_video</b> together.</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>return $url;</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">This line just returns the $url variable so we can use it later. The function can then be used by doing something like this:</p>
<blockquote style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;"><p><code>echo get_video_url($url);</code></p></blockquote>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">The rest is just closing the function and the <b>if()</b> operator. Try to look the function up in the PHP manual (they&#8217;re linked above).</p>
<p style="font-weight: bold; font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">Tips</p>
<p style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">If you want to make a downloader for other sites, try using this method:</p>
<ol style="font-family: 'Tahoma','arial','helvetica','sans-serif'; text-align: justify;">
<li>Get the firefox plugin: <a href="https://addons.mozilla.org/en-US/firefox/addon/966" target="_blank">tamper data</a></li>
<li>Go to the site with tamper data open and see what requests come in.</li>
<li>Look for an xml page or an flv file.</li>
<li>Look for a pattern and see how you could automate this.</li>
<li>Write a script for it.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://flixey.com/2009/04/19/flv-downloader-tips/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->