<?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>Tutorials Bay</title>
	<atom:link href="http://tutorialsbay.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tutorialsbay.com</link>
	<description>Quality Tutorials for everyone!</description>
	<lastBuildDate>Tue, 24 Apr 2012 10:11:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>use example.com instead of localhost on your development server</title>
		<link>http://tutorialsbay.com/use-example-com-instead-of-localhost-on-your-development-server/</link>
		<comments>http://tutorialsbay.com/use-example-com-instead-of-localhost-on-your-development-server/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 18:31:12 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[localhost]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=714</guid>
		<description><![CDATA[I have xampp (apache, mysql,php) development server on my windows 7, I&#8217;m developing a PHP application using a modern php5 framework that has cool URL routing, I was having some problems getting the routing to work the way I wanted because http://localhost or http://127.0.0.1 doesn&#8217;t have an extension like any domain (eg: .com , .net) [...]]]></description>
			<content:encoded><![CDATA[<p>I have xampp (apache, mysql,php) development server on my windows 7, I&#8217;m developing a PHP application using a modern php5 framework that has cool URL routing, I was having some problems getting the routing to work the way I wanted because http://localhost or http://127.0.0.1 doesn&#8217;t have an extension like any domain (eg: .com , .net) and so I wanted to use example.com (example.com can be replaced by any domain you might think of!) to access my localhost.</p>
<p><a href="http://tutorialsbay.com/wp-content/uploads/2012/03/exampe.com-xampp.jpg"><img src="http://tutorialsbay.com/wp-content/uploads/2012/03/exampe.com-xampp.jpg" alt="exampe.com-xampp" title="exampe.com-xampp" width="572" height="306" class="alignnone size-full wp-image-715" /></a></p>
<p>I want it to resolve to my local server, for an example</p>
<p>I have my app in</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">c:<span style="color: #000000; font-weight: bold;">//</span>xampp<span style="color: #000000; font-weight: bold;">/</span>htdocs<span style="color: #000000; font-weight: bold;">/</span>myapp</pre></div></div>

<p>and I want to see myapp whenever I visit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http:<span style="color: #000000; font-weight: bold;">//</span>example.com<span style="color: #000000; font-weight: bold;">/</span>myapp</pre></div></div>

<p>instead of visiting http://localhost/myapp or http://127.0.0.1/myapp</p>
<p>You can accomplish this easily and have any domain resolves to your localhost on xampp, open the following file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">C:\Windows\System32\drivers\etc\hosts</pre></div></div>

<p>and at the very end of the hosts file just type local server ip 127.0.0.1 and hit TAB once and type example.com or any other domain you want, this can be any domain really</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">127.0.0.1		example.com</pre></div></div>

<p>save and close the file and now if you open your browser and visit <strong>example.com/myapp</strong> you should see your application and if you visit example.com you will see what you used to see whenever you visit http://localhost or 127.0.0.1, the default xampp page.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/use-example-com-instead-of-localhost-on-your-development-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter Captcha &amp; Session &#8211; How to by Example</title>
		<link>http://tutorialsbay.com/codeigniter-captcha-session-how-to-by-example/</link>
		<comments>http://tutorialsbay.com/codeigniter-captcha-session-how-to-by-example/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 21:40:43 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CodeIgniter]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=699</guid>
		<description><![CDATA[Today I was in need to add captcha spam protection to a form I have in a Codeigniter app I&#8217;m building for a client, I have looked at Codeigniter captcha helper but the example was not clear enough and was showing that you must use database and that was something I did not want. I [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was in need to add captcha spam protection to a form I have in a Codeigniter app I&#8217;m building for a client, I have looked at Codeigniter captcha helper but the example was not clear enough and was showing that you must use database and that was something I did not want. I wanted something simple, not many files, almost no configuration and No database needed.</p>
<p>I have  Googled a bit  and I found Google reCaptcha implemented as a CodeIgniter library but that was not very cool, very bad documentation and unclear demo, too many files to upload and configure, actually it was a very bad library and so I gave up and decided to look again at codeignirer captcha helper.</p>
<p>after reading all its documentation I got better ideas on how to use it and so implemented it in my app in 5 minutes and it was working exactly as I wanted and without a database!</p>
<p>see the example below of how I have my controller and view files and you will know how easy it is to  get Codeginiter captcha working with session and without a database</p>
<p><strong style="color:red;">IMPORTANT: </strong><br />
codeigniter captcha helper needs GD library installed on your server and you must create a folder and name it captcha in your Codeigniter root and change its permission to 777 or 666</p>
<p><strong>My controller</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> HomeController <span style="color: #000000; font-weight: bold;">extends</span> CI_Controller <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/********************************************************
* This is the index page for this controller 
********************************************************/</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
           <span style="color: #666666; font-style: italic;">// load the session library</span>
	    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// if form was submitted and given captcha word matches one in session</span>
               <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'word'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">userdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'word'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                       <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'success_view.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #666666; font-style: italic;">// load codeigniter captcha helper</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'captcha'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$vals</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'img_path'</span>	 <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'./captcha/'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'img_url'</span>	 <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://domain.com/captcha/'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'img_width'</span>	 <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'200'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'img_height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'border'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> 
                <span style="color: #0000ff;">'expiration'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">7200</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                 <span style="color: #666666; font-style: italic;">// create captcha image</span>
                <span style="color: #000088;">$cap</span> <span style="color: #339933;">=</span> create_captcha<span style="color: #009900;">&#40;</span><span style="color: #000088;">$vals</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">// store image html code in a variable</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cap</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
               <span style="color: #666666; font-style: italic;">// store the captcha word in a session</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_userdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'word'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cap</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'word'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'captcha_view.php'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>My View</strong> (captcha_view.php)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// this will show the captcha image?&gt;</span>
<span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;word&quot;</span>  <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span>  <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/codeigniter-captcha-session-how-to-by-example/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>wp shortcode outputs showing on top or wrong location [solution]</title>
		<link>http://tutorialsbay.com/wp-shortcode-outputs-showing-on-top-or-wrong-location-solution/</link>
		<comments>http://tutorialsbay.com/wp-shortcode-outputs-showing-on-top-or-wrong-location-solution/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 23:29:19 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=687</guid>
		<description><![CDATA[Today I have built a function for a client that does include a file from wordpress wp-content directory and I have made a shortcode to use this function within posts &#038; pages or widgets the function is very simple and all it does is includes a file function my_func&#40;&#41; &#123; echo '&#60;div id=&#34;testimonials&#34;&#62;'; include&#40;ABSPATH . [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have built a function for a client that does include a file from wordpress wp-content directory and I have made a shortcode to use this function within posts &#038; pages or widgets the function is very simple and all it does is includes a file</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span>  <span style="color: #0000ff;">'&lt;div id=&quot;testimonials&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content/plugins/wp-content-slider/content-slider.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and the short code</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'show_func'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_func'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and while using the shortcode within WordPress page the output is being displayed on top of the page just before the page contents and this is very weird as the shortcode output should display wherever you have placed the shortcode within your page or post!</p>
<p>If you ever want to make a shortcode for a file include, sometimes you may need that for you own functions or just customizing a plugin that requires file include, you will need to add <strong>ob_start();</strong> at the begining of the function&#8217;s code and then add the rest of the function code/include or anything it has and once done from your code Just create a variable with value of <strong>ob_get_clean();</strong> and then return that variable.</p>
<p>See the example below on how a function would look like to have it display WordPress shortcode output exactly where you place it on a page or post.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>  <span style="color: #0000ff;">'&lt;div id=&quot;testimonials&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content/plugins/content-slider/content-slider.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myvariable</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$myvariable</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/wp-shortcode-outputs-showing-on-top-or-wrong-location-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 10.10 Skype won&#8217;t quit and using 100% of CPU [solution]</title>
		<link>http://tutorialsbay.com/ubuntu-10-10-skype-frozen-wont-close/</link>
		<comments>http://tutorialsbay.com/ubuntu-10-10-skype-frozen-wont-close/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 19:12:50 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=681</guid>
		<description><![CDATA[Today while I was chatting to friends on skype I suddenly stopped receiving their PMs, actually skype stopped sending or receiving messages I clicked on skype icon then &#8220;quit&#8221; it just won&#8217;t close and so i opened terminal and ran top command and skype was using 100% of CPU, very weird! so I ran killall [...]]]></description>
			<content:encoded><![CDATA[<p>Today while I was chatting to friends on skype I suddenly stopped receiving their PMs, actually skype stopped sending or receiving messages I clicked on skype icon then &#8220;quit&#8221; it just won&#8217;t close and so i opened terminal and ran top command and skype was using 100% of CPU, very weird! so I ran</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">killall</span> skype</pre></div></div>

<p>and that didn&#8217;t kill the process! tried xkill and also didn&#8217;t work! and finally the following command killed skype and everything back to normal!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> skype</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/ubuntu-10-10-skype-frozen-wont-close/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu &#8211; Cannot ioctl TUNSETIFF tun: Operation not permitted</title>
		<link>http://tutorialsbay.com/ubuntu-cannot-ioctl-tunsetiff-tun-operation-not-permitted-errno1/</link>
		<comments>http://tutorialsbay.com/ubuntu-cannot-ioctl-tunsetiff-tun-operation-not-permitted-errno1/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 21:43:22 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=677</guid>
		<description><![CDATA[I have openVPN access server setup on an openVZ vps, I&#8217;m using Ubuntu and I usually connect to my openvpn access server using profile file like this openvpn --config profile.ovpn Today for some reason I was not able to connect to my openVPN and I was getting the following errors: Sat Mar 10 23:31:34 2012 [...]]]></description>
			<content:encoded><![CDATA[<p>I have openVPN access server setup on an openVZ vps, I&#8217;m using Ubuntu and I usually connect to my openvpn access server using profile file like this</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openvpn <span style="color: #660033;">--config</span> profile.ovpn</pre></div></div>

<p>Today for some reason I was not able to connect to my openVPN and I was getting the following errors:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Sat Mar <span style="color: #000000;">10</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">34</span> <span style="color: #000000;">2012</span> Note: Cannot ioctl TUNSETIFF tun: Operation not permitted <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">errno</span>=<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Sat Mar <span style="color: #000000;">10</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">34</span> <span style="color: #000000;">2012</span> Note: Attempting fallback to kernel <span style="color: #000000;">2.2</span> TUN<span style="color: #000000; font-weight: bold;">/</span>TAP interface
Sat Mar <span style="color: #000000;">10</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">34</span> <span style="color: #000000;">2012</span> Cannot allocate TUN<span style="color: #000000; font-weight: bold;">/</span>TAP dev dynamically
Sat Mar <span style="color: #000000;">10</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span>:<span style="color: #000000;">34</span> <span style="color: #000000;">2012</span> Exiting</pre></div></div>

<p>Googled a bit but no luck, until I decided to try to connect with sudo at the beginning so I ran:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openvpn <span style="color: #660033;">--config</span> profile.ovpn</pre></div></div>

<p>and that fixed the problem <img src='http://tutorialsbay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/ubuntu-cannot-ioctl-tunsetiff-tun-operation-not-permitted-errno1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cPanel FTP 550 Could not delete/edit Permission denied</title>
		<link>http://tutorialsbay.com/cpanel-ftp-550-could-not-deleteedit-permission-denied/</link>
		<comments>http://tutorialsbay.com/cpanel-ftp-550-could-not-deleteedit-permission-denied/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 15:37:46 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=670</guid>
		<description><![CDATA[This cpanel ftp problem is usually caused when there is something wrong with files ownership, this happened to me today while I was trying to delete some files from a cPanel account using FileZilla, It even happened while I was trying to use cPanel file manager, there is an easy and quick way to fix [...]]]></description>
			<content:encoded><![CDATA[<p>This cpanel ftp problem is usually caused when there is something wrong with files ownership, this happened to me today while I was trying to delete some files from a cPanel account using FileZilla, It even happened while I was trying to use cPanel file manager, there is an easy and quick way to fix this permission problem.</p>
<p>If you have a VPS or Dedicated server and have access to SSH, then ssh to your server and cd to the <strong>public_html</strong> directory of the user who&#8217;s having the problem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>username<span style="color: #000000; font-weight: bold;">/</span>public_html</pre></div></div>

<p>then run the following command to fix the permission problem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> username.username <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #660033;">-R</span></pre></div></div>

<p>replace username with the actual cPanel username</p>
<p>and if you are on a shared hosting and don&#8217;t have SSH access, you might want to refer your hosting company to this page</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/cpanel-ftp-550-could-not-deleteedit-permission-denied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Tkinter &amp; Sqlite3 GUI programming tutorial</title>
		<link>http://tutorialsbay.com/python-tkinter-sqlite3-gui/</link>
		<comments>http://tutorialsbay.com/python-tkinter-sqlite3-gui/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 20:00:38 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=658</guid>
		<description><![CDATA[I have been playing with Python &#38; Tkinter for couple of days, then thought of sqlite3 so I can do something useful with Python Tkinter &#38; sqlite3, after this tutorial you will know how to create basic a Python program to store notes in sqlite3 database and retrieve them, This program should work on Windows, [...]]]></description>
			<content:encoded><![CDATA[<p>I have been playing with Python &amp; Tkinter for couple of days, then thought of sqlite3 so I can do something useful with Python Tkinter &amp; sqlite3, after this tutorial you will know how to create basic a Python program to store notes in sqlite3 database and retrieve them, This program should work on Windows, Linux and Mac.<br />
the final program will look like this:<br />
<img src="http://tutorialsbay.com/wp-content/uploads/2012/02/python-tkinter-program.png" alt="python-tkinter-program" title="Python Tkinter" width="351" height="346" class="alignnone size-full wp-image-664" /></p>
<p>You will need:<br />
<a title="Opens in new window" href="http://python.org">Python</a> installed<br />
<a title="opens in new window" href="http://sqlite3.org" target="_blank">Sqlite3</a> Library</p>
<p>Sqlite comes with a Command Line Shell for creating and managing databases</p>
<p><strong>Create an empty sqlite database</strong><br />
If you are on windows go to <strong>Start &gt; run</strong> , type CMD ad the command line window will appear, make sure you have an empty folder created wherever you want to build the program, in my case I created a folder on desktop called &#8220;program&#8221;, if you did like me then in windows command line windows type</p>
<p class="note">cd Desktop/program</p>
<p>At a shell or DOS prompt, enter</p>
<p class="note">sqlite3 mydb</p>
<p>that creates an empty sqlite3 database, now lets create a table to store notes</p>
<p class="note">create table mynotes(note varchar(50) );</p>
<p>the above line creates an empty table inside the database &#8220;<strong>mydb</strong>&#8221;</p>
<p><strong>Python file</strong><br />
Create an empty file inside the same dir and name it <strong>prog.py</strong><br />
and paste the following inside it (don&#8217;t worry I will try to explain most of it):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">Tkinter</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
<span style="color: #ff7700;font-weight:bold;">import</span> sqlite3
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Program:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, master<span style="color: black;">&#41;</span>:
        frame = Frame<span style="color: black;">&#40;</span>master, width=<span style="color: #ff4500;">80</span>, height=<span style="color: #ff4500;">50</span><span style="color: black;">&#41;</span>
        frame.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">text</span> = Label<span style="color: black;">&#40;</span>frame, text=<span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">text</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">text</span>.<span style="color: black;">grid</span><span style="color: black;">&#40;</span>row=<span style="color: #ff4500;">0</span>, sticky=W, pady=<span style="color: #ff4500;">10</span>, padx=<span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span> = Entry<span style="color: black;">&#40;</span>frame, width=<span style="color: #ff4500;">45</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span>.<span style="color: black;">grid</span><span style="color: black;">&#40;</span>row=<span style="color: #ff4500;">1</span>, rowspan=<span style="color: #ff4500;">2</span>, sticky=W,  pady=<span style="color: #ff4500;">5</span>, padx=<span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">btn</span> = Button<span style="color: black;">&#40;</span>frame, text=<span style="color: #483d8b;">&quot;Add note&quot;</span>, command=<span style="color: #008000;">self</span>.<span style="color: black;">add_note</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">btn</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">btn</span>.<span style="color: black;">grid</span><span style="color: black;">&#40;</span>row=<span style="color: #ff4500;">3</span>, rowspan=<span style="color: #ff4500;">2</span>, sticky=W, pady=<span style="color: #ff4500;">10</span>, padx=<span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">showbtn</span> = Button<span style="color: black;">&#40;</span>frame, text=<span style="color: #483d8b;">&quot;Show Notes&quot;</span>, command = <span style="color: #008000;">self</span>.<span style="color: black;">show_notes</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">showbtn</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">showbtn</span>.<span style="color: black;">grid</span><span style="color: black;">&#40;</span>row=<span style="color: #ff4500;">3</span>, rowspan=<span style="color: #ff4500;">2</span>,  pady=<span style="color: #ff4500;">10</span>, padx=<span style="color: #ff4500;">80</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
        <span style="color: #808080; font-style: italic;"># create an empty Tkinter listbox</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">content</span> = Listbox<span style="color: black;">&#40;</span>master, width=<span style="color: #ff4500;">50</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">content</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> add_note<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
&nbsp;
        <span style="color: #808080; font-style: italic;"># if texfield is empty</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> == <span style="color: #483d8b;">&quot;&quot;</span>:
            <span style="color: #808080; font-style: italic;"># then set text label text</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">text</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;text&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;Please type a note&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
&nbsp;
            <span style="color: #808080; font-style: italic;"># everything is ok lets get the typed note</span>
            item = <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># create sqlite connection            </span>
            conn = sqlite3.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'mynotes'</span><span style="color: black;">&#41;</span>
            c = conn.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># insert a row</span>
            c.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;insert into notes (mynote) values (?)&quot;</span>, <span style="color: black;">&#40;</span>item,<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
            conn.<span style="color: black;">commit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>                  
&nbsp;
            <span style="color: #808080; font-style: italic;"># close connection</span>
            c.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># clear input</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">TextField</span>.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, END<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> show_notes<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
            conn = sqlite3.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'mynotes'</span><span style="color: black;">&#41;</span>
            c = conn.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># select all entries from database</span>
            <span style="color: #008000;">list</span> = c.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;SELECT * FROM notes&quot;</span><span style="color: black;">&#41;</span>
            conn.<span style="color: black;">commit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># list has an array so lets loop the array and insert each item to</span>
            <span style="color: #808080; font-style: italic;"># our listbox</span>
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">for</span> row <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">list</span>:
                    <span style="color: #008000;">self</span>.<span style="color: black;">content</span>.<span style="color: black;">insert</span><span style="color: black;">&#40;</span>END, row<span style="color: black;">&#41;</span>                    
            c.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
root = Tk<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
application = Program<span style="color: black;">&#40;</span>root<span style="color: black;">&#41;</span>
root.<span style="color: black;">mainloop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Lets explain the code above</p>
<div class="note">
    def __init__(self, master):<br />
        frame = Frame(master, width=80, height=50)<br />
        frame.pack()
</div>
<p class="note">
def __init__(self, master):
</pre>
<p>function for initialization.</p>
<div class="note">
frame = frame = Frame(master, width=80, height=50)<br />
frame.pack()
</div>
<p>Creates the main frame</p>
<div class="note">
        self.text = Label(frame, text="")<br />
        self.text.pack()<br />
        self.text.grid(row=0, sticky=W, pady=10, padx=10)
</div>
<p>it creates a label where we can put any text we want, we created a label to show a message if field left empty<br />
row , sticky, pady, padx control the position of the label</p>
<div class="note">
        self.TextField = Entry(frame, width=45)<br />
        self.TextField.pack()<br />
        self.TextField.grid(row=1, rowspan=2, sticky=W,  pady=5, padx=10)
</div>
<p>Creates a text field, you may note there is "frame" as first argument, that's the name of Tkinter frame we want the text field in</p>
<div class="note">
        self.btn = Button(frame, text="Add note", command=self.add_note)<br />
        self.btn.pack()<br />
        self.btn.grid(row=3, rowspan=2, sticky=W, pady=10, padx=10)
</div>
<p>Creates a button, <strong>text</strong> argument is the text displayed on the button, <strong>command</strong> is the function to run when you click that button</p>
<div class="note">
        self.content = Listbox(master, width=50)<br />
        self.content.pack()
</div>
<p>Creates an empty Tkinter listbox (thats where we will display sqlite3 contents)</p>
<div class="note">
item = self.TextField.get()<br />
            conn = sqlite3.connect('mynotes')<br />
            c = conn.cursor()</p>
<p>            # insert a row<br />
            c.execute("insert into notes (mynote) values (?)", (item,))<br />
            conn.commit()<br />
            c.close()</p>
<p>            # clear input<br />
            self.TextField.delete(0, END)
</p></div>
<p>where <strong>item </strong>= <strong>self.TextField.get()</strong> we are getting the text typed into Textfield.<br />
where <strong>self.TextField.delete(0, END)</strong> we are reseting the field.<br />
<strong>sqlite3.connect('mynotes')</strong> creates a sqlite connection to mynotes (the database).</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/python-tkinter-sqlite3-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP search facebook posts using Graph  API (JSON)</title>
		<link>http://tutorialsbay.com/php-search-facebook-posts-json/</link>
		<comments>http://tutorialsbay.com/php-search-facebook-posts-json/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 21:57:54 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=642</guid>
		<description><![CDATA[Facebook offers a flexible and easy to use API called Graph, graph is simply a URL that once you open in a browser or within your code it return a JSON (JavaScript Object Notation ) string, in this tutorial you will learn how to use php and facebook graph API to access public posts and [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook offers a flexible and easy to use API called Graph, graph is simply a URL that once you open in a browser or within your code it return a JSON (JavaScript Object Notation ) string, in this tutorial you will learn how to use php and facebook graph API to access public posts and parse JSON results with php, We will build together a php  search engine to parse JSON returned by Facebook Graph and display results to visitors</p>
<p>view this in action <a href="http://tutorialsbay.com/demo/graph-search" title="Opens in new window" target="_blank"><strong>Demo</strong></a></p>
<p>If you don&#8217;t know what is <a title="Opens in new window" href="http://www.json.org/" target="_blank">Json</a>, a Json string looks like this</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
<span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;John Smith&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;Age&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;30&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;username&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Jsith&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;location&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Chicago&quot;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Our search engine will be 2 pages<br />
<strong><br />
index.html<br />
search.php<br />
</strong></p>
<p>index.html content</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form action=&quot;search.php&quot; method=&quot;post&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;keyword&quot;&gt;
&lt;input type=&quot;submit&quot; value=&quot;search&quot;&gt;
&lt;/form&gt;</pre></div></div>

<p>in the above step we build a basic html page with a form that contains text field and submit button to submit the form to our search.php, then once a user type a keyword and hit submit we want to take that keyword and search facebook public posts suing their graph API.</p>
<p>Now in <strong>search.php</strong> We need to catch the submitted keyword from index.html</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$keyword</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'keyword'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The graph url which will return a JSON string is https://graph.facebook.com/search<br />
the url accepts many parameters but we will use the basic ones such as type and q (query)<br />
you can see what the JSON results would look like before we parse them with PHP here:<br />
<a title="ope" href="https://graph.facebook.com/?q=hello&amp;type=post" target="_blank">https://graph.facebook.com/search?q=hello&amp;type=post</a><br />
Now lets set the graph url we will be opening with php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// set graph url</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://graph.facebook.com/search?&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// add parameters to graph url</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;type=posts&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;q=<span style="color: #006699; font-weight: bold;">$keyword</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>in the above step we have a prepared graph url with type parameter and q parameter, the q parameter is the keyword we want to search for and type is the kind of contents we need, we are going to search for posts, aren&#8217;t we?<br />
Now that facebook graph url is ready with the keyword we want to search for, lets have php open it so it returns the JSON results</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$graph_url</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong><br />
$result</strong> will be the variable holding the JSON data returned by Facebook Graph, We now need to parse JSON and display it as readable text or HTML content, We will parse it using php function &#8211; json_decode() -</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the json_decode() function in the way used above converts the JSON string into accessible objects, We will need to do a foreach loop to access those objects and print them, lets do that now</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$json</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$show</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created_time</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;hr&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now you might be wondering why used $json->data and not $json alone, the answer is because all the returned results in JSON are inside an array called &#8220;data&#8221; and also you may have noticed to show the name of poster I&#8217;m doing $json->from->name is because &#8220;from&#8221; is an array and name is an object inside that array you can see how it looks like here <a title="ope" href="https://graph.facebook.com/?q=hello&amp;type=post" target="_blank">https://graph.facebook.com/?q=hello&amp;type=post</a>, In this tutorial I&#8217;m only showing name of person who made the post,  message which is post content, created time is the timestamp of the post date you can access many more such as Facebook user ID , description, comments count etc. By simple doing $show->xx where xx is the object name! I hope this helps you in your next Facebook app project! you can what we have created in action here</p>
<p>search.php all together will look like this</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$keyword</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'keyword'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://graph.facebook.com/search?&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;type=posts&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;q=<span style="color: #006699; font-weight: bold;">$keyword</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$graph_url</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$json</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$show</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$show</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created_time</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;hr&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/php-search-facebook-posts-json/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CodeIgniter time ago &#8211; How to get it done!</title>
		<link>http://tutorialsbay.com/codeigniter-time-ago/</link>
		<comments>http://tutorialsbay.com/codeigniter-time-ago/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 23:04:45 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=636</guid>
		<description><![CDATA[In today&#8217;s web, its much better to use x hour ago, day ago , month ago , a year ago etc. CodeIgniter has a built-in function in date_helper that allows you to convert any date/time to &#8220;xx Time ago&#8221; style, its called timespan() it takes 2 arguments the first one is the date/time you want [...]]]></description>
			<content:encoded><![CDATA[<p>In today&#8217;s web, its much better to use x hour ago, day ago , month ago , a year ago etc. CodeIgniter has a built-in function in date_helper that allows you to convert any date/time to &#8220;xx Time ago&#8221; style, its called timespan() it takes 2 arguments the first one is the date/time you want to convert to &#8220;time ago style&#8221; and the second one should be current date time, below is an example show you how to use CodeIgniter timespan function</p>
<p>First you will need to load the date helper</p>
<div class="note php">$this-&gt;load-&gt;helper(&#8216;date&#8217;);</div>
<p>Now lets use the function in any of our controllers</p>
<div class="note php">timespan(1326927423, time() ) . &#8220;ago&#8221; ;</div>
<p>That will outputs something like</p>
<div class="note php">2 hours ago</div>
<p>Note that <strong>1326927423</strong> is a UNIX date format, see this <a title="Opens in new window" href="http://php.net/manual/en/function.date.php" target="_blank">page</a> to learn about date formats and how to convert them.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/codeigniter-time-ago/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install OpenVPN Access server on a VPS</title>
		<link>http://tutorialsbay.com/openvpn-access-server-on-a-openvz-vps/</link>
		<comments>http://tutorialsbay.com/openvpn-access-server-on-a-openvz-vps/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 22:47:24 +0000</pubDate>
		<dc:creator>Mody</dc:creator>
				<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://tutorialsbay.com/?p=633</guid>
		<description><![CDATA[Let install OpenVZ AS (Access server) on an openvz VPS, as most vps providers are using openvz technology. We will be installing openvpn AS on a VPS with centOS 6 32bit, It should be no problem if you are using 64bit also this tutorial can work just fine on a dedicated server or Xen VPS. [...]]]></description>
			<content:encoded><![CDATA[<p>Let install OpenVZ AS (Access server) on an openvz VPS, as most vps providers are using openvz technology.<br />
We will be installing openvpn AS on a VPS with centOS 6 32bit, It should be no problem if you are using 64bit also this tutorial can work just fine on a dedicated server or Xen VPS.</p>
<p>The first thing you should do if you are on a openVZ VPS is asking your vps provider to enable TUN/TAP device for you or just give them the following commands to run on their hardware node<br />
to enable TUN/TAP</p>
<div class="note">vzctl set 101 &#8211;devnodes net/tun:rw &#8211;save</div>
<p>to enable IP tables if necessary</p>
<div class="note">vzctl set 101 &#8211;iptables ipt_REJECT &#8211;iptables ipt_tos &#8211;iptables ipt_TOS &#8211;iptables ipt_LOG &#8211;iptables ip_conntrack &#8211;iptables ipt_limit &#8211;iptables ipt_multiport &#8211;iptables iptable_filter &#8211;iptables iptable_mangle &#8211;iptables ipt_TCPMSS &#8211;iptables ipt_tcpmss &#8211;iptables ipt_ttl &#8211;iptables ipt_length &#8211;iptables ipt_state &#8211;iptables iptable_nat &#8211;iptables ip_nat_ftp &#8211;save</div>
<p>where 101 is your vps CID.</p>
<p>Now ssh to your server, if you are on Linux (Ctrl + t) to open terminal and type inside</p>
<div class="note">ssh root@xxx.xxx.xxx.xx</div>
<p>Where xxx.xx.. is your server IP address, it will then ask for root password just type it and hit enter to login to your server.</p>
<p>If you are on windows then use <a title="Opens in new window" href="https://www.google.com/search?client=ubuntu&amp;channel=fs&amp;q=putty&amp;ie=utf-8&amp;oe=utf-8" target="_blank">putty</a> to connect to your server.<br />
now that you&#8217;re logged in, run the following command to download openvpn access server installation script<br />
<strong>for centOS 32bit do this</strong></p>
<div class="note">wget http://swupdate.openvpn.org/as/openvpn-as-1.8.3-CentOS5.i386.rpm</div>
<p><strong>for centOS 64bit do this</strong></p>
<div class="note">wget http://swupdate.openvpn.org/as/openvpn-as-1.8.3-CentOS5.x86_64.rpm</div>
<p>run Openvpn Access Server installer for (32bit)</p>
<div class="note">rpm -i openvpn-as-1.8.3-CentOS5.i386.rpm</div>
<p>run Openvpn Access Server installer for (64bit)</p>
<div class="note">rpm -i openvpn-as-1.8.3-CentOS5.x86_64.rpm</div>
<p>it will take anywhere between 4 minutes and 10 minutes, it will create the master username(openvpn) so once done lets change the user &#8220;openvpn&#8221; password by running this</p>
<div class="note">passwd openvpn</div>
<p>choose a password, type and confirm it and that is it! you got openvpn access server installed and ready, to login to openvpn access server admin, the url would be something like this</p>
<div class="note">https://xxx.xxx.xxx:943/admin</div>
<p>where xxx.xxx.xxx is your server IP address, and make sure the url is starting with <strong>https</strong>, the user name would be <strong>openvpn</strong> and password would be the one you have chosen in last step.</p>
<p>and to login as a client the url would be</p>
<div class="note">https://xxx.xxx.xxx</div>
<p>the first time a client connect to openvpn access server, he may be asked to download openvpn connect client.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialsbay.com/openvpn-access-server-on-a-openvz-vps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

