<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Neo22s</title> <link>http://neo22s.com</link> <description>Web development, scripts, source code and IT stuff</description> <lastBuildDate>Thu, 02 Sep 2010 17:46:06 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Neo22s" /><feedburner:info uri="neo22s" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Neo22s</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>OC Mod: Advanced Spam by Country</title><link>http://feedproxy.google.com/~r/Neo22s/~3/WJvpPEcns3k/</link> <comments>http://neo22s.com/oc-mod-advanced-spam-by-country/#comments</comments> <pubDate>Thu, 02 Sep 2010 17:46:06 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1210</guid> <description><![CDATA[This is the solution I use in classifiedsbarcelona.com to prevent Spam from India. Usage: Edit your commmon.php find the function isInSpamList And replace the whole function with this code (there&#8217;s more than 1 function be aware) //////////////////////////////////////////////////////////// function get_tag&#40;$tag,$xml&#41;&#123; preg_match_all&#40;'/&#60;'.$tag.'&#62;(.*)&#60;\/'.$tag.'&#62;$/imU',$xml,$match&#41;; return $match&#91;1&#93;; &#125; &#160; function valid_ip&#40;$ip&#41;&#123; return &#40; ! preg_match&#40; &#34;/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/&#34;, $ip&#41;&#41; ? FALSE : [...]]]></description> <content:encoded><![CDATA[<p>This is the solution I use in classifiedsbarcelona.com to prevent Spam from India.</p><p>Usage:</p><p>Edit your commmon.php find the function isInSpamList</p><p>And replace the whole function with this code (there&#8217;s more than 1 function be aware)<br /> <span id="more-1210"></span></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">////////////////////////////////////////////////////////////</span>
<span style="color: #000000; font-weight: bold;">function</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;(.*)&lt;\/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;$/imU'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> valid_ip<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> geoIP<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">=-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>valid_ip<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stringIp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$stringIp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$geoip</span><span style="color: #339933;">=</span><span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #000088;">$stringIp</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$geoip</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//only return if IP is the same if not continue</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'http://api.hostip.info/?ip='</span><span style="color: #339933;">.</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Making an API call to Hostip:</span>
	<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//echo $url;</span>
&nbsp;
	<span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gml:name'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$city</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$countryName</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'countryName'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$countryName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$countryName</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$countryAbbrev</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'countryAbbrev'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$countryAbbrev</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$countryAbbrev</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'city'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$city</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$countryName</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'countryAb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$countryAbbrev</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #339933;">,</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Setting a cookie with the data, which is set to expire in half month:</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$geoip</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> isInSpamList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//return is was taged as spam (in /manage is where we tag)</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$ocdb</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$res</span><span style="color: #339933;">=</span><span style="color: #000088;">$ocdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT idPost FROM &quot;</span><span style="color: #339933;">.</span>TABLE_PREFIX<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;posts p where isAvailable=2  and ip='<span style="color: #006699; font-weight: bold;">$ip</span>' LIMIT 1&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    <span style="color: #000088;">$geoip</span><span style="color: #339933;">=</span>geoIP<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'india'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'(unknown country?)'</span><span style="color: #009900;">&#41;</span>  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//ohohoho SPAMMER! from india</span>
	    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//nothing found</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//ohohoho SPAMMER!</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div><p>This will make everything a bit slower but works fine to me.</p><p>Thinking about to add it in newer versions&#8230;.with config in the admin of course.</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/WJvpPEcns3k" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/oc-mod-advanced-spam-by-country/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/oc-mod-advanced-spam-by-country/</feedburner:origLink></item> <item><title>OC Mod: Ads only in child categories</title><link>http://feedproxy.google.com/~r/Neo22s/~3/u4eeTy6M51o/</link> <comments>http://neo22s.com/oc-mod-ads-only-in-child-categories/#comments</comments> <pubDate>Fri, 27 Aug 2010 16:13:37 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1208</guid> <description><![CDATA[Just a simple mod to allow publishing advertisement in child categories. Edit the files: /content/item-new.php /content/item-manage.php Search for: $query=&#34;SELECT idCategory,name,(select name from &#34;.TABLE_PREFIX.&#34;categories where idCategory=C.idCategoryParent) FROM &#34;.TABLE_PREFIX.&#34;categories C order by idCategoryParent, `order`&#34;; Replace in both files for: $query=&#34;SELECT idCategory,name,(select name from &#34;.TABLE_PREFIX.&#34;categories where idCategory=C.idCategoryParent) FROM &#34;.TABLE_PREFIX.&#34;categories C where C.idCategoryParent!=0 order by idCategoryParent, `order`&#34;;]]></description> <content:encoded><![CDATA[<p>Just a simple mod to allow publishing advertisement in child categories.</p><p>Edit the files:</p><p>/content/item-new.php<br /> /content/item-manage.php</p><p>Search for:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT idCategory,name,(select name from &quot;</span><span style="color: #339933;">.</span>TABLE_PREFIX<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;categories where idCategory=C.idCategoryParent) FROM &quot;</span><span style="color: #339933;">.</span>TABLE_PREFIX<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;categories C order by idCategoryParent, `order`&quot;</span><span style="color: #339933;">;</span></pre></div></div><p>Replace in both files for:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT idCategory,name,(select name from &quot;</span><span style="color: #339933;">.</span>TABLE_PREFIX<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;categories where idCategory=C.idCategoryParent) 
	FROM &quot;</span><span style="color: #339933;">.</span>TABLE_PREFIX<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;categories C where C.idCategoryParent!=0 order by idCategoryParent, `order`&quot;</span><span style="color: #339933;">;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/u4eeTy6M51o" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/oc-mod-ads-only-in-child-categories/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/oc-mod-ads-only-in-child-categories/</feedburner:origLink></item> <item><title>Calculate movie hash</title><link>http://feedproxy.google.com/~r/Neo22s/~3/YYueQ-UBS0Q/</link> <comments>http://neo22s.com/calculate-movie-hash/#comments</comments> <pubDate>Thu, 26 Aug 2010 19:14:34 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1206</guid> <description><![CDATA[PHP code to calculate the movie Hash. Uses size + 64bit chksum of the first and last 64k (even if they overlap because the file is smaller than 128k) Usage: echo OpenSubtitlesHash&#40;&#34;/home/chema/Desktop/Monty Pythons Life of Brian.avi&#34;&#41;; Code: function OpenSubtitlesHash&#40;$file&#41; &#123; $handle = fopen&#40;$file, &#34;rb&#34;&#41;; $fsize = filesize&#40;$file&#41;; &#160; $hash = array&#40;3 =&#62; 0, 2 =&#62; [...]]]></description> <content:encoded><![CDATA[<p>PHP code to calculate the movie Hash.</p><p>Uses size + 64bit chksum of the first and last 64k (even if they overlap because the file is smaller than 128k)</p><p><strong>Usage:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> OpenSubtitlesHash<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/home/chema/Desktop/Monty Pythons Life of Brian.avi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p><span id="more-1206"></span><br /> <strong>Code:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> OpenSubtitlesHash<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$fsize</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> 
                  <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> 
                  <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fsize</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFFFF</span><span style="color: #339933;">,</span> 
                  <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fsize</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFFFF</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8192</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tmp</span> <span style="color: #339933;">=</span> ReadUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> AddUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tmp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fsize</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">65536</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">fseek</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> ? <span style="color: #000088;">$offset</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> SEEK_SET<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8192</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tmp</span> <span style="color: #339933;">=</span> ReadUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> AddUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tmp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> UINT64FormatHex<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ReadUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$u</span> <span style="color: #339933;">=</span> <span style="color: #990000;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;va/vb/vc/vd&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$u</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$u</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$u</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;c&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$u</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> AddUINT64<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$o</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$carry</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$carry</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #208080;">0xffff</span> <span style="color: #009900;">&#41;</span> 
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$o</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$carry</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xffff</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$carry</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> 
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$o</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$carry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$carry</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$o</span><span style="color: #339933;">;</span>   
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> UINT64FormatHex<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>   
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%04x</span><span style="color: #009933; font-weight: bold;">%04x</span><span style="color: #009933; font-weight: bold;">%04x</span><span style="color: #009933; font-weight: bold;">%04x</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p><a href="http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes">source</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/YYueQ-UBS0Q" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/calculate-movie-hash/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/calculate-movie-hash/</feedburner:origLink></item> <item><title>Open Classifieds – Update to latest version 1.7.0.2</title><link>http://feedproxy.google.com/~r/Neo22s/~3/nAMjKUsbjdw/</link> <comments>http://neo22s.com/open-classifieds-update-to-latest-version-1-7-0-2/#comments</comments> <pubDate>Tue, 17 Aug 2010 05:23:26 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[News]]></category> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1202</guid> <description><![CDATA[IMPORTANT &#8211; From OC Blog We just found an important issue in the software that can be dangerous if somebody finds out how to take advantage of it. Also I added all the language files (because of that the download file now is bigger) and there&#8217;s a temporary fix for an issue related with the dates in [...]]]></description> <content:encoded><![CDATA[<p>IMPORTANT &#8211; <a href="http://open-classifieds.com/2010/08/16/important-update-to-latest-version-1-7-0-2/">From OC Blog</a></p><p>We just found an important issue in the software that can be dangerous if somebody finds out how to take advantage of it.</p><p>Also I added all the language files (because of that the download file now is bigger) and there&#8217;s a temporary fix for an issue related with the dates in case you want to change the dates format.</p><p>Please download ASAP the latest version of the software 1.7.0.2</p><p><a href="http://j.mp/oc1702"><strong>DOWNLOAD Open Classifieds 1.7.0.2</strong><strong><br /> </strong><strong> </strong> </a></p><p><strong>How to upgrade from 1.7.0.x to 1.7.0.2:<br /> </strong></p><ul><li>Make backups for everything (DB and files)</li><li>Donwnload the latest version 1.7.0.2</li><li>Unpack</li><li>Copy files *.php files from folder /includes/ <strong>exception of  config.php</strong></li><li>Replace new files with old ones, be aware don&#8217;t replace config.php</li><li>Finally replace folder /admin/ with the latest downloaded files</li><li>Test your system everything should be fine</li></ul><p><strong>How to do a new install:</strong></p><ul><li>Download</li><li>Unpack</li><li>Run the installation in http://yourdomain.com/install/</li><li>Follow the steps</li><li>Working!</li></ul><p>Please anything, any problem we are in the forum for you.</p><p>Regards</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/nAMjKUsbjdw" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/open-classifieds-update-to-latest-version-1-7-0-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/open-classifieds-update-to-latest-version-1-7-0-2/</feedburner:origLink></item> <item><title>Ocaku – classifieds community search engine</title><link>http://feedproxy.google.com/~r/Neo22s/~3/i5a1bOobWQM/</link> <comments>http://neo22s.com/ocaku-classifieds-community-search-engine/#comments</comments> <pubDate>Thu, 15 Jul 2010 09:47:38 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[News]]></category> <category><![CDATA[Open Classifieds]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1195</guid> <description><![CDATA[Last months I&#8217;ve been pretty busy with my studies and I needed to do a final project for my Master in Software Engineering. This project is Ocaku, that was presented to the jury of the master 1 week a go. I&#8217;ve got an score of 9 over 10 possible points, not bad at all :D [...]]]></description> <content:encoded><![CDATA[<p>Last months I&#8217;ve been pretty busy with my studies and I needed to do a final project for my Master in Software Engineering.</p><p>This project is Ocaku, that was presented to the jury of the master 1 week a go. I&#8217;ve got an score of 9 over 10 possible points, not bad at all :D</p><p>Now I need to promote my work and I will love any kind of help spreading it ;)</p><p><strong>What is Ocaku?<br /> </strong><br /> Ocaku.com is the finest community for classifieds sites all over the world.</p><p>With the union of all this pages  we have a great multi lingual search engine that allows us to search everywhere in the world.</p><p>Ocaku is free of charge to use and will try to survive using  advertisements, do not hesitate to contact us to advertise in our pages.</p><p><a href="http://api.ocaku.com/">API</a> for usage of Ocaku in your site.</p><p>Presentation (spanish sorry):<br /> <span id="more-1195"></span><br /> <iframe src="http://docs.google.com/present/embed?id=dk2w426_344f267fjfg&#038;size=m" frameborder="0" width="555" height="451"></iframe></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/i5a1bOobWQM" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/ocaku-classifieds-community-search-engine/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://neo22s.com/ocaku-classifieds-community-search-engine/</feedburner:origLink></item> <item><title>Open Classifieds Professional Edition</title><link>http://feedproxy.google.com/~r/Neo22s/~3/bqE0FSu-tqQ/</link> <comments>http://neo22s.com/open-classifieds-professional-edition/#comments</comments> <pubDate>Fri, 02 Jul 2010 10:18:59 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1191</guid> <description><![CDATA[I need to be honest, Open Classifieds is in a huge problem. We have many downloads, load of work to do, support to offer to you and others and that&#8217;s not possible since we don&#8217;t get any benefit from the software. I started this just as an small script and I decided to release it [...]]]></description> <content:encoded><![CDATA[<p>I need to be honest, Open Classifieds is in a huge problem.</p><p>We have many downloads, load of work to do, support to offer to you and others and that&#8217;s not possible since we don&#8217;t get any benefit from the software.</p><p>I started this just as an small script and I decided to release it under GPL, I never expected to grow this much.</p><p>The problem is that I&#8217;m spending many hours in this project and I can&#8217;t. I need money to make a living like anyone else. Donations and services are not enough, currently we work on this 3 persons, being me the one who spends the most time in this.</p><p>So I don&#8217;t want to have 2 different software (1 GPL and other with extra stuff private), I really believe in Open Source and I think that from the services should be enough, but is not.</p><p>For me the solution seems to be offering a professional edition that&#8217;s not more than few services wrapped in a better price.</p><h2>Open Classifieds Professional Edition</h2><ul><li>Software installation</li><li>1 year Premium support (direct support from email)</li><li><a href="http://open-classifieds.com/professional-edition/">read more</a></li></ul><h3><a href="http://open-classifieds.com/professional-edition/">Promotion 40€</a></h3><p>This is the last chance to make Open Classifieds work as a business, if doesn&#8217;t succeed I will need to stop working as I am doing right now. Is sad but is just like this, I will stop the support and the development for next releases and I will just fix bugs. Hope is not like this, I&#8217;m just being realistic :(</p><p><a href="http://open-classifieds.com/2010/07/02/open-classifieds-professional-edition/">source open classifieds</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/bqE0FSu-tqQ" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/open-classifieds-professional-edition/feed/</wfw:commentRss> <slash:comments>3</slash:comments> <feedburner:origLink>http://neo22s.com/open-classifieds-professional-edition/</feedburner:origLink></item> <item><title>PHP Geotarget IP</title><link>http://feedproxy.google.com/~r/Neo22s/~3/lnZpt1aO4aI/</link> <comments>http://neo22s.com/php-geotarget-ip/#comments</comments> <pubDate>Fri, 02 Jul 2010 06:52:48 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1189</guid> <description><![CDATA[Just a function to get geographical info about an IP. I use this actually to stop spammers from certain countries&#8230;I know a bit to radical, but after using IP (of banned lists), captchas, akismet, banned names etc&#8230;I don&#8217;t know what else to do :S. (it seems is already working no spam in 1 week) Usage: [...]]]></description> <content:encoded><![CDATA[<p>Just a function to get geographical info about an IP.</p><p>I use this actually to stop spammers from certain countries&#8230;I know a bit to radical, but after using IP (of banned lists), captchas, akismet, banned names etc&#8230;I don&#8217;t know what else to do :S. (it seems is already working no spam in 1 week)</p><p><strong>Usage:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$geoip</span><span style="color: #339933;">=</span>geoIP<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'81.60.189.183'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//using an existing IP</span>
<span style="color: #000088;">$geoip</span><span style="color: #339933;">=</span>geoIP<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//will use clients IP</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'countryAb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'city'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'india'</span><span style="color: #009900;">&#41;</span>  <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'country not allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//to ban a country</span></pre></div></div><p><strong>The code:<br /> </strong><br /> <span id="more-1189"></span></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;(.*)&lt;\/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;$/imU'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> valid_ip<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> geoIP<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">=-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>valid_ip<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stringIp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$stringIp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$geoip</span><span style="color: #339933;">=</span><span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #000088;">$stringIp</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$geoip</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//only return if IP is the same if not continue</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'http://api.hostip.info/?ip='</span><span style="color: #339933;">.</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Making an API call to Hostip:</span>
	<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//echo $url;</span>
&nbsp;
	<span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gml:name'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$city</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$countryName</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'countryName'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$countryName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$countryName</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$countryAbbrev</span> <span style="color: #339933;">=</span> get_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'countryAbbrev'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$countryAbbrev</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$countryAbbrev</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$stringIp</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'city'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$city</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'country'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$countryName</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$geoip</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'countryAb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$countryAbbrev</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'geoip'</span><span style="color: #339933;">,</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$geoip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Setting a cookie with the data, which is set to expire in 2 weeks:</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$geoip</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/lnZpt1aO4aI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/php-geotarget-ip/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://neo22s.com/php-geotarget-ip/</feedburner:origLink></item> <item><title>Open Classifieds 1.7.0. final release</title><link>http://feedproxy.google.com/~r/Neo22s/~3/j1vr8jlh4Wo/</link> <comments>http://neo22s.com/open-classifieds-1-7-0-final-release/#comments</comments> <pubDate>Fri, 25 Jun 2010 11:05:33 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1187</guid> <description><![CDATA[Finally! After more than2 month of hard work done by Chema, Arnaldo and Oliver (soon I will introduce the new team) we are glad to release today Open Classifieds 1.7. There&#8217;s many new things that I&#8217;m sure you will love: Changed default theme to wpClassifieds Modified install database script to add locations support Added support [...]]]></description> <content:encoded><![CDATA[<p>Finally!</p><p>After more than<strong>2 month of hard work </strong>done by Chema, Arnaldo and Oliver (soon I will introduce the new team) we are glad to release today Open Classifieds 1.7.</p><p>There&#8217;s many new things that I&#8217;m sure you will love:</p><ul><li>Changed default theme to wpClassifieds</li><li>Modified install database script to add locations support</li><li>Added support for custom SMTP host configuration</li><li>Added new admin section to manage locations</li><li>Added new sidebar function to show location links (locations)</li><li>Changed way the images are stored, also deleted table images.</li><li>Added Site Stats in admin</li><li>Added expire headers for better cache</li><li>Now prices allows float numbers</li><li>No hacker defense in admin</li><li>Account management, create new users account to post!</li><li>Email templates</li><li>Improved installer step by step.</li><li>New look for Admin and installer.</li><li>Advertisement setting for AdSense in admin.</li><li>Among others</li></ul><h2><strong><a href="http://open-classifieds.com/download/">Download<br /> </a></strong></h2><p><strong>How to install</strong><span id="more-1187"></span></p><ul><li>Download</li><li>Unpack</li><li>Run the installation in http://yourdomain.com/install/</li><li>Follow the steps</li><li>Working!</li></ul><p><strong>How to upgrade</strong></p><ul><li>Make backups for everything</li><li>Do same as install</li><li>Then run http://yourdomain.com/install/upgrade.php</li><li>Check your site ;)</li></ul><p>Please any doubt use the <a href=http://open-classifieds.com/forum/forum/17-1">forum for this release</a>.</p><p>We are working in the documentation, new screenshots, etc&#8230;</p><p>For the translations<a href="http://open-classifieds.com/forum/topic/translations-for-17"> please read this</a>.</p><p>Enjoy ;)</p><p><a href="http://open-classifieds.com/2010/06/25/open-classifieds-1-7-0-final-release/">source open classifieds blog</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/j1vr8jlh4Wo" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/open-classifieds-1-7-0-final-release/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/open-classifieds-1-7-0-final-release/</feedburner:origLink></item> <item><title>Open Classifieds 1.7. Release Candidate 2</title><link>http://feedproxy.google.com/~r/Neo22s/~3/VUvb37qvQ_o/</link> <comments>http://neo22s.com/open-classifieds-1-7-release-candidate-2/#comments</comments> <pubDate>Fri, 18 Jun 2010 07:38:11 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[News]]></category> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1183</guid> <description><![CDATA[Almost 2 weeks after the first release I think we fixed like 15 different small bugs. None of them severe. Because of that here you have the Open Classifieds 1.7. Release Candidate 2, which is going to be the latest RC. Next week 1.7.0. will be officially released. Download now Open Classifieds 1.7. RC 2 [...]]]></description> <content:encoded><![CDATA[<p>Almost 2 weeks after the first release I think we fixed like 15 different small bugs. None of them severe.</p><p>Because of that here you have the Open Classifieds 1.7. Release Candidate 2, which is going to be the latest RC.</p><p>Next week 1.7.0. will be officially released.</p><p><a href="https://sourceforge.net/projects/openclassifieds/files/openclassifieds/1.7/Open_Classifieds_1.7.0_RC2.tar.gz/download"><strong>Download now Open Classifieds 1.7. RC 2</strong></a></p><p><strong>How to install</strong><br /> <span id="more-1183"></span></p><ul><li>Download</li><li>Unpack</li><li>Run the installation in http://yourdomain.com/install/</li><li>Follow the steps</li><li>Test!</li></ul><p><strong> How to upgrade</strong></p><ul><li>Make backups for everything</li><li>Erase all your content except for the folder /images/</li><li>Do same as install</li><li>Then run http://yourdomain.com/install/upgrade.php</li><li>Hope everything goes well ;)</li></ul><p><strong>Please don&#8217;t use yet this software in production environments.</strong></p><p><strong><br /> </strong></p><p><strong><span style="font-weight: normal;"><a href="http://open-classifieds.com/forum/forum/17-rc-2">Use the forum for 1.7. RC 2</a> for any doubts of bug hunting.</span></strong></p><p>We need also to re do almost all the open-classifieds.com page, updating all the content to fit 1.7. documentation etc&#8230;</p><p>source <a href="http://open-classifieds.com/2010/06/18/open-classifieds-1-7-release-candidate-2/">Open Classifieds blog</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/VUvb37qvQ_o" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/open-classifieds-1-7-release-candidate-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/open-classifieds-1-7-release-candidate-2/</feedburner:origLink></item> <item><title>Teleworking, advantages and tricks</title><link>http://feedproxy.google.com/~r/Neo22s/~3/abkNa2ezMnI/</link> <comments>http://neo22s.com/teleworking-advantages-and-tricks/#comments</comments> <pubDate>Mon, 14 Jun 2010 16:29:24 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Talks]]></category><guid isPermaLink="false">http://neo22s.com/?p=1181</guid> <description><![CDATA[Sorry but this is in Spanish once more since is a work for school.]]></description> <content:encoded><![CDATA[<p>Sorry but this is in Spanish once more since is a work for school.</p><p><iframe src="http://docs.google.com/present/embed?id=dk2w426_335dn8c9jdr&#038;size=m" frameborder="0" width="555" height="451"></iframe></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/abkNa2ezMnI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/teleworking-advantages-and-tricks/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/teleworking-advantages-and-tricks/</feedburner:origLink></item> <item><title>Open Classifieds 1.7. Release Candidate 1</title><link>http://feedproxy.google.com/~r/Neo22s/~3/GUuC2mIALSA/</link> <comments>http://neo22s.com/open-classifieds-1-7-release-candidate-1/#comments</comments> <pubDate>Sun, 06 Jun 2010 21:14:09 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1178</guid> <description><![CDATA[source Open Classifieds Blog Finally! After 2 month of hard work done by Chema, Arnaldo and Oliver (soon I will introduce the new team) we are glad to release today the first release candidate for Open Classifieds 1.7. There&#8217;s many new things that I&#8217;m sure you will love: Changed default theme to wpClassifieds Modified install [...]]]></description> <content:encoded><![CDATA[<p>source <a href="http://open-classifieds.com/2010/06/06/open-classifieds-1-7-release-candidate-1/">Open Classifieds Blog</a></p><p>Finally!</p><p>After <strong>2 month of hard work </strong>done by Chema, Arnaldo and Oliver (soon I will introduce the new team) we are glad to release today the first release candidate for Open Classifieds 1.7.<br /> <span id="more-1178"></span><br /> There&#8217;s many new things that I&#8217;m sure you will love:</p><ul><li>Changed default theme to wpClassifieds</li><li>Modified install database script to add locations support</li><li>Added support for custom SMTP host configuration</li><li>Added new admin section to manage locations</li><li>Added new sidebar function to show location links (locations)</li><li>Changed way the images are stored, also deleted table images.</li><li>Added Site Stats in admin</li><li>Added expire headers for better cache</li><li>Now prices allows float numbers</li><li>No hacker defense in admin</li><li>Account management, create new users account to post!</li><li>Email templates</li><li>Improved installer step by step.</li><li>New look for Admin and installer.</li><li>Advertisement setting for AdSense in admin.</li><li>Among others</li></ul><p><strong>Not for production environments!!</strong></p><p>Test it please, and bring us feedback in the specific <a href="http://open-classifieds.com/forum/forum/17-rc1">forum for this release</a>.</p><h2><strong><a href="https://sourceforge.net/projects/openclassifieds/files/openclassifieds/1.7/Open_Classifieds_1.7.0_RC1.tar.gz/download">Download<br /> </a></strong></h2><p><strong>How to install</strong></p><ul><li>Download</li><li>Unpack</li><li>Run the installation in http://yourdomain.com/install/</li><li>Follow the steps</li><li>Test!</li></ul><p><strong>How to upgrade</strong></p><ul><li>Make backups for everything</li><li>Do same as install</li><li>Then run http://yourdomain.com/install/upgrade.php</li><li>Hope everything goes well ;)</li></ul> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/GUuC2mIALSA" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/open-classifieds-1-7-release-candidate-1/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/open-classifieds-1-7-release-candidate-1/</feedburner:origLink></item> <item><title>Prevent code injection in PHP – Updated</title><link>http://feedproxy.google.com/~r/Neo22s/~3/GCEa3zZUCTE/</link> <comments>http://neo22s.com/prevent-code-injection-in-php-updated/#comments</comments> <pubDate>Wed, 02 Jun 2010 06:48:15 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1176</guid> <description><![CDATA[Long time a go I wrote this article on how to prevent code injection in PHP, but is kind of old and uses the deprecated method &#8220;eregi&#8221;. I rewrited the function and now looks like this, the hacker defense for php: function hackerDefense&#40;&#41;&#123; // begin hacker defense $notAllowedExp = array&#40; '/&#60;[^&#62;]*script.*\&#34;?[^&#62;]*&#62;/','/&#60;[^&#62;]*style.*\&#34;?[^&#62;]*&#62;/', '/&#60;[^&#62;]*object.*\&#34;?[^&#62;]*&#62;/','/&#60;[^&#62;]*iframe.*\&#34;?[^&#62;]*&#62;/', '/&#60;[^&#62;]*applet.*\&#34;?[^&#62;]*&#62;/','/&#60;[^&#62;]*window.*\&#34;?[^&#62;]*&#62;/', '/&#60;[^&#62;]*docuemnt.*\&#34;?[^&#62;]*&#62;/','/&#60;[^&#62;]*cookie.*\&#34;?[^&#62;]*&#62;/', '/&#60;[^&#62;]*meta.*\&#34;?[^&#62;]*&#62;/','/&#60;[^&#62;]*alert.*\&#34;?[^&#62;]*&#62;/', [...]]]></description> <content:encoded><![CDATA[<p>Long time a go I wrote this article on <a href="http://neo22s.com/prevent-code-injection-in-php/">how to prevent code injection in PHP</a>, but is kind of old and uses the deprecated method &#8220;eregi&#8221;.</p><p>I rewrited the function and now looks like this, the hacker defense for php:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> hackerDefense<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// begin hacker defense</span>
	<span style="color: #000088;">$notAllowedExp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>	
			<span style="color: #0000ff;">'/&lt;[^&gt;]*script.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*style.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'/&lt;[^&gt;]*object.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*iframe.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'/&lt;[^&gt;]*applet.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*window.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'/&lt;[^&gt;]*docuemnt.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*cookie.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'/&lt;[^&gt;]*meta.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*alert.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'/&lt;[^&gt;]*form.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*php.*\&quot;?[^&gt;]*&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/&lt;[^&gt;]*img.*\&quot;?[^&gt;]*&gt;/'</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//not allowed in the system</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$postvalue</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #666666; font-style: italic;">//checking posts				</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$notAllowedExp</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$exp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//checking there's no matches</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$exp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postvalue</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Code not allowed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//die!!!</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// end hacker defense 	</span>
<span style="color: #009900;">&#125;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/GCEa3zZUCTE" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/prevent-code-injection-in-php-updated/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/prevent-code-injection-in-php-updated/</feedburner:origLink></item> <item><title>Search suggestions in AJAX + PHP</title><link>http://feedproxy.google.com/~r/Neo22s/~3/YM7UOmQ9two/</link> <comments>http://neo22s.com/search-suggestions-in-ajax-php/#comments</comments> <pubDate>Wed, 26 May 2010 15:01:47 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1168</guid> <description><![CDATA[Simple search suggestions for PHP using ajax. HTML: &#60;input type=&#34;text&#34; name=&#34;s&#34; id=&#34;s&#34; value=&#34;&#34; onkeyup=&#34;showSugestions();&#34; /&#62; &#60;div id=&#34;livesearch&#34;&#62;&#60;/div&#62; JavaScript: function ajax&#40;id,page&#41;&#123;//loads using ajax &#160; if &#40;window.XMLHttpRequest&#41; xmlhttp=new XMLHttpRequest&#40;&#41;;// code for IE7+, Firefox, Chrome, Opera, Safari else xmlhttp=new ActiveXObject&#40;&#34;Microsoft.XMLHTTP&#34;&#41;;// code for IE6, IE5 &#160; xmlhttp.onreadystatechange=function&#40;&#41;&#123; if &#40;xmlhttp.readyState==4 &#38;&#38; xmlhttp.status==200&#41;&#123; document.getElementById&#40;id&#41;.innerHTML=xmlhttp.responseText; &#125; &#125; &#160; xmlhttp.open&#40;&#34;GET&#34;,page,true&#41;; xmlhttp.send&#40;&#41;; &#125; &#160; [...]]]></description> <content:encoded><![CDATA[<p>Simple search suggestions for PHP using ajax.</p><p><strong>HTML:</strong></p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">onkeyup</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;showSugestions();&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;livesearch&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div><p><span id="more-1168"></span><br /> <strong>JavaScript:</strong></p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> ajax<span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span>page<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">//loads using ajax</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> xmlhttp<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// code for IE7+, Firefox, Chrome, Opera, Safari</span>
	<span style="color: #000066; font-weight: bold;">else</span> xmlhttp<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// code for IE6, IE5</span>
&nbsp;
	xmlhttp.<span style="color: #660066;">onreadystatechange</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	  	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xmlhttp.<span style="color: #660066;">readyState</span><span style="color: #339933;">==</span><span style="color: #CC0000;">4</span> <span style="color: #339933;">&amp;&amp;</span> xmlhttp.<span style="color: #000066;">status</span><span style="color: #339933;">==</span><span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	  		document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span>xmlhttp.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span>
	  	<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	xmlhttp.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span>page<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	xmlhttp.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> showResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">//used in the search box</span>
	str<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;s&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
	  document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;livesearch&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
	  document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;livesearch&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">border</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;0px&quot;</span><span style="color: #339933;">;</span>
	  <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	ajax<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;livesearch&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;/livesearch.php?q=&quot;</span><span style="color: #339933;">+</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;livesearch&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;livesearch&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">border</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;1px solid #A5ACB2&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> timeout<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> showSugestions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	clearTimeout<span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	timeout<span style="color: #339933;">=</span>setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;showResult()&quot;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p><strong>PHP</strong>:<br /> This is just an example now returns the same string, you should add here you sql or xml etc&#8230;</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//get the q parameter from URL</span>
<span style="color: #000088;">$q</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//echo $q;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//lookup all links from the sql if length of q&gt;0</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">245</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//here the code to return</span>
   <span style="color: #000088;">$hint</span><span style="color: #339933;">.=</span><span style="color: #000088;">$q</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//output the response</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$hint</span><span style="color: #339933;">;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/YM7UOmQ9two" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/search-suggestions-in-ajax-php/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://neo22s.com/search-suggestions-in-ajax-php/</feedburner:origLink></item> <item><title>Cache expire Headers in PHP</title><link>http://feedproxy.google.com/~r/Neo22s/~3/kjF-qnvFwms/</link> <comments>http://neo22s.com/cache-expire-headers-in-php/#comments</comments> <pubDate>Sat, 15 May 2010 18:01:33 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Open Classifieds]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1164</guid> <description><![CDATA[Really useful way to take stress to you server is sending to the browser proper header establishing when your content will expire and until when needs to be cached. Imagine how many less request you will have since the browser have that info already cached! How to do it in PHP, just put this code [...]]]></description> <content:encoded><![CDATA[<p>Really useful way to take stress to you server is sending to the browser proper header establishing when your content will expire and until when needs to be cached.</p><p>Imagine how many less request you will have since the browser have that info already cached!</p><p>How to do it in PHP, just put this code at the top of your code, before anything it&#8217;s output.</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$expire</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// seconds, minutes, hours, days</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Pragma: public'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache-Control: maxage='</span><span style="color: #339933;">.</span><span style="color: #000088;">$expire</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Expires: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D, d M Y H:i:s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #000088;">$expire</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' GMT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Last-Modified: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D, d M Y H:i:s'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' GMT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Just be aware of the time you put, if your site needs to have the latest fresh news it may be not be agood Idea to use more than few minutes expire.<br /> <span id="more-1164"></span></p><p>This will be implemented int he new version of Open Classifieds ;), 1.7. coming soon&#8230;.</p><p>Source: <a href="http://php.net/manual/en/function.header.php">php.net</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/kjF-qnvFwms" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/cache-expire-headers-in-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/cache-expire-headers-in-php/</feedburner:origLink></item> <item><title>Light PHP Frameworks</title><link>http://feedproxy.google.com/~r/Neo22s/~3/5hhli_CrcsQ/</link> <comments>http://neo22s.com/light-php-frameworks/#comments</comments> <pubDate>Fri, 14 May 2010 22:21:14 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1160</guid> <description><![CDATA[I have this thing with light and fast things&#8230;.I love performance! The thing is that I use my own framework to develop PHP, but what is a framework exactly? when is a framework or just a set of utils? My point is that I don&#8217;t like frameworks such as Zend or others that are heavy, [...]]]></description> <content:encoded><![CDATA[<p>I have this thing with light and fast things&#8230;.I love performance!</p><p>The thing is that I use my own framework to develop PHP, but what is a framework exactly? when is a framework or just a set of utils?</p><p>My point is that I don&#8217;t like frameworks such as Zend or others that are heavy, loaded with stuff I will never use, of course this can be great for backends where there&#8217;s lack of performance since there&#8217;s not many users&#8230;I&#8217;m talking about the scenario of front end.</p><p>In front end architecture the king is the MVC design pattern. Why not just create a bunch of utilities to have an easy fast MVC and then add the classes or functions that you need?</p><p>For this things can be great any of this solutions:</p><p><strong><a href="http://fatfree.sourceforge.net/">Fat Free</a>: </strong>Light MVC framework with many extra functionality in just few KB, take a look, really good documentation. Just I don&#8217;t like too much the templating feature since PHP it&#8217;s actually a template engine it self, don&#8217;t forget that&#8230;</p><p><a href="http://github.com/nicolaslattuada/minimal-php-mvc/"><strong>Miminal PHP MVC:</strong></a> I think the name it&#8217;s enough to know what&#8217;s about. This is more or less what I&#8217;m using with more functionality that I use in my projects, but the concept it self is great, MINIMAL.</p><p><a title="The no-framework PHP MVC framework" href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html"><strong>The no-framework PHP MVC framework</strong></a>: This is more an article written by Rasmus Lerdorf (creator of PHP) regarding frameworks. Really interesting reading.</p><p>I still don&#8217;t have my framework clean enough to make it public but I just would like to share something really simple but at the same time really useful as it is the folder structure for my projects:<br /> <span id="more-1160"></span></p><pre>
/Root - nothing here is public to the web users
/cache  - for cached files if I don use something as APC or Xcache
/core - Here they go the includes of the application and external classes, aldo the main controller of the APP.
/locale - Localization goes here
/models - models for the APP classes
/public  - here goes the visible part of the web, normally contains just 1 php file and CSS's, images, htaccess. etc.
/templates - PHP files to include as templates for content
</pre><p>It&#8217;s pretty simple but just following this you have a clean start and easy to control source, period ;)</p><p>Please if you know any other light framework let me know, since I&#8217;m building mine from the things I like the most of each of them :P</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/5hhli_CrcsQ" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/light-php-frameworks/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://neo22s.com/light-php-frameworks/</feedburner:origLink></item> <item><title>Ubuntu 10.04 Lucid Lynx in Eee PC 1101HA</title><link>http://feedproxy.google.com/~r/Neo22s/~3/FmSLJNvqVag/</link> <comments>http://neo22s.com/ubuntu-10-04-lucid-lynx-in-eee-pc-1101ha/#comments</comments> <pubDate>Tue, 04 May 2010 17:06:13 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Linux]]></category><guid isPermaLink="false">http://neo22s.com/?p=1155</guid> <description><![CDATA[There&#8217;s new Ubuntu version and of course some drivers don&#8217;t work properly in the Netbook&#8230;. To fix the Video card: UPDATE: Finally something that works good, and official. wget http://dl.dropbox.com/u/1338581/Gma500/scripts/poulsbo.sh &#038;&#038; sh ./poulsbo.sh Old, not so good: Add in /etc/grub.d/40-custom insmod 915resolution 915resolution 5c 1366 768 set gfxmode=1366x768 edit /etc/default/grub add a line with  &#8221;GRUB_GFXMODE=1366&#215;768&#8243; [...]]]></description> <content:encoded><![CDATA[<p>There&#8217;s new Ubuntu version and of course some drivers don&#8217;t work properly in the Netbook&#8230;.</p><p><strong>To fix the Video card:</strong></p><p>UPDATE:<br /> Finally something that works good, and <a href="https://wiki.ubuntu.com/HardwareSupportComponentsVideoCardsPoulsbo#karmic">official</a>.</p><pre>wget http://dl.dropbox.com/u/1338581/Gma500/scripts/poulsbo.sh &#038;&#038; sh ./poulsbo.sh
</pre><p><span id="more-1155"></span><br /> Old, not so good:</p><ul><li>Add in /etc/grub.d/40-custom</li></ul><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">insmod 915resolution
915resolution 5c <span style="color: #000000;">1366</span> <span style="color: #000000;">768</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">gfxmode</span>=1366x768</pre></div></div><ul><li>edit /etc/default/grub</li><li>add a line with  &#8221;GRUB_GFXMODE=1366&#215;768&#8243;</li><li>update-grub</li></ul><p>On next reboot you&#8217;ll have 1366&#215;768 resolution in X, even if slow, at least it looks better.</p><p><del datetime="2010-05-21T06:19:54+00:00">Waiting the driver&#8230;..<br /> </del><br /> source <a href="http://ubuntuforums.org/showthread.php?t=1229345&amp;highlight=gma500&amp;page=50">ubuntuforums</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/FmSLJNvqVag" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/ubuntu-10-04-lucid-lynx-in-eee-pc-1101ha/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/ubuntu-10-04-lucid-lynx-in-eee-pc-1101ha/</feedburner:origLink></item> <item><title>Generating a unique Key</title><link>http://feedproxy.google.com/~r/Neo22s/~3/Al1IKc3BK9g/</link> <comments>http://neo22s.com/generating-an-unique-key/#comments</comments> <pubDate>Tue, 04 May 2010 08:44:08 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1149</guid> <description><![CDATA[I need a unique Key to use to identify an object. I use this in PHP: $key = md5&#40;uniqid&#40;mt_rand&#40;&#41;, false&#41;&#41;; This should be unique, but can you believe that will never be repeated? I don&#8217;t trust it&#8230; Just check it in your DB just in case: function generateKey&#40;&#41;&#123;//Generate a unique key do&#123; $key = md5&#40;uniqid&#40;mt_rand&#40;&#41;, [...]]]></description> <content:encoded><![CDATA[<p>I need a unique Key to use to identify an object.</p><p>I use this in PHP:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">uniqid</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>This should be unique, but can you believe that will never be repeated?  I don&#8217;t trust it&#8230;</p><p>Just check it in your DB just in case:<br /> <span id="more-1149"></span></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> generateKey<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//Generate a unique key </span>
    <span style="color: #b1b100;">do</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">uniqid</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>validateKeyn<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> validateKey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//check the DB</span>
       <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT theKey FROM Table WHERE theKey ='&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' LIMIT 1&quot;</span><span style="color: #339933;">;</span>
       <span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Also imagine you need to create a kind of serial number, you can use this interesting function from <a href="http://phpgoogle.blogspot.com/2007/08/four-ways-to-generate-unique-id-by-php.html">corner</a>:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Generate Guid </span>
<span style="color: #000000; font-weight: bold;">function</span> NewGuid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">uniqid</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #000088;">$guidText</span> <span style="color: #339933;">=</span> 
        <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> 
        <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> 
        <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> 
        <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> 
        <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$guidText</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// End Generate Guid </span>
<span style="color: #000088;">$Guid</span> <span style="color: #339933;">=</span> NewGuid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>This will return something like: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX style unique id, (8 letters)-(4 letters)-(4 letters)-(4 letters)-(12 letters)</p><p>Update: I just found that is <a href="http://wordwhirled.blogspot.com/2005/12/unique-or-unique.html">&#8220;a unique&#8221; instead of &#8220;an unique&#8221;</a> xD</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/Al1IKc3BK9g" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/generating-an-unique-key/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/generating-an-unique-key/</feedburner:origLink></item> <item><title>Moving option elements HTML</title><link>http://feedproxy.google.com/~r/Neo22s/~3/U1VawHtfg4c/</link> <comments>http://neo22s.com/moving-option-elements-html/#comments</comments> <pubDate>Tue, 27 Apr 2010 18:54:24 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[JavaScript]]></category><guid isPermaLink="false">http://neo22s.com/?p=1132</guid> <description><![CDATA[Not much to explain just an example: Left Left 1 Left 2 Left 3 Left 4 Left 5 Right Right 1 Right 2 Right 3 Right 4 Right 5 Show me the code! HTML &#60;div class=&#34;OneOfTwo&#34; style=&#34;width:60%&#34;&#62; &#60;div style=&#34;float:left;&#34;&#62; &#60;strong&#62;Left&#60;/strong&#62;&#60;br /&#62; &#60;select id=&#34;available&#34; size=&#34;5&#34; multiple=&#34;multiple&#34; style=&#34;width: 170px;&#34;&#62; &#60;option&#62;Left 1&#60;/option&#62; &#60;option&#62;Left 2&#60;/option&#62; &#60;option&#62;Left 3&#60;/option&#62; &#60;option&#62;Left 4&#60;/option&#62; [...]]]></description> <content:encoded><![CDATA[<p><script type='text/javascript' src='http://lab.neo22s.com/movingSelect/movingSelect.js'></script><br /> Not much to explain just an example:</p><div class="OneOfTwo" style="width:60%"><div style="float:left;"> <strong>Left</strong></p> <select id="available" size="5" multiple="multiple" style="width: 170px;"><option>Left 1</option><option>Left 2</option><option>Left 3</option><option>Left 4</option><option>Left 5</option> </select></div><div style="float:left;height:50px;padding-top:25px;"> <input type="button"  value="&lt;" onclick="swapElement('selected','available')" /></p> <input type="button" value="&gt;" onclick="swapElement('available','selected')"  /></div><div style="float:left;"> <strong>Right</strong></p> <select id="selected" name="SIDEBAR[]" size="5" multiple="multiple" style="width: 170px;"><option>Right 1</option><option>Right 2</option><option>Right 3</option><option>Right 4</option><option>Right 5</option> </select><p></p> <input type="button"  value="UP" onclick=" moveUp('selected')" /> <input type="button"  value="DOWN" onclick="moveDown('selected')" /></div></div><div style="clear:both"></div><p>Show me the code!<br /> <span id="more-1132"></span><br /> <strong>HTML<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;OneOfTwo&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:60%&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float:left;&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>Left<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;available&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">multiple</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multiple&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 170px;&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Left 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Left 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Left 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Left 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Left 5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float:left;height:50px;padding-top:25px;&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>  <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&amp;lt;&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;swapElement('selected','available')&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&amp;gt;&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;swapElement('available','selected')&quot;</span>  <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float:left;&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>Right<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;selected&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;SIDEBAR[]&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">multiple</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multiple&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 170px;&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Right 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Right 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Right 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Right 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>Right 5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>  <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UP&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot; moveUp('selected')&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>  <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DOWN&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;moveDown('selected')&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clear:both&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div><p><strong>JavaScript<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> moveUp<span style="color: #009900;">&#40;</span>selectId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectList <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>selectId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectOptions <span style="color: #339933;">=</span> selectList.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'option'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> selectOptions.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> opt <span style="color: #339933;">=</span> selectOptions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>opt.<span style="color: #660066;">selected</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			selectList.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>opt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selectList.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>opt<span style="color: #339933;">,</span> selectOptions<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
       <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> moveDown<span style="color: #009900;">&#40;</span>selectId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectList <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>selectId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectOptions <span style="color: #339933;">=</span> selectList.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'option'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> selectOptions.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> opt <span style="color: #339933;">=</span> selectOptions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>opt.<span style="color: #660066;">selected</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		   <span style="color: #003366; font-weight: bold;">var</span> nextOpt <span style="color: #339933;">=</span> selectOptions<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		   opt <span style="color: #339933;">=</span> selectList.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>opt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   nextOpt <span style="color: #339933;">=</span> selectList.<span style="color: #660066;">replaceChild</span><span style="color: #009900;">&#40;</span>opt<span style="color: #339933;">,</span> nextOpt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   selectList.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>nextOpt<span style="color: #339933;">,</span> opt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
       <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> swapElement<span style="color: #009900;">&#40;</span>fromList<span style="color: #339933;">,</span>toList<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> selectOptions <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>fromList<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> selectOptions.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> opt <span style="color: #339933;">=</span> selectOptions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>opt.<span style="color: #660066;">selected</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>fromList<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>opt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>toList<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>opt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            i<span style="color: #339933;">--;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> selectAllOptions<span style="color: #009900;">&#40;</span>selStr<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> selObj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>selStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>selObj.<span style="color: #660066;">options</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        selObj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">selected</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>How to catch everything in PHP, using a form:</p><p>First in the form we need to select all the elements of the input before sending:</p><pre lag="html4strict">
<form action="" method="post" onsubmit="selectAllOptions('selected');">
inside here the selects
</form>
</pre><p>To catch it in PHP:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SIDEBAR&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SIDEBAR&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Now you have in $_POST["SIDEBAR"] all the elements separated by coma, remember that you receive an Array.</p><p>Source from different places <a href="http://www.sitepoint.com/forums//showthread.php?t=564568">I</a> , <a href="http://www.mredkj.com/tutorials/tutorial_mixed2b.html">II</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/U1VawHtfg4c" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/moving-option-elements-html/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/moving-option-elements-html/</feedburner:origLink></item> <item><title>Check if URL exists and is Online – PHP</title><link>http://feedproxy.google.com/~r/Neo22s/~3/ujjfGfgKHVY/</link> <comments>http://neo22s.com/check-if-url-exists-and-is-online-php/#comments</comments> <pubDate>Mon, 26 Apr 2010 15:19:03 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1139</guid> <description><![CDATA[Imagine you need to check if a site is online or not, seems pretty easy since there&#8217;s plenty of tools to check this, but this can be a huge bottleneck for your app. I have tried different ways with sockets, header and curl in order to know which one is the fastest option. Tested code [...]]]></description> <content:encoded><![CDATA[<p>Imagine you need to check if a site is online or not, seems pretty easy since there&#8217;s plenty of tools to check this, but this can be a huge bottleneck for your app.</p><p>I have tried different ways with sockets, header and curl in order to know which one is the fastest option.</p><p>Tested code done to the site yahoo.com (10 attempts each and we keep best result as time):<br /> <span id="more-1139"></span><br /> <strong>Sockets + Header:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trim'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #cc66cc;">80</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$path</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;?<span style="color: #006699; font-weight: bold;">$url[query]</span>&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">gethostbyname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
&nbsp;
     <span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fsockopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errno</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errstr</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//socket not opened</span>
&nbsp;
        <span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;HEAD <span style="color: #006699; font-weight: bold;">$path</span> HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Host: <span style="color: #006699; font-weight: bold;">$url[host]</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//socket opened</span>
        <span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
	 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#^HTTP/.*\s+[(200|301|302)]+\s#i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//matching header</span>
	       <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> 
	 <span style="color: #009900;">&#125;</span> 
	 <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if parse url</span>
 <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div><p>Time: 0.222 seconds, never more than 0.225s</p><p><strong>Curl:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$resURL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #339933;">,</span> CURLOPT_BINARYTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #339933;">,</span> CURLOPT_HEADERFUNCTION<span style="color: #339933;">,</span> <span style="color: #0000ff;">'curlHeaderCallback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #339933;">,</span> CURLOPT_FAILONERROR<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_exec</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$intReturnCode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #339933;">,</span> CURLINFO_HTTP_CODE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$resURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$intReturnCode</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">200</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$intReturnCode</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">302</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$intReturnCode</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">304</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></div></div><p>Time: 0.224 seconds, few times reached 0.227</p><p><strong>Headers:<br /> </strong></p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">@</span><span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_headers</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^HTTP\/\d\.\d\s+(200|301|302)/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div><p>Time: 0.891 seconds, few times more than 1.5s</p><p>As you can see for me the <strong>fastest way is Socket + Header</strong>, even though Curl is pretty fast!</p><p>Also note, that I didn&#8217;t use other systems such as fopen or file_get_contents since we don&#8217;t need to retrieve the page, and what we need is just the header.</p><p>Extra, check url correct formation:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> isURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$pattern</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/ujjfGfgKHVY" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/check-if-url-exists-and-is-online-php/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://neo22s.com/check-if-url-exists-and-is-online-php/</feedburner:origLink></item> <item><title>Delete SVN files in Linux</title><link>http://feedproxy.google.com/~r/Neo22s/~3/vcv_M7aYv1E/</link> <comments>http://neo22s.com/delete-svn-files-in-linux/#comments</comments> <pubDate>Fri, 23 Apr 2010 09:32:05 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Linux]]></category><guid isPermaLink="false">http://neo22s.com/?p=1137</guid> <description><![CDATA[I use SVN kind of a lot, and when I need to pack the files to distribute them is not nice to leave the SVN files..Here a really simple way of deleting those anoying files: find . -name '.svn' -type d &#124; xargs rm -rf This searches for all directories which have svn related files. [...]]]></description> <content:encoded><![CDATA[<p>I use SVN kind of a lot, and when I need to pack the files to distribute them is not nice to leave the SVN files..Here a really simple way of deleting those anoying files:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'.svn'</span> <span style="color: #660033;">-type</span> d <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span></pre></div></div><p>This searches for all directories which have svn related files. This is a useful command, but might not work as expected if there are hundreds of thousands files on the server. In this case the following command may be useful:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> .svn <span style="color: #660033;">-prune</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div><p>Source <a href="http://www.devarticles.in/miscelleneous/delete-svn-files-in-linux-or-windows/">devarticles.in</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/vcv_M7aYv1E" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/delete-svn-files-in-linux/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/delete-svn-files-in-linux/</feedburner:origLink></item> <item><title>Optimize your DB from PHP</title><link>http://feedproxy.google.com/~r/Neo22s/~3/7fR9OqNr7iU/</link> <comments>http://neo22s.com/optimize-your-db-from-php/#comments</comments> <pubDate>Wed, 21 Apr 2010 22:21:01 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1129</guid> <description><![CDATA[This is a functionality I&#8217;ve been using in Open Classifieds since the 1.6.1. version. It currently works for MySam working as follows: If the table has deleted or split rows, repair the table. If the index pages are not sorted, sort them. If the table&#8217;s statistics are not up to date, update them. And for InnoDB, [...]]]></description> <content:encoded><![CDATA[<p>This is a functionality I&#8217;ve been using in Open Classifieds since the 1.6.1. version.</p><p>It currently works for MySam working as follows:</p><ul><li>If the table has deleted or split rows, repair the table.</li><li>If the index pages are not sorted, sort them.</li><li>If the table&#8217;s statistics are not up to date, update them.</li></ul><p>And for InnoDB, rebuilds the table to update index statistics and free unused space.</p><p>And if we want to do this in PHP for all the tables in your DB simply do this:</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$result</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SHOW TABLE STATUS FROM '</span><span style="color: #339933;">.</span> DB_NAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tables</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  
    <span style="color: #000088;">$tables</span><span style="color: #339933;">=</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$tables</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'OPTIMIZE TABLE '</span><span style="color: #339933;">.</span><span style="color: #000088;">$tables</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h3&gt;Optimized all the tables found in the database: <span style="color: #006699; font-weight: bold;">$tables</span>&lt;/h3&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div><p>That&#8217;s all! simple yet effective ;)</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/7fR9OqNr7iU" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/optimize-your-db-from-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/optimize-your-db-from-php/</feedburner:origLink></item> <item><title>Speed up your WordPress II</title><link>http://feedproxy.google.com/~r/Neo22s/~3/E_sLCmXSdqs/</link> <comments>http://neo22s.com/speed-up-your-wordpress-ii/#comments</comments> <pubDate>Mon, 19 Apr 2010 08:32:27 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://neo22s.com/?p=1124</guid> <description><![CDATA[In the first part we explained some tricks to make your WordPress faster, but sometimes this is not even enough&#8230;.we need more speed! Before I explain more tricks I will like to make a note; I don&#8217;t recommend you to change anything from the core of WP. We could make WP much faster by just [...]]]></description> <content:encoded><![CDATA[<p>In the <a href="http://neo22s.com/speed-up-your-wordpress/">first part</a> we explained some tricks to make your WordPress faster, but sometimes this is not even enough&#8230;.we need more speed!</p><p>Before I explain more tricks I will like to make a note; <strong>I don&#8217;t recommend you to change anything from the core of WP</strong>. We could make WP much faster by just <a href="http://talks.php.net/show/cp10/7">tweaking a bit the core</a>&#8230;but I don&#8217;t recommend to you if later you need to upgrade you WP you will lose all that changes!</p><p>Then I&#8217;m going to focus in tweaking the Theme and usage of some plugins.</p><ul><li>Use less plugins, and remove the tables they are created and no longer are needed</li><li>Get rid off the widget bar and make it static! This will reduce lot of calls to the DB.</li><li>Try to make it everything as static as possible ;)</li><li>Use a CDN, less stress for your server, since will receive less requests. You can use Coral CDN (a bit slow) or Amazon for example.</li><li>Try to use only one CSS and one JS, with <a href="http://wordpress.org/extend/plugins/w3-total-cache/">w3 total cache </a>this is kind of easy to do.</li><li>Be careful with missing files, if the file doesn&#8217;t exist a 404 page returns and needs to be executed :S you can check this here tools.pingdom.com (great tool)</li><li>Erase the comments and use Disqus (export them first, <a href="http://wordpress.org/extend/plugins/disqus-comment-system/">you can use the plugin</a>), this is extremely tweaking, but can be a last solution, I&#8217;m not at this point yet but&#8230;.maybe.</li><li><a href="http://wordpress.org/extend/plugins/w3-total-cache/"> W3 Total Cache</a> is probably the best cache plugin now a days, give it a try!</li></ul><p>And I think that&#8217;s all&#8230;.</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/E_sLCmXSdqs" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/speed-up-your-wordpress-ii/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/speed-up-your-wordpress-ii/</feedburner:origLink></item> <item><title>Cache up to 30 times faster</title><link>http://feedproxy.google.com/~r/Neo22s/~3/jz1FIh3zseo/</link> <comments>http://neo22s.com/cache-up-to-30-times-faster/#comments</comments> <pubDate>Sat, 17 Apr 2010 10:22:22 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://neo22s.com/?p=1122</guid> <description><![CDATA[Is not bullshit I swear! Absolutely possible, but you need to be using a VPS or a dedicated server to do this. This is really handy if you are not using a cache system such as APC or xcache, and you store your cached files in folders. For this we will use TMPFS Tmpfs is [...]]]></description> <content:encoded><![CDATA[<p>Is not bullshit I swear! Absolutely possible, but you need to be using a VPS or a dedicated server to do this.</p><p>This is really handy if you are not using a cache system such as APC or xcache, and you store your cached files in folders.</p><p><strong>For this we will use TMPFS</strong></p><blockquote><p> Tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it’s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I’ve had the opportunity to meet.</p></blockquote><p><strong>Example to use it in your WordPress:<br /> </strong> (check the right paths)</p><p>Edit /etc/fstab/ and we add the file system</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tmpfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>neo22s<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>cache tmpfs defaults,<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">size</span></span>=2g,noexec,nosuid,<span style="color: #007800;">uid</span>=<span style="color: #000000;">648</span>,<span style="color: #007800;">gid</span>=<span style="color: #000000;">648</span>,<span style="color: #007800;">mode</span>=<span style="color: #000000;">1755</span> <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></div></div><p>Add a new line at /etc/rc.local in order to execute it on system start up:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ionice <span style="color: #660033;">-c3</span> <span style="color: #660033;">-n7</span> <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">19</span> rsync <span style="color: #660033;">-ahv</span> <span style="color: #660033;">--stats</span> <span style="color: #660033;">--delete</span> <span style="color: #000000; font-weight: bold;">/</span>_b<span style="color: #000000; font-weight: bold;">/</span>tmpfs<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>neo22s<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div><p>New crontab job (using crontab-e), to execute</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ionice <span style="color: #660033;">-c3</span> <span style="color: #660033;">-n7</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">19</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rsync <span style="color: #660033;">-ah</span> <span style="color: #660033;">--stats</span> <span style="color: #660033;">--delete</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>neo22s<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>_b<span style="color: #000000; font-weight: bold;">/</span>tmpfs<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div><p><strong>Done!<br /> </strong><br /> Currently I&#8217;m not using this method since I have xcache that make my life easier working with w3 total cache plugin, great solution.</p><p>Of course you can use TMPFS for many other things, check <a href="http://www.askapache.com/web-hosting/super-speed-secrets.html">askapache</a>, where you can find loads of info and examples a great work.</p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/jz1FIh3zseo" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/cache-up-to-30-times-faster/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://neo22s.com/cache-up-to-30-times-faster/</feedburner:origLink></item> <item><title>Happy Birthday Open Classifieds ;)</title><link>http://feedproxy.google.com/~r/Neo22s/~3/rK8oqcs4-4I/</link> <comments>http://neo22s.com/happy-birthday-open-classifieds/#comments</comments> <pubDate>Thu, 15 Apr 2010 16:26:44 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[News]]></category> <category><![CDATA[Open Classifieds]]></category><guid isPermaLink="false">http://neo22s.com/?p=1119</guid> <description><![CDATA[Today is the 1st year birthday of Open Classifieds. Actually the idea it’s older but the first release (0.8) it’s just 1 year old. Since then there’s been more than 16.000 downloads and as far as I know few thousands of sites currently using it ;) I want also to use this post to ask [...]]]></description> <content:encoded><![CDATA[<p><strong>Today is the 1st year birthday of Open Classifieds.<br /> </strong><br /> Actually the idea it’s older but the first release (0.8) it’s just 1 year old.</p><p>Since then there’s been more than<strong> 16.000 downloads </strong>and as far as I know few thousands of sites currently using it ;)</p><p><strong>I want also to use this post to ask for help.<br /> </strong></p><p>The growth of downloads and forum posts it’s been increasing considerable. This brings lot of work…</p><p>I need help to continue developing and to maintain this soft.</p><p>Currently the 2.0 version is not even started due to the lack of help.</p><p>Also here there’s a list of things you help with!</p><ul><li>Development</li><li>Design</li><li>Documentation (the FAQs are really old v1.5.4)</li><li>Translate the site to any other language</li><li>Donations to pay hosting!</li><li>And any other kind of help it’s welcome.</li></ul><p><strong>UPDATE:</strong></p><p>Chi, an Australian friend of mine, did this awesome new design for OC, but needs to be coded to HTML+CSS, after that I can make it work in OC ;)</p><p><a rel="lightbox[945]" href="http://openclassifieds.s3.amazonaws.com/wp-content/uploads/2010/04/OC_V1_Website.jpg"><img title="OC_V1_Website" src="http://openclassifieds.s3.amazonaws.com/wp-content/uploads/2010/04/OC_V1_Website-293x300.jpg" alt="" width="293" height="300" /></a></p><p>BTW I’m at the Campus Party Europe, having lot of fun ;)</p><p><a href="http://open-classifieds.com/2010/04/15/happy-birthday-open-classifieds/">source open classifieds blog</a></p> <img src="http://feeds.feedburner.com/~r/Neo22s/~4/rK8oqcs4-4I" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/happy-birthday-open-classifieds/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/happy-birthday-open-classifieds/</feedburner:origLink></item> <item><title>Extract images from HTML</title><link>http://feedproxy.google.com/~r/Neo22s/~3/mpB_x-eqB3M/</link> <comments>http://neo22s.com/extract-image-from-html/#comments</comments> <pubDate>Mon, 12 Apr 2010 14:24:05 +0000</pubDate> <dc:creator>Chema</dc:creator> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://neo22s.com/?p=1117</guid> <description><![CDATA[Small script to extract the images from a text or HTML. $html=file_get_contents&#40;&#34;http://neo22s.com&#34;&#41;; $imgsrc_regex = '!http://.+\.(?:jpe?g&#124;gif&#124;png)!Ui'; preg_match&#40;$imgsrc_regex, $html, $matches&#41;; print_r &#40;$matches&#41;;]]></description> <content:encoded><![CDATA[<p>Small script to extract the images from a text or HTML.</p><div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span><span style="color: #339933;">=</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://neo22s.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgsrc_regex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'!http://.+\.(?:jpe?g|gif|png)!Ui'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgsrc_regex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><img src="http://feeds.feedburner.com/~r/Neo22s/~4/mpB_x-eqB3M" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://neo22s.com/extract-image-from-html/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://neo22s.com/extract-image-from-html/</feedburner:origLink></item> </channel> </rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using xcache
Page Caching using xcache
Database Caching 10/15 queries in 0.020 seconds using xcache

Served from: neo22s.com @ 2010-09-07 23:30:42 -->
