<?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>Okada Design Blog &#187; Web Development</title>
	<atom:link href="http://www.okadadesign.no/blog/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.okadadesign.no/blog</link>
	<description>Welcome to Okada Design Web Development Blog</description>
	<lastBuildDate>Wed, 11 Jan 2012 23:21:51 +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>Norwegian Characters in CodeIgniter and Editor</title>
		<link>http://www.okadadesign.no/blog/web-development/norwegian-characters-in-codeigniter-and/</link>
		<comments>http://www.okadadesign.no/blog/web-development/norwegian-characters-in-codeigniter-and/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 16:49:43 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2738</guid>
		<description><![CDATA[ <p>I had a problem with Norwegian characters today. I found that my editor&#8217;s encoding was set to iso-8859-1, so I needed to change it to UTF-8. I kept the following in config.php in CodeIgniter.</p> $config['charset'] = &#34;UTF-8&#34;; <p>Then I needed to retype all the Norwegian characters in the editor.</p> <p>I set all database [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/firefox/using-scribefire-blog-editor/' rel='bookmark' title='Using ScribeFire Blog Editor'>Using ScribeFire Blog Editor</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fnorwegian-characters-in-codeigniter-and%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fnorwegian-characters-in-codeigniter-and%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had a problem with Norwegian characters today. I found that my editor&#8217;s encoding was set to iso-8859-1, so I needed to change it to UTF-8. I kept the following in config.php in CodeIgniter.</p>
<pre class="brush: php; title: ; notranslate">
$config['charset'] = &quot;UTF-8&quot;;
</pre>
<p>Then I needed to retype all the Norwegian characters in the editor.</p>
<p>I set all database charset to UTF-8 as well.</p>
<pre class="brush: php; title: ; notranslate">
DEFAULT CHARSET=utf8
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/firefox/using-scribefire-blog-editor/' rel='bookmark' title='Using ScribeFire Blog Editor'>Using ScribeFire Blog Editor</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/norwegian-characters-in-codeigniter-and/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing DocumentRoot from /var/www to /home/myname/www</title>
		<link>http://www.okadadesign.no/blog/web-development/changing-documentroot-from-varwww-to-homemynamewww/</link>
		<comments>http://www.okadadesign.no/blog/web-development/changing-documentroot-from-varwww-to-homemynamewww/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 15:36:08 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2736</guid>
		<description><![CDATA[ <p>This is a quick tip to change your document root in Ubuntu. If you are using github, it is a bit troublesome to work in /var/www directory. You need to type &#8216;sudo&#8217; each time or change to super user. But if you change your localhost document root to your home directory, you don&#8217;t [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/ubuntu/installing-lamp-and-phpmyadmin-on-ubuntu/' rel='bookmark' title='Installing LAMP and phpMyAdmin on Ubuntu'>Installing LAMP and phpMyAdmin on Ubuntu</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-add-httpd-conf-to-xampp/' rel='bookmark' title='How to add httpd.conf to XAMPP'>How to add httpd.conf to XAMPP</a></li>
<li><a href='http://www.okadadesign.no/blog/jquery/changing-form-input-styles-on-focus-with-jquery-by-sam-dunn/' rel='bookmark' title='&quot;Changing Form Input Styles on Focus with jQuery&quot; by Sam Dunn'>&quot;Changing Form Input Styles on Focus with jQuery&quot; by Sam Dunn</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fchanging-documentroot-from-varwww-to-homemynamewww%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fchanging-documentroot-from-varwww-to-homemynamewww%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This is a quick tip to change your document root in Ubuntu. If you are using github, it is a bit troublesome to work in /var/www directory. You need to type &#8216;sudo&#8217; each time or change to super user. But if you change your localhost document root to your home directory, you don&#8217;t need to do it.</p>
<p>From terminal.</p>
<div class="codesnip-container" >sudo gedit /etc/apache2/sites-available/default</div>
<p>Change the following line.</p>
<div class="codesnip-container" ><VirtualHost *:80><br />
&#8230;<br />
&#8230;<br />
	DocumentRoot /var/www<br />
	<Directory /><br />
		Options FollowSymLinks<br />
		AllowOverride None<br />
	</Directory><br />
	<Directory /var/www/><br />
		Options Indexes FollowSymLinks MultiViews<br />
		AllowOverride All<br />
		Order allow,deny<br />
		allow from all<br />
	</Directory><br />
&#8230;<br />
&#8230;</div>
<p>to the following.</p>
<div class="codesnip-container" ><VirtualHost *:80><br />
&#8230;</p>
<p>	DocumentRoot /home/yourdirectory/www<br />
	<Directory /><br />
		Options FollowSymLinks<br />
		AllowOverride None<br />
	</Directory><br />
	<Directory /home/yourdirectory/www/><br />
		Options Indexes FollowSymLinks MultiViews<br />
		AllowOverride All<br />
		Order allow,deny<br />
		allow from all<br />
	</Directory><br />
&#8230;<br />
&#8230;</div>
<p>Don&#8217;t forget to change &#8216;yourdirectory&#8217;.</p>
<p>Then from terminal.</p>
<div class="codesnip-container" >sudo apache2ctl -t<br />
sudo apache2ctl restart<br />
suso /etc/init.d/apache2 restart</div>
<p>Then transfer all your directory from /var/www to /home/yourname/www.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/ubuntu/installing-lamp-and-phpmyadmin-on-ubuntu/' rel='bookmark' title='Installing LAMP and phpMyAdmin on Ubuntu'>Installing LAMP and phpMyAdmin on Ubuntu</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-add-httpd-conf-to-xampp/' rel='bookmark' title='How to add httpd.conf to XAMPP'>How to add httpd.conf to XAMPP</a></li>
<li><a href='http://www.okadadesign.no/blog/jquery/changing-form-input-styles-on-focus-with-jquery-by-sam-dunn/' rel='bookmark' title='&quot;Changing Form Input Styles on Focus with jQuery&quot; by Sam Dunn'>&quot;Changing Form Input Styles on Focus with jQuery&quot; by Sam Dunn</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/changing-documentroot-from-varwww-to-homemynamewww/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending email from localhost using MSMTP with gmail</title>
		<link>http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/</link>
		<comments>http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 11:24:05 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[localhost]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2683</guid>
		<description><![CDATA[ <p>If you are using Ubuntu and having a problem or setting up sending email from localhost, you can use Msmtp. In this article I go through how to install msmtp and create some hml and php files to test it. Furthermore I will explain how to set up email config for BackendPro which [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-send-email-from-your-own-localhost/' rel='bookmark' title='How to send email from your own localhost'>How to send email from your own localhost</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter'>Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fsending-email-from-localhost-using-msmtp-with-gmail%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fsending-email-from-localhost-using-msmtp-with-gmail%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2011/03/icon_128.png" alt="" title="icon_128" width="128" height="128" class="alignleft size-full wp-image-2688" />If you are using Ubuntu and having a problem or setting up sending email from localhost, you can use Msmtp. In this article I go through how to install msmtp and create some hml and php files to test it. Furthermore I will explain how to set up email config for BackendPro which is a control panel for CodeIgniter.<br />
You will see how easy to set it up.</p>
<div class="clearboth">&nbsp;</div>
<p><span id="more-2683"></span></p>
<p>Credit goes to <a href="http://www.absolutelytech.com/2010/07/17/howto-configure-msmtp-to-work-with-gmail-on-linux/">this</a> and <a href="http://www.absolutelytech.com/2010/07/18/howto-send-emailsusing-mail-function-from-localhost-in-php-through-msmtp-using-gmail-account-on-linux/">this article</a>.</p>
<p>Install msmtp and ca-certificates for use with SSL:</p>
<pre class="brush: php; title: ; notranslate">
sudo apt-get install msmtp ca-certificates
</pre>
<p>Open msmtprc to edit.<br />
If you don&#8217;t know where msmtprc, then use &#8216;which msmtprc&#8217; in terminal</p>
<pre class="brush: php; title: ; notranslate">
sudo gedit /etc/msmtprc
</pre>
<p>Add the followings to this file.</p>
<pre class="brush: php; title: ; notranslate">
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
port 587
auth on
user username(at)gmail.com
password mypass
from username(at)gmail.com
logfile /var/log/msmtp.log
</pre>
<p>Change username(at) with your username and mypass with your password for gmail.</p>
<p>Change file permission.</p>
<pre class="brush: php; title: ; notranslate">
sudo chmod 0644 /etc/msmtprc
</pre>
<p>Open php.ini to edit</p>
<pre class="brush: php; title: ; notranslate">
sudo gedit /etc/php5/apache2/php.ini
</pre>
<p>Uncomment &#8216;sendmail_path&#8217; and add this.</p>
<pre class="brush: php; title: ; notranslate">
sendmail_path = '/usr/bin/msmtp -t'
</pre>
<p>Restart apache</p>
<pre class="brush: php; title: ; notranslate">
sudo /etc/init.d/apache2 restart
</pre>
<h3>Testing</h3>
<p>Then test with the following code.</p>
<p>Method 1<br />
Create /var/www/mail.htm</p>
<pre class="brush: php; title: ; notranslate">
&lt;form method=&quot;post&quot; action=&quot;sendmail.php&quot;&gt;
Email: &lt;input name=&quot;email&quot; type=&quot;text&quot; /&gt;&lt;br /&gt;
Message:&lt;br /&gt;
&lt;textarea name=&quot;message&quot; rows=&quot;15&quot; cols=&quot;40&quot;&gt;
&lt;/textarea&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>And  /var/www/sendmail.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( &quot;youremail(at)gmail.com&quot;, &quot;Feedback Form Results&quot;,
$message, &quot;From: $email&quot; );
header( &quot;SUBJECTHERE&quot; );
?&gt;
</pre>
<p>Change youremail(at)gmail.com to whatever you like. Then go to http://localhost/mail.htm to fill up the form.</p>
<p>Method 2</p>
<p>Create /var/www/mail1.php and add this.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
if ( mail ( 'youremail(at)gmail.com', 'Test mail from localhost', 'Working Fine.' ) ){
echo 'Mail sent';
}
else{
echo 'Error. Please check error log.';
}
?&gt;
</pre>
<p>Change youremail(at)gmail.com to your email for receiving this email. And visit http://localhost/mail1.php to send email.</p>
<h3>BackendPr0</h3>
<p>If you are using <a href="http://www.okadadesign.no/blog/downloads/">any BackendPro applications</a> then login to the backend and go to System>Settings>Email configuration. Change &#8216;Sendmail path&#8217; feild to /usr/bin/msmtp -t and &#8216;Email&#8217; to Sendmail from a dropdown.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-send-email-from-your-own-localhost/' rel='bookmark' title='How to send email from your own localhost'>How to send email from your own localhost</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter'>Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter</title>
		<link>http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/</link>
		<comments>http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 21:10:15 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[VM Virtualbox]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2674</guid>
		<description><![CDATA[ <p>Following up from the previous Aha moment post, this is Aha moment 2 and I am accessing localhost on Ubuntu from Windows 7 in VM Virtualbox. I have VM Virtualbox on Ubuntu 10.10 and I installed Windows 7 in this virtualbox. If I tried to access localhost on Ubuntu from a browser in [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter'>Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/ubuntu/tips-for-ubuntu-10-04/' rel='bookmark' title='Tips for Ubuntu 10.04'>Tips for Ubuntu 10.04</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/' rel='bookmark' title='Sending email from localhost using MSMTP with gmail'>Sending email from localhost using MSMTP with gmail</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fwindows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fwindows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2011/02/icon_128.png" alt="" title="icon_128" width="128" height="128" class="alignleft size-full wp-image-2681" />Following up from the previous Aha moment post, this is Aha moment 2 and I am accessing localhost on Ubuntu from Windows 7 in VM Virtualbox. I have VM Virtualbox on Ubuntu 10.10 and I installed Windows 7 in this virtualbox. If I tried to access localhost on Ubuntu from a browser in Windows 7, I get an error. So this is how to access it.</p>
<p>The first thing to check is Ubuntu side. Open if you have nothing in /etc/apache2/httpd.conf. If you have any virtual host you need to delete them and restart the apache. If it is clear, then on terminal type ifconfig to check your inet addr.</p>
<p>Mine is following.</p>
<div class="clearboth">&nbsp;</div>
<pre>
<div class="codesnip-container" >eth0  ...
	...
	...

lo	...
	...
	...
wlan0		...
		inet addr:192.168.1.2 Bcast ....</div>
</pre>
<p>Find inet addr. Mine is 192.168.1.2.</p>
<p>Start your VM Virtualbox and Windows 7. Open your browser and type http://192.168.1.2/mysite/.</p>
<p>If your web app is on CodeIgniter, then open system>application>config>config.php and change the following.</p>
<pre class="brush: php; title: ; notranslate">
$config['base_url']	= &quot;http://192.168.1.2/mysite/&quot;;
</pre>
<p>And it should show your website from localhost on Ubuntu.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter'>Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/ubuntu/tips-for-ubuntu-10-04/' rel='bookmark' title='Tips for Ubuntu 10.04'>Tips for Ubuntu 10.04</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/' rel='bookmark' title='Sending email from localhost using MSMTP with gmail'>Sending email from localhost using MSMTP with gmail</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter</title>
		<link>http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/</link>
		<comments>http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 12:48:05 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows XP]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2670</guid>
		<description><![CDATA[ <p>Well I had a aha moment today, so I thought I should share this. I know that the title is a bit confusing. </p> <p>There are times still I have to use Windows. And there are times when you have to develop for IE7. My set up for this is using IE 7 [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter'>Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/path-problems-with-codeigniter-on-windows/' rel='bookmark' title='Path problems with Codeigniter on Windows'>Path problems with Codeigniter on Windows</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-send-email-from-your-own-localhost/' rel='bookmark' title='How to send email from your own localhost'>How to send email from your own localhost</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fwindows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fwindows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2011/02/icon_1281.png" alt="" title="icon_128" width="128" height="128" class="alignleft size-full wp-image-2695" />Well I had a aha moment today, so I thought I should share this. I know that the title is a bit confusing. </p>
<p>There are times still I have to use Windows. And there are times when you have to develop for IE7. My set up for this is using IE 7 on Windows XP which is installed in VMware running on Windows 7. Well I could do it on Ubuntu as well. And I use XAMPP on Windows 7 for development.</p>
<h3>Use IPv4 Address value</h3>
<p>I had a hard time to display localhost on IE 7. When I use http://localhost/mywebsite, it works fine in my browsers on Windows 7, but it did not display in browsers in Windows XP. In a short answer, use http://192.168.1.2/. If this does not work for you, read on.</p>
<p>On Windows 7, go to Control panes > Network and Internet > Networking and Sharing center, then click your wireless connection or if you are using cable, then cable connection. Please note that it is not a VMware Adapters. When you open the Wireless Network Connection status, click Details. Find the vaule for IPv4 Address. For me it is 192.168.1.2. Use this in a browser in VMware to display a localhost from Windows 7.</p>
<h3>Using CodeIgniter?</h3>
<p>If you are using CodeIgniter, then you need to do one more step. Open your system>application>config>config.php and add the following to your base_url.</p>
<pre class="brush: php; title: ; notranslate">
$config['base_url']	= &quot;http://192.168.1.2/mywebsite/&quot;;
</pre>
<p>Without this line, all the internal links, images, CSS and scripts are broken. Adding this will fix the problems.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/web-development/windows-in-vm-virtualbox-on-ubuntu-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter'>Windows in VM Virtualbox on Ubuntu, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/path-problems-with-codeigniter-on-windows/' rel='bookmark' title='Path problems with Codeigniter on Windows'>Path problems with Codeigniter on Windows</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-send-email-from-your-own-localhost/' rel='bookmark' title='How to send email from your own localhost'>How to send email from your own localhost</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework on Codeigniter: Youtube</title>
		<link>http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/</link>
		<comments>http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 22:28:47 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[youtube]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=452</guid>
		<description><![CDATA[ <p> This post is about how to use Zend Framework on Codeigniter to show Youtube videos. </p> Download Note: <p>The download file is set up for Windows. If you are not using Windows, then open application/helpers/zend_framework_helper.php and comment out Windows part and uncomment the other part.</p> &#60;?php // For Windows ini_set(&#34;include_path&#34;, ini_get(&#34;include_path&#34;).PATH_SEPARATOR.str_replace(&#34;/&#34;, &#34;\\&#34;, [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-youtube-class-on-codeigniter-with-jquery/' rel='bookmark' title='Zend framework Youtube class on Codeigniter with jquery'>Zend framework Youtube class on Codeigniter with jquery</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/' rel='bookmark' title='How to implement Zend Framework with Codeigniter'>How to implement Zend Framework with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/zend-framework/zend-framework-flickr-class-on-codeignier-with-jquery/' rel='bookmark' title='Zend framework Flickr class on Codeignier with jquery'>Zend framework Flickr class on Codeignier with jquery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fzend-framework-on-codeigniter-youtube%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fzend-framework-on-codeigniter-youtube%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignleft size-full wp-image-466" title="youtube3" src="http://www.okadadesign.no/blog/wp-content/uploads/2009/11/youtube3.jpg" alt="youtube3" width="420" height="413" /><br />
This post is about how to use Zend Framework on Codeigniter to show Youtube videos.<br />
<span id="more-452"></span></p>
<div class="clearboth"></div>
<h4 class="download"><a href="http://www.box.net/shared/0cxtrq8apq">Download</a></h4>
<h5>Note:</h5>
<p>The download file is set up for Windows. If you are not using Windows, then open application/helpers/zend_framework_helper.php and comment out Windows part and uncomment the other part.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// For Windows
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).PATH_SEPARATOR.str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).&quot;contrib\\&quot;);
require_once ('Zend/Loader.php');

// For Non-Windows
/*
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).PATH_SEPARATOR.BASEPATH.&quot;/contrib/&quot;);
require_once 'Zend/Loader.php';
*/

?&gt;
</pre>
<h3>Implement Zend Framework in Codeigniter</h3>
<p>First you have to implement Zend Framework in Codeigniter. <a href="http://www.okadadesign.no/blog/?p=410">Please read this post</a>.</p>
<h3>Controller/youtube2.php</h3>
<p>Create a file and add the following code.<br />
<!--more--></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Youtube2 extends Controller{
    protected $_youTube;

function __construct() {
    parent::Controller();
    Zend_Loader::loadClass('Zend_Gdata_YouTube');
    $this-&gt;_youTube = new Zend_Gdata_YouTube;
    }

function index(){
      // Gets playlists
    $data['playlistfeed']= $this-&gt;_youTube-&gt;getPlaylistListFeed('NationalGeographic');
    $this-&gt;load-&gt;view ('youtube_view2',$data);
    }

public function listAction(){
    // Gets playlist videos
    $playlistId = $this-&gt;uri-&gt;segment(4);
    $query = $this-&gt;_youTube-&gt;newVideoQuery(
    'http://gdata.youtube.com/feeds/playlists/' . $playlistId);
    $data['videoFeed']= $this-&gt;_youTube-&gt;getVideoFeed($query);
    $this-&gt;load-&gt;view('listaction_view', $data);
    }

public function viewAction(){
    // Gets video
    $videoId = $this-&gt;uri-&gt;segment(4);
    $data['videoId'] = $this-&gt;uri-&gt;segment(4);
    $data['videoEntry'] = $this-&gt;_youTube-&gt;getVideoEntry($videoId);
    $this-&gt;load-&gt;view('youtube_video_view', $data);
    }
}
</pre>
<p>Firstly I am adding a protected variable $_youTube.<br />
In the constructor, I load the class Zend_Gdata_Youtube, and create a new object.</p>
<p>In the function index, I add a variable playlistfeed and send it to a view called youtube_view2 which I am going to create it shortly.</p>
<p>I am going to collect National geographic videos in this case. You can change it as you wish.</p>
<h3>views/youtube_view2.php</h3>
<p>Create a file and add the following code.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Video lists&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;National Geographic Videos on Youtube&lt;/h1&gt;
&lt;dl&gt;
&lt;?php foreach ($playlistfeed as $playlistEntry): &gt;
&lt;?php $id = substr(strrchr(
$playlistEntry-&gt;getPlaylistVideoFeedUrl(), '/'
), 1); &gt;
&lt;dt&gt;
&lt;a href=&quot;youtube2/listAction/id/&lt;?php echo $id; &gt;/&quot;&gt;
&lt;?php echo $playlistEntry-&gt;title-&gt;text; &gt;
&lt;/a&gt;
&lt;/dt&gt;
&lt;dd&gt;&lt;?php echo $playlistEntry-&gt;description-&gt;text; &gt;&lt;/dd&gt;
&lt;?php endforeach; &gt;
&lt;/dl&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This will output the following html.</p>
<pre class="brush: xml; title: ; notranslate">
...
&lt;h1&gt;National Geographic Videos on Youtube&lt;/h1&gt;
&lt;dl&gt;
&lt;dt&gt;
&lt;a href=&quot;youtube2/listAction/id/746AD498C993B957/&quot;&gt;
Oceans&lt;/a&gt;

&lt;/dt&gt;
&lt;dd&gt;Explore the beauty of the world's oceans.&lt;/dd&gt;
&lt;dt&gt;
&lt;a href=&quot;youtube2/listAction/id/355D512277EFFA06/&quot;&gt;
Animal Attack!&lt;/a&gt;
&lt;/dt&gt;
...
...
</pre>
<p>When you click a link, it will take you listAction() function in youtube2 class and the fourth segment will be used as id in that class.<br />
<img class="alignleft size-full wp-image-464" title="youtube1" src="http://www.okadadesign.no/blog/wp-content/uploads/2009/11/youtube1.jpg" alt="youtube1" width="420" height="374" /></p>
<div class="clearboth"></div>
<h3>views/listaction_view.php</h3>
<p>Create a file and add the following code.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Youtube Video Details&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;National Geographic Videos on Youtube. Videos about &lt;?php echo $videoFeed-&gt;title-&gt;text; &gt;&lt;/h1&gt;
&lt;dl&gt;
&lt;?php foreach ($videoFeed as $videoEntry): &gt;
&lt;?php $id = substr(strrchr($videoEntry-&gt;getFlashPlayerUrl(), '/'),
1); &gt;

&lt;dt&gt;
    &lt;h2&gt;
        &lt;?php echo &quot;Video Title: &quot;. $videoEntry-&gt;mediaGroup-&gt;title-&gt;text; &gt;

&lt;/h2&gt;
   &lt;h3&gt; &lt;?php echo anchor(&quot;youtube2/viewAction/id/$id/&quot;,&quot;Watch Video&quot;);&gt;
&lt;/h3&gt;

&lt;/dt&gt;
&lt;dd&gt;&lt;?php echo $videoEntry-&gt;mediaGroup-&gt;description-&gt;text. &quot;&lt;br /&gt;&lt;br /&gt;&quot;; &gt;
&lt;b&gt;&lt;?php echo &quot;Video id: &quot;. $id; &gt;
&lt;/b&gt;
&lt;/dd&gt;
&lt;?php endforeach; &gt;
&lt;/dl&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This listAction() function outputs the following html.</p>
<pre class="brush: xml; title: ; notranslate">
...
&lt;h1&gt;National Geographic Videos on Youtube. Videos about Oceans&lt;/h1&gt;
&lt;dl&gt;

&lt;dt&gt;
    &lt;h2&gt;
        Video Title: Feeding Frenzy: Manta Rays in the Maldives
&lt;/h2&gt;
   &lt;h3&gt; &lt;a href=&quot;http://127.0.0.1/ci_zend/index.php/youtube2/viewAction/id/yihoIvUBDM4?f=playlists&amp;amp;amp;app=youtube_gdata&quot;&gt;Watch Video&lt;/a&gt;&lt;/h3&gt;

&lt;/dt&gt;
&lt;dd&gt;When tide and current turn a tiny bay into a bowl of plankton, manta rays in the Maldives gather for a roiling, whirling feast.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Video id: yihoIvUBDM4?f=playlists&amp;amp;amp;app=youtube_gdata&lt;/b&gt;
&lt;/dd&gt;

&lt;dt&gt;
    &lt;h2&gt;
        Video Title: Penguins vs. Pelicans
&lt;/h2&gt;
   &lt;h3&gt; &lt;a href=&quot;http://127.0.0.1/ci_zend/index.php/youtube2/viewAction/id/Fhmm-A8wBzk?f=playlists&amp;amp;amp;app=youtube_gdata&quot;&gt;Watch Video&lt;/a&gt;&lt;/h3&gt;

&lt;/dt&gt;
...
...
</pre>
<p>The links will take you to youtube2 viewAction () function with Youtube video identifier.<br />
The viewAction() function will take the forth segment and show a video in the next step.</p>
<p><img class="alignleft size-full wp-image-465" title="youtube2" src="http://www.okadadesign.no/blog/wp-content/uploads/2009/11/youtube2.jpg" alt="youtube2" width="420" height="420" /></p>
<div class="clearboth"></div>
<h3>views/youtube_video_view.php</h3>
<p>Create a file and add the following code.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Watch: Youtube Videos&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;&lt;?php echo $videoEntry-&gt;mediaGroup-&gt;title-&gt;text; &gt;&lt;/h1&gt;
&lt;object width=&quot;425&quot; height=&quot;355&quot;&gt;
&lt;param name=&quot;movie&quot;
value=&quot;http://www.youtube.com/v/&lt;?php echo $videoId; &gt;&amp;amp;amp;rel=0&quot;&gt;
&lt;/param&gt;
&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;
&lt;embed src=&quot;http://www.youtube.com/v/&lt;?php echo $videoId; &gt;&amp;amp;amp;rel=0&quot;
type=&quot;application/x-shockwave-flash&quot;
wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;355&quot;&gt;
&lt;/embed&gt;
&lt;/object&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This view outputs the following html.</p>
<pre class="brush: xml; title: ; notranslate">
...
&lt;h1&gt;Feeding Frenzy: Manta Rays in the Maldives&lt;/h1&gt;
&lt;object width=&quot;425&quot; height=&quot;355&quot;&gt;
&lt;param name=&quot;movie&quot;
value=&quot;http://www.youtube.com/v/yihoIvUBDM4&amp;amp;amp;rel=0&quot;&gt;
&lt;/param&gt;
&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;
&lt;embed src=&quot;http://www.youtube.com/v/yihoIvUBDM4&amp;amp;amp;rel=0&quot;
type=&quot;application/x-shockwave-flash&quot;
wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;355&quot;&gt;
&lt;/embed&gt;
&lt;/object&gt;
...
...
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-youtube-class-on-codeigniter-with-jquery/' rel='bookmark' title='Zend framework Youtube class on Codeigniter with jquery'>Zend framework Youtube class on Codeigniter with jquery</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/' rel='bookmark' title='How to implement Zend Framework with Codeigniter'>How to implement Zend Framework with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/zend-framework/zend-framework-flickr-class-on-codeignier-with-jquery/' rel='bookmark' title='Zend framework Flickr class on Codeignier with jquery'>Zend framework Flickr class on Codeignier with jquery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to implement Zend Framework with Codeigniter</title>
		<link>http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/</link>
		<comments>http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 12:14:58 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=410</guid>
		<description><![CDATA[ Download Files <p>There are quite few posts how to use Zend framework in Codeigniter.</p> Beyond Coding Freakauth Phil&#8217;s post <p>However none of them worked on my XAMPP. I thought there might be some who are struggling to use Zend frame work on Windows. Here is how I did.</p> <p>Here you can read why [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-youtube-class-on-codeigniter-with-jquery/' rel='bookmark' title='Zend framework Youtube class on Codeigniter with jquery'>Zend framework Youtube class on Codeigniter with jquery</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/' rel='bookmark' title='Zend Framework on Codeigniter: Youtube'>Zend Framework on Codeigniter: Youtube</a></li>
<li><a href='http://www.okadadesign.no/blog/zend-framework/zend-framework-flickr-class-on-codeignier-with-jquery/' rel='bookmark' title='Zend framework Flickr class on Codeignier with jquery'>Zend framework Flickr class on Codeignier with jquery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fhow-to-implement-zend-framework-with-codeigniter-on-windows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fhow-to-implement-zend-framework-with-codeigniter-on-windows%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h4 class="download">
<a href="http://www.box.net/shared/0cxtrq8apq">Download Files</a></h4>
<p>There are quite few posts how to use Zend framework in Codeigniter.</p>
<ol>
<li>
<a href="http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/">Beyond Coding</a>
</li>
<li><a href="http://freakauth.4webby.com/tutorials/using-zend-framework-components-in-code-igniter">Freakauth</a>
</li>
<li><a href="http://www.mynameisphil.net/article/may/2009/implementing-the-zend-framework-with-codeigniter/11">Phil&#8217;s post</a></li>
</ol>
<p>However none of them worked on my XAMPP. I thought there might be some who are struggling to use Zend frame work on Windows. Here is how I did.</p>
<p><a href="http://www.okadadesign.no/blog/?p=414">Here you can read</a> why they don&#8217;t work with Windows.</p>
<h3>Adding Zend Framework</h3>
<p><a href="http://www.mynameisphil.net/article/may/2009/implementing-the-zend-framework-with-codeigniter/11">Here you can read</a> how to add Zend Framework. And I use this structure for this post.</p>
<p>You need to create a folder ../system/contrib/ and add Zend folders in this folder.</p>
<pre>
<div class="codesnip-container" >../system/
         contrib/
               Zend/
                     Acl/
                     Acl.php
                     Amf/
                     Amf.php ...</div>
</pre>
<p>Create a file system/application/helpers/zend_framework_helper.php and add the following.<br />
<span id="more-410"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).PATH_SEPARATOR.str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).&quot;contrib\\&quot;);
require_once ('Zend/Loader.php');
?&gt;
</pre>
<p>If you are not using Windows, then add the following instead.</p>
<pre class="brush: php; title: ; notranslate">
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).PATH_SEPARATOR.BASEPATH.&quot;/contrib/&quot;);
require_once 'Zend/Loader.php';
</pre>
<h3>Adding it in autoload.php</h3>
<p>Open config/autoload.php and add the following.</p>
<pre class="brush: php; title: ; notranslate">
$autoload['helper'] = array('zend_framework');
</pre>
<h3>Using Zend in Codeigniter</h3>
<p>Now you can load any Zend class by adding Zend_Loader::loadClass(&#8216;ZEND-CLASS-HERE&#8217;);.<br />
You can see all the Zend classes here. <a href="http://framework.zend.com/manual/en/">http://framework.zend.com/manual/en/</a></p>
<p>Here are three examples.</p>
<h4>Zend_Service_Flickr</h4>
<p>Create a file controllers/flickr.php and add the following.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Flickr extends Controller
{
function __construct()
{
parent::Controller();

}

function index()
{

Zend_Loader::loadClass('Zend_Service_Flickr');

$flickr = new Zend_Service_Flickr('ADD-YOUR-KEY-HERE');
try
{

$results = $flickr-&gt;tagSearch(&quot;cat&quot;);
if ($results-&gt;totalResults() &gt; 0)
{

foreach ($results as $result)
{
echo '&lt;img src=&quot;'.$result-&gt;Square-&gt;uri.'&quot; /&gt;';
}

}
else
{
echo '&lt;p style=&quot;color: orange; font-weight: bold&quot;&gt;No Results Found.&lt;/p&gt;';
}
}
catch (Zend_Service_Exception $e)
{
echo '&lt;p style=&quot;color: red; font-weight: bold&quot;&gt;An error occured, please try again later. (' .$e-&gt;getMessage(). ')&lt;/p&gt;';
}

}
}

?&gt;
</pre>
<p>Don&#8217;t forget to change ADD-YOUR-KEY-HERE to your Flickr key.<br />
If you don&#8217;t have one, <a href="http://www.flickr.com/services/api/misc.api_keys.html">get it from here</a>.<br />
Then visit your controller, http://127.0.0.1/codeigniter/index.php/flickr to see the result.</p>
<h4>Using Zend_Gdata_YouTube</h4>
<p>Create another file controllers/youtube.php and add the following.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Youtube extends Controller
{
function __construct()
{
parent::Controller();

}

function index()
{

    Zend_Loader::loadClass('Zend_Gdata_YouTube');
    $youtube = new Zend_Gdata_YouTube();
    $query = $youtube-&gt;newVideoQuery();
    $query-&gt;videoQuery = 'cat';
    $query-&gt;startIndex = 10;
    $query-&gt;maxResults = 20;
    $query-&gt;orderBy = 'viewCount';

    $data['queryurl'] =  $query-&gt;queryUrl;
    $data['videofeed'] =  $youtube-&gt;getVideoFeed($query);
    $this-&gt;load-&gt;view('youtube_view', $data);
  }
}

?&gt;
</pre>
<h5>views/youtube_view.php</h5>
<p>Create this file and add the following.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

foreach ($videofeed as $videoEntry) {
    echo &quot;---------VIDEO----------&lt;br /&gt;&quot;;
    echo &quot;Title: &quot; . $videoEntry-&gt;getVideoTitle() . &quot;&lt;br /&gt;&quot;;
    echo &quot;\nDescription:&lt;br /&gt;&quot;;
    echo $videoEntry-&gt;getVideoDescription();
    echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
}
?&gt;
</pre>
<p>Then visit a new page http://127.0.0.1/codeigniter/index.php/youtube to the result.</p>
<h4>Using Google calendar</h4>
<p>Create controller/googlecalendar.php and add the following. Use your google email and password.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Googlecalendar extends Controller
{
function __construct()
{
parent::Controller();

}

function index()
{
    Zend_Loader::loadClass('Zend_Gdata_Calendar');
     Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    // Parameters for ClientAuth authentication

$user = &quot;YOUR gmail HERE&quot;;
$pass = &quot;YOUR PASS&quot;;

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);

try {
    $listFeed= $service-&gt;getCalendarListFeed();
} catch (Zend_Gdata_App_Exception $e) {
    echo &quot;Error: &quot; . $e-&gt;getMessage();
}
echo &quot;&lt;h1&gt;Calendar List Feed&lt;/h1&gt;&quot;;
echo &quot;&lt;ul&gt;&quot;;
foreach ($listFeed as $calendar) {
    echo &quot;&lt;li&gt;&quot; . $calendar-&gt;title .
         &quot; (Event Feed: &quot; . $calendar-&gt;id . &quot;)&lt;/li&gt;&quot;;
}
echo &quot;&lt;/ul&gt;&quot;;
}
}
?&gt;
</pre>
<p>Then again visit http://127.0.0.1/codeigniter/googlecalendar.</p>
<h4 class="download">
<a href="http://www.box.net/shared/0cxtrq8apq">Download Files</a></h4>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-youtube-class-on-codeigniter-with-jquery/' rel='bookmark' title='Zend framework Youtube class on Codeigniter with jquery'>Zend framework Youtube class on Codeigniter with jquery</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/' rel='bookmark' title='Zend Framework on Codeigniter: Youtube'>Zend Framework on Codeigniter: Youtube</a></li>
<li><a href='http://www.okadadesign.no/blog/zend-framework/zend-framework-flickr-class-on-codeignier-with-jquery/' rel='bookmark' title='Zend framework Flickr class on Codeignier with jquery'>Zend framework Flickr class on Codeignier with jquery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Path problems with Codeigniter on Windows</title>
		<link>http://www.okadadesign.no/blog/xampp/path-problems-with-codeigniter-on-windows/</link>
		<comments>http://www.okadadesign.no/blog/xampp/path-problems-with-codeigniter-on-windows/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 11:53:12 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=414</guid>
		<description><![CDATA[ <p>I posted how to implement Zend Framework here. However I had a problem with Window&#8217;s path when I was trying it.</p> <p>I have found a couple of things about paths in Windows when I am using Codeigniter. As all know that Windows uses \ for the path. For example, C:\xampp\htdocs\codeigniter\system\contrib. Linux uses / [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/' rel='bookmark' title='How to implement Zend Framework with Codeigniter'>How to implement Zend Framework with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter'>Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/' rel='bookmark' title='Zend Framework on Codeigniter: Youtube'>Zend Framework on Codeigniter: Youtube</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fpath-problems-with-codeigniter-on-windows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fxampp%2Fpath-problems-with-codeigniter-on-windows%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I posted <a href="http://www.okadadesign.no/blog/?p=410">how to implement Zend Framework here</a>. However I had a problem with Window&#8217;s path when I was trying it.</p>
<p>I have found a couple of things about paths in Windows when I am using Codeigniter.<br />
As all know that Windows uses \ for the path. For example, C:\xampp\htdocs\codeigniter\system\contrib. Linux uses / for the path. For example, /home/1/o/mywebsite/www/codeigniter/system/.</p>
<p>If you are using XAMPP or WAMP for your web development, you might have a problem with this difference.<br />
<span id="more-414"></span></p>
<h3>BASEPATH in Codeigniter</h3>
<p>Enter the following to view/welcome_message.php in your freshly installed Codeigniter. </p>
<pre class="brush: php; title: ; notranslate">
echo 'Basepath: ' . BASEPATH . '&lt;br /&gt;';
</pre>
<p>And visit http://127.0.0.7/codeigniter/index.php/welcome.<br />
You will see the following.</p>
<pre class="brush: xml; title: ; notranslate">
1. Basepath: C:\xampp\htdocs\codeigniter/system/
</pre>
<p>Did you notice \codeigniter/?</p>
<p>In practical situation, you would add the following for your live server(Linux).</p>
<pre class="brush: php; title: ; notranslate">
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).
PATH_SEPARATOR.BASEPATH.&quot;/contrib/&quot;);
</pre>
<p>However this will not work on your Windows.<br />
You need to use the following instead.</p>
<pre class="brush: php; title: ; notranslate">
ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).
PATH_SEPARATOR.str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).&quot;contrib\\&quot;);
</pre>
<p>str_replace() function will replace / in BASEPATH with \.</p>
<p>If you want to see some of your paths in Codeigniter, add the following in your view/welcome_message.php and see the results.</p>
<pre class="brush: php; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome to CodeIgniter&lt;/title&gt;

&lt;style type=&quot;text/css&quot;&gt;

body {
 background-color: #fff;
 margin: 40px;
 font-family: Lucida Grande, Verdana, Sans-serif;
 font-size: 14px;
 color: #4F5155;
}

a {
 color: #003399;
 background-color: transparent;
 font-weight: normal;
}

h1 {
 color: #444;
 background-color: transparent;
 border-bottom: 1px solid #D0D0D0;
 font-size: 16px;
 font-weight: bold;
 margin: 24px 0 2px 0;
 padding: 5px 0 6px 0;
}

code {
 font-family: Monaco, Verdana, Sans-serif;
 font-size: 12px;
 background-color: #f9f9f9;
 border: 1px solid #D0D0D0;
 color: #002166;
 display: block;
 margin: 14px 0 14px 0;
 padding: 12px 10px 12px 10px;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;When you are using set_include_path(), before get_include_path(), it will add one semi-colon, after get_include_path.&lt;/h2&gt;
&lt;?php
$src_name= 'kame.png';
echo 'PART 1&lt;br /&gt;';
&gt;
&lt;?=
'1. Basepath: ' . BASEPATH . '&lt;br /&gt;'.
'2. Apppath: ' . APPPATH . '&lt;br /&gt;'.
'3. Ext: ' . EXT . '&lt;br /&gt;' .
'4. Fcpath: ' . FCPATH .'&lt;br /&gt;' .
'5. Self: ' . SELF .'&lt;br /&gt;' .
// '6. base_url(): ' . base_url() . '&lt;br /&gt;'.
'7. site_url(): ' . site_url(). '&lt;br /&gt;'.
'8. current_url(): ' . current_url(). '&lt;br /&gt;'.
'9. uri_string(): ' . uri_string(). '&lt;br /&gt;'.
'10. index_page(): ' . index_page(). '&lt;br /&gt;'.
'11. realpath(__FILE__): ' . realpath(__FILE__). '&lt;br /&gt;'.
'12. realpath(dirname(__FILE__)): ' . realpath(dirname(__FILE__)). '&lt;br /&gt;'.
'13. realpath(dirname(__FILE__))/: '. realpath(dirname(__FILE__)).'/'.'&lt;br /&gt;'.
'14. str_replace(&quot;\\&quot;, &quot;/&quot;, realpath(dirname(__FILE__))): '. str_replace(&quot;\\&quot;, &quot;/&quot;, realpath(dirname(__FILE__))).'&lt;br /&gt;'.
'14a. str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH): '. str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).'&lt;br /&gt;'.
'15. getcwd(), current working directory: '. getcwd(). '&lt;br /&gt;'.
'16. PATH_SEPARATOR: ' . PATH_SEPARATOR. '&lt;br /&gt;'.
'17. basename($src_name,\'.png\')): ' . basename($src_name,'.png'). '&lt;br /&gt;'.
'18. ini_get(\'include_path\') . PATH_SEPARATOR . APPPATH . \'libraries\': ' . ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries' . '&lt;br /&gt;'.
'19. get_include_path() :'. get_include_path().PATH_SEPARATOR.'&lt;br /&gt;' ;

&gt;
&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 2&lt;br /&gt;&lt;br /&gt;';
echo '1. dirname(dirname(__FILE__));'.dirname(dirname(__FILE__)).'&lt;br /&gt;';
echo '2. ini_get(\'include_path\') . PATH_SEPARATOR . str_replace(&quot;/&quot;, &quot;\\&quot;, APPPATH) . \'libraries\': ' . ini_get('include_path') . PATH_SEPARATOR . str_replace(&quot;/&quot;, &quot;\\&quot;, APPPATH) . 'libraries' . '&lt;br /&gt;';
echo '3. set_include_path(get_include_path() . PATH_SEPARATOR . :'. set_include_path(get_include_path() . PATH_SEPARATOR) .'&lt;br /&gt;';
echo '4. ini_get(\'include_path\'): ' . ini_get('include_path') . '&lt;br /&gt;';
echo '5. PATH_SEPARATOR . APPPATH . \'libraries\': ' .  PATH_SEPARATOR . APPPATH . 'libraries' . '&lt;br /&gt;'
// 'realpath($_SERVER['DOCUMENT_ROOT']): ' . realpath($_SERVER['DOCUMENT_ROOT']).'&lt;br /&gt;';

&gt;

&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 3&lt;br /&gt;&lt;br /&gt;';
echo '1. $_SERVER[\'DOCUMENT_ROOT\']: '. $_SERVER['DOCUMENT_ROOT'];
echo &quot;&lt;br /&gt;&quot;;
$base_url = '\\img\\';
$src_name = 'photo.png';
$base_path = realpath(&quot;photo.png&quot;);

echo '$base_url(): ';
echo &quot;$base_url () &lt;br /&gt;&quot;;
echo 'realpath(\'./img/\'): ';
echo &quot;&lt;br /&gt;&quot;;
echo realpath('./img/') ;
echo &quot;&lt;br /&gt;&quot;;
echo '$src_name: ';
echo &quot;$src_name&quot;;
echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
echo '$_SERVER[\'DOCUMENT_ROOT\']: ';
echo  $_SERVER['DOCUMENT_ROOT'];
echo &quot;&lt;br /&gt;&quot;;
echo 'realpath($_SERVER[\'DOCUMENT_ROOT\']): ';
echo realpath($_SERVER['DOCUMENT_ROOT']);
echo &quot;&lt;br /&gt;&quot;;
$base_path = realpath('./img/');//This will show C:\xampp\htdocs\ci_day6_working_copy\img

$src_name = 'photo.png';//source name
$source_image = realpath($base_path.'/'.$src_name);
echo '$source_image is: ' . $source_image;

 echo &quot;&lt;br /&gt;&quot;;
$realpathtoBasepath = realpath(BASEPATH.'fonts/texb.ttf');
echo $realpathtoBasepath;
&gt;

&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 4&lt;br /&gt;&lt;br /&gt;';
echo 'Here echoing $my_include_folder = realpath(dirname(__FILE__)).\'/assets/classes\';'.&quot;&lt;br /&gt;&quot;;
echo 'Here is the second line get_include_path() . PATH_SEPARATOR . $my_include_folder1;&lt;br /&gt;';
$my_include_folder1 = realpath(dirname(__FILE__)).'/assets/classes1';
echo get_include_path();
echo PATH_SEPARATOR;
echo '$my_include_folder1: '.$my_include_folder1. &quot;&lt;br /&gt;&quot;;
echo get_include_path() . PATH_SEPARATOR . $my_include_folder1;

&gt;

&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 5&lt;br /&gt;&lt;br /&gt;';
echo 'Here echoing $my_include_folder2 = realpath(dirname(__FILE__)).\'\\assets\\classes\';'.&quot;&lt;br /&gt;&quot;;
echo 'Here is the second line set_include_path(get_include_path() . PATH_SEPARATOR . $my_include_folder2);&lt;br /&gt;';
$my_include_folder2 = realpath(dirname(__FILE__)).'\\assets\\classes2';
echo get_include_path() . PATH_SEPARATOR . $my_include_folder2;

&gt;

&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 6&lt;br /&gt;&lt;br /&gt;';
echo 'Here echoing ini_set(&quot;include_path&quot;, ini_get(&quot;include_path&quot;).PATH_SEPARATOR.BASEPATH.&quot;/contrib/&quot;); '.&quot;&lt;br /&gt;&quot;;
echo ini_get(&quot;include_path&quot;).PATH_SEPARATOR.BASEPATH.&quot;/contrib/&quot;; 

&gt;
&lt;?php
echo '&lt;br /&gt;&lt;br /&gt;PART 7&lt;br /&gt;&lt;br /&gt;';
echo 'Here echoing ini_get(&quot;include_path&quot;).PATH_SEPARATOR.str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).&quot;\\contrib\\&quot;
'.&quot;&lt;br /&gt;&quot;;
echo ini_get(&quot;include_path&quot;).PATH_SEPARATOR.str_replace(&quot;/&quot;, &quot;\\&quot;, BASEPATH).&quot;contrib\\Zend\\Loader.php&quot;

&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/xampp/how-to-implement-zend-framework-with-codeigniter-on-windows/' rel='bookmark' title='How to implement Zend Framework with Codeigniter'>How to implement Zend Framework with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/windows-xp-in-vmware-on-windows-7-localhost-and-base-url-of-codeigniter/' rel='bookmark' title='Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter'>Windows XP in VMware on Windows 7, localhost and base url of CodeIgniter</a></li>
<li><a href='http://www.okadadesign.no/blog/xampp/zend-framework-on-codeigniter-youtube/' rel='bookmark' title='Zend Framework on Codeigniter: Youtube'>Zend Framework on Codeigniter: Youtube</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/xampp/path-problems-with-codeigniter-on-windows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Codeigniter shopping cart v1.0 code updates</title>
		<link>http://www.okadadesign.no/blog/web-development/codeigniter-shopping-cart/</link>
		<comments>http://www.okadadesign.no/blog/web-development/codeigniter-shopping-cart/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:08:48 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=402</guid>
		<description><![CDATA[ <p>I added the following article to Codeigniter wiki today</p> <p>You can find a newer version here.</p> Download Files Background and Credits <p>I learnt Codeigniter from a book &#8220;Professional Codeigniter&#8221; by Mr. Thomas Myer.</p> <p>I started learning PHP six months ago and read a couple of good books about PHP and I had basic [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-minor-updates/' rel='bookmark' title='Shopping cart v1.1 minor updates'>Shopping cart v1.1 minor updates</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-beta-updates/' rel='bookmark' title='Shopping Cart v1.1 Beta updates'>Shopping Cart v1.1 Beta updates</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fcodeigniter-shopping-cart%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fcodeigniter-shopping-cart%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I added the following article to <a href="http://codeigniter.com/wiki/Codeigniter_shopping_cart/">Codeigniter wiki</a> today</p>
<p><a href="http://www.okadadesign.no/blog/?p=665">You can find a newer version here.</a></p>
<h4 class="download"><a href="http://www.box.net/shared/8svdaaay28">Download Files</a></h4>
<h3>Background and Credits</h3>
<p>I learnt Codeigniter from a book <a href="http://www.amazon.com/Professional-CodeIgniter-Thomas-Myer/dp/0470282452/ref=sr_1_2?ie=UTF8&#038;s=books&#038;qid=1257891007&#038;sr=8-2">&#8220;Professional Codeigniter&#8221; by Mr. Thomas Myer.</a></p>
<p>I started learning PHP six months ago and read a couple of good books about PHP and I had basic knowledge but not practical experience of PHP.</p>
<p>Professional Codeigniter was delightful to read. I have learnt a lot from the book. I highly recommend the book if you are a beginner like me and want to learn CI in practical ways.</p>
<p>Especially I enjoyed it in three ways.<br />
1. There are some bugs which could not make it for the final edition. But I am glad that it did not make it. Because fixing these taught me more than I expected. I used the <a href="http://p2p.wrox.com/book-professional-codeigniter-isbn-978-0-470-28245-8-414/"> book forum</a>, CI forum and Stackoverflow to solve the problems.</p>
<p>2. Reading a book which teachs you how to create one applicatoin, in this case is shopping cart, is the best way for me to learn PHP and CI. </p>
<p>3. While I was reading the book, I wanted to change the application in my way. And this was again good learning for me.</p>
<p>I recommend the book and read through it to understand fully.      </p>
<p>I obtained <a href="http://p2p.wrox.com/book-professional-codeigniter-isbn-978-0-470-28245-8/74799-what-license-shopping-cart-sample-codes.html">a permission from the author</a> and I&#8217;d like to add my version of updated code here.<br />
<span id="more-402"></span></p>
<h3>Updates</h3>
<h4> Fixed ALL the bugs in front-end and back-end. (hopefully)</h4>
<p>As I stated it before the author&#8217;s final code did not make the printed edition. So there are some mistakes and typos. So I corrected as much as possible. I don&#8217;t say that it is complete, but nearly.</p>
<h4> Added captcha to newsletter subscribe.</h4>
<p>I wrote a small post <a href="http://www.okadadesign.no/blog/?p=384">here</a> about it.</p>
<h4>Added a contact page with captcha.</h4>
<h4>Updated to CI 1.7.2</h4>
<p>It seems the original code was developed with 1.6 or so. I updated to 1.7.2.</p>
<h4>Changed to jQuery</h4>
<p>Original code had Prototype for javascript. I migraged to jQuery.</p>
<h4>Added a nudge menu to the front-end</h4>
<p>Once I added jQuery, there are many menus I could add. However I just chose <a href="http://davidwalsh.name/dw-content/jquery-link-nudging.php">David Walsh&#8217;s nudge menu for the front sub-menu.</a></p>
<h4>Random feature products images have a link to product page</h4>
<p>There are random feature products on the right column. I added links to individual product pages.</p>
<h4>Changed admin/products to show more details including categor names</h4>
<p>Products page shows more details</p>
<h4>Search function does not pick up inactive products</h4>
<h4>Added table-sort function (jQuery) to all the backend pages</h4>
<p>This enables to sort in both ways, including show rows (10, 20, 30, etc) as well.<br />
I used <a href="http://datatables.net/index">jQuery Data tables</a> plugin for this.</p>
<h4>Scroll to top</h4>
<p><a href="http://www.okadadesign.no/blog/?p=48">Here is how.</a></p>
<h4>And more</h4>
<p>I changed other small items which I don&#8217;t remember.</p>
<h3>Original code</h3>
<p><a href="http://www.wrox.com/WileyCDA/Section/id-105001.html">Wrox.com</a></p>
<h4 class="download"><a href="http://www.box.net/shared/8svdaaay28">Download Files</a></h4>
<h3>Back-end</h3>
<p>http://127.0.0.1/codeigniter_shopping/index.php/welcome/verify</p>
<p>login name: admin<br />
password: admin</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-minor-updates/' rel='bookmark' title='Shopping cart v1.1 minor updates'>Shopping cart v1.1 minor updates</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-beta-updates/' rel='bookmark' title='Shopping Cart v1.1 Beta updates'>Shopping Cart v1.1 Beta updates</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/codeigniter-shopping-cart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Codeigniter captcha plug-in Part 2</title>
		<link>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/</link>
		<comments>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 17:22:07 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[captcha]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=384</guid>
		<description><![CDATA[ <p>DOWN LOAD In the previous post I wrote a basic method how to use captcha plug-in with Codeigniter. Today I am going to write a simple but practical newsletter subsciption page using captcha. We will use CI&#8217;s form_validation class.</p> ci_captcha <p>Please read the previous post to customize it. You need to create a [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-use-codeigniter-captcha-plug-in/' rel='bookmark' title='How to use Codeigniter captcha plug-in Part 1'>How to use Codeigniter captcha plug-in Part 1</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fhow-to-use-codeigniter-captcha-plug-in-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fhow-to-use-codeigniter-captcha-plug-in-part-2%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.box.net/shared/s7r1q5fqll">DOWN LOAD</a><br />
<a href="http://www.okadadesign.no/blog/?p=276">In the previous post</a> I wrote a basic method how to use captcha plug-in with Codeigniter.<br />
Today I am going to write a simple but practical newsletter subsciption page using captcha.<br />
We will use CI&#8217;s form_validation class.</p>
<h3>ci_captcha</h3>
<p>Please read the previous post to customize it.<br />
You need to create a folder called captcha as the same level as system.<br />
<span id="more-384"></span></p>
<h3>Database</h3>
<p>We need two tables, captcha and subscribers.</p>
<pre class="brush: php; title: ; notranslate">

CREATE TABLE IF NOT EXISTS `captcha` (
  `captcha_id` bigint(13) unsigned NOT NULL AUTO_INCREMENT,
  `captcha_time` int(10) unsigned NOT NULL,
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `word` varchar(20) NOT NULL,
  PRIMARY KEY (`captcha_id`),
  KEY `word` (`word`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

CREATE TABLE IF NOT EXISTS `subscribers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ;
</pre>
<h3>Config</h3>
<p>config/autoload.php</p>
<pre class="brush: php; title: ; notranslate">
$autoload['libraries'] = array('database', 'session');

$autoload['helper'] = array('url');
</pre>
<p>You can autoload library(form_validation) here as well.</p>
<h3>Model</h3>
<p>The code is from a Codeigniter book Professional CodeIgniter by Thomas Myer.</p>
<p>models/msubscribers.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class MSubscribers extends Model{

	function MSubscribers(){
		parent::Model();
	}

function getSubscriber($id){
    $this-&gt;db-&gt;where('id',$id);
    $this-&gt;db-&gt;limit(1);
    $Q = $this-&gt;db-&gt;getwhere('subscribers');
    if ($Q-&gt;num_rows() &gt; 0){
      $data = $Q-&gt;row_array();
    }

    $Q-&gt;free_result();
    return $data;
 }

 function getAllSubscribers(){
     $data = array();
     $Q = $this-&gt;db-&gt;get('subscribers');
     if ($Q-&gt;num_rows() &gt; 0){
       foreach ($Q-&gt;result_array() as $row){
         $data[] = $row;
       }
    }
    $Q-&gt;free_result();
    return $data;
 }

 function createSubscriber(){
	$this-&gt;db-&gt;where('email', $_POST['email']);
	$this-&gt;db-&gt;from('subscribers');
	$ct = $this-&gt;db-&gt;count_all_results();

	if ($ct == 0){
		$data = array(
			'name' =&gt; $_POST['name'],
			'email' =&gt; $_POST['email']
		);

		$this-&gt;db-&gt;insert('subscribers', $data);
 	}
 }

 function updateSubscriber(){
	$data = array(
		'name' =&gt; $_POST['name'],
		'email' =&gt; $_POST['email']

	);

 	$this-&gt;db-&gt;where('id', $_POST['id']);
	$this-&gt;db-&gt;update('subscribers', $data);	

 }

 function removeSubscriber($id){
 	$this-&gt;db-&gt;where('id', $id);
	$this-&gt;db-&gt;delete('subscribers');

 } 

}//end class
?&gt;
</pre>
<h3>Controller</h3>
<p>controllers/welcome.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Welcome extends Controller {
  function  __construct(){
    parent::Controller();
    $this-&gt;load-&gt;model('MSubscribers');
    $this-&gt;load-&gt;helper(array('form', 'url'));
    $this-&gt;load-&gt;library('form_validation');
    session_start();
    $this-&gt;output-&gt;enable_profiler(FALSE);
  }

  function index(){

    	$captcha_result = '';
	$data['cap_img'] = $this -&gt; _make_captcha();
	$this-&gt;load-&gt;view('subscribe', $data);
  }

  function subscribe(){
    /**
	 * form_validation
	 */
	$this-&gt;form_validation-&gt;set_rules('name', 'Name', 'required');
	$this-&gt;form_validation-&gt;set_rules('email', 'Email',  'required|valid_email');
	$this-&gt;form_validation-&gt;set_rules('captcha', 'Captcha', 'required');
	if ( $this -&gt; _check_capthca() ) {
        if ($this-&gt;form_validation-&gt;run() == FALSE)
		{
		    $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'All fields are required . Please try again!');
		    redirect('welcome/index');
		}
		else
		{
		    $this-&gt;MSubscribers-&gt;createSubscriber();
		    $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'Thanks for subscribing!');
		    redirect('welcome/index','refresh');
		}
      }else {
        $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'Enter captcha . Please try again!');
	redirect('welcome/index');
      }
  }
  /**
   * For captcha
   *
   */
   function _make_captcha()
  {
    $this -&gt; load -&gt; plugin( 'captcha' );
    $vals = array(
      'img_path' =&gt; './captcha/', // PATH for captcha ( *Must mkdir (htdocs)/captcha )
      'img_url' =&gt; 'captcha/', // URL for captcha img
      'img_width' =&gt; 200, // width
      'img_height' =&gt; 60, // height
      // 'font_path'     =&gt; '../system/fonts/2.ttf',
      'expiration' =&gt; 7200 ,
      );
    // Create captcha
    $cap = create_captcha( $vals );
    // Write to DB
    if ( $cap ) {
      $data = array(
        'captcha_id' =&gt; '',
        'captcha_time' =&gt; $cap['time'],
        'ip_address' =&gt; $this -&gt; input -&gt; ip_address(),
        'word' =&gt; $cap['word'] ,
        );
      $query = $this -&gt; db -&gt; insert_string( 'captcha', $data );
      $this -&gt; db -&gt; query( $query );
    }else {
      return &quot;Umm captcha not work&quot; ;
    }
    return $cap['image'] ;
  }

  function _check_capthca()
  {
    // Delete old data ( 2hours)
    $expiration = time()-7200 ;
    $sql = &quot; DELETE FROM captcha WHERE captcha_time &lt; ? &quot;;
    $binds = array($expiration);
    $query = $this-&gt;db-&gt;query($sql, $binds);

    //checking input
    $sql = &quot;SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time &gt; ?&quot;;
    $binds = array($_POST['captcha'], $this-&gt;input-&gt;ip_address(), $expiration);
    $query = $this-&gt;db-&gt;query($sql, $binds);
    $row = $query-&gt;row();

  if ( $row -&gt; count &gt; 0 )
    {
      return true;
    }
    return false;

  }

  /**
   * End of captcha
   */
}//end controller class

?&gt;
</pre>
<h3>View</h3>
<p>views/subscribe.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Using captcha with Codeigniter&lt;/title&gt;
  &lt;base href=&quot;&lt;?=base_url();?&gt;&quot;&gt;
  &lt;/head&gt;
&lt;body&gt;
&lt;div id='main'&gt;

&lt;?php
if ($this-&gt;session-&gt;flashdata('subscribe_msg')){
	echo &quot;&lt;div class='message'&gt;&quot;;
	echo $this-&gt;session-&gt;flashdata('subscribe_msg');
	echo &quot;&lt;/div&gt;&quot;;
}
?&gt;
&lt;?php echo form_open(&quot;welcome/subscribe&quot;); ?&gt;
&lt;?php echo form_fieldset('Subscribe To Our Newsletter'); ?&gt;
&lt;h5&gt;Name&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&lt;?php echo set_value('name'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;Email&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;Are you human?&lt;/h5&gt;
&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;

&lt;input type=&quot;text&quot; name=&quot;captcha&quot; value=&quot;&quot; size=&quot;40&quot; /&gt;

&lt;div&gt;&lt;input type=&quot;submit&quot; value=&quot;Subscribe&quot; /&gt;&lt;/div&gt;
&lt;?php echo form_fieldset_close(); ?&gt;
&lt;?php echo form_close(); ?&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2009/11/newsletter1.jpg" alt="newsletter1" title="newsletter1" width="314" height="403" class="alignleft size-full wp-image-389" /></p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-use-codeigniter-captcha-plug-in/' rel='bookmark' title='How to use Codeigniter captcha plug-in Part 1'>How to use Codeigniter captcha plug-in Part 1</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

