<?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>TECHiE TALKS &#187; Programming</title>
	<atom:link href="http://www.icpep.org/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icpep.org</link>
	<description>Just another techie stuff</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Infix to Postfix and Prefix</title>
		<link>http://www.icpep.org/infix-to-postfix-and-prefix/</link>
		<comments>http://www.icpep.org/infix-to-postfix-and-prefix/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 00:27:57 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Works]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1171</guid>
		<description><![CDATA[image from www.codeproject.com On the last day of our class for the first semester, our instructor gave us an assignment about infix, postfix and prefix.  The assignment was to create a program that converts infix equations to its postfix form and prefix form.  I search around the net and the resources are so few that it took me days to have a sample program in C.  I am not that good in C programming but I can create C++ or [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.icpep.org/wp-content/uploads/2010/11/binexptrees.jpg"><img class="size-full wp-image-1172 aligncenter" title="infix prefix and postfix equations" src="http://www.icpep.org/wp-content/uploads/2010/11/binexptrees.jpg" alt="infix prefix and postfix equations" width="266" height="249" /></a><br />
<em>image from www.codeproject.com</em></p>
<p>On the last day of our class for the first semester, our instructor gave us an assignment about infix, postfix and prefix.  The assignment was to create a program that converts infix equations to its postfix form and prefix form.  I search around the net and the resources are so few that it took me days to have a sample program in C.  I am not that good in C programming but I can create C++ or C programs.  The code provided here may not be that well optimized and the structures may not be that perfect but it works well.  I used Visual C++ in modifying the program(<em>yes I just modified a program</em>):).  <a title="Infix prefix postfix c++" href="http://www.icpep.org/downloads/postfix_infix_prefix.rar" target="_blank">You can download the files here</a></p>
<div id="seo_alrp_related"><h2>Posts Related to Infix to Postfix and Prefix</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmailer/" rel="bookmark">PHPMailer</a></h3><p>Sending E-Mail with PHP can be simple, or it can be very complex depending on what you want to do.  PHPmailer is a free PHP ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/what-is-programming-language/" rel="bookmark">What is Programming Language</a></h3><p>When you enter a darkened room and want to see what is inside, you turn on a light switch. When you leave the room, you ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/computer-security-threats/" rel="bookmark">Computer Security Threats</a></h3><p>In a Windows XP system files computer security threats are not new to it. The damage caused by viruses can range from rendering useless just ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/bubble-sort-and-graphics-h-in-dev-c/" rel="bookmark">Bubble Sort and Graphics.h in Dev C++</a></h3><p>Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/file-extension-wps/" rel="bookmark">File Extension WPS</a></h3><p>File Extension WPS or files that has a ".wps" is not a virus(except if there is something embedded with it) but rather it is a ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/infix-to-postfix-and-prefix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple PHP Date Function</title>
		<link>http://www.icpep.org/simple-php-date-function/</link>
		<comments>http://www.icpep.org/simple-php-date-function/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 03:06:41 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1149</guid>
		<description><![CDATA[PHP has a function date where you can specify different ways on how to display the date.  How do you generate current date and display only month and date like &#8216;September 2010&#8242;.  Here is a simple php howto,&#60;div&#62;function curDate()&#160;{&#60;/div&#62; &#60;div id=&#34;_mcePaste&#34;&#62;return date(&#34;Y-m-d&#34;,mktime(date(&#34;h&#34;)+8, date(&#34;i&#34;), date(&#34;s&#34;), date(&#34;m&#34;) &#160;, date(&#34;d&#34;), date(&#34;Y&#34;)));&#60;/div&#62; &#60;div id=&#34;_mcePaste&#34;&#62;}&#60;/div&#62; &#60;div&#62;$now = substr(curDate(),0,7);&#60;/div&#62; &#60;div&#62;echo date(&#34;F Y&#34;, strtotime($now));&#60;/div&#62; &#60;div&#62;?&#38;gt;&#60;/div&#62; The code above will simply output September 2010, a simple code that will surely help you especially when coding PHP from scratch. Posts Related [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.icpep.org/wp-content/uploads/2010/09/month-year-in-php.jpg"><img class="size-full wp-image-1150 aligncenter" title="month year in php" src="http://www.icpep.org/wp-content/uploads/2010/09/month-year-in-php.jpg" alt="" width="429" height="60" /></a></p>
<p>PHP has a function date where you can specify different ways on how to display the date.  How do you generate current date and display only month and date like &#8216;September 2010&#8242;.  Here is a simple php howto,</p><pre class="crayon-plain-tag"><code>&lt;div&gt;function curDate()&nbsp;{&lt;/div&gt;
&lt;div id=&quot;_mcePaste&quot;&gt;return date(&quot;Y-m-d&quot;,mktime(date(&quot;h&quot;)+8, date(&quot;i&quot;), date(&quot;s&quot;), date(&quot;m&quot;) &nbsp;, date(&quot;d&quot;), date(&quot;Y&quot;)));&lt;/div&gt;
&lt;div id=&quot;_mcePaste&quot;&gt;}&lt;/div&gt;
&lt;div&gt;$now = substr(curDate(),0,7);&lt;/div&gt;
&lt;div&gt;echo date(&quot;F Y&quot;, strtotime($now));&lt;/div&gt;
&lt;div&gt;?&amp;gt;&lt;/div&gt;</code></pre><p>
The code above will simply output September 2010, a simple code that will surely help you especially when coding PHP from scratch.</p>
<div id="seo_alrp_related"><h2>Posts Related to Simple PHP Date Function</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-compare-date/" rel="bookmark">PHP Compare Date</a></h3><p>I was creating a program for a library and that is to have a system that will manage the borrowing of books. I was searching ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/nokia-cellphone-hacks/" rel="bookmark">Nokia Cellphone Hacks</a></h3><p>Your Nokia cell phone can be programmed to pick up radar speed traps, when programmed your cell phone picks up the radar and alerts you ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/getting-main-domain/" rel="bookmark">Getting Main Domain</a></h3><p>Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/how-to-check-for-virus-presence/" rel="bookmark">How to check for virus Presence</a></h3><p>There are some tools and procedures that can tell with 99.44 percent accuracy whether your computer has a virus. Here are the actions to take: ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-query/" rel="bookmark">Code Igniter Query</a></h3><p>Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/simple-php-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bubble Sort and Graphics.h in Dev C++</title>
		<link>http://www.icpep.org/bubble-sort-and-graphics-h-in-dev-c/</link>
		<comments>http://www.icpep.org/bubble-sort-and-graphics-h-in-dev-c/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 00:49:20 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1101</guid>
		<description><![CDATA[Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided to write how to use graphics.h in dev-c++.  I am expecting that you have already installed bloodshed dev-cpp on your machine.  Graphics.h is a header file found in borlan c but because of its late development devcpp is now the mostly used IDE and compiler in programming c++. Below are the steps on how to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.icpep.org/wp-content/uploads/2010/07/dev-c++.jpg"><img class="size-full wp-image-1102 aligncenter" title="dev c++" src="http://www.icpep.org/wp-content/uploads/2010/07/dev-c++.jpg" alt="dev c++" width="472" height="293" /></a></p>
<p style="text-align: justify;">Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided to write how to use graphics.h in dev-c++.  I am expecting that you have already installed bloodshed dev-cpp on your machine.  Graphics.h is a header file found in borlan c but because of its late development devcpp is now the mostly used IDE and compiler in programming c++.</p>
<p style="text-align: justify;">Below are the steps on how to get graphics.h running on your machine,</p>
<ol>
<li>download <a title="graphics.h in dev cpp" href="http://www.icpep.org/downloads/graphics.h" target="_blank">graphics.h</a> and save it to the <strong>include</strong> folder where you installed dev-cpp (C:\Dev-Cpp\include)</li>
<li>Download <a title="libbgi" href="http://www.icpep.org/downloads/libbgi.a">libbgi.a</a> and save it in the <strong>lib </strong>folder where you installed dev-cpp (C:\Dev-Cpp\lib)</li>
<li>So when you have to create a program that needs the use of graphics.h  you must instruct the linker to link in certain libraries by going to <strong>projects &gt; project options &gt; parameters tab &gt; linker column </strong>copy the lines below and paste it on that column.</li>
</ol>
<pre class="crayon-plain-tag"><code>-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32</code></pre><p>
By then you should be able to use graphics.h. As a sample I created this bubble sort algorithm as an example on how to use graphics.h in c++.<span id="more-1101"></span></p>
<div style="border: 2px solid #CECECE; padding: 5px; background: #F1F1F1;">
<div id="_mcePaste">#include &lt;iostream&gt;</div>
<div id="_mcePaste">#include &lt;graphics.h&gt;</div>
<p>#define PIXEL_COUNT 1000<br />
#define DELAY_TIME  1  /* in milliseconds */<br />
#define CLIP_ON     1</p>
<p>//using namespace std;</p>
<p>int main () {</p>
<p>int temp, x, toSort[300], loop, isSwapped=1;<br />
/* request autodetection */<br />
int gdriver = DETECT, gmode, errorcode;</p>
<p>/* initialize graphics and local variables */<br />
initgraph(&amp;gdriver, &amp;gmode, &#8220;&#8221;);</p>
<p>/* read result of initialization */<br />
errorcode = graphresult();</p>
<p>if (errorcode != grOk) {  /* an error occurred */</p>
<p>printf(&#8220;Graphics error: %s\n&#8221;, grapherrormsg(errorcode));<br />
printf(&#8220;Press any key to halt:&#8221;);<br />
getch();<br />
exit(1);               /* terminate with an error code */</p>
<p>}</p>
<p>/* Generate the numbers */<br />
for(x=0; x&lt;300; x++) {<br />
toSort[x] = rand() % 300 + 1;<br />
}</p>
<p>for(loop=0; (loop &lt;= 300)&amp;&amp; isSwapped == 1; loop++) {<br />
isSwapped = 0;<br />
for(x=0; x&lt;300; x++) {            if(toSort[x] &gt; toSort[x+1]) {</p>
<p>//swapping of data<br />
temp = toSort[x];<br />
toSort[x] = toSort[x+1];<br />
toSort[x+1] = temp;<br />
isSwapped = 1;</p>
<p>}<br />
std::cout &lt;&lt; loop &lt;&lt; &#8220;=&gt; &#8220;&lt;&lt; x &lt;&lt; &#8220;,&#8221; &lt;&lt; toSort[x] &lt;&lt; &#8221; &#8220;;</p>
<p>putpixel(x, toSort[x], 16776960);<br />
delay(DELAY_TIME);</p>
<p>}<br />
std::cout &lt;&lt; &#8220;\n\n&#8221;;<br />
if(isSwapped == 1) {<br />
cleardevice();<br />
}<br />
//loop++;<br />
}</p>
<p>//cout &lt;&lt; endl &lt;&lt; &#8220;\n\n\n&#8221;;<br />
std::cout &lt;&lt; &#8220;Loop Count: &#8221; &lt;&lt; loop &lt;&lt; &#8220;\n\n\n&#8221;;<br />
system(&#8220;pause&#8221;);<br />
return 0;<br />
}</p>
</div>
<p style="text-align: justify;">The program will have scattered points on the screen and will form a line as the loop iterates and at the end it will display how many loops are needed to sort the randomly generated numbers.</p>
<p style="text-align: justify;">If you have problems using the functions you can refer to this <a href="http://www.cs.colorado.edu/~main/bgi/doc/">link</a>.  I hope this helps in solving your problem about dev c++ graphics.h with the <strong>bubble sort algorithm</strong>.</p>
<div id="seo_alrp_related"><h2>Posts Related to Bubble Sort and Graphics.h in Dev C++</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/assembly-language-tutorial/" rel="bookmark">Assembly Language Tutorial</a></h3><p>Here is another Assembly Language Tutorial Sample Program. This program is creating a fixed password to a certain application. This One of the basic examples ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/learning-c/" rel="bookmark">Learning C++</a></h3><p>Since C++ is the first Language I've learned and time passed by and I forgot how create one now. So i'll be learning once again ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/howto-hello-world-in-c/" rel="bookmark">Howto Hello World in C++</a></h3><p>//Printing Hellow World! #include &lt;iostream&gt; int main() { std::cout &lt;&lt; "Hello World! \n"; system("pause"); return 0; } Line begins with //, indicating that the remainder ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/c-reading-from-a-text-file/" rel="bookmark">C++ Reading From a Text File</a></h3><p>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int main() { string line; int count = 0; ifstream FileName ("try.txt"); if (FileName.is_open() &amp;&amp; !FileName.eof()){ ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-curl/" rel="bookmark">PHP Curl</a></h3><p>If you are a web developer and having problems on Installing PHP Curl on Apache with PHP installed on Windows Operating System, below is my ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/bubble-sort-and-graphics-h-in-dev-c/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Change a String or Character in MySQL</title>
		<link>http://www.icpep.org/change-a-string-or-character-in-mysql/</link>
		<comments>http://www.icpep.org/change-a-string-or-character-in-mysql/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 05:00:01 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1066</guid>
		<description><![CDATA[Knowing the right MySQL statement is the most important part in having thousands of data in your database, one false move and you can&#8217;t undo things.    If you want to change a string or character in your database and doing it manually in thousands or millions of entries then that should consume all of your time. One example scenario is when you want to change all the entries containing a character &#8216;_&#8217; to this character &#8216;-&#8217; .  All you need [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1067 aligncenter" title="mysql" src="http://www.icpep.org/wp-content/uploads/2010/04/mysql.jpg" alt="" width="300" height="225" /></p>
<p style="text-align: justify;">Knowing the right MySQL statement is the most important part in having thousands of data in your database, one false move and you can&#8217;t undo things.    If you want to change a string or character in your database and doing it manually in thousands or millions of entries then that should consume all of your time.</p>
<p style="text-align: justify;">One example scenario is when you want to change all the entries containing a character &#8216;_&#8217; to this character &#8216;-&#8217; .  All you need to do is have a backup first on that specific table or database so that whatever false move you  will be doing, you can still have the data back.  After having the backup here is the SQL syntax that you should enter:</p>
<div style="border: 2px solid #CECECE; padding: 5px; background: #F1F1F1;">UPDATE Table SET Column = Replace(Column, &#8216;find value&#8217;, &#8216;replacement value&#8217;) WHERE xxx</div>
<p>Where in my scenario:</p>
<div style="border: 2px solid #CECECE; padding: 5px; background: #F1F1F1;">UPDATE paging SET pagename = Replace(pagename, &#8216;_&#8217;, &#8216;-&#8217;)</div>
<p>There within less than a minute I was able to change all the data containing &#8216;_&#8217;.  It saved me a lot of time and I can continue coding some other stuff rather than editing the data manually.  Hope this helps and happy coding!</p>
<div id="seo_alrp_related"><h2>Posts Related to Change a String or Character in MySQL</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/mysql-reset-root-password/" rel="bookmark">MySQL Reset Root Password</a></h3><p>My friend forgot his mysql password and the database needs to be accessed by the root user.  My friend is running MySQL 5.1 and as ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmyadmin-importing-large-data/" rel="bookmark">PHPMyAdmin Importing Large Data</a></h3><p>By Default phpmyadmin can import data on your mysql database up to 2MB of data and beyond that will be an error.  This has been ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-query/" rel="bookmark">Code Igniter Query</a></h3><p>Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/mysql-duplicate-error/" rel="bookmark">Mysql Duplicate Error</a></h3><p>I created a web application that managers collected links.  The web application was called duplicate checker where premium links collected are being stored in a ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/facebook-farmville-cheat/" rel="bookmark">Facebook Farmville Cheat</a></h3><p>In the past few months I was into gaming online and one of the famous site today is facebook wherein I am playing games.  Facebook ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/change-a-string-or-character-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Main Domain</title>
		<link>http://www.icpep.org/getting-main-domain/</link>
		<comments>http://www.icpep.org/getting-main-domain/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 18:04:13 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1046</guid>
		<description><![CDATA[Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found this function while searching for a good Regular Expression to fulfill such result. {code type=php}&#60;?php function get_base_domain($url)  { $debug = 0; $base_domain = &#8221;; $G_TLD = array( &#8216;biz&#8217;,'com&#8217;,'edu&#8217;,'gov&#8217;,'info&#8217;,'int&#8217;,'mil&#8217;,'name&#8217;,'net&#8217;,'org&#8217;,'aero&#8217;,'asia&#8217;,'cat&#8217;,'coop&#8217;,'jobs&#8217;,'mobi&#8217;,'museum&#8217;, &#8216;pro&#8217;,'tel&#8217;,'travel&#8217;,'arpa&#8217;,'root&#8217;,'berlin&#8217;,'bzh&#8217;,'cym&#8217;,'gal&#8217;,'geo&#8217;,'kid&#8217;,'kids&#8217;,'lat&#8217;,'mail&#8217;,'nyc&#8217;,'post&#8217;,'sco&#8217;,'web&#8217;,'xxx&#8217;, &#8216;nato&#8217;,'example&#8217;,'invalid&#8217;,'localhost&#8217;,'test&#8217;,'bitnet&#8217;,'csnet&#8217;,'ip&#8217;,'local&#8217;,'onion&#8217;,'uucp&#8217;, &#8216;co&#8217; ); // country tlds (source: http://en.wikipedia.org/wiki/Country_code_top-level_domain) $C_TLD = array( &#8216;ac&#8217;,'ad&#8217;,'ae&#8217;,'af&#8217;,'ag&#8217;,'ai&#8217;,'al&#8217;,'am&#8217;,'an&#8217;,'ao&#8217;,'aq&#8217;,'ar&#8217;,'as&#8217;,'at&#8217;,'au&#8217;,'aw&#8217;,'ax&#8217;,'az&#8217;, &#8216;ba&#8217;,'bb&#8217;,'bd&#8217;,'be&#8217;,'bf&#8217;,'bg&#8217;,'bh&#8217;,'bi&#8217;,'bj&#8217;,'bm&#8217;,'bn&#8217;,'bo&#8217;,'br&#8217;,'bs&#8217;,'bt&#8217;,'bw&#8217;,'by&#8217;,'bz&#8217;, &#8216;ca&#8217;,'cc&#8217;,'cd&#8217;,'cf&#8217;,'cg&#8217;,'ch&#8217;,'ci&#8217;,'ck&#8217;,'cl&#8217;,'cm&#8217;,'cn&#8217;,'co&#8217;,'cr&#8217;,'cu&#8217;,'cv&#8217;,'cx&#8217;,'cy&#8217;,'cz&#8217;, &#8216;de&#8217;,'dj&#8217;,'dk&#8217;,'dm&#8217;,'do&#8217;,'dz&#8217;,'ec&#8217;,'ee&#8217;,'eg&#8217;,'er&#8217;,'es&#8217;,'et&#8217;,'eu&#8217;,'fi&#8217;,'fj&#8217;,'fk&#8217;,'fm&#8217;,'fo&#8217;, &#8216;fr&#8217;,'ga&#8217;,'gd&#8217;,'ge&#8217;,'gf&#8217;,'gg&#8217;,'gh&#8217;,'gi&#8217;,'gl&#8217;,'gm&#8217;,'gn&#8217;,'gp&#8217;,'gq&#8217;,'gr&#8217;,'gs&#8217;,'gt&#8217;,'gu&#8217;,'gw&#8217;, &#8216;gy&#8217;,'hk&#8217;,'hm&#8217;,'hn&#8217;,'hr&#8217;,'ht&#8217;,'hu&#8217;,'id&#8217;,'ie&#8217;,'il&#8217;,'im&#8217;,'in&#8217;,'io&#8217;,'iq&#8217;,'ir&#8217;,'is&#8217;,'it&#8217;,'je&#8217;, &#8216;jm&#8217;,'jo&#8217;,'jp&#8217;,'ke&#8217;,'kg&#8217;,'kh&#8217;,'ki&#8217;,'km&#8217;,'kn&#8217;,'kr&#8217;,'kw&#8217;,'ky&#8217;,'kz&#8217;,'la&#8217;,'lb&#8217;,'lc&#8217;,'li&#8217;,'lk&#8217;, &#8216;lr&#8217;,'ls&#8217;,'lt&#8217;,'lu&#8217;,'lv&#8217;,'ly&#8217;,'ma&#8217;,'mc&#8217;,'md&#8217;,'mg&#8217;,'mh&#8217;,'mk&#8217;,'ml&#8217;,'mm&#8217;,'mn&#8217;,'mo&#8217;,'mp&#8217;,'mq&#8217;, &#8216;mr&#8217;,'ms&#8217;,'mt&#8217;,'mu&#8217;,'mv&#8217;,'mw&#8217;,'mx&#8217;,'my&#8217;,'mz&#8217;,'na&#8217;,'nc&#8217;,'ne&#8217;,'nf&#8217;,'ng&#8217;,'ni&#8217;,'nl&#8217;,'no&#8217;,'np&#8217;, &#8216;nr&#8217;,'nu&#8217;,'nz&#8217;,'om&#8217;,'pa&#8217;,'pe&#8217;,'pf&#8217;,'pg&#8217;,'ph&#8217;,'pk&#8217;,'pl&#8217;,'pn&#8217;,'pr&#8217;,'ps&#8217;,'pt&#8217;,'pw&#8217;,'py&#8217;,'qa&#8217;, &#8216;re&#8217;,'ro&#8217;,'ru&#8217;,'rw&#8217;,'sa&#8217;,'sb&#8217;,'sc&#8217;,'sd&#8217;,'se&#8217;,'sg&#8217;,'sh&#8217;,'si&#8217;,'sk&#8217;,'sl&#8217;,'sm&#8217;,'sn&#8217;,'sr&#8217;,'st&#8217;, &#8216;sv&#8217;,'sy&#8217;,'sz&#8217;,'tc&#8217;,'td&#8217;,'tf&#8217;,'tg&#8217;,'th&#8217;,'tj&#8217;,'tk&#8217;,'tl&#8217;,'tm&#8217;,'tn&#8217;,'to&#8217;,'tr&#8217;,'tt&#8217;,'tv&#8217;,'tw&#8217;, &#8216;tz&#8217;,'ua&#8217;,'ug&#8217;,'uk&#8217;,'us&#8217;,'uy&#8217;,'uz&#8217;,'va&#8217;,'vc&#8217;,'ve&#8217;,'vg&#8217;,'vi&#8217;,'vn&#8217;,'vu&#8217;,'wf&#8217;,'ws&#8217;,'ye&#8217;,'yu&#8217;, &#8216;za&#8217;,'zm&#8217;,'zw&#8217;,'eh&#8217;,'kp&#8217;,'me&#8217;,'rs&#8217;,'um&#8217;,'bv&#8217;,'gb&#8217;,'pm&#8217;,'sj&#8217;,'so&#8217;,'yt&#8217;,'su&#8217;,'tp&#8217;,'bu&#8217;,'cs&#8217;,'dd&#8217;,'zr&#8217; ); [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify; padding-left: 30px;"><img class="size-full wp-image-1047 aligncenter" title="php" src="http://www.icpep.org/wp-content/uploads/2010/04/php.jpg" alt="" width="300" height="225" /></p>
<p style="text-align: justify;">Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found this function while searching for a good Regular Expression to fulfill such result.</p>
<p>{code type=php}&lt;?php</p>
<p>function get_base_domain($url)  {<br />
$debug = 0;<br />
$base_domain = &#8221;;</p>
<p>$G_TLD = array(<br />
&#8216;biz&#8217;,'com&#8217;,'edu&#8217;,'gov&#8217;,'info&#8217;,'int&#8217;,'mil&#8217;,'name&#8217;,'net&#8217;,'org&#8217;,'aero&#8217;,'asia&#8217;,'cat&#8217;,'coop&#8217;,'jobs&#8217;,'mobi&#8217;,'museum&#8217;,<br />
&#8216;pro&#8217;,'tel&#8217;,'travel&#8217;,'arpa&#8217;,'root&#8217;,'berlin&#8217;,'bzh&#8217;,'cym&#8217;,'gal&#8217;,'geo&#8217;,'kid&#8217;,'kids&#8217;,'lat&#8217;,'mail&#8217;,'nyc&#8217;,'post&#8217;,'sco&#8217;,'web&#8217;,'xxx&#8217;,<br />
&#8216;nato&#8217;,'example&#8217;,'invalid&#8217;,'localhost&#8217;,'test&#8217;,'bitnet&#8217;,'csnet&#8217;,'ip&#8217;,'local&#8217;,'onion&#8217;,'uucp&#8217;,<br />
&#8216;co&#8217; );</p>
<p>// country tlds (source: http://en.wikipedia.org/wiki/Country_code_top-level_domain)<br />
$C_TLD = array(<br />
&#8216;ac&#8217;,'ad&#8217;,'ae&#8217;,'af&#8217;,'ag&#8217;,'ai&#8217;,'al&#8217;,'am&#8217;,'an&#8217;,'ao&#8217;,'aq&#8217;,'ar&#8217;,'as&#8217;,'at&#8217;,'au&#8217;,'aw&#8217;,'ax&#8217;,'az&#8217;,<br />
&#8216;ba&#8217;,'bb&#8217;,'bd&#8217;,'be&#8217;,'bf&#8217;,'bg&#8217;,'bh&#8217;,'bi&#8217;,'bj&#8217;,'bm&#8217;,'bn&#8217;,'bo&#8217;,'br&#8217;,'bs&#8217;,'bt&#8217;,'bw&#8217;,'by&#8217;,'bz&#8217;,<br />
&#8216;ca&#8217;,'cc&#8217;,'cd&#8217;,'cf&#8217;,'cg&#8217;,'ch&#8217;,'ci&#8217;,'ck&#8217;,'cl&#8217;,'cm&#8217;,'cn&#8217;,'co&#8217;,'cr&#8217;,'cu&#8217;,'cv&#8217;,'cx&#8217;,'cy&#8217;,'cz&#8217;,<br />
&#8216;de&#8217;,'dj&#8217;,'dk&#8217;,'dm&#8217;,'do&#8217;,'dz&#8217;,'ec&#8217;,'ee&#8217;,'eg&#8217;,'er&#8217;,'es&#8217;,'et&#8217;,'eu&#8217;,'fi&#8217;,'fj&#8217;,'fk&#8217;,'fm&#8217;,'fo&#8217;,<br />
&#8216;fr&#8217;,'ga&#8217;,'gd&#8217;,'ge&#8217;,'gf&#8217;,'gg&#8217;,'gh&#8217;,'gi&#8217;,'gl&#8217;,'gm&#8217;,'gn&#8217;,'gp&#8217;,'gq&#8217;,'gr&#8217;,'gs&#8217;,'gt&#8217;,'gu&#8217;,'gw&#8217;,<br />
&#8216;gy&#8217;,'hk&#8217;,'hm&#8217;,'hn&#8217;,'hr&#8217;,'ht&#8217;,'hu&#8217;,'id&#8217;,'ie&#8217;,'il&#8217;,'im&#8217;,'in&#8217;,'io&#8217;,'iq&#8217;,'ir&#8217;,'is&#8217;,'it&#8217;,'je&#8217;,<br />
&#8216;jm&#8217;,'jo&#8217;,'jp&#8217;,'ke&#8217;,'kg&#8217;,'kh&#8217;,'ki&#8217;,'km&#8217;,'kn&#8217;,'kr&#8217;,'kw&#8217;,'ky&#8217;,'kz&#8217;,'la&#8217;,'lb&#8217;,'lc&#8217;,'li&#8217;,'lk&#8217;,<br />
&#8216;lr&#8217;,'ls&#8217;,'lt&#8217;,'lu&#8217;,'lv&#8217;,'ly&#8217;,'ma&#8217;,'mc&#8217;,'md&#8217;,'mg&#8217;,'mh&#8217;,'mk&#8217;,'ml&#8217;,'mm&#8217;,'mn&#8217;,'mo&#8217;,'mp&#8217;,'mq&#8217;,<br />
&#8216;mr&#8217;,'ms&#8217;,'mt&#8217;,'mu&#8217;,'mv&#8217;,'mw&#8217;,'mx&#8217;,'my&#8217;,'mz&#8217;,'na&#8217;,'nc&#8217;,'ne&#8217;,'nf&#8217;,'ng&#8217;,'ni&#8217;,'nl&#8217;,'no&#8217;,'np&#8217;,<br />
&#8216;nr&#8217;,'nu&#8217;,'nz&#8217;,'om&#8217;,'pa&#8217;,'pe&#8217;,'pf&#8217;,'pg&#8217;,'ph&#8217;,'pk&#8217;,'pl&#8217;,'pn&#8217;,'pr&#8217;,'ps&#8217;,'pt&#8217;,'pw&#8217;,'py&#8217;,'qa&#8217;,<br />
&#8216;re&#8217;,'ro&#8217;,'ru&#8217;,'rw&#8217;,'sa&#8217;,'sb&#8217;,'sc&#8217;,'sd&#8217;,'se&#8217;,'sg&#8217;,'sh&#8217;,'si&#8217;,'sk&#8217;,'sl&#8217;,'sm&#8217;,'sn&#8217;,'sr&#8217;,'st&#8217;,<br />
&#8216;sv&#8217;,'sy&#8217;,'sz&#8217;,'tc&#8217;,'td&#8217;,'tf&#8217;,'tg&#8217;,'th&#8217;,'tj&#8217;,'tk&#8217;,'tl&#8217;,'tm&#8217;,'tn&#8217;,'to&#8217;,'tr&#8217;,'tt&#8217;,'tv&#8217;,'tw&#8217;,<br />
&#8216;tz&#8217;,'ua&#8217;,'ug&#8217;,'uk&#8217;,'us&#8217;,'uy&#8217;,'uz&#8217;,'va&#8217;,'vc&#8217;,'ve&#8217;,'vg&#8217;,'vi&#8217;,'vn&#8217;,'vu&#8217;,'wf&#8217;,'ws&#8217;,'ye&#8217;,'yu&#8217;,<br />
&#8216;za&#8217;,'zm&#8217;,'zw&#8217;,'eh&#8217;,'kp&#8217;,'me&#8217;,'rs&#8217;,'um&#8217;,'bv&#8217;,'gb&#8217;,'pm&#8217;,'sj&#8217;,'so&#8217;,'yt&#8217;,'su&#8217;,'tp&#8217;,'bu&#8217;,'cs&#8217;,'dd&#8217;,'zr&#8217;<br />
);</p>
<p>// get domain<br />
if ( !$full_domain = get_url_domain($url) ) {<br />
return $base_domain;<br />
}</p>
<p>// now the fun<br />
// break up domain, reverse<br />
$DOMAIN = explode(&#8216;.&#8217;, $full_domain);<br />
if ( $debug ) print_r($DOMAIN);<br />
$DOMAIN = array_reverse($DOMAIN);<br />
if ( $debug ) print_r($DOMAIN);</p>
<p>// first check for ip address<br />
if ( count($DOMAIN) == 4 &amp;&amp; is_numeric($DOMAIN[0]) &amp;&amp; is_numeric($DOMAIN[3]) ) {<br />
return $full_domain;<br />
}</p>
<p>// if only 2 domain parts, that must be our domain<br />
if ( count($DOMAIN) &lt;= 2 ) return $full_domain;</p>
<p>if ( in_array($DOMAIN[0], $C_TLD) &amp;&amp; in_array($DOMAIN[1], $G_TLD) &amp;&amp; $DOMAIN[2] != &#8216;www&#8217; ) {<br />
$full_domain = $DOMAIN[2] . &#8216;.&#8217; . $DOMAIN[1] . &#8216;.&#8217; . $DOMAIN[0];<br />
}<br />
else {<br />
$full_domain = $DOMAIN[1] . &#8216;.&#8217; . $DOMAIN[0];;<br />
}</p>
<p>// did we succeed?<br />
return $full_domain;<br />
}</p>
<p>function get_url_domain($url)  {<br />
$domain = &#8221;;<br />
$_URL = parse_url($url);</p>
<p>// sanity check<br />
if ( empty($_URL) || empty($_URL['host']) )  {<br />
$domain = &#8221;;<br />
}<br />
else {<br />
$domain = $_URL['host'];<br />
}<br />
return $domain;<br />
}<br />
?&gt;{/code}<br />
To test the code we can use the function,<br />
{code type=php}$url  = &#8216;http://www.icpep.org&#8217;;<br />
echo get_base_domain($url) ; // icpep.org{/code}<br />
<a href="http://icpep.org/wp-content/uploads/files/get.main.domain.txt">Click here to download</a>.</p>
<p style="text-align: justify;">This code really helped me a lot.  There are a lot of Regular expressions out there but this simple approach can break all those head breaking expressions.  Btw, this function is free of use and is under GNU licensing.   Hope this functions is of big help to you also, happy coding!</p>
<div id="seo_alrp_related"><h2>Posts Related to Getting Main Domain</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/fixing-apaches-error-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127-0-1-1-for-servername-in-ubuntu/" rel="bookmark">Fixing Apache&#8217;s Error: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName in Ubuntu</a></h3><p>One of the server I am using is running ubuntu. I am installing memcached on the server and every time I restart the web server ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-displaying-on-the-browser/" rel="bookmark">PHP Displaying On the Browser</a></h3><p>When its your first time to code HTML , the tendency of opening the file is by clicking it twice and yes the expected result ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-query/" rel="bookmark">Code Igniter Query</a></h3><p>Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/simple-php-date-function/" rel="bookmark">Simple PHP Date Function</a></h3><p>PHP has a function date where you can specify different ways on how to display the date.  How do you generate current date and display ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-compare-date/" rel="bookmark">PHP Compare Date</a></h3><p>I was creating a program for a library and that is to have a system that will manage the borrowing of books. I was searching ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/getting-main-domain/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Translation Services</title>
		<link>http://www.icpep.org/translation-services/</link>
		<comments>http://www.icpep.org/translation-services/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 18:17:32 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=881</guid>
		<description><![CDATA[Google has provided web developers foreign language translation api. Web content translation is not a problem anymore, with google&#8217;s Google Translate, research from different countries is now made possible. This is a big help especially for researchers on the net, we can now easily understand web contents and even text from outside sources which also serves as a document translation services. Google allows us to copy and paste phrases, sentences and paragraphs from outside sources to their google translate and [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-882 aligncenter" title="translate_logo" src="http://www.icpep.org/wp-content/uploads/2009/10/translate_logo.gif" alt="translate_logo" width="205" height="40" /></p>
<p style="text-align: justify;">Google has provided web developers <span>foreign language translation api. </span><span>Web content translation is not a problem anymore, with google&#8217;s Google Translate, research from different countries is now made possible. </span></p>
<p style="text-align: justify;"><span>This is a big help especially for researchers on the net, we can now easily understand web contents and even text from outside sources which also serves as a document translation services.  Google allows us to copy and  paste phrases, sentences and paragraphs from outside sources  to their google translate and by selecting the language you desire we can now get translation to it.</span></p>
<p style="text-align: justify;">But how do we add google translate on our website?  I have provided 3 different ways on how to achieve google translate on your website.  The easiest is for wordpress users, you can add a <span>web content translation by downloading the plugin <a title="Global Translator" href="http://wordpress.org/extend/plugins/global-translator/">Global Translator </a> </span>.  Follow the steps carefully and you can provide your users translation of different languages according to your choice as set on the administration panel.</p>
<p>The second way of adding a web content translation software by google is by adding a snippet of  codes which they have provided on their site<a href="http://translate.google.com/translate_tools"> Google Translate</a> or just copy and paste the code below and add it on your website.  This is also the code I used in this blog.<span id="more-881"></span></p>
<div style="border:1px solid #00B3F0; background-color: #F4F4F4;padding: 5px;">&lt;div id=&#8221;google_translate_element&#8221;&gt;&lt;/div&gt;&lt;script&gt;</p>
<p>function googleTranslateElementInit() {</p>
<p>new google.translate.TranslateElement({</p>
<p>pageLanguage: &#8216;en&#8217;</p>
<p>}, &#8216;google_translate_element&#8217;);</p>
<p>}</p>
<p>&lt;/script&gt;&lt;script src=&#8221;http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit&#8221;&gt;&lt;/script&gt;</p></div>
<p>If you want to have your own design and style you can still add translation to your site below is an example of the code.  Make sure you have images of the flags as what I used in the code.</p>
<div style="border:1px solid #00B3F0; background-color: #F4F4F4;padding:5px;">&lt;form action=&#8221;http://www.google.com/translate&#8221; &gt;</p>
<p>&lt;script language=&#8221;JavaScript&#8221;&gt;</p>
<p>&lt;!&#8211;</p>
<p>document.write (&#8220;&lt;input name=u value=&#8221;+location.href+&#8221; type=hidden&gt;&#8221;)</p>
<p>// &#8211;&gt;</p>
<p>&lt;/script&gt;</p>
<p>&lt;table width=&#8221;185&#8243; height=&#8221;100%&#8221; align=&#8221;right&#8221; style=&#8221;margin-right:5px;&#8221;&gt;</p>
<p>&lt;tr&gt;</p>
<p>&lt;td colspan=&#8221;5&#8243; style=&#8221;background:#C9E2FF;color:#000099;padding:5px; border:1px solid #ACC5EF;&#8221;&gt;&lt;span style=&#8221;font-size:10px; &#8220;&gt;&lt;b&gt;Click flag to change language&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;</p>
<p>&lt;/tr&gt;</p>
<p>&lt;tr&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;</p>
<p>&lt;input name=&#8221;hl&#8221; value=&#8221;en&#8221; type=&#8221;hidden&#8221;&gt;</p>
<p>&lt;input name=&#8221;ie&#8221; value=&#8221;UTF8&#8243; type=&#8221;hidden&#8221;&gt;</p>
<p>&lt;input name=&#8221;langpair&#8221; value=&#8221;" type=&#8221;hidden&#8221;&gt;</p>
<p>&lt;input name=&#8221;langpair&#8221; value=&#8221;en|fr&#8221; title=&#8221;French&#8221; src= &#8220;images/flags/french.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221;  type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|ko&#8221; title=&#8221;Korean&#8221; src= &#8220;images/flags/korean.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221;  type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|da&#8221; title=&#8221;Danish&#8221; src= &#8220;images/flags/denmark.png&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|cy&#8221; title=&#8221;Welsh&#8221; src= &#8220;images/flags/welsh.gif&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221;  type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|zh-CN&#8221; title=&#8221;Chinese Simplified&#8221; src= &#8220;images/flags/chinese.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;/tr&gt;</p>
<p>&lt;tr&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|de&#8221; title=&#8221;German&#8221; src= &#8220;images/flags/german.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|it&#8221; title=&#8221;Italian&#8221; src= &#8220;images/flags/italian.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|sl&#8221; title=&#8221;Slovenian&#8221; src= &#8220;images/flags/slovenian.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|ru&#8221; title=&#8221;Russian&#8221; src= &#8220;images/flags/russia.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221;  type=&#8221;image&#8221; &gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|pt&#8221; title=&#8221;Portuguese&#8221; src= &#8220;images/flags/pt.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;/tr&gt;</p>
<p>&lt;tr&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|es&#8221; title=&#8221;Spanish&#8221; src= &#8220;images/flags/spanish.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair&#8221; value=&#8221;en|ja&#8221; title=&#8221;Japanese&#8221; src= &#8220;images/flags/japanese.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;</p>
<p>&lt;input name=&#8221;langpair&#8221; value=&#8221;en|cs&#8221; title=&#8221;Czech&#8221; src= &#8220;images/flags/czech.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;</p>
<p>&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair2&#8243; value=&#8221;en|no&#8221; title=&#8221;Norwegian&#8221; src= &#8220;images/flags/norwegian.jpg&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;td align=&#8221;center&#8221;&gt;&lt;input name=&#8221;langpair2&#8243; value=&#8221;en|ar&#8221; title=&#8221;Arabic&#8221; src= &#8220;images/flags/arabic.gif&#8221; onClick=&#8221;this.form.langpair.value=this.value&#8221; type=&#8221;image&#8221; /&gt;&lt;/td&gt;</p>
<p>&lt;/tr&gt;</p>
<p>&lt;/table&gt;</p>
<p>&lt;/form&gt;</p></div>
<p>An example of the snippet can be found in this <a href="http://rstrading.com">link</a>.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<h3 class="r"><a class="l" onmousedown="return clk(this.href,'','','res','1','','0CAkQFjAA')" href="http://www.translate.google.com/translate_t"><em> </em><em>Google Translate</em></a></h3>
</div>
<div id="seo_alrp_related"><h2>Posts Related to Translation Services</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/facebook-on-pidgin/" rel="bookmark">Facebook on Pidgin</a></h3><p>Pidgin is a free chat client that can handle different chat networks like yahoo, google talk, AIM, AOL and many more all at once.  But ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/wordpress-update-services/" rel="bookmark">WordPress Update Services</a></h3><p>This post is intended for wordpress users. When you post a new article on your blog or website wordpress automatically informs/notify some update services to ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/website-virus-ncoyrl-htm-zcv-gif-and-iframe/" rel="bookmark">Website Virus (ncoyrl.htm, zcv.gif and iframe)</a></h3><p>With millions of websites in search engines we can never be sure that the sites we are visiting are not harmful.  Some search engines like Google helps ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/article-submission-websites/" rel="bookmark">Article Submission Websites</a></h3><p>Search Engine Optimization is one of the most difficult thing to do to get your site ranked in the top 3 search engines namely Google, ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/chrome-on-backtrack-5/" rel="bookmark">Chrome On Backtrack 5 and VLC</a></h3><p>image taken www.nightlion.net Chromium, google's browser is one of the fastest browser.  Since I started using chrome, I have a hard time going back to ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/translation-services/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code Igniter Query</title>
		<link>http://www.icpep.org/code-igniter-query/</link>
		<comments>http://www.icpep.org/code-igniter-query/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:36:53 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=869</guid>
		<description><![CDATA[Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the package. In Code Igniter the class that has the database queries or the methods that deals with getting the data on the database is placed inside the MODEL folder.  Just remember the &#8220;D&#8221; which tells us that Database methods are placed in this folder as what Jeffrey Way said in his tutorials. Here are different [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><img src="http://www.icpep.org/wp-content/uploads/2009/10/php-code.jpg" alt="php code" title="php code" width="360" height="288" class="alignnone size-full wp-image-875" /></p>
<p><a href="http://www.icpep.org/code-igniter-installation-and-first-run/">Code Igniter</a> is one of the best PHP framework available today.  It is free to download and user guide can be found together with the package.</p>
<p>In Code Igniter the class that has the database queries or the methods that deals with getting the data on the database is placed inside the MODEL folder.  Just remember the &#8220;D&#8221; which tells us that Database methods are placed in this folder as what Jeffrey Way said in his tutorials.</p>
<p>Here are different Methods to query the database which is based in <a href="http://net.tutsplus.com">Nettuts+</a> tutorials.</p>
<p>Inside my Model folder I created a file Mydb.php, so the name of my class should be the same as the filename I created.<br />
<span id="more-869"></span></p><pre class="crayon-plain-tag"><code>&lt; ?php
class Mydb extends Model {

	function getData() {
		$this-&gt;db-&gt;select('title,content'); #where title and content are fields
		$sql = $this-&gt;db-&gt;get('data');  #data is a database table
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
        }

}

?&gt;</code></pre>
<p>In this method the line <em>$this->db->select(&#8216;title,content&#8217;);</em> is using code igniter &#8220;active records&#8221; where I stated the fields I need but if you want to get all the data just remove this line.  The line <em>$sql = $this->db->get(&#8216;data&#8217;);</em> tells the name of the table where I want to get the fields title and content.  To make sure I have something to work on the line <em>$sql->num_rows() > 0</em> is placed and the data is placed inside the array $data[].</p>
<p>To be more specific in using code igniter active records,</p>
<pre class="crayon-plain-tag"><code>&lt; ?php
class Mydb extends Model {

	function getData() {
		$this-&gt;db-&gt;select('title,content'); 
		$this-&gt;db-&gt;from('data');
		$this-&gt;db-&gt;where('id',1); 
		$sql = $this-&gt;db-&gt;get();  
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
        }
}

?&gt;</code></pre><p><p>Another way of querying is:</p><pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = $this-&gt;db-&gt;query('SELECT * FROM data');
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p>
<p>The line<em> $sql = $this->db->query(&#8216;SELECT * FROM data&#8217;);</em> is simply putting the query inside the predefined method in Code Igniter $this->db->query(&#8216;[query]&#8216;).  Still the data returned is an array.</p>
<p>To query with a user input,</p>
<pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = &quot;select * from data where id=?&quot;;
		$val = $this-&gt;db-&gt;query($sql, 2);
		if($val-&gt;num_rows() &gt; 0) {
			foreach($val-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p><p>
<p>The line <em>$sql = &#8220;select * from data where id=?&#8221;;</em> is our database query where ? is any value passed to it.  The line <em>$val = $this->db->query($sql, 2);</em> is where we execute our query and the value passed to &#8220;?&#8221; is 2. But what if we have more than 1 condition in our query,</p><pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = &quot;select * from data where id=? and author = ?&quot;;
		$val = $this-&gt;db-&gt;query($sql, array(1, 'Allan'));
		if($val-&gt;num_rows() &gt; 0) {
			foreach($val-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p><p><p>
<p>If we have more than one condition in our query we just use an array stating the value for our conditions.</p>
<div id="seo_alrp_related"><h2>Posts Related to Code Igniter Query</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/mysql-duplicate-error/" rel="bookmark">Mysql Duplicate Error</a></h3><p>I created a web application that managers collected links.  The web application was called duplicate checker where premium links collected are being stored in a ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmyadmin-importing-large-data/" rel="bookmark">PHPMyAdmin Importing Large Data</a></h3><p>By Default phpmyadmin can import data on your mysql database up to 2MB of data and beyond that will be an error.  This has been ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-installation-and-first-run/" rel="bookmark">Code Igniter Installation and First Run</a></h3><p>Code Igniter is an PHP Application Development Framework - a toolkit for PHP developers. The main goal of Code Igniter is to enable developers to ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/setting-up-a-memcached-server/" rel="bookmark">Setting Up a MemCached Server</a></h3><p>image from www.memcached.org Based on their official website memcached is defined as: Free & open source, high-performance, distributed memory object caching system, generic in nature, ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/change-a-string-or-character-in-mysql/" rel="bookmark">Change a String or Character in MySQL</a></h3><p>Knowing the right MySQL statement is the most important part in having thousands of data in your database, one false move and you can't undo ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/code-igniter-query/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Session Authentication</title>
		<link>http://www.icpep.org/session-authentication/</link>
		<comments>http://www.icpep.org/session-authentication/#comments</comments>
		<pubDate>Wed, 20 May 2009 12:25:56 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=609</guid>
		<description><![CDATA[One problem in creating a PHP Session Authentication is that when you are logged in and suddenly logs out and click the back button you will be returned to the page where you kast visited.   Isn&#8217;t this a problem especially when you have important data in that page.  So if you have problem with this let me share a code that will surely eleminate the problem.  In this code there is no need for javascripts to disable the back button(what [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-610 aligncenter" title="phpsession" src="http://www.icpep.org/wp-content/uploads/2009/05/phpsession.jpg" alt="phpsession" width="446" height="210" /></p>
<p style="text-align: justify;">One problem in creating a PHP Session Authentication is that when you are logged in and suddenly logs out and click the back button you will be returned to the page where you kast visited.   Isn&#8217;t this a problem especially when you have important data in that page.  So if you have problem with this let me share a code that will surely eleminate the problem.  In this code there is no need for javascripts to disable the back button(what if js is disabled on the browser?).</p>
<p style="text-align: justify;">The code uses session and when the user logs out the user is redirected to the login page and when he clicks the back button it will redirect back to the login page.  This is one trick for PHP Security Authentication.</p>
<p style="text-align: center;"><p></p><pre class="crayon-plain-tag"><code>#create a function to redirect the user to login page
#this should be on your php functions
function redirect($url){
	echo &quot;&amp;lt;script type='text/javascript'&amp;gt;&quot;; 
	echo &quot;window.location.href='$url'&quot;;
	echo &quot;&amp;lt;/script&amp;gt;&quot;; 
}

#this should be in your page where you authenticate the user
session_start();
$sql = mysql_query(&quot;select * from user
       where username=\&quot;$username\&quot; and userpassword=\&quot;$password\&quot;&quot;);

if(mysql_num_rows($sql) &amp;gt; 0) {
 $_SESSION['auth'] = true;
} else{
  redirect('login.php');
}

#so on the logout file there should be
session_destroy();
redirect('login.php');</code></pre>
<p align="justify"><span id="more-609"></span>Before starting in any of your PHP file you need to put this codes so that every now and the session is well monitored.</p>
<pre class="crayon-plain-tag"><code>if( $_SESSION['auth'] == true) {

#PHP code here ...

} else{

redirect('login.php');
}</code></pre><p>
<p style="text-align: justify;">So in this code if the session is not true the user is redirected to the login page.  So when the user press that back button the user is always redirected to login page because the session created was destroyed.  I hope this code will help a lot especially those who just started their PHP programming.</p>
<div id="seo_alrp_related"><h2>Posts Related to Session Authentication</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/black-hat-seo/" rel="bookmark">black hat Search Engine Optimization</a></h3><p>These black hat SEO techniques usually include one or more of the following characteristics: 1. One who breaks search engine rules. 2. Unethically presents content ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/backtrack-5-bug-fix/" rel="bookmark">Backtrack 5 Bug Fix</a></h3><p>I switched my ubuntu Oneiric to bactrack 5 Gnome and try out the new tools I wanted to use. Lately I thought everything will be ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-query/" rel="bookmark">Code Igniter Query</a></h3><p>Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/top-10-benifits-of-standards-based-programming/" rel="bookmark">TOP 10 Benefits of Standards-based Programming</a></h3><p>1. Deliver to multiple user agents. The same piece of marked-up content is readily deliverable in a wide variety of user agents, the collective name ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/telepornnet-redirect/" rel="bookmark">Teleporn.net Redirect</a></h3><p>In the past few days I was solving a problem on a site and the problem was this; The site has an iframe virus, the ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/session-authentication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Neural Network Programming</title>
		<link>http://www.icpep.org/neural-network-programming/</link>
		<comments>http://www.icpep.org/neural-network-programming/#comments</comments>
		<pubDate>Wed, 13 May 2009 12:27:51 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Neural Networks]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=573</guid>
		<description><![CDATA[Thank You to Jovencito Talasan One method of Neural Network Programming is Q Learning that will be applied for ai robots. Q learning is is an off-policy method that can be run on top of any strategy wandering in the Markov Decision Process (MDP). It uses the information observed to approximate the optimal function, from which one can construct the optimal policy or to summarize the function of Q learning, only the state-action function needs to be stored and updated. [...]]]></description>
			<content:encoded><![CDATA[<p>Thank You to Jovencito Talasan</p>
<p align="justify">One method of Neural Network Programming is Q Learning that will be applied for ai robots.  Q learning is is an off-policy method that can be run on top of any strategy wandering in the Markov Decision Process (MDP). It uses the information observed to approximate the optimal function, from which one can construct the optimal policy or to summarize the function of Q learning, only the state-action function needs to be stored and updated.</p>
<p>This the intelliBrain Mobot&#8217;s <strong>Flow Chart</strong>:</p>
<p align="center"><img class="aligncenter size-full wp-image-485" title="flow-chart-of-mobile-robot-function" src="http://www.icpep.org/wp-content/uploads//flow-chart-of-mobile-robot-function.jpg" alt="flow-chart-of-mobile-robot-function" width="297" height="240" /></p>
<p><span id="more-573"></span></p>
<p align="justify">The Language used for the Neural Network Programming is JAVA.  The Program was then loaded to the controller.</p>
<pre class="crayon-plain-tag"><code>LEARN_RATE = 0.35f; // the learning rate constant
public static float EXPLORE_RATE = 0.15f; // the rate it tries out random
//actions
private static Servo mLeftServo;
private static Servo mRightServo;
byte [][] state;
byte [][]action;
private static float [][] Q; // table of Q-values (action,state)
byte i = -1; // last state
byte a = -1; // last action
byte a1 = 0; // action with highest q-value
float r = 0; // Last reward
public ObstacleAvoidance(byte actions, byte states) // constructor
{
state = new byte[states][4]; // 16 unique states, 4 unique SENSOR
action = new byte[actions][2]; // 4 unique actions with 2 actuators
initAction(action);
initState(state);
Q = new float[actions][states]; // table of Q-values for action-states
//setRandomValues(Q);
setLearnedQValues(Q);
}
public static void main(String [] args)
{
byte actions = 4;
byte states = 16;
long iterMax=100000;
ObstacleAvoidance qutil = new ObstacleAvoidance(actions, states);
ObstacleAvoidance qbrain = new ObstacleAvoidance(actions, states);
byte[] e = new byte[8]; // The environment values
2
byte [] motorCommand = new byte[2]; // Commands to send to motors
mLeftServo=IntelliBrain.getServo(1);
mRightServo=IntelliBrain.getServo(2);
for (long iter=0;iter&amp;lt;=3)
e[0]=1;
else
e[0]=0;
if(e[5]&amp;lt;=4)
e[1]=1;
else
e[1]=0;
if (e[6]&amp;lt;=3)
e[2]=1;
else
e[2]=0;
if (e[7]&amp;lt;=3)
e[3]=1;
else
e[3]=0;
}
public static void initAction(byte [][] state)
{
byte count = 0;
for(byte i=0;i&amp;lt;2;++i)
for(byte j=0;j&amp;lt;2;++j)
{
state[count][0] = i;
state[count][1] = j;
++count;
}
}
public static void initState(byte [][] state)
{
byte count = 0;
for(byte i=0;i&amp;lt;2;++i)
for(byte j=0;j&amp;lt;2;++j)
for(byte k=0;k&amp;lt;2;++k)
for(byte l=0;l&amp;lt;2;++l)
{
state[count][0] = i;
state[count][1] = j;
state[count][2] = k;
state[count][3] = l;
5
++count;
}
}
public static void setRandomValues(float [][] Q)
{
for(byte i=0;i=0)
{
r = getRewardValue(e);
a1 = getMaxAction(j);
Q[a][i] = Q[a][i] + LEARN_RATE * (r + Q[a1][j] - Q[a][i]);
// Q[&quot;+a+&quot;][&quot;+i+&quot;] = &quot; + System.out.println(&quot;&quot;+Q[a][i]);
}
i = j;
// GREEDY
float rand = (float)Math.random();
if(rand &amp;gt; EXPLORE_RATE)
{
a = getMaxAction(j);
//System.out.println(&quot;Q[&quot;+a+&quot;][&quot;+j+&quot;] = &quot; + Q[a][j]);
}
// E-GREEDY
else
a = (byte)(Math.random() * 4);
buzzer.beep();
return a;
}
// find the largest Q-value for a given state (j), and return action
public byte getMaxAction(byte state)
8
{
float max = -1000;
byte action = 0;
for(byte a=0;a max)
{
max = Q[a][state];
action = a;
}
}
return action;
}
public byte getState(byte [] e)
{
byte count = 0;
for(byte i=0;i&amp;lt;2;++i)
for(byte j=0;j&amp;lt;2;++j)
for(byte k=0;k&amp;lt;2;++k)
for(byte l=0;l&amp;lt;2;++l)
{
if (e[0] == state[count][0])
if (e[1] == state[count][1])
if (e[2] == state[count][2])
if (e[3] == state[count][3])
return count;
++count;
}
return -1;
}
public float getRewardValue(byte [] e)
{
byte reward=0;
if(a==0)
reward += 3; // good reward
if (e[0] == 1||e[1] == 1||e[2] == 1||e[3] == 1)
reward -= 2; // give bad reward: penalize
return reward ;
}
}</code></pre><p>
To view the Result of the intellibrain Neural Network Programming on ai Robots.  Click <a href="http://www.icpep.org/robot-kits/"> here</a></p>
<div id="seo_alrp_related"><h2>Posts Related to Neural Network Programming</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/mikrotik-router-filtering-bogus-ips/" rel="bookmark">Mikrotik Router Filtering Bogus IPs</a></h3><p>Mikrotik is a router os that comes with a lot of features.  To see what you can do with it, just visit their official website ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/getting-main-domain/" rel="bookmark">Getting Main Domain</a></h3><p>Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/robotic-kits/" rel="bookmark">Robotic Kits</a></h3><p>MOBOT - Mobot is the term used for a Mobile Robot. A mobile robot consist of wheels that serves as the feet of a walking ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/howto-hello-world-in-c/" rel="bookmark">Howto Hello World in C++</a></h3><p>//Printing Hellow World! #include &lt;iostream&gt; int main() { std::cout &lt;&lt; "Hello World! \n"; system("pause"); return 0; } Line begins with //, indicating that the remainder ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/c-reading-from-a-text-file/" rel="bookmark">C++ Reading From a Text File</a></h3><p>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int main() { string line; int count = 0; ifstream FileName ("try.txt"); if (FileName.is_open() &amp;&amp; !FileName.eof()){ ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/neural-network-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Assembly Language Tutorial</title>
		<link>http://www.icpep.org/assembly-language-tutorial/</link>
		<comments>http://www.icpep.org/assembly-language-tutorial/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 02:32:43 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=474</guid>
		<description><![CDATA[Here is another Assembly Language Tutorial Sample Program. This program is creating a fixed password to a certain application. This One of the basic examples unlike some of the other programs that passwords can be changed without accessing the source code. But here we created a program that has a fixed password abcdef. It is then displayed as a # when type from the keyboard. When password is correct the background color is the changed and the ASCII characters then [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Here is another Assembly Language Tutorial Sample Program.  This program is creating a fixed password to a certain application.  This One of the basic examples unlike some  of the other programs that passwords can be changed without accessing the source code.  But here we created a program that has a fixed password abcdef.  It is then displayed as a # when type from the keyboard. When password is correct the background color is the changed and the ASCII characters then is displayed.   A86 is used as the assembler for the program.  Below is a sample output of the program.</p>
<p style="text-align: center;"><img class="size-full wp-image-500 aligncenter" title="password_assemblylanguagetutorial" src="http://www.icpep.org/wp-content/uploads//password_assemblylanguagetutorial.jpg" alt="password_assemblylanguagetutorial" width="500" height="250" /><strong></strong></p>
<p><span id="more-474"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-4547412119801593";
/* Assembly Language Tutorial */
google_ad_slot = "4908892565";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p><pre class="crayon-plain-tag"><code>call clear		;clear the screen
call center

mov ah,09h		;display string
lea dx,msg2		;prints Enter password
int 21h

mov bl,3

again:
        mov ah,07		;direct keyboard input
        int 21h
        mov bh,al		;move the input al to bh
        cmp bh,0dh
        je again
        call asterisk
        cmp bh,'a'		;compare bh with J
        je again1		;if equal jump to again
        jne wrong		;if not to wrong

again1:
        mov ah,07
        int 21h
        mov bh,al
        cmp bh,0dh
        je invalid9
        call asterisk
        cmp bh,08h
        je again
        cmp bh,'b'		;compare bh with P
        je again2
        jne wrong
again2:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,'c'		;compare bh with h
        je again3
        jne wrong

invalid9:
         call invalid8

 again3:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,'d'		;compare bh with I
        je again4
        jne wrong

again4:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,'P'		;compare bh with C
        je again5
        jne wrong
again5:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,'e'		;compare bh with E
        je again6
        jne wrong
again6:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,'f'		;compare bh with s
        je again7
        jne wrong

invalid8:
        call invalid

again7:
        mov ah,07
        int 21h
        mov bh,al
        cmp bh,0dh	;compare the input with the enter key
        je exit
        jne wrong

wrong:
        mov ah,07
        int 21h
        mov bh,al
        call asterisk
        cmp bh,0dh	;compare the input with the enter key
        je invalid
        jne wrong

invalid:
        call clear
        call center
        mov ah,09
        lea dx,msg1	;prints retry password
        int 21h
        dec bl		;decrements bl until 3 attempts
        cmp bl,0
        je invalid2
        jmp again

invalid2:
        call clear
        call center
        mov ah,09		;print password failed!!!
        lea dx,msg3
        int 21h
        int 20h

exit:
        call clear
        call center</code></pre><p><script type="text/javascript"><!--
google_ad_client = "pub-4547412119801593";
/* 665E59Assembly Language Tutorial Sample Program */
google_ad_slot = "8541998060";
google_ad_width = 250;
google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p><pre class="crayon-plain-tag"><code>;ASCII program

	mov ax,0600		;setting background
	mov bh, 30h		;color of the attribute
	mov cx,0000h		;where the color starts to point
	mov dx,184fh		;where the color ends to point
	int 10h			

	mov ax,0b800		;location of the screen
	mov es,ax		;location of the screen move to es register
	mov bx,60+(160*4)	;where the title starts to display and move to bx register
	mov si,msg4		;the message move to si register
	mov cx,16		;the numbers of letters that will display

print:

	mov al,b[si]		;the value of si is move to al register
	mov es:[bx],al		;move the value of al to the location of es:[bx]
	inc si			;increment the si
	add bx,2		;add bx by 1 for the attribute
	loop print		;looping
	int 21h			;to terminate the loop

	mov bh,0		;holds the characters
	mov di,160*8		;where the characters will display and move to di register
	mov cx,255		;the number of characetrs that will display

char:
        mov al,bh		;moving bh to the al register
        mov es:[di],al		;move the value of al is move to the location of es:[di]
        inc bh			;increment the bh
        add di,8		;to make 20 columns
        loop char		;looping
	int 20h			;to terminate the loop

msg4:db 'ASCII CHARACTERS'

msg3 db 'PASSWORD INCORRECT!DENIED ACCESS!$'
msg2 db 'PASSWORD: $'
msg1 db 'RETRY: $'

asterisk:			;prints asterisk
        mov ah,09h
        lea dx,ask
        int 21h
        ret

ask db '#$'

clear:			;clear screen
        mov ax,03
        int 10h
center:			;set cursor at the center
        mov ah,02
        mov bh,00
        mov dh,12
        mov dl,33
        int 10h
        ret</code></pre>
<div id="seo_alrp_related"><h2>Posts Related to Assembly Language Tutorial</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-compare-date/" rel="bookmark">PHP Compare Date</a></h3><p>I was creating a program for a library and that is to have a system that will manage the borrowing of books. I was searching ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/howto-hello-world-in-c/" rel="bookmark">Howto Hello World in C++</a></h3><p>//Printing Hellow World! #include &lt;iostream&gt; int main() { std::cout &lt;&lt; "Hello World! \n"; system("pause"); return 0; } Line begins with //, indicating that the remainder ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/filezilla-saved-passwords/" rel="bookmark">Filezilla Saved Passwords</a></h3><p>Filezilla is an FTP Client used for transferring files from one host to the other or is used to exchange and manipulate files over a ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/bubble-sort-and-graphics-h-in-dev-c/" rel="bookmark">Bubble Sort and Graphics.h in Dev C++</a></h3><p>Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/set-boot-to-cd-rom/" rel="bookmark">Set Boot To CD ROM</a></h3><p>In most computers the first booting device set is the HD0 or your hard disk where your Operating System is installed or in older PC's ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/assembly-language-tutorial/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

