<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>technology articles - life articles - health articles - love articles &#187; Php</title>
	<atom:link href="http://www.oneclickme.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oneclickme.com</link>
	<description>Knowledge Magazine - Technology - Life - Health - Love</description>
	<lastBuildDate>Mon, 30 Jan 2012 03:35:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Get List Site of Search Results Google with PHP</title>
		<link>http://www.oneclickme.com/get-list-site-of-search-results-google-with-php/</link>
		<comments>http://www.oneclickme.com/get-list-site-of-search-results-google-with-php/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 16:34:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[php search google]]></category>
		<category><![CDATA[search google]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=734</guid>
		<description><![CDATA[Want to get all the top google  search results in an array with PHP? Just read on and do it yourself! This script basically outputs the url’s of all the top results of a google search, but it can be modified to output other details also. We will be using the google ajax api in this script. As you might have found, by default it gives out only 4 results. Or you may manage to [...]]]></description>
			<content:encoded><![CDATA[<p>Want to <strong>get all the top google  search results</strong> in an array<strong> with PHP</strong>? Just read on and do it yourself!</p>
<p>This script basically <strong>outputs the url’s</strong> of all the top results of a <strong>google search</strong>, but it can be modified to output <strong>other details also</strong>.<br />
We will be using the <strong>google ajax api</strong> in this script. As you might have found, by default it gives out<strong> only 4 results</strong>. Or you may manage to <strong>get 8 </strong>with one more parameter. But here, with some tweaks, you will<strong> get the top 64 results</strong>! (And 64 is the upper limit, because google doesn’t like bots.)</p>
<p>&nbsp;</p>
<div>
<div id="highlighter_398640">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div>
<div>19</div>
<div>20</div>
<div>21</div>
<div>22</div>
<div>23</div>
<div>24</div>
<div>25</div>
<div>26</div>
<div>27</div>
<div>28</div>
<div>29</div>
<div>30</div>
<div>31</div>
<div>32</div>
<div>33</div>
<div>34</div>
<div>35</div>
<div>36</div>
<div>37</div>
</td>
<td>
<div>
<div><code>&lt;?php</code></div>
<div><code>function</code> <code>google_search_api(</code><code>$args</code><code>, </code><code>$referer</code> <code>= </code><code>'<a href="http://localhost/testing/">http://localhost/testing/</a>'</code><code>, </code><code>$endpoint</code> <code>= </code><code>'web'</code><code>)</code></div>
<div><code>{</code></div>
<div><code>$url</code> <code>= </code><code>"<a href="http://ajax.googleapis.com/ajax/services/search/">http://ajax.googleapis.com/ajax/services/search/</a>"</code><code>.</code><code>$endpoint</code><code>;</code></div>
<div></div>
<div><code>if</code> <code>( !</code><code>array_key_exists</code><code>(</code><code>'v'</code><code>, </code><code>$args</code><code>) )</code></div>
<div><code>$args</code><code>[</code><code>'v'</code><code>] = </code><code>'1.0'</code><code>;</code></div>
<div><code>//$args['key']="ABQIAAAArMTuM-CBxyWL0PYBLc7SuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT-uD75NXlWUsDRBw-8aVAlQ29oCg";</code></div>
<div><code>//$args['userip']=$_SERVER['REMOTE_ADDR'];</code></div>
<div><code>$args</code><code>[</code><code>'rsz'</code><code>]=</code><code>'8'</code><code>;</code></div>
<div><code>$url</code> <code>.= </code><code>'?'</code><code>.http_build_query(</code><code>$args</code><code>, </code><code>''</code><code>, </code><code>'&amp;'</code><code>);</code></div>
<div><code>$ch</code> <code>= curl_init();</code></div>
<div><code>curl_setopt(</code><code>$ch</code><code>, CURLOPT_URL, </code><code>$url</code><code>);</code></div>
<div><code>curl_setopt(</code><code>$ch</code><code>, CURLOPT_RETURNTRANSFER, 1);</code></div>
<div><code>// note that the referer *must* be set</code></div>
<div><code>curl_setopt(</code><code>$ch</code><code>, CURLOPT_REFERER, </code><code>$referer</code><code>);</code></div>
<div><code>$body</code> <code>= curl_exec(</code><code>$ch</code><code>);</code></div>
<div><code>curl_close(</code><code>$ch</code><code>);</code></div>
<div><code>//decode and return the response</code></div>
<div><code>return</code> <code>json_decode(</code><code>$body</code><code>,true);</code></div>
<div><code>}</code></div>
<div><code>$query</code><code>=urldecode(isset(</code><code>$_GET</code><code>[</code><code>'q'</code><code>])?</code><code>$_GET</code><code>[</code><code>'q'</code><code>]:</code><code>"none"</code><code>);</code></div>
<div><code>echo</code> <code>"Results for: $query&lt;br /&gt;-----&lt;br /&gt;"</code><code>;</code></div>
<div><code>$res</code> <code>= google_search_api(</code><code>array</code><code>(</code><code>'q'</code> <code>=&gt; </code><code>$query</code><code>));</code></div>
<div><code>$pages</code><code>=</code><code>$res</code><code>[</code><code>'responseData'</code><code>][</code><code>'cursor'</code><code>][</code><code>'pages'</code><code>];</code></div>
<div><code>$nres</code><code>=0;</code></div>
<div><code>for</code><code>(</code><code>$i</code><code>=0;</code><code>$i</code><code>&lt;</code><code>count</code><code>(</code><code>$pages</code><code>);</code><code>$i</code><code>++)</code></div>
<div><code>{</code></div>
<div><code>$res</code> <code>= google_search_api(</code><code>array</code><code>(</code><code>'q'</code> <code>=&gt; </code><code>$query</code><code>,</code><code>'start'</code><code>=&gt;</code><code>$rez</code><code>[</code><code>'responseData'</code><code>][</code><code>'cursor'</code><code>][</code><code>'pages'</code><code>][</code><code>$i</code><code>][</code><code>'start'</code><code>]));</code></div>
<div><code>for</code><code>(</code><code>$j</code><code>=0;</code><code>$j</code><code>&lt;</code><code>count</code><code>(</code><code>$res</code><code>[</code><code>'responseData'</code><code>][</code><code>'results'</code><code>]); </code><code>$j</code><code>++)</code></div>
<div><code>{</code></div>
<div><code>$nres</code><code>++;</code></div>
<div><code>echo</code> <code>urldecode(</code><code>$res</code><code>[</code><code>'responseData'</code><code>][</code><code>'results'</code><code>][</code><code>$j</code><code>][</code><code>'url'</code><code>]).</code><code>"&lt;br /&gt;"</code><code>;</code></div>
<div><code>}</code></div>
<div><code>}</code></div>
<div><code>echo</code> <code>"&lt;br /&gt;---&lt;br /&gt;Total number of reuslts: $nres"</code><code>;</code></div>
<div><code>?&gt;</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Here is what we have done in this <strong>script</strong>:</p>
<ul>
<li>First, we have <strong>a function</strong> that requests <strong>search results from google</strong>.</li>
<li>google_search_api($args, $referer = ‘http://localhost/testing/’, $endpoint = ‘web’)<br />
We have used the usual <strong>code provided by google</strong> to<strong> fetch the search results with php</strong>.</li>
<li>But have done a tweak to<strong> get 8 results</strong> at a time, <strong>instead of 4</strong>. the tweak is:<br />
$args['rsz']=’8′;<br />
This code tells google to return 8(the maximum for one query) results instead of the default 4.</li>
<li>The next step is to get <strong>all the 64 results</strong> for a single search. We go around with it by querying again and again and specifying the “start” parameter in the search request url.<br />
$res = google_search_api(array(‘q’ =&gt; $query,<strong>‘start’=&gt;$rez['responseData']['cursor']['pages'][$i]['start']</strong>));</li>
<li>But before we request paged results, we need to setup a loop.<br />
$res = google_search_api(array(‘q’ =&gt; $query));<br />
<strong> $pages=$res['responseData']['cursor']['pages'];</strong><br />
$nres=0;<br />
<strong> for($i=0;$i&lt;count($pages);$i++)</strong><br />
{  … }<br />
We do a request from google to get the values of start parameter. We get the whole pagination information in the array, <strong>$pages</strong></li>
<li>The rest is just displaying the url’s of all the search results and the number of results returned.</li>
<li>you can display description, title, cached url,etc from the<br />
<strong> $res['responseData']['results']</strong><br />
array. For the structure of the results array, use <strong></strong><br />
<strong>print_r($res['responseData']['results']);</strong></li>
</ul>
<p>Hope you find this code helpful. Please feel free to comment and ask any doubt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/get-list-site-of-search-results-google-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get URI of feedburner</title>
		<link>http://www.oneclickme.com/how-to-get-uri-of-feedburner/</link>
		<comments>http://www.oneclickme.com/how-to-get-uri-of-feedburner/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:38:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Search Engine Optimization]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=630</guid>
		<description><![CDATA[Feedburner is one of the biggest RSS Feeds provider to reach your readers be able to read or subscribe your latest news/articles automatically. Go to Feedburner.com and login Click “My Feeds” in the upper-left-hand corner Select your feed from the list Click the “Publicize” tab Click “Email Subscriptions” on the left Make sure “Feedburner” is selected, and click “Activate” In &#8220;Subscription Management&#8221; you will see some code as: onsubmit=&#8221;window.open(&#8216;http://feedburner.google.com/fb/a/mailverify?uri=wordpressyeah/wordpresstheme&#8217;, &#8216;popupwindow&#8217;, &#8220;wordpressyeah/wordpresstheme&#8221; is your uri.]]></description>
			<content:encoded><![CDATA[<p>Feedburner is one of the biggest RSS  Feeds provider to reach your readers be able to read or subscribe your  latest news/articles automatically.</p>
<ol>
<li>Go to Feedburner.com and login</li>
<li>Click “My Feeds” in the upper-left-hand corner</li>
<li>Select your feed from the list</li>
<li>Click the “Publicize” tab</li>
<li>Click “Email Subscriptions” on the left</li>
<li>Make sure “Feedburner” is selected, and click “Activate”</li>
</ol>
<p>In <strong>&#8220;Subscription Management&#8221; </strong>you will see some code as:</p>
<blockquote><p>onsubmit=&#8221;window.open(&#8216;http://feedburner.google.com/fb/a/mailverify?uri=wordpressyeah/wordpresstheme&#8217;, &#8216;popupwindow&#8217;,</p></blockquote>
<p>&#8220;<strong><span style="color: #ff0000;">wordpressyeah/wordpresstheme</span></strong>&#8221; is your uri.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/how-to-get-uri-of-feedburner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run php scripts using cronjob in linux – centos</title>
		<link>http://www.oneclickme.com/how-to-run-php-scripts-using-cronjob-in-linux-centos/</link>
		<comments>http://www.oneclickme.com/how-to-run-php-scripts-using-cronjob-in-linux-centos/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 04:10:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[cronjob]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=618</guid>
		<description><![CDATA[First make sure you have crontab installed. Make sure php is working properly. Now the script you want to execute make sure it has an execute chmod attribute on it. If not add like this chmod +x scriptname.php On the very first line of your php script add the following line line #!/usr/bin/php then edit your root crontab file using $ crontab -e and press ‘i’ to edit and add the following cronjob commands # [...]]]></description>
			<content:encoded><![CDATA[<p>First make sure you have crontab installed.<br />
Make sure php is working properly.</p>
<p>Now the script you want to execute make sure it has an execute chmod attribute on it. If not add like this</p>
<p><code>chmod +x scriptname.php</code></p>
<p>On the very first line of your php script add the following line line</p>
<p><code>#!/usr/bin/php</code></p>
<p>then edit your root crontab file using</p>
<p>$<code> crontab -e</code></p>
<p>and press ‘i’ to edit and add the following cronjob commands</p>
<p># run everday at 10:45<br />
45 10 * * *     /path/to/myphpscript.php<br />
#run every 5 minutes<br />
*/5 * * * *     /path/to/myphpscript.php</p>
<p>then press escape and enter :wq to save and quite simple</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/how-to-run-php-scripts-using-cronjob-in-linux-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix Timeout Issues in CURL, PHP, and Apache</title>
		<link>http://www.oneclickme.com/fix-timeout-issues-in-curl-php-and-apache/</link>
		<comments>http://www.oneclickme.com/fix-timeout-issues-in-curl-php-and-apache/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 04:32:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=613</guid>
		<description><![CDATA[Hitting strange errors when trying to execute long-running PHP processes, like large file reads, generating static HTML pages, file uploads, or CURL calls? It might not be just bugs in your code. Are you getting pages that seem to load, but then nothing shows up in the browser? When you go to a page, does your browser sometimes ask, “You have chosen to open something.php which is a : PHP file. What should Firefox do [...]]]></description>
			<content:encoded><![CDATA[<p>Hitting strange errors when trying to  execute long-running PHP processes, like large file reads, generating  static HTML pages, file uploads, or CURL calls?  It might not be just  bugs in your code.</p>
<p>Are you getting pages that seem to load,  but then nothing shows up in the browser?  When you go to a page, does  your browser sometimes ask, “You have chosen to open something.php which  is a : PHP file. What should Firefox do with this file” or possibly  “File name: something.php File type: PHP File Would you like to open the  file or save it to your computer”  Do you get internal server errors at  random intervals?</p>
<p>Depending on what you are trying to, you  could be running into timeout issues, either in PHP, in a particular  library, in Apache (or IIS or whatever web server you use), or even in  the browser.  Timeout issues can be a real pain because you don’t run  into them very often and they don’t result in clear error messages.</p>
<p>&nbsp;</p>
<p>Let’s take a PHP script that does a number of CURL calls as an example.  <a href="http://us3.php.net/manual/en/ref.curl.php" target="_blank">PHP gives you access to libcurl</a> a really powerful tool for calling up other web pages, web services, RSS feeds, <a href="http://blog.taragana.com/index.php/archive/how-to-use-curl-in-php-for-authentication-and-ssl-communication/" target="_blank">and whatever else you can dream up</a>,  right in your PHP code.  This article is not a general introduction to  CURL, so I won’t go into detail, but basically the CURL functions allow  your code to make requests and get responses from web sites just like a  browser.  You can then parse the results use the data on your site.</p>
<p>Let’s say you have a page on your site  where you would like to display the latest posts from a few of your  friends’ websites, and they don’t have RSS feeds set up.  When a user  comes to your site, you can make a series of CURL calls to get the data:</p>
<blockquote><p>$curl_session = curl_init();<br />
curl_setopt($curl_session, CURLOPT_HEADER, false);<br />
curl_setopt($curl_session, CURLOPT_FOLLOWLOCATION, true);<br />
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);<br />
curl_setopt ($curl_session, CURLOPT_HTTPGET, true);<br />
curl_setopt($curl_session, CURLOPT_URL, ‘http://www.example.com’);<br />
$string = curl_exec($curl_session);</p></blockquote>
<p>&nbsp;</p>
<p>You can now parse the results in $string  and hack out the most recent post.  You would repeat these calls for  each of your friends’ web sites.</p>
<p>You try running the page and everything  seems to work at first, but then you hit reload and get some strange  behavior, like the the problems listed above.  In the worst cases, you  won’t get the same exact error each time – sometimes the page will load,  some times you’ll get an empty $string or errors from curl, sometimes a  blank page will appear, and some times you will be asked to download  the PHP file – which includes all your source code!</p>
<p>In this situation you could be timing out.   CURL is going out to another web server and your code will have to  wait for it to finish before moving on to something else.  In addition,  your web server may be waiting on PHP to finish it’s work before sending  something to the browser.</p>
<p>Luckily, there are a few ways to control  how long the CURL functions, PHP, and Apache wait and you can do a  little bit to ensure that the user’s browser doesn’t just give up  either.</p>
<p>CURL has two options worth looking at,  CURLOPT_TIMEOUT and  CURLOPT_CONNECTTIMEOUT.  The former sets how long  CURL will run before it gives up and the latter sets how long CURL will  wait to even connect to the site you want to pull data from.  If you  wanted to wait at most 4 seconds to connect and 8 seconds total, you  would set it like this:</p>
<blockquote><p>curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 4);<br />
curl_setopt($curl_session, CURLOPT_TIMEOUT, 8);</p></blockquote>
<p>This can be very helpful if you are  connecting to a large number of different web sites or connecting to  sites that not always available or are on slow hosts.  You may wish to  set the timeouts much higher, if you really need to get that data, or  fairly low, if you have a lot of CURL calls and don’t want PHP to time  out.  You can get an idea how long things are taking by using  curl_getinfo():</p>
<blockquote><p>echo ‘</p>
<pre>';
print_r(curl_getinfo($curl_session));
echo '</pre>
<p>‘;</p></blockquote>
<p>PHP may also time out if it is running for  too long.  Luckily, you can control this to some extent by changing a  setting in your php.ini or using the set_time_limit() function.  If you  can make changes to php.ini, it might be worth adding or adjusting the  following lines:</p>
<blockquote><p>max_execution_time = 300     ; Maximum execution time of each script, in seconds<br />
max_input_time = 60	; Maximum amount of time each script may spend parsing request data<br />
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)</p></blockquote>
<p>If you don’t have access to php.ini, you  may be able to use set_time_limit() to change the max_execution time on  each page where it is needed.  If you are in a shared hosting  environment, don’t monkey with these values too much or you might impact  other users.  If you raise the time limit too high, you may get an  angry email from your admin.  Some hosts have programs set up to look  out for long-running processes and kill them – check with your admin if  you raise the time limit and the script still dies an early death.</p>
<p>Your web server (Apache is used for this  example) may also be running into timeout issues.  If you have access to  your httpd.conf, changing the timeout is pretty easy:</p>
<blockquote><p>Timeout 300</p></blockquote>
<p>Unfortunately, not everyone will be able  to edit their httpd.conf and this is not something you can add to an  .htaccess file to change for just the scripts in a particular directory.   Luckily we can work around this limitation, so long as we are sending  the webpage to the user in parts, rather than waiting for the entire PHP  script to execute and then sending the response.</p>
<p>How do we do it?  First, make sure mod_gzip is turned off in an .htaccess file:</p>
<blockquote><p>mod_gzip_on no<br />
mod_gzip_item_include mime ^text/.*<br />
mod_gzip_item_exclude mime ^image/.*$</p></blockquote>
<p>Mod_gzip is a great way to reduce  bandwidth use and increase site performance, but it waits until PHP has  completed executing before zipping and sending the web page to the user.</p>
<p>Second, take a look at your PHP code and make sure you are not output buffering the whole page, including output buffering to <a href="http://www.ilovejackdaniels.com/php/php-gzip-and-htaccess/" target="_blank">send gz-encoded (gzipped) output</a>.  Output buffering <a href="http://www.holmdesigns.com/wp/?p=61" target="_blank">can give you a lot of control</a>, but in this case it can cause problems.  You can Look for something like this:</p>
<blockquote><p>ob_start();<br />
// …<br />
//  a whole ton of time-consuming code here<br />
// …<br />
ob_flush();<br />
//or possibly ob_end_flush();</p></blockquote>
<p>Finally, if you have a number of  time-intensive sections in your code, you can force some data out to the  browser to keep Apache going and help make sure the browser doesn’t  lose interest either.  It might look something like this:</p>
<blockquote><p>echo “Loading Steve’s page …”;<br />
// …<br />
// a time-consuming CURL call<br />
// …<br />
//do a flush to keep browser interested…<br />
echo str_pad(”<br />
Loaded. “,8);<br />
sleep(1);<br />
flush();<br />
echo “Loading Jill’s page …”;<br />
// …<br />
// a time-consuming CURL call<br />
// …<br />
echo str_pad(”<br />
Loaded … “,8);<br />
sleep(1);<br />
flush();</p></blockquote>
<p>The <a href="http://us3.php.net/flush" target="_blank">flush() function</a> is the main trick – it tells PHP to send out what it has generated so  far.  The str_pad() and sleep() calls might not be necessary in this  case, but the general idea is that some browsers need a minimum of 8  bytes to start displaying and the delay from the sleep(1) call seems to  make IE happy.</p>
<p>This technique is not just useful in  getting around timeout problems, it can also be used on long pages to  give the user something to start looking at while the rest of the data  loads.  Also, some browsers might not handle content serves as XML  incrementally â€“ in that case you might want to serve it as text/html:</p>
<blockquote><p>header(”Content-Type: text/html”);</p></blockquote>
<p>Hopefully this will help you track down  those nasty timeout-related bugs.  Have questions or some other tips?   Post in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/fix-timeout-issues-in-curl-php-and-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Memcached for PHP on 8.04 and newer</title>
		<link>http://www.oneclickme.com/installing-memcached-for-php-on-8-04-and-newer/</link>
		<comments>http://www.oneclickme.com/installing-memcached-for-php-on-8-04-and-newer/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 08:55:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=611</guid>
		<description><![CDATA[Just as a note and to update everyone who still links to this article through Google. It is now much easier to install Memcached and getting it ready for action. It involves a few very simple steps. To install in terminal type: Code: sudo apt-get install memcached sudo apt-get install php5-memcache sudo /etc/init.d/apache2 restart Now memcached is installed, the next step is to run an instance of it and test it. Lets create an instance [...]]]></description>
			<content:encoded><![CDATA[<div>
<div id="post_message_60224">
<blockquote><p><strong></p>
<p></strong>Just as a note and to update everyone who still links to this  article through Google. It is now much easier to install Memcached and  getting it ready for action.</p>
<p>It involves a few very simple steps. To install in terminal type:</p>
<div>
<div>Code:</div>
<pre>sudo apt-get install memcached
sudo apt-get install php5-memcache
sudo /etc/init.d/apache2 restart</pre>
</div>
<p>Now memcached is installed, the next step is to run an instance  of it and test it. Lets create an instance as root, I will show you how  to start this up automatically when system reboots later;</p>
<div>
<div>Code:</div>
<pre><span style="color: #666666;"><em>
# replace 24 with however many megabytes of cache is appropriate</em></span>
memcached <span style="color: #660033;">-u</span> root <span style="color: #660033;">-d</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">24</span> <span style="color: #660033;">-l</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">11211
</span></pre>
</div>
<p>Lets Telnet into the instance and test it;</p>
<div>
<div>Code:</div>
<pre>telnet 127.0.0.1 11211</pre>
</div>
<p>Now we can do a few tests on it to see if it writes and reads;</p>
<div>
<div>Code:</div>
<pre>set test2 1 0 2
ab
STORED
set test3 1 0 3
abc
STORED
get test2
VALUE test2 1 2
ab
END
get test3
VALUE test3 1 3
abc
END
set test4 1 0 2
abcde
CLIENT_ERROR bad data chunk
ERROR</pre>
</div>
<p>Cool, if above is working your application will be fine when it tries to use memcached. To refine your configuration look at;</p>
<div>
<div>Code:</div>
<pre>/etc/memcached.conf
# Remember to restart memcache after server change with:
/etc/init.d/memcached restart</pre>
</div>
<p>Now finally you might want to use multiple instances of memcache  servers depending on how many sites you are running on the same server.  So lets add the startup instances to the following file (not directory).  Simply edit the file and add something similar to this. The only  differences are the port numbers which represents different memcache  instances; Now open <strong>/etc/rc.local </strong>and do something add your instances:</p>
<div>
<div>Code:</div>
<pre>#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
memcached -u www-data -d -m 16 -l 127.0.0.1 -p 11211
memcached -u www-data -d -m 16 -l 127.0.0.1 -p 11212
memcached -u www-data -d -m 16 -l 127.0.0.1 -p 11213
memcached -u www-data -d -m 16 -l 127.0.0.1 -p 11214

exit 0</pre>
</div>
<p>Now even if the server reboots, your instances will run.</p>
<p>Here are some other neat tips, to check if your instances run execute:</p>
<div>
<div>Code:</div>
<pre>ps -A | grep memcached</pre>
</div>
<p>If you ever need to stop your memcached daemons, use the killall command:</p>
<div>
<div>Code:</div>
<pre>killall memcached</pre>
</div>
<p><strong><br />
Installing Memcached for PHP on Ubuntu Feisty Fawn or older.</strong></p>
<p><strong>Memcached</strong></p>
<p>Problems start when you are dealing with more than one webserver.  Since there is no shared cache between the servers situations can occur  where data is updated on one server and it takes a while before the  other server is up to date.. It can be really useful to have a really  high TTL on your data and simply replace or delete the cache whenever  there is an actual update. When you are dealing with multiple webservers  this scheme is simply not possible with the previous caching methods.<br />
Introducing <a href="http://www.danga.com/memcached/" target="_blank">memcached</a>. Memcached is a cache server originally developed by the LiveJournal people and now being used by sites like <a href="http://digg.com/" target="_blank">Digg</a>, <a href="http://www.facebook.com/" target="_blank">Facebook</a>, <a href="http://slashdot.org/" target="_blank">Slashdot</a> and <a href="http://www.wikipedia.org/" target="_blank">Wikipedia</a>.<br />
<strong>How it works</strong></p>
<ul>
<li>Memcached consists of a server and a client  part.. The server is a standalone program that runs on your servers and  the client is in this case a PHP extension.</li>
<li>If you have 3 webservers which all run Memcached, all webservers  connect to all 3 memcached servers. The 3 memcache servers are all in  the same &#8216;pool&#8217;.</li>
<li>The cache servers all only contain part of the cache. Meaning, the cache is not replicated between the memcached servers.</li>
<li>To find the server where the cache is stored (or should be stored) a  so-called hashing algorithm is used. This way the &#8216;right&#8217; server is  always picked.</li>
<li>Every memcached server has a memory limit. It will never consume  more memory than the limit. If the limit is exceeded, older cache is  automatically thrown out (if the TTL is exceed or not).</li>
<li>This means it cannot be used as a place to simply store data.. The  database does that part. Don&#8217;t confuse the purpose of the two!</li>
<li>Memcached runs the fastest (like many other applications) on a Linux 2.6 kernel.</li>
<li>By default, memcached is completely open.. Be sure to have a  firewall in place to lock out outside ip&#8217;s, because this can be a huge  security risk.</li>
</ul>
<div>
<div>Code:</div>
<pre>sudo apt-get install make

sudo apt-get install php5-dev

sudo apt-get install php-pear

sudo apt-get install zlib1g-dev

sudo apt-get install memcached

sudo pecl install Memcache</pre>
</div>
<p><span style="color: red;">Don&#8217;t forget to enable the extension in  /etc/php5/apache2/php.ini by adding the line extension=memcache.so and  restarting the webserver.</span></p>
<p>This documentation was extended from :<br />
<a href="http://www.rooftopsolutions.nl/article/107" target="_blank">http://www.rooftopsolutions.nl/article/107</a></p></blockquote>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/installing-memcached-for-php-on-8-04-and-newer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quy tắc viết htaccess trong PHP</title>
		<link>http://www.oneclickme.com/quy-t%e1%ba%afc-vi%e1%ba%bft-htaccess-trong-php/</link>
		<comments>http://www.oneclickme.com/quy-t%e1%ba%afc-vi%e1%ba%bft-htaccess-trong-php/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 15:14:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Others]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=607</guid>
		<description><![CDATA[Hướng dẫn &#8211; .htaccess rewrite tips using RewriteRule and RewriteCond for .htaccess mod_rewrite Be aware that mod_rewrite (RewriteRule, RewriteBase, and RewriteCond) code is executed for each and every HTTP request that accesses a file in or below the directory where the code resides, so it’s always good to limit the code to certain circumstances if readily identifiable. For example, to limit the next 5 RewriteRules to only be applied to .html and .php files, you [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff0000; font-family: Arial;">Hướng dẫn &#8211; .htaccess rewrite tips using RewriteRule and RewriteCond for .htaccess mod_rewrite</span></strong></p>
<p>Be aware that mod_rewrite (<em>RewriteRule, RewriteBase, and RewriteCond</em>)  code is executed for each and every HTTP request that accesses a file  in or below the directory where the code resides, so it’s always good to  limit the code to certain circumstances if readily identifiable.<br />
<strong>For example</strong>, to limit the next 5 RewriteRules to only be applied  to .html and .php files, you can use the following code, which tests if  the url does not end in .html or .php and if it doesn’t, it will skip  the next 5 RewriteRules.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule !\.(html|php)$ - [S=5]
RewriteRule ^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]</pre>
</div>
<p><strong>.htaccess rewrite examples should begin with:</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks

RewriteEngine On
RewriteBase /</pre>
</div>
<p><strong>Require the www</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]</pre>
</div>
<p><strong>Loop Stopping Code</strong></p>
<p>Sometimes your rewrites cause infinite loops, stop it with one of these rewrite code snippets.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule .* - [L]

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]</pre>
</div>
<p><strong>Cache-Friendly File Names</strong></p>
<p>This is probably my favorite, and I use it on every site I work on. It  allows me to update my javascript and css files in my visitors cache’s  simply by naming them differently in the html, on the <a id="gal_10_26893_1" href="http://sinhvienit.net/@forum/autolink.php?id=10&amp;forumid=351&amp;script=showthread" target="_blank">server</a> they stay the same <a id="gal_11_26893_2" href="http://sinhvienit.net/@forum/autolink.php?id=11&amp;forumid=351&amp;script=showthread" target="_blank">name</a>.  This rewrites all files for /zap/j/anything-anynumber.js to  /zap/j/anything.js and /zap/c/anything-anynumber.css to  /zap/c/anything.css</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]</pre>
</div>
<p><strong>SEO friendly link for non-flash browsers</strong></p>
<p>When you use flash on your site and you properly supply a link to  download flash that shows up for non-flash aware browsers, it is nice to  use a shortcut to keep your code clean and your external links to a  minimum. This code allows me to link to site.com/getflash/ for non-flash  aware browsers.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule ^getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash [NC,L,R=307]</pre>
</div>
<p><strong>Removing the Query_String</strong></p>
<p>On many sites, the page will be displayed for both page.html and  page.html?anything=anything, which hurts your SEO with duplicate  content. An easy way to fix this issue is to redirect external requests  containing a query string to the same uri without the query_string.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://www.askapache.com%{REQUEST_URI}? [R=301,L]</pre>
</div>
<p><strong>Sending requests to a php script</strong></p>
<p>This .htaccess rewrite example invisibly rewrites requests for all Adobe pdf files to be handled by /cgi-bin/pdf-script.php</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]</pre>
</div>
<p><strong>Setting the language variable based on Client</strong></p>
<p>For sites using multiviews or with multiple language capabilities, it  is nice to be able to send the correct language automatically based on  the clients preferred language.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]
RewriteRule ^(.*)$ - [env=prefer-language:%1]</pre>
</div>
<p><strong>Deny Access To Everyone Except PHP fopen</strong></p>
<p>This allows access to all files by php fopen, but denies anyone else.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.+$ [NC]
RewriteRule .* - [F,L]</pre>
</div>
<p>If you are looking for ways to block or deny specific  requests/visitors, then you should definately read Blacklist with  mod_rewrite.  I give it a 10/10<br />
<strong>Deny access to anything in a subfolder except php fopen</strong></p>
<p>This can be very handy if you want to serve media files or special downloads but only through a php proxy script.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]
RewriteRule .* - [F,L]</pre>
</div>
<p><strong>Require no www</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^askapache\.com$ [NC]
RewriteRule ^(.*)$ http://askapache.com/$1 [R=301,L]</pre>
</div>
<p><strong>Check for a key in QUERY_STRING</strong></p>
<p>Uses a RewriteCond Directive to check QUERY_STRING for passkey, if it  doesn’t find it it redirects all requests for anything in the  /logged-in/ directory to the /login.php script.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !passkey
RewriteRule ^/logged-in/(.*)$ /login.php [L]</pre>
</div>
<p><strong>Removes the QUERY_STRING from the URL</strong></p>
<p>If the QUERY_STRING has any value at all besides blank than the?at the  end of /login.php? tells mod_rewrite to remove the QUERY_STRING from  login.php and redirect.</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} .
RewriteRule ^login.php /login.php? [L]</pre>
</div>
<p><strong>Fix for infinite loops</strong></p>
<p>An error message related to this isRequest exceeded the limit of 10  internal redirects due to probable configuration error. Use  &#8216;LimitInternalRecursion&#8217; to increase the limit if necessary. Use  &#8216;LogLevel debug&#8217; to get a backtrace.or you may seeRequest exceeded the  limit,probable configuration error,Use &#8216;LogLevel debug&#8217; to get a  backtrace, orUse &#8216;LimitInternalRecursion&#8217; to increase the limit if  necessary</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]</pre>
</div>
<p><strong>External Redirect .php files to .html files (SEO friendly)</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule ^(.*)\.php$ /$1.html [R=301,L]</pre>
</div>
<p><strong>Internal Redirect .php files to .html files (SEO friendly)</strong></p>
<p>Redirects all files that end in .html to be served from filename.php so  it looks like all your pages are .html but really they are .php</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteRule ^(.*)\.html$ $1.php [R=301,L]</pre>
</div>
<p><strong>block access to files during certain hours of the day</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# If the hour is 16 (4 PM) Then deny all access
RewriteCond %{TIME_HOUR} ^16$
RewriteRule ^.*$ - [F,L]</pre>
</div>
<p><strong>Rewrite underscores to hyphens for SEO URL</strong></p>
<p>Converts all underscores “_” in urls to hyphens “-” for SEO benefits…  See the full article for more info.</p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule !\.(html|php)$ - [S=4]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]

RewriteCond %{ENV:uscor} ^Yes$
RewriteRule (.*) http://d.com/$1 [R=301,L]</pre>
</div>
<p><strong>Require the www without hardcoding</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$     [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]</pre>
</div>
<p><strong>Require no subdomain</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]</pre>
</div>
<p><strong>Require no subdomain</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([^\.]+\.[^\.0-9]+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]</pre>
</div>
<p><strong>Redirecting WordPress Feeds to Feedburner</strong></p>
<p>Full article:Redirecting WordPress Feeds to Feedburner</p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/feed\.gif$
RewriteRule .* - [L]

RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</pre>
</div>
<p><strong>Only allow GET and PUT Request Methods</strong></p>
<p>Article: Request Methods</p>
<div>
<div>Code:</div>
<pre dir="ltr">
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !^(GET|PUT)
RewriteRule .* - [F]</pre>
</div>
</pre>
</div>
<p><strong>Prevent Files image/file hotlinking and bandwidth stealing</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]</pre>
</div>
<p><strong>Stop browser prefetching</strong></p>
<div>
<div>Code:</div>
<pre dir="ltr">RewriteEngine On
SetEnvIfNoCase X-Forwarded-For .+ proxy=yes
SetEnvIfNoCase X-moz prefetch no_access=yes

# block pre-fetch requests with X-moz headers
RewriteCond %{ENV:no_access} yes
RewriteRule .* - [F,L]</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/quy-t%e1%ba%afc-vi%e1%ba%bft-htaccess-trong-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using wp_pagenavi() with custom queries</title>
		<link>http://www.oneclickme.com/using-wp_pagenavi-with-custom-queries/</link>
		<comments>http://www.oneclickme.com/using-wp_pagenavi-with-custom-queries/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 17:53:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=604</guid>
		<description><![CDATA[The old way (which still works): query_posts( array( 'tag' =&#62; 'foo', 'paged' =&#62; get_query_var('paged') ) );   while ( have_posts() ) : the_post(); the_title(); // more stuff here endwhile;   wp_pagenavi();   wp_reset_query(); // avoid errors further down the page The new way (better, because it has less side-effects): $my_query = new WP_Query( array( 'tag' =&#62; 'foo', 'paged' =&#62; get_query_var('paged') ) );   while ( $my_query-&#62;have_posts() ) : $my_query-&#62;the_post(); the_title(); // more stuff here endwhile; [...]]]></description>
			<content:encoded><![CDATA[<p>The old way (which still works):</p>
<div>
<div>
<pre>query_posts( array( 'tag' =&gt; 'foo', 'paged' =&gt; get_query_var('paged') ) );
 
while ( have_posts() ) : the_post();
	the_title();
	// more stuff here
endwhile;
 
wp_pagenavi();
 
wp_reset_query();	// avoid errors further down the page</pre>
</div>
</div>
<p>The new way (better, because it has less side-effects):</p>
<div>
<div>
<pre>$my_query = new WP_Query( array( 'tag' =&gt; 'foo', 'paged' =&gt; get_query_var('paged') ) );
 
while ( $my_query-&gt;have_posts() ) : $my_query-&gt;the_post();
	the_title();
	// more stuff here
endwhile;
 
wp_pagenavi( array( 'query' =&gt; $my_query ) );
 
wp_reset_postdata();	// avoid errors further down the page</pre>
</div>
</div>
<p>Notice that, in both cases, I <strong>included the ‘paged’ parameter</strong>. Without it, you would see the same posts on all pages.</p>
<h3>‘smaller’ and ‘larger’ classes</h3>
<p>Each link has now an additional ‘smaller’ or ‘larger’ class, depending on where it is, in relation to the current page.</p>
<p>For example, if you’re on page 2, the link to page 1 will have the  ‘smaller’ class, while links to page 3, 4, 5 etc. will have the ‘larger’  class.</p>
<p>This allows even more customization via CSS.</p>
<p>Article from : <strong>http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/using-wp_pagenavi-with-custom-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tìm hiểu về Comet</title>
		<link>http://www.oneclickme.com/tim-hi%e1%bb%83u-v%e1%bb%81-comet/</link>
		<comments>http://www.oneclickme.com/tim-hi%e1%bb%83u-v%e1%bb%81-comet/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 11:37:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>
		<category><![CDATA[ajax push engine]]></category>
		<category><![CDATA[ape]]></category>
		<category><![CDATA[comet server]]></category>
		<category><![CDATA[redis]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=600</guid>
		<description><![CDATA[comet là một kỹ thuật để tạo hiệu ứng push dữ liệu từ server đến client browser (thay vì client browser request/poll server như chúng ta vẫn biết) redis là csdl, đặc điểm của nó là nằm trong RAM (và đồng bộ vào disk theo chu kỳ do mình thiết lập) nên tốc độ cực nhanh (như memcache bởi cũng h/đ trong RAM &#8211; thậm chí nhiều benchmark còn cho thấy nó nhanh hơn cả [...]]]></description>
			<content:encoded><![CDATA[<p><strong>comet là một kỹ thuật để tạo hiệu ứng push dữ liệu từ server đến client  browser (thay vì client browser request/poll server như chúng ta vẫn  biết)</strong></p>
<p>redis là csdl, đặc điểm của nó là nằm trong RAM (và đồng bộ vào disk  theo chu kỳ do mình thiết lập) nên tốc độ cực nhanh (như memcache bởi  cũng h/đ trong RAM &#8211; thậm chí nhiều benchmark còn cho thấy nó nhanh hơn  cả memcache). Ngoài ra nó hỗ trợ nhiều định dạng dữ liệu (thay vì chỉ là  một key-value store như memcache) với nhiều operation hữu ích nên có  thể xứ lý dữ liệu trong csdl 1 cách linh hoạt. Nói chung bạn sẽ ko phải  lo lắng về vấn đề tốc độ của csdl nếu chọn nó (<a href="http://redis.io/topics/benchmarks" target="_blank">http://redis.io/topics/benchmarks</a>). Mà trong chat app thì performance là 1 tiêu chí quan trọng hàng đầu.</p>
<p>Vì csdl cho 1 ứng dụng chat ko đòi hỏi nhiều tính năng của một  relational DB nên theo mình dùng mysql trong trường hợp này là ko nên.  Có rất nhiều giải pháp nosql tốt khác hiện nay.</p>
<div>
Link: <a href="http://www.ddth.com/showthread.php/548690-gi%C3%BAp-v%E1%BB%9Bi-php-ajax-chat#ixzz1WEDTWvzh">http://www.ddth.com/showthread.php/548690-gi%C3%BAp-v%E1%BB%9Bi-php-ajax-chat#ixzz1WEDTWvzh</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/tim-hi%e1%bb%83u-v%e1%bb%81-comet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Ldap là gì?</title>
		<link>http://www.oneclickme.com/open-ldap-la-gi/</link>
		<comments>http://www.oneclickme.com/open-ldap-la-gi/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 03:54:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=597</guid>
		<description><![CDATA[LDAP là một phương tiện chứa dữ liệu nó không phải là một công nghệ. Đúng ra, LDAP là một protocol (Light Weight Access Protocol) nhưng nó có ứng dụng cho protocol nhằm mục đích lưu trữ dữ liệu. Các dịch vụ ứng dụng khả năng của LDAP rất rộng rãi nhất là trong khu vực xác thực người dùng (authentication và authorisation). Mường tượng nó như một DNS có chứa thông tin. Một cách [...]]]></description>
			<content:encoded><![CDATA[<p>LDAP là một phương tiện chứa dữ liệu nó không  phải là một công nghệ. Đúng ra, LDAP là một protocol (Light Weight  Access Protocol) nhưng nó có ứng dụng cho protocol nhằm mục đích lưu trữ  dữ liệu.</p>
<p>Các dịch vụ ứng dụng khả năng của LDAP rất rộng rãi nhất là trong  khu vực xác thực người dùng (authentication và authorisation). Mường  tượng nó như một DNS có chứa thông tin.</p>
<p>Một cách tổng quát mà nói, LDAP thường phân chia theo O  (Organisation &#8211; tổ chức) và các OU (Organisation Unit &#8211; phân bộ). Trong  các OU có thể có những OU con và trong các OU có các CN (Common Name),  những nhóm giá trị này thường được gọi là DN (Distinguished Name &#8211; tên  gọi phân biệt). Mỗi giá trị chứa trong LDAP thuộc dạng tên:giá trị,  thường được gọi là LDAP Attribute (viết tắt là attr, mỗi attr được nhận  diện như một LDAP Object.</p>
<p>Những điểm ở trên hình thành một cái gọi là LDAP schema và có tiêu  chuẩn thống nhất giữa các ứng dụng phát triển LDAP. Đây là lý do LDAP  được ưa chuộng cho công tác lưu trữ và tích hợp với các cơ phận  authentication / authorisation vì chúng có thể được dùng giữa các LDAP  system (bất kể công ty sản xuất) miễn sao các cty sản xuất tuân thủ đúng  tiêu chuẩn chung.</p>
<p>Nếu có ai hỏi, tại sao không dùng CDSL để chứa account của người  dùng mà phải đụng tới LDAP. Câu trả lời là: vẫn có thể dùng CSDL cho mục  đích đó. Tuy nhiên, CSDL không linh động bằng vì mỗi CSDL có những điểm  khác nhau. LDAP như một bộ phận độc lập dùng để lưu dữ liệu, bất cứ hệ  thống nào cần thông tin về user account (chẳng hạn), đều có thể share  chung một (hoặc nhiều LDAP có cùng thông tin). Thử hình dung một hệ  thống có 100 UNIX server và mỗi server phải bảo trì 1 /etc/passwd file.  Làm cách nào để đồng bộ hóa 100 /etc/passwd file một cách bảo đảm, gọn  gàng? Ngoài hệ thống NIS (và NIS+) cho mục đích này, càng ngày càng  nhiều hệ thống tích hợp và sử dụng LDAP vì nó không giới hạn platform.</p>
<p>LDAP đóng vai trò rất quan trọng trong việc ứng dụng SSO (single  sign on). Điều này có nghĩa là một người đăng nhập vào một hệ thống,  người ấy có thể truy cập đến các servers / services / tài nguyên&#8230; cho  phép mà không cần phải xác thực lại. Thử hình dung việc logon  mail.yahoo.com, sau đó có thể nhảy đến yahoo 360, yahoo mailing list&#8230;.  mà không cần phải xác thực tài khoản nữa. Thử hình dung yahoo sẽ có  những dịch vụ khác và mỗi yahoo account chỉ cần chứa ở 1 nơi và các dịch  vụ để dùng chung một LDAP chứa account để xác thực người dùng. Thử hình  dung yahoo có 1000 servers và 1000 /etc/passwd file để bảo trì <img src="http://www.hvaonline.net/hvaonline/images/smilies/068ae40523a24c9ef54edefd375e542d.gif" border="0" alt="smilie" align="absbottom" />).</p>
<p>Ngoài ra, LDAP được tạo ra đặc biệt cho hành động &#8220;đọc&#8221;. Bởi thế,  xác thực người dùng bằng phương tiện &#8220;lookup&#8221; LDAP nhanh, hiệu suất, ít  tốn tài nguyên, đơn giản hơn là query 1 user account trên CSDL</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/open-ldap-la-gi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Logging of Slow Queries (Slow Query Log) in MySQL Database</title>
		<link>http://www.oneclickme.com/enable-logging-of-slow-queries-slow-query-log-in-mysql-database/</link>
		<comments>http://www.oneclickme.com/enable-logging-of-slow-queries-slow-query-log-in-mysql-database/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 10:33:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kinh nghiệm]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Technology articles]]></category>

		<guid isPermaLink="false">http://www.oneclickme.com/?p=584</guid>
		<description><![CDATA[One of the main requirements for a fast web server is to has efficient and effective SQL statements or queries that are optimized. Any non-optimal SQL (Structured Query Language) commands or statements that take too long or lengthy time to execute will use up a lot of system resources, causing MySQL database to run slower, and then more and more queries backlogs queuing up, and when connection limit is reached, visitors are been denied or [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main requirements for a fast web server is to has efficient and effective SQL statements or queries that are optimized. Any non-optimal SQL (<span style="color: #1fa2e1;">Structured Query Language</span>) commands or statements that take too long or lengthy time to execute will use up a lot of system resources, causing MySQL database to run slower, and then more and more queries backlogs queuing  up, and when connection limit is reached, visitors are been denied or  refused connection. In worst case scenario, your <span style="color: #1fa2e1;">web server</span> will go down as well, or continuously underperform. The case is  especially true when you are using MyISAM table type which uses  table-level locking instead of row-level locking in a high traffic  website.<br />
Sometime, a single SQL query may be the cause of all the server’s  problems. MySQL has built-in functionality to capture slow query log or  identify queries that are not optimal and take a long time to finish,  which allows you to log all slow running queries which took over defined  number of seconds to execute by MySQL <span style="color: #1fa2e1;">database engine</span> to a file. Slow query log is not activated or on by default MySQL installation, thus it is one of the less-used logs.</p>
<p>To enable slow query log, simply add the following line to MySQL configuration file (my.cnf or my.ini), and then restart the <span style="color: #1fa2e1;">MySQL server</span>:</p>
<p>log-slow-queries</p>
<p>or</p>
<p>log-slow-queries = <em>[path to the log file]</em></p>
<p>Replace <em>[path to the log file]</em> with actual path to the slow query log file you want the MySQL to write the log to, which is the optional value.</p>
<p>Or you can start mysqld with with the –log-slow-queries[=file_name]  option to enable the slow query log. In both syntaxes, if not log file  name is specified, the default name is <em>host_name</em>-slow.log,  stored in the MySQL data file directory. If a filename is given, but not  as an absolute pathname, the server writes the file in the data  directory too.</p>
<p>After enabling slow query log, MySQL will create, capture and log to  the log file with all SQL statements that took more than long_query_time  seconds to execute, which is by default set to 10 seconds. The time to  acquire the initial table locks is not counted as <span style="color: #1fa2e1;">execution time</span>.  mysqld writes a statement to the slow query log after it has been  executed and after all locks have been released, so log order might be  different from execution order.</p>
<p>You can then examine all the <span style="color: #1fa2e1;">SQL queries</span> that took longer than the pre-defined number of seconds (10 seconds by default)  in the <em>host_name</em>-slow.log,  and then take the necessary steps to optimize the SQL statements. The  slow query log will tell you about what was time the query completed,  how long the query took to run, how long it took to secure its locks,  how many rows were sent back as a result, how many rows were examined to  determine the result, which database was used, and the actual query  itself. But bear in mind that a SQL query contained in the log may have  already optimum, but executed slowly due to the system resources been  used up by the actual slow statement that need to be fine tuned.</p>
<a id='wpaudio-4f2f0fcc7ca3a' class='wpaudio wpaudio-autoplay' href='http://wordpressyeah.com/download/Lang-tham-NooPhuocthinh.mp3'>Artist - Song</a>
]]></content:encoded>
			<wfw:commentRss>http://www.oneclickme.com/enable-logging-of-slow-queries-slow-query-log-in-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://wordpressyeah.com/download/Lang-tham-NooPhuocthinh.mp3" length="3203072" type="audio/mpeg" />
		</item>
	</channel>
</rss>

