tag:blogger.com,1999:blog-59608172600391312302024-03-13T11:17:40.244-07:00Knowledge BasePlace to share knowledge and experienceAsadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-5960817260039131230.post-87257748759240240552013-07-01T12:44:00.001-07:002017-01-25T22:06:23.400-08:00Forcing some urls to HTTPS and some on HTTP using cakephp<div dir="ltr" style="text-align: left;" trbidi="on">
Hi guys, today I was trying to do this task and did a lot of R&D. Tried some httaccess rules, tried cakephp routers and most specially which did my half work ( forcing some urls to https ) is security component of cakephp. But non of these components and techniques worked well like I wanted to do it. Then I wrote a simple function and it worked well.<br />
<br />
Here is I am gonna show you how to redirect some urls like checkout, login, register on HTTPS and vice virsa. Here is that function,<br />
<br />
<pre style="background-image: URL(https://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">/*
redicting some urls to https
*/
function securityrules()
{
$arrparams = $this->params;
if( $_SERVER["HTTPS"] == "on" )
{
if( $arrparams['action'] != "login" && $arrparams['action'] != "register" && $arrparams['action'] != "reset" )
{
$this->redirect('http://' . env('SERVER_NAME') . $this->here);
}
}
else
{
if( $arrparams['action'] == "login" || $arrparams['action'] == "register" || $arrparams['action'] == "reset" )
{
$this->redirect('https://' . env('SERVER_NAME') . $this->here);
}
}
}
</code></pre>
And for using it place this function in AppController.php and call it at the start of beforeFilter() function
And enjoy. Don't waste your time on other stupid techniques like i wasted my whole day :(
Thanks</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com1tag:blogger.com,1999:blog-5960817260039131230.post-65468189594221428472012-11-30T04:51:00.002-08:002018-03-02T01:30:09.429-08:00Number of Users Online script in PHP<div dir="ltr" style="text-align: left;" trbidi="on">
Sometime our clients demand for showing how many visitors are online currently on their website. This can be done by many ways. I am going to illustrate two methods of doing this. One is file based and other one is database based. Let us see how to achieve this by both methods one by one.<br />
<br />
<b>1) File Based Method:</b><br />
<br />
In this method PHP script writes online visitors information in a text file. That text file is updated after a specific interval of time and script reads that file and show a counter of online visitors where required. Let us see the details of this method step by step,<br />
<br />
<b>Step 1) </b>First of all you have to create a .txt file and place it on any folder in your server. In my case I am creating this file on root folder of my website and naming it ip.txt. After updating this file by code, it looks something like this,<br />
<br />
<div class="wp_syntax">
<div class="code">
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">127.0.0.1****1354262381++++
127.0.0.1****1354262381++++
127.0.0.1****1354262381++++
</code></pre>
</div>
</div>
<br />
Step 2):Then copy and paste the code below where you want to show that counter,
<br />
<div class="wp_syntax">
<div class="code">
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
<php
$url = $_SERVER['SCRIPT_FILENAME'];
$pp = strrpos($url,"/");
$url = substr($url,0,$pp);
$ura = $_SERVER['SCRIPT_NAME'];
$host = $_SERVER['SERVER_NAME'];
$ser = "http://$host";
$ura= $ser.$ura;
$pp1 = strrpos($ura,"/");
$ura = substr($ura,0,$pp1);
$url1=explode('/', $url);
$url=array_pop($url1);
$url1=implode('/', $url1);
$ura1=explode('/', $ura);
$ura=array_pop($ura1);
$ura1=implode('/', $ura1);
$hm = "$url1";
$hm2 = "$ura1";
include "onlinevisitors.php";
?>
</code></pre>
</div>
</div>
<br />
Step 3): Next step is to create a file named onlinevisitors.php file and place in the folder where you included it in above code. In our case root folder,<br />
<br />
<div class="wp_syntax">
<div class="code">
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
<?php
$rip = $_SERVER['REMOTE_ADDR'];
$sd = time();
$count = 1;
$file1 = "ip.txt";
$lines = file($file1);
$line2 = "";
foreach ($lines as $line_num => $line)
{
//echo $line."";
$fp = strpos($line,'****');
$nam = substr($line,0,$fp);
$sp = strpos($line,'++++');
$val = substr($line,$fp+4,$sp-($fp+4));
$diff = $sd-$val;
if($diff < 300 && $nam != $rip)
{
$count = $count+1;
$line2 = $line2.$line;
//echo $line2;
}
}
$my = $rip."****".$sd."++++\n";
$open1 = fopen($file1, "w");
fwrite($open1,"$line2");
fwrite($open1,"$my");
fclose($open1);
echo "<table width=180 height=30 bgcolor=#fdfdfd style=\"border: 1px green solid;\"><tr><td align=left valign=top>";
echo "</td><td align=center>";
echo "<span style=\"font-family: verdana,arial,helvetica; font-size: 11px; font-weight: bold; color: #aaccaa;\">";
echo "Total users online - <font color=red>$count</font></span><br>";
echo "</td></tr></table>";
?>
</code></pre>
</div>
</div>
<br />
<b>2) Database Driven Method:</b> <br />
<br />
comming soon...</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-78151114750990552462012-11-14T22:55:00.001-08:002012-11-15T00:04:33.370-08:00Which Web Programming language to learn to keep you employed?<div dir="ltr" style="text-align: left;" trbidi="on">
There are thousands of programming languages out there and have their own value over one and other. But there are a few programming languages which can keep you employed and you don't have to worry about earnings. Learning a right programming language on right time and right place is very necessary for your carrier. There are many examples out there who are not happy with their field and struggling in the market due to this fact. That's why I am going to share with my blog readers about the best programming languages and their scope in different areas of the world. <br />
<ul style="text-align: left;">
<li>PHP</li>
<li>MySQL</li>
<li>Javascript</li>
<li>Perl</li>
<li>Ruby</li>
<li>Python</li>
<li>ASP.net</li>
</ul>
<a name='more'></a><h4 style="text-align: left;">
<u>PHP:</u></h4>
<div style="text-align: left;">
PHP stands for <b>P</b>HP: <b>H</b>ypertext <b>P</b>reprocessor. PHP is an open source web programming language and is no doubt is the king of all web-programming languages. It is widely being used in latest websites. Almost 75% servers now-days are running PHP. PHP is also called server-side programming language because its code runs on the server and processed html code is sent to the user's browser. Many of the famous cms like wordpress, joomla, drupal etc are developed in PHP, even the most popular social networking website <a href="http://www.facebook.com/" rel="nofollow">facebook</a> is also developed in PHP. PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid,
PostgreSQL, Generic ODBC, etc.). If you want to read further about it you can go to its tutorial by clicking this url <a href="http://www.php.net/" rel="nofollow">http://www.php.net/</a><br />
<h4 style="text-align: left;">
<u>MySQL </u>:</h4>
</div>
This is another programming language you must learn for web development. This is also open source like PHP. This is used as database programming language. MySQL is actually relational database management system. Relational database means data is stored in tables and tables are linked to each other for normalization. MySQL Database Server is very fast, reliable, scalable, and easy to use. MySQL Server works in client/server or embedded systems.<br />
<h4 style="text-align: left;">
<u>JavaScript:</u></h4>
<div style="text-align: left;">
<span style="font-weight: normal;">JavaScript is the power of webpages. It is client side scripting language so its code runs on the user's browser, </span>allowing webpages to respond to user interactions such as clicking on elements and timing events.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
The most popular framework jQuery is actually javascript framework. JQuery lets you write less code and
gives you greater browser compatibility, and is quickly becoming the
standard for modern webpages. It’s particularly useful for targeting
specific parts of a webpage using familiar CSS terms and doing something
with them, such as showing or hiding them. Although JQuery is made from
Javascript, it introduces its own unique language components too, so
just because you know Javascript doesn’t mean you can automatically use
JQuery (you could also argue that you don’t need to know much Javascript
to be able to use jQuery). We’ll definitely be looking at this one at
some point. <br />
<h4 style="text-align: left;">
<u>Perl:</u></h4>
<div style="text-align: left;">
<span style="font-weight: normal;">Perl is a programming language which can be used for a large variety of tasks. A typical simple use of Perl would be for extracting information from a text file and printing out a report or for converting a text file into another form. But Perl provides a large number of tools for quite complicated problems, including systems programming. </span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-weight: normal;">Perl is implemented as an interpreted (not compiled) language. Thus, the execution of a Perl script tends to use more CPU time than a corresponding C program, for instance. On the other hand, computers tend to get faster and faster, and writing something in Perl instead of C tends to save your time. </span></div>
<h4 style="text-align: left;">
<u><b><span style="font-weight: normal;"><b>Ruby</b>:</span></b></u></h4>
<div style="text-align: left;">
<span style="font-weight: normal;">Ruby and its most popular framework Ruby-on-Rails is another one of the widely used web programming language. This is also open source and server side programming language like PHP. But it is pretty much different than php. Its has a number of advantages like repid development, less repetition and speed. But unfortunately most of the web server don't support it. So if you are planning to use it you have to configure your own server.</span></div>
<div style="text-align: left;">
<span style="font-weight: normal;"><br /></span></div>
<h4 style="text-align: left;">
<span style="font-weight: normal;"><u><b>Python:</b></u></span></h4>
<div style="text-align: left;">
<span style="font-weight: normal;">Python is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java. Some of its key distinguishing features include:</span></div>
<ul style="text-align: left;">
<li><span style="font-weight: normal;">very clear, readable syntax</span></li>
<li><span style="font-weight: normal;">strong introspection capabilities</span></li>
<li><span style="font-weight: normal;">intuitive object orientation</span></li>
<li><span style="font-weight: normal;">natural expression of procedural code</span></li>
<li><span style="font-weight: normal;">full modularity, supporting hierarchical packages</span></li>
<li><span style="font-weight: normal;">exception-based error handling</span></li>
<li><span style="font-weight: normal;">very high level dynamic data types</span></li>
<li><span style="font-weight: normal;">extensive standard libraries and third party modules for virtually every task</span></li>
<li><span style="font-weight: normal;">extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)</span></li>
<li><span style="font-weight: normal;">embeddable within applications as a scripting interface</span></li>
</ul>
<h4 style="text-align: left;">
<span style="font-weight: normal;"><b><u>ASP.NET:</u></b></span></h4>
ASP.NET is a development framework for building web pages and web
sites with HTML, CSS, JavaScript and server scripting.<br />
<br />
ASP.NET supports three different development models: Web Pages, MVC (Model View Controller), and Web Forms:<br />
<br />
You can find its tutorial on this url <a href="http://www.w3schools.com/aspnet/default.asp" rel="nofollow">http://www.w3schools.com/aspnet/default.asp</a><br />
<br />
<br /></div>
</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-81004842791507507212012-11-13T23:07:00.003-08:002012-11-22T05:00:11.614-08:00How to increase PTCL EVO signals<div dir="ltr" style="text-align: left;" trbidi="on">
PTCL EVO is one of the best source of wireless internet connectivity and it offers coverage in more than 250 cities in pakistan nationwide. But sometimes eVo customers are returning their devices within 3 days because of dis-satisfaction or no signals at there homes or offices. So i thought there should be some method to strengthen the eVo signals so that customers can enjoy the great internet service out there.<br />
<br />
<a name='more'></a><br />
There are 2 methods which i tried and found great.<br />
<br />
<u><b>Method # 1:</b></u><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-oXItU0Uz1TY/UKNCfaaJaiI/AAAAAAAACuE/X-6KvDjfjIE/s1600/PTCL_EVDO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="http://1.bp.blogspot.com/-oXItU0Uz1TY/UKNCfaaJaiI/AAAAAAAACuE/X-6KvDjfjIE/s320/PTCL_EVDO.jpg" width="320" /></a></div>
<br />
Get a CD with both sides empty (meaning no sticker on either side) and flip it over to EVO device's antenna.<br />
<br />
<u><b>Method # 2:</b></u><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-CngSMxZkyXE/UKNC4uXk27I/AAAAAAAACuM/EUM0jwJ2_-Y/s1600/USB_PTCL.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-CngSMxZkyXE/UKNC4uXk27I/AAAAAAAACuM/EUM0jwJ2_-Y/s320/USB_PTCL.jpg" width="225" /></a></div>
You will need a thin wire (preferably silver or copper).
To get started turn the wires around the antenna, so as to form a spiral
around it as shown. The top part should stick out about 10 cms, and
then you will need to add some more spirals (three or four) such that
they are roughly 5 cm. After that you need to leave a straight wire
about 1.5 cm in length. To turn the wire, I would suggest you twist it around a pencil or pen and then adjust the spiral distance by hand.<br />
<br /></div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com6tag:blogger.com,1999:blog-5960817260039131230.post-60669830856667889862012-11-09T05:00:00.001-08:002012-11-09T05:00:05.991-08:00What is radiotherapy treatment?<div dir="ltr" style="text-align: left;" trbidi="on">
As x-Rays have been discovered almost 10 years ago and these are being used in medical science. These are used for the diagnosis purpose as well as for the treatment such as radiotherapy. There are two types of radiotherapy,<br />
<br />
1. External radiotherapy<br />
<br />2. Internal radiotherapy<br />
<br />
External radiotherapy is for external body and internal radiotherapy is used for internal body parts. Radiotherapy is actually used to distroye cancel cells but it may damage normal cells as well. But fortunately normal cells can repair themselves later on.<br />
<br />
<a name='more'></a><br />
<b>How Radiotherapy do its work:</b><br />
<br />Radiotherapy treatments works by destroying DNA of cancer cells so that they wont be able to reproduce which cause reducing tumours. Radiotherapy treatment is used in following reasons,<br />
<br />
<ul style="text-align: left;">
<li> To destroy the tumour – this may include radiotherapy on its own or combined with other treatments such as surgery or chemotherapy. If the aim is to cure your cancer with radiotherapy, this is known as primary therapy or radical radiotherapy.</li>
<li> To reduce the size of a tumour before surgery. This is called neo-adjuvant treatment.</li>
<li> To make sure all the cancer cells are destroyed after surgery. This is called adjuvant treatment.</li>
<li> In the emergency treatment of a cancer pressing on your spinal cord to reduce the size of the cancer and prevent damage to your nerves.</li>
<li> In advanced cancer to slow down the progress of the disease, relieve pain and other symptoms. This is called palliative treatment.</li>
</ul>
<div style="text-align: left;">
<br /></div>
<br />
<br /></div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-4167016711549887162012-11-09T02:05:00.001-08:002012-11-29T03:08:27.272-08:00List of TOP 60 Insurance Companies in Pakistan<div dir="ltr" style="text-align: left;" trbidi="on">
<b>I. Public sector</b><br />
<br />
1. National Insurance Corporation <a href="http://www.nicl.com.pk/" rel="nofollow">http://www.nicl.com.pk/</a><br />
2. <a href="http://www.pakre.org.pk/ms/" rel="nofollow">Pakistan Reinsurance Company Ltd</a>.<br />
3. <a href="http://www.postallifeinsurance.gov.in/" rel="nofollow">Postal Life Insurance</a><br />
4. <a href="http://www.statelife.com.pk/" rel="nofollow">State Life Insurance Corporation Ltd</a>.<br />
<br />
<br />
<a name='more'></a><br />
<b>II. Private sector</b><br />
<br />
a) Incorporated in Pakistan<br />
<br />
1. <a href="http://www.adamjeeinsurance.com/" rel="nofollow">Adamjee Insurance Company Ltd</a>.<br />
2. Agro General Insurance Company Ltd.<br />
3. <a href="http://www.allianzefu.com/" rel="nofollow">Allianz EFU Health Insurance Company Ltd</a>.<br />
4. <a href="http://www.alphainsurance.com.pk/" rel="nofollow">Alpha Insurance Company Ltd</a>.<br />
5. Amercian Life Insurance Company Ltd.<br />
6. <a href="http://asiainsurance.com.pk/" rel="nofollow">Asia Insurance Company Ltd</a>.<br />
7. Asian Mutual Insurance Company Ltd.<br />
8. <a href="http://www.agico.com.pk/" rel="nofollow">Askari General Insurance Company Ltd</a>.<br />
9. <a href="http://www.beemapakistan.com/" rel="nofollow">Beema Insurance Company Ltd</a>.<br />
10. Business & Industrial Insurance Company Ltd.<br />
11. Capital Insurance Company Ltd.<br />
12. Central Insurance Company Ltd.<br />
13. Century Insurance Company Ltd.<br />
14. Commercial Union Life Assurance Company<br />
15. Co-operative Insurance Society of Pakistan Ltd.<br />
16. Credit Insurance Company Ltd.<br />
17. Crescent Star Insurance Company Ltd.<br />
18. Dadabhoy Insurance Company Ltd.<br />
19. Delta Insurance Company Ltd.<br />
20. E.F.U.General Insurance Company Ltd.<br />
21. E.F.U.Life Insurance Company Ltd.<br />
22. East West Insurance Company Ltd.<br />
23. Excel Insurance Company Ltd.<br />
24. Gulf Insurance Company Ltd.<br />
25. Habib Insurance Company Ltd.<br />
26. Indus International Insurance Company Ltd.<br />
27. International General Insurance Co. of Pak<br />
28. Ittefaq General Insurance Company Ltd.<br />
29. Jupiter Insurance Company Ltd.<br />
30. Metropoliton Life Assurance Company Ltd.<br />
31. Muslim Insurance Company Ltd.<br />
32. National General Insurance Company Ltd.<br />
33. New Jubilee Insurance Comapny Ltd.<br />
34. North Star Insurance Company Ltd.<br />
35. Orient Insurance Company Ltd.<br />
36. Pakistan General Insurance Company Ltd.<br />
37. Pakistan Guarantee Insurance Company Ltd.<br />
38. Pakistan Mutual Insurance Company Ltd.<br />
39. Platinum Insurance Company Ltd.<br />
40. Premier Insurance Company Ltd.<br />
41. Prime Insurance Company Ltd.<br />
42. Raja Insurance Company Ltd.<br />
43. Reliance Insurance Company Ltd.<br />
44. Seafield Insurance Company Ltd.<br />
45. Security General Insurance Company Ltd.<br />
46. Shaheen Insurance Company Ltd.<br />
47. Sliver Star Insurance Company Ltd.<br />
48. Union Insurance Company of Pakistan Ltd.<br />
49. United Insurance Company of Pakistan Ltd.<br />
50. Universal Insurance Company Ltd.<br />
<br />
b) Incorporated abroad<br />
<br />
1. ACE Insurance Aid Pacific Ltd.<br />
2. CGU Assurance Company Ltd.<br />
3. New Hampshire Insurance Company Ltd.<br />
4. New Zealand Insurance Company Ltd.<br />
5. Royal & Sun Alliance Assurance plc.</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com15tag:blogger.com,1999:blog-5960817260039131230.post-8245167242484416592012-11-09T01:38:00.003-08:002012-11-09T01:39:13.162-08:00Tips on Accessing DSL Router, Modem or CPE<div dir="ltr" style="text-align: left;" trbidi="on">
We are going to discuss that how can we access the DSL Modem, Router or CPE to put the internet settings and to configure it.<br />
<br />
By following theses simple steps we can access the CPE and establish a connection to internet.<br />
<br />
Keep reading this post for complete guide.<br />
<br />
<b>Connect the CPE to the Computer</b>:<br />
<br />
<ol>
<li>Connect the Power Adapter to the AC power plug and attach the connector of
adapter to the CPE and switch it on.</li>
<li>Attach one end of LAN wire (RJ-45) to the LAN interface of CPE and the other
end to the LAN wire to the LAN interface of computer’s LAN card.</li>
<li>Link Indicator lights will lit up and show the connectivity.</li>
</ol>
<b>DSL Configuration in CPE and Computer</b>:<br />
<ol>
<li>Go to Start Menu > Control Panel > Network and Internet Connections > Network
Connections. Check that the Local Area Connection is enabled. Right click local
Area network and click properties.</li>
<li>Double click “internet protocol (TCP/IP)”, Check “Use the following IP
address” and make the following settings:</li>
<li>IP Address: 192.168.1.5</li>
<li>Subnet Mask: 255.255.255.0</li>
<li>Gateway: 192.168.1.1</li>
<li>Then, check “Obtain DNS server addresses automatically” and click "OK" to apply these settings.</li>
</ol>
Now open Internet Explorer and type “192.168.1.1” in address bar and press
enter. There must not be any proxy setting in the internet Explorer.<br />
<br />
A small pop up window will open as shown in the figure below and ask ”User Name”
and “Password” for opening the CPE’s interface.<br />
<br />
Enter User Name: “<b>admin</b>” and Password: “<b>admin</b>” and press OK.<br />
<br />
<br />
You can read this <a href="http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html" target="_blank">http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html</a> to learn how to do router settings.</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-87395506179856563082012-11-08T23:08:00.000-08:002012-11-08T23:08:15.493-08:00Techniques of Adding New Widget Sections In Blogger On Different Places?<div dir="ltr" style="text-align: left;" trbidi="on">
Adding new widget sections in blogger template is very easy task to do. There are many posts about this topic on the internet but those are very lengthy to read. Purpose of my post is to clear the concept.<br />
<br />
If you want to add a widget which should be shown on home page of your blogspot blog then you have to follow these steps.<br />
<br />
Step # 1. Go to templates section of your blog and click on html Editor.<br />
<br />
Step # 2. Now decide where you want to add new widget section.<br />
<br />
Step # 3. And past below code and save.<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"><b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:section class='sidebar' id='magazine-left' showaddelement='yes' >
<b:widget id='Text51' locked='false' title='Test Title 1' type='Text'/>
</b:section> </b:if>
</code></pre>
<br />
If you want to add a widget which should be displayed on every page of your blog then you have to past below code in the corresponding area and save the template. All other steps will remain same.<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"><b:section class='sidebar' id='magazine-left' showaddelement='yes' >
<b:widget id='Text51' locked='false' title='Test Title 1' type='Text'/>
</b:section></code></pre>
<br /></div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-70871210780065369152012-11-08T22:14:00.001-08:002012-11-09T01:40:33.461-08:00How to do PTCL DSL Modem and Router configuration<div dir="ltr" style="text-align: left;" trbidi="on">
Hi guys, today i am going to share with you the most important and useful information regarding PTCL DSL modem configuration. This is a common problem that our internet stops working and we have no knowledge about what to do. There are two methods of configuring PTCL DSL router.<br />
<br />
<br />
<b>1. Call 1236 Helpline:</b><br />
<br />
One method id to call 1236 PTCL line anf ask them, they should configure you DSL modem remotely and the other method is to configure you modem manually.<br />
<br />
<br />
<b>2. Manual Method:</b><br />
<br />
2nd method is to do manual configuration. First of all open Internet Explorer and write “192.168.1.1” in address bar and press
enter. There must not be any proxy setting in the internet Explorer. This will open a login window and will ask for username and password to access the router console. The default username and password for router is admin/admin. So write admin in username box and admin in password box and click on login button.<br />
<br />
How to access router using browser can be found in this post <a href="http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html">http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html</a><br />
<br />
<a name='more'></a><br />
<b>How To Enter Settings</b> <b>?</b> After accessing your modem, enter the settings as shown in the images below.<br />
<br />
<ul>
<li>Click on "Quick Setup" or "Connect to Internet" then enter VPI and VCI click next (as shown in images)</li>
<li>Follow the images for further configuration.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-AY1p3ZKtR5c/UJyc0RvNheI/AAAAAAAACtY/3iRbhOizsV8/s1600/ptcl-dsl-router-settings.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="http://3.bp.blogspot.com/-AY1p3ZKtR5c/UJyc0RvNheI/AAAAAAAACtY/3iRbhOizsV8/s640/ptcl-dsl-router-settings.jpg" width="365" /></a></div>
<br />
<b>VPI and VCI Settings</b>:<br />
<br />
<ul>
<li>For Copper customers use <b>VPI</b> = 0 and <b>VCI</b> = 103 (<span style="color: red;">If PTCL line form exchange to your nearest DP (Distribution Point) is of Copper</span>)</li>
<li>For Fiber customers use <b>VPI</b> = 8 and <b>VCI</b> = 81 (<i><span style="color: red;">If PTCL link form exchange to you nearest DP (Distribution Point) is on Fiber</span></i>)</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-DMvQYBII4Lk/UJydzpjVibI/AAAAAAAACtg/86JkYrW2RBU/s1600/auto-settings.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="http://1.bp.blogspot.com/-DMvQYBII4Lk/UJydzpjVibI/AAAAAAAACtg/86JkYrW2RBU/s400/auto-settings.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-MasFB3Jebhg/UJyeTJltO2I/AAAAAAAACto/SU5pvZ4sg6I/s1600/username-password.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="http://1.bp.blogspot.com/-MasFB3Jebhg/UJyeTJltO2I/AAAAAAAACto/SU5pvZ4sg6I/s400/username-password.jpg" width="400" /></a></div>
<br />
<b>DSL User-Name name and Password</b>:<br />
<br />
<ul>
<li>(Default user name is you PTCL Land Line Number and Default Password
is PTCL) or call 1236 and ask them for your DSL username and password.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-DeatDvRWIow/UJye7o_CeAI/AAAAAAAACtw/O3UGX1YtKTs/s1600/ptcl-dsl-router-final-manual-settings.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://2.bp.blogspot.com/-DeatDvRWIow/UJye7o_CeAI/AAAAAAAACtw/O3UGX1YtKTs/s400/ptcl-dsl-router-final-manual-settings.jpg" width="305" /> </a> </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Thats is, You are done with manual settings of your router. Surf the internet and enjoy :)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com1tag:blogger.com,1999:blog-5960817260039131230.post-86446416169584822712012-11-02T05:49:00.002-07:002012-11-02T05:49:51.175-07:00Befor you start anything, Learn how to finish it...<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-CIkT3ouwLd8/UJPBUkGl8wI/AAAAAAAACtI/HntD9DtVmoQ/s1600/403539_510379815652991_257075263_n.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="http://3.bp.blogspot.com/-CIkT3ouwLd8/UJPBUkGl8wI/AAAAAAAACtI/HntD9DtVmoQ/s640/403539_510379815652991_257075263_n.jpg" width="483" /></a></div>
<br /></div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com3tag:blogger.com,1999:blog-5960817260039131230.post-65925720482340593532012-10-10T06:14:00.002-07:002012-10-10T06:15:41.030-07:00Images of Shangri-La Pakistan<div dir="ltr" style="text-align: left;" trbidi="on">
Shangrila Lake or Lower Kachura Lake is a part of the Shangrila resort located at a drive of about 20 minutes from Skardu (nearly 2,500 m or 8,200 feet) town.<br />
<br />
It is a popular tourist destination, and has a unique restaurant that is built on the fuselage of an aircraft that had crashed nearby.<br />
<br />
Shangrila was established in 1983 with the opening of the first Resort Hotel in Skardu, Baltistan. It was named "heaven on earth" because of its spectacular beauty,and breathtaking view and peaceful atmosphere. Shangrila Resort Hotel was founded by the late Brig.(Retd) Muhammad Aslam Khan, the first commander of the Northern Scouts of the Pakistan Army.<br />
<br />
Shangrila was named after a book titled "Lost Horizon" by James Hilton. In the novel, the author narrates a tale in which an aeroplane crash landed near a riverbed, in the early 1920s. The surviving passengers came across some Buddhist monks from a nearby temple and sought their help. They were taken to a beautiful lamasery filled with a variety of fruits and flowers. The monks looked quite young, although they claimed to be hundreds of years old. The idyllic place was called Shangri-la, a Tibetan word meaning "Heaven on earth".<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-ICz6C5hGBgQ/UHV0NX1FczI/AAAAAAAACr4/9Tl9ZqwWIOc/s1600/2220575781_8630bb067d.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="http://4.bp.blogspot.com/-ICz6C5hGBgQ/UHV0NX1FczI/AAAAAAAACr4/9Tl9ZqwWIOc/s400/2220575781_8630bb067d.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ZTt5qcT98hM/UHV0Obcof-I/AAAAAAAACr8/v224UcdkDaY/s1600/SHANGRILAHDWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://1.bp.blogspot.com/-ZTt5qcT98hM/UHV0Obcof-I/AAAAAAAACr8/v224UcdkDaY/s400/SHANGRILAHDWallpaper.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-v4dN0oZwkBw/UHV0PViweGI/AAAAAAAACsI/1GVw8RWtmTw/s1600/ShangrilaHDBestWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="292" src="http://3.bp.blogspot.com/-v4dN0oZwkBw/UHV0PViweGI/AAAAAAAACsI/1GVw8RWtmTw/s400/ShangrilaHDBestWallpaper.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-1nCBojQ8VyU/UHV0Sn82jMI/AAAAAAAACsQ/r688ciF5QDE/s1600/ShangrilaPakistanWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="http://4.bp.blogspot.com/-1nCBojQ8VyU/UHV0Sn82jMI/AAAAAAAACsQ/r688ciF5QDE/s400/ShangrilaPakistanWallpaper.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-OJ0MeHYrM3M/UHV0TalxkeI/AAAAAAAACsU/xjv5_YPpAxA/s1600/ShangrilaWallpaperpakistan.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="285" src="http://2.bp.blogspot.com/-OJ0MeHYrM3M/UHV0TalxkeI/AAAAAAAACsU/xjv5_YPpAxA/s400/ShangrilaWallpaperpakistan.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-InF4v6ByPSI/UHV0UIZ2HUI/AAAAAAAACsc/RAavWvM_2fk/s1600/pakistanshangrilaBestWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="http://2.bp.blogspot.com/-InF4v6ByPSI/UHV0UIZ2HUI/AAAAAAAACsc/RAavWvM_2fk/s400/pakistanshangrilaBestWallpaper.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-fYxjetJqJI8/UHV0VGEZAGI/AAAAAAAACsk/LUZADjDmKsM/s1600/shangrilaPakistanHDWallpaper.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-fYxjetJqJI8/UHV0VGEZAGI/AAAAAAAACsk/LUZADjDmKsM/s400/shangrilaPakistanHDWallpaper.JPG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-WDEycF_a46E/UHV0V8KpO4I/AAAAAAAACsw/G1oARyT2Xqo/s1600/shangrilahotelWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://2.bp.blogspot.com/-WDEycF_a46E/UHV0V8KpO4I/AAAAAAAACsw/G1oARyT2Xqo/s400/shangrilahotelWallpaper.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-HKDl4YOFbuA/UHV0WyyWC8I/AAAAAAAACs4/7UDgYtG8ghY/s1600/shangrilahotelpakistanbestHDWallpaper.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-HKDl4YOFbuA/UHV0WyyWC8I/AAAAAAAACs4/7UDgYtG8ghY/s400/shangrilahotelpakistanbestHDWallpaper.jpg" width="400" /></a></div>
</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-7602332181248009812012-09-29T03:56:00.000-07:002012-09-29T03:56:38.205-07:00javascript - window.open not working in IE - (RESOLVED)<div dir="ltr" style="text-align: left;" trbidi="on">
Browser compatibility is an issue which each and every web-developer has to face. New window popup using javascript is the same kind of issue and javascript fuction window.open() has different functionality in defferent browsers like in firefox and chrome it works and in IE-8 etc sometimes it does'nt work.<br />
<br />
I also faced this problem today and did R&D on it, and found a very simple solution to this. here is the solution of this problem.<br />
<br />
In IE, you can't have spaces in your second variable (the new window's name).<br />
<br />
Try:<br />
<pre class="default prettyprint"><code><span class="pln"> </span></code></pre>
<pre class="default prettyprint"><span style="color: red;"><code><span style="color: blue;"><span class="pln">window</span><span class="pun">.</span></span><span class="pln"><span style="color: blue;">open</span> </span><span style="color: black;"><span class="pun">(</span></span><span class="pln">address</span><span class="pun">,</span><span class="str">'Ver_articulo'</span><span class="pun">,</span><span class="pln"> config</span><span class="pun">=</span><span class="pln">center</span><span style="color: black;"><span class="pun">);</span></span></code></span></pre>
<pre class="default prettyprint"><span style="color: red;"><code><span style="color: black;"><span class="pun"> </span></span></code></span></pre>
<pre class="default prettyprint"><span style="color: red;"><code><span style="color: black;"><span class="pun">Please post your comment and share this with others if you really like this post. </span></span></code></span></pre>
<pre class="default prettyprint"><span style="color: red;"><code></code></span></pre>
<pre class="default prettyprint"><span style="color: red;"><code><span class="pln"></span></code></span></pre>
</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-35316580931662031042012-06-14T01:13:00.000-07:002012-06-14T01:14:29.585-07:00Email validation using PHP and REGULAR EXPRESSION<div dir="ltr" style="text-align: left;" trbidi="on">
Form validation is a very important part of web programming. This is to avoid any mistakenly adding data in database. Validating emails can be done in many ways. But the most faster and efficient way to validate emails is using regular expression. <br />
<br />
Here is the code of this validation in PHP.
<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">if(isset($todo) and $todo=="test")
{
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
echo "<center>Invalid email</center>";
}else{
echo "<center>Valid Email</center>";
}
}
</code></pre>
<br /></div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-79930660951053361472012-05-28T23:49:00.001-07:002012-11-14T04:31:46.263-08:00How to delete DUPLICATE records from MYSQL table<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="entry">
Some times we need to delete duplicate rows from a table. Because there is no need for keeping duplicate records in same table. Deleting these duplicate records is very easy. It can be don using some simple SQL queries.<br />
<br />
Here’s two easy ways to clean out that table quickly.<br />
<br />
1) Use ALTER IGNORE on MySQL 5.1+<br />
MySQL will allow you to create a unique index on a table with duplicate records with its IGNORE SQL extension:<br />
<br />
<div class="wp_syntax">
<div class="code">
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ALTER IGNORE TABLE 'SHIPMENTS' ADD UNIQUE INDEX (CART_ID, TRACKING_NUMBER)
</code></pre>
</div>
</div>
<br />
Duplicates will be deleted.<br />
<br />
2) Recreate the table with GROUP BY<br />
<br />
<div class="wp_syntax">
<div class="code">
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> execute 'CREATE TABLE shipments_deduped like shipments;'
execute 'INSERT shipments_deduped SELECT * FROM shipments GROUP BY cart_id, tracking_number;'
execute 'RENAME TABLE shipments TO shipments_with_dupes;'
execute 'RENAME TABLE shipments_deduped TO shipments;'
add_index :shipments, [:cart_id, :tracking_number], :unique => true
execute 'DROP TABLE shipments_with_dupes;'
</code></pre>
</div>
</div>
<br />
Recreating the table is much, much faster than trying to delete the
records in the existing table and doesn’t lock the existing table,
making your application downtime minimal.<br />
<br />
<a href="http://our-knowledge-base.blogspot.com/2012/11/list-of-top-60-insurance-companies-in.html" rel="nofollow">Insurance</a></div>
</div>
Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-87652253967223066232012-05-25T04:56:00.001-07:002012-05-25T04:57:21.974-07:00How to download and unzip a .ZIP file using php<div dir="ltr" style="text-align: left;" trbidi="on">
Today I was working on a website which will be an affiliate member of another big company with already running a very good website ( i don't want to mention the name of that affiliate program because with this my idea is some how disclosed to the public and i don't want to do so :) ). In that affiliate program I have to download the feeds in .zip form and then importing that in my database. So I needed a script to automatically download, unzip and then import that data in my database. By using my experience and skills and also with the help of Google, I have successfully written a script for this purpose. In this post I am going to share the same,<br />
<br />
First part of my script checks that php zip extension is loaded or not.
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> if (!extension_loaded('zip')) {
dl('zip.so');
}
</code></pre>
After that, mention the path of download file and destination folder and rest of the script is as follows,
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> $target_url = "http://www.example.com/test.zip";
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
$file_zip = "downloads/new.zip";
$file_txt = "downloads/".md5(time())."new.txt";
echo "<br>Starting<br>Target_url: $target_url";
echo "<br>Headers stripped out";
// make the cURL request to $target_url
$ch = curl_init();
$fp = fopen("$file_zip", "w");
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FILE, $fp);
$page = curl_exec($ch);
if (!$page) {
echo "<br />cURL error number:" .curl_errno($ch);
echo "<br />cURL error:" . curl_error($ch);
exit;
}
curl_close($ch);
echo "<br>Downloaded file: $target_url";
echo "<br>Saved as file: $file_zip";
echo "<br>About to unzip ...";
// Un zip the file
$zip = new ZipArchive;
if (! $zip) {
echo "<br>Could not make ZipArchive object.";
exit;
}
if($zip->open("$file_zip") != "true") {
echo "<br>Could not open $file_zip";
}
$zip->extractTo("$file_txt");
$zip->close();
echo "<br>Unzipped file to: $file_txt<br><br>";
</code></pre>
If you like this script, so please post your comments and feedback. Your good feedback is the main desire of me to continue writing useful posts for my blog reader.
Thanks
</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-65393790388902061962012-05-22T00:47:00.002-07:002012-05-22T00:47:22.932-07:00Password protection using .htaccess<div dir="ltr" style="text-align: left;" trbidi="on">
Some times, some portions of website need to be password protected in order to prevent it from UN-autorized access. There are many ways to do this. One way is achieved by server side programming and other way to achieve this is client side programming like java-script. In this post I will discuss password protection using .htaccess file. This method have following steps to follow,<br />
<br />
1. First decide what portion or directory you want to make password protected. I am considering root directory in this post.<br />
<br />
2. After this go to this URL <a href="http://www.tools.dynamicdrive.com/password/" rel="nofollow" target="_blank">http://www.tools.dynamicdrive.com/password/</a> and generate code for your .htaccess and .htpasswd files.<br />
<br />
3. After this you need to save these codes in .htaccess and .htpasswd files respectively. I you are unable to create .htaccess file, you can read this <a href="http://our-knowledge-base.blogspot.com/2012/05/how-to-create-htaccess-file-simple.html" rel="nofollow" target="_blank">http://our-knowledge-base.blogspot.com/2012/05/how-to-create-htaccess-file-simple.html</a> article to learn how to create this. Creating .htpasswd file is exactly same like creating .htaccess file.<br />
<br />
4. Now upload the both file in the corresponding directory. Your website is password protected now.<br />
<br />
feel free to post your feedback<br />
<br />
Thanks <br />
<br />
<br /></div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-42778890155298887182012-05-22T00:45:00.001-07:002012-05-22T01:00:30.532-07:00How to create .htaccess file - Simple steps<div dir="ltr" style="text-align: left;" trbidi="on">
I this simple step by step tutorial I will tell you how to create .htaccess file using a notepad editor.<br />
Here are the steps to do this,<br />
<br />
1. Open your Windows notepad editor.<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://2.bp.blogspot.com/-VRgl-kVO9nc/T7tFdqXmreI/AAAAAAAACfM/qMkS7XZpvnQ/s1600/step1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="http://2.bp.blogspot.com/-VRgl-kVO9nc/T7tFdqXmreI/AAAAAAAACfM/qMkS7XZpvnQ/s320/step1.jpg" width="320" /></a></div>
<br />
2. Make sure that the word wrap function is off.<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-bAoooXA6w54/T7tF4CvBFhI/AAAAAAAACfU/-mkNkQjGS8k/s1600/step2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="http://3.bp.blogspot.com/-bAoooXA6w54/T7tF4CvBFhI/AAAAAAAACfU/-mkNkQjGS8k/s320/step2.jpg" width="320" /></a></div>
<br />
3. Select File, then select New<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-J7YiQTK5D5E/T7tGEbQr7zI/AAAAAAAACfc/LCNIi0_HhDc/s1600/step3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="233" src="http://4.bp.blogspot.com/-J7YiQTK5D5E/T7tGEbQr7zI/AAAAAAAACfc/LCNIi0_HhDc/s320/step3.jpg" width="320" /></a></div>
<br />
4. You should have a screen that doesn’t contain any text.<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-8eyoZ1e56w4/T7tGby62ToI/AAAAAAAACfk/8acA9LZrpas/s1600/step4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="http://1.bp.blogspot.com/-8eyoZ1e56w4/T7tGby62ToI/AAAAAAAACfk/8acA9LZrpas/s320/step4.jpg" width="320" /></a></div>
<br />
5. Next, select Save As<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-zBbkrjYTmv0/T7tG2NdFsmI/AAAAAAAACfs/159KFa17ubo/s1600/step5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="http://1.bp.blogspot.com/-zBbkrjYTmv0/T7tG2NdFsmI/AAAAAAAACfs/159KFa17ubo/s320/step5.jpg" width="320" /></a></div>
<br />
6. Type the following for your file name, .htaccess<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/--VgqXgj9PR8/T7tG_jI_o4I/AAAAAAAACf0/Cxb_gV1uzmc/s1600/step6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="135" src="http://3.bp.blogspot.com/--VgqXgj9PR8/T7tG_jI_o4I/AAAAAAAACf0/Cxb_gV1uzmc/s400/step6.jpg" width="400" /></a></div>
<br />
Browse your folders and select which folder you want to save the .htaccess file in, then click Save<br />
The
next step is to verify that the file was named .htaccess by the editor.
You simply open the Windows file manager, locate the file, right-click
the file icon and selecting Properties.) If the file was named with the
.txt suffix, you can rename the file to .htaccess and your done.<br />
<br />
Thanks <br />
</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-25835522513513498662012-05-18T02:53:00.001-07:002012-05-18T02:53:37.340-07:00Balanced Diet Plane<div dir="ltr" style="text-align: left;" trbidi="on">
Hey guys, if you want a perfect diet plane chart, then this post is just for you.<br />
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: medium none; width: 658px;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.75pt;" valign="top" width="76"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-size: 12pt;">Cereals (per 100 grams) Calories</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-size: 12pt;"></span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 67.95pt;" valign="top" width="91"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Breads
(per slice) Calories</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-size: 12pt;"></span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 84.5pt;" valign="top" width="113"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Vegetables
(per 100 grams) Calories</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-size: 12pt;"></span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 87.1pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Fruits
(per 100 grams) Calories</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-size: 12pt;"></span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;" valign="top" width="94"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Desserts
(per 100 grams) Calories</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-size: 12pt;"></span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 70.75pt;" valign="top" width="94"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Milk
Products (per cup) Calories</span></b></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 55.35pt;" valign="top" width="74"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Comic Sans MS"; font-size: 12pt;">Others
Calories</span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.75pt;" valign="top" width="76"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: brown; font-family: "Comic Sans MS"; font-size: 12pt;">Bajra 360 <br />
<br />
Maize flour 355 <br />
<br />
Rice 325 <br />
<br />
Wheat flour 341</span><span style="font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 67.95pt;" valign="top" width="91"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: green; font-family: "Comic Sans MS"; font-size: 12pt;">Chapati (wheat bread) (medium) 119 <br />
<br />
White bread 60 <br />
<br />
Paratha (not stuffed) 280</span><span style="font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 84.5pt;" valign="top" width="113"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: indigo; font-family: "Comic Sans MS"; font-size: 12pt;">Cabbage 45 <br />
<br />
Carrot 48 <br />
<br />
Cauliflower 30 <br />
<br />
Corn (baked) 84 <br />
<br />
Cucumber 12 <br />
<br />
Eggplant (Fresh) 24 <br />
<br />
Eggplant (Cooked) 69 <br />
<br />
Fenugreek (methi) 49 <br />
<br />
French Beans 26 <br />
<br />
Lettuce 21 <br />
<br />
Peas 93 <br />
<br />
Potato 97 <br />
<br />
Potato (fried- 1 cup) 450 <br />
<br />
Potato (baked- 1 cup) 100 <br />
<br />
Potato (mashed- 1 cup) 245 <br />
<br />
Potato (boiled- 1 cup) 83 <br />
<br />
Pumpkin (cooked) 33 <br />
<br />
Spinach 26 <br />
<br />
Tomato (fresh) 21 <br />
<br />
Tomato (stuffed and baked) 58 <br />
<br />
Tomato (baked) 39</span><span style="font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 87.1pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: blue; font-family: "Comic Sans MS"; font-size: 12pt;">Apple 56 <br />
<br />
Banana 153 <br />
<br />
Black Grapes 45 <br />
<br />
Chickoo (Sapota) 94 <br />
<br />
Cherries 70 <br />
<br />
Dates 281 <br />
<br />
Guava 66 <br />
<br />
Litchies 61 <br />
<br />
Mango 70 <br />
<br />
Muskmelon 74 <br />
<br />
Orange 53 <br />
<br />
Papaya 32 <br />
<br />
Peach 50 <br />
<br />
Pears 51 <br />
<br />
Pineapple 46 <br />
<br />
Plums 56 <br />
<br />
Pomegranate 77 <br />
<br />
Watermelon 16</span><span style="font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;" valign="top" width="94"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: violet; font-family: "Comic Sans MS"; font-size: 12pt;">Biscuits 399 <br />
<br />
Boondi ladoo 150 <br />
<br />
Cake (with icing) 302 <br />
<br />
Cake (without icing) 218 <br />
<br />
Cookies (butter cookies) 482 <br />
<br />
Custard 205 <br />
<br />
Fruit pie 236 <br />
<br />
Fruit salad 80 <br />
<br />
Gujia 501 <br />
<br />
Gulab Jamun 387 <br />
<br />
Halwa (atta) 263 <br />
<br />
Halwa (rawa) 181 <br />
<br />
Halwa (sohan halwa) 399 <br />
<br />
Jalebi 494 <br />
<br />
Jelly 65 <br />
<br />
Kheer (rice) 141 <br />
<br />
Kheer (rice-carrot) 226 <br />
<br />
Malpua 325 <br />
<br />
Sandesh 57</span><span style="font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 70.75pt;" valign="top" width="94"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red; font-family: "Comic Sans MS"; font-size: 12pt;">Buffalo milk 115 <br />
<br />
Butter (100gms.) 750 <br />
<br />
Buttermilk 19 <br />
<br />
Cheese 315 <br />
<br />
Cow milk 100 <br />
<br />
Cream (100gms) 210 <br />
<br />
Ghee (100gms) 910 <br />
<br />
Skimmed milk 45</span><span style="color: violet; font-family: "Comic Sans MS"; font-size: 12pt;"></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 55.35pt;" valign="top" width="74"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: olive; font-family: "Comic Sans MS"; font-size: 12pt;">Coconut water (100 ml) 25 <br />
<br />
Coffee 40 <br />
<br />
Honey (1 tbsp) 90 <br />
<br />
Orange juice (100 ml) 47 <br />
<br />
Sugar (1 tbsp) 48 <br />
<br />
Tea 30 <br />
<br />
Tomato juice (100ml) 22</span><span style="color: violet; font-family: "Comic Sans MS"; font-size: 12pt;"></span></div>
</td>
</tr>
</tbody></table>
</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com10tag:blogger.com,1999:blog-5960817260039131230.post-42306213432465285132012-05-18T00:42:00.001-07:002012-05-18T00:42:26.264-07:00How to change "font-family" in dompdf script<div dir="ltr" style="text-align: left;" trbidi="on">
In latest web development industry document conversion from one format to other format is very important. Sometimes we need to generate spread sheet files, some times we need to generate word files and some times PDF files. In this topic I will be talking about PDF file conversion.<br />
<br />
For generating PDF files from the given data, there are a number of scripts and modules written in php and different languages. DomPDF is one of them written in php. DomPDF is fabulous in its features. It allows direct conversion of HTML files to PDF files. But there are some limitations like some times it never generates the exact copy of that HTML. Some times font-family doesn't apply correctly as we apply in HTML file. I had the same problem last days when I was using DomPDF for my PDF generation. I goggled the web and found some solutions. And on the basis of those many solutions and posts, I wrote a summarized article focusing on this problem.<br />
<br />
It need some simple steps to follow,<br />
<br />
<ol>
<li><a href="http://dl.dropbox.com/u/37908711/public_scripts/dompdf.rar" rel="nofollow">Download</a> archive from approved answer. Extract files <code>/dompdf/lib/fonts/times*.*</code>.</li>
<li>Copy them in your dompdf fonts folder.</li>
<li>Edit <code>dompdf_font_family_cache.dist.php</code> with snippet 1.</li>
<li>In CSS use <code>font-family: times;</code>.</li>
</ol>
<br />
Snippet 1:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /* ... */
'times' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
'times-roman' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
/* ... */
</code></pre>
<br />
If you want to use your own TTF font (say, <code>Arial.ttf</code>):<br />
<ol>
<li>Run: <code>ttf2afm -o Arial.afm Arial.ttf</code>. (I did it in Ubuntu.)</li>
<li>Run: <code>ttf2ufm -a -F Arial.ttf</code>. (you can use <code>/dompdf/lib/ttf2ufm/bin/ttf2ufm.exe</code>.)</li>
<li>Copy <code>Arial.*</code> files in <code>/dompdf/lib/fonts/</code>.</li>
<li>Add to <code>dompdf_font_family_cache.dist.php</code> snippet 2.</li>
<li>In CSS use <code>font-family: arial;</code>. </li>
</ol>
<br />
Snippet 2:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /* ... */
'arial' => array (
'normal' => DOMPDF_FONT_DIR . 'Arial',
'bold' => DOMPDF_FONT_DIR . 'Arial',
'italic' => DOMPDF_FONT_DIR . 'Arial',
'bold_italic' => DOMPDF_FONT_DIR . 'Arial'
)
/* ... */
</code></pre>
<br />
Please feel free to post you comments and suggestions.<br />
<br />
Thanks<br />
</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com8tag:blogger.com,1999:blog-5960817260039131230.post-77475958167994192692012-05-03T23:30:00.000-07:002012-05-04T00:15:41.514-07:00Working with arrays in pyrocms plugins<div dir="ltr" style="text-align: left;" trbidi="on">
Hi guys, I am writing this post for one of my cool blog reader. He posted a comment that how we can return arrays from plugins to plugin view files and then how we can loop through and display the values of that array.<br />
<br />
Pyrocms is very cool in handling this type of thing because it has a very strong template engine already built-in its codeignitor package. In order to explain how to use array in pyrocms plugin, i will take the same "example" plugin which I explained in this post <a href="http://our-knowledge-base.blogspot.com/2012/04/how-to-develop-custom-plugin-in-pyrocms.html" target="_blank">http://our-knowledge-base.blogspot.com/2012/04/how-to-develop-custom-plugin-in-pyrocms.html</a>.<br />
<br />
<b>Adding another function:</b><br />
<br />
Open "example" plugin code and put the following function some where in that class.
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
public function myposts()
{
$plugin_data = array();
$plugin_data[] = array(
'value' => "Post # 1 value",
'title' => 'Post # 1 title'
);
$plugin_data[] = array(
'value' => "Post # 2 value",
'title' => 'Post # 2 title'
);
$plugin_data[] = array(
'value' => "Post # 3 value",
'title' => 'Post # 3 title'
);
return $plugin_data;
}
?>
</code></pre>
<br />
so after adding this function whole plugin code will look like this,<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: <?php defined('BASEPATH') OR exit('No direct script access allowed');
2: /**
3: * Example Plugin
4: *
5: * Quick plugin to demonstrate how things work
6: *
7: * @package PyroCMS
8: * @author PyroCMS Dev Team
9: * @copyright Copyright (c) 2009 - 2010, PyroCMS
10: *
11: */
12: class Plugin_Example extends Plugin
13: {
14: /**
15: * Hello
16: *
17: * Usage:
18: * {{ example:hello }}
19: *
20: * @param array
21: * @return array
22: */
23: function hello()
24: {
25: $name = $this->attribute('name', 'World');
26: return 'Hello '.$name.'!';
27: }
28:
29:
30:
31: public function myposts()
32: {
33: $plugin_data = array();
34: $plugin_data[] = array(
35: 'value' => "Post # 1 value",
36: 'title' => 'Post # 1 title'
37: );
38: $plugin_data[] = array(
39: 'value' => "Post # 2 value",
40: 'title' => 'Post # 2 title'
41: );
42: $plugin_data[] = array(
43: 'value' => "Post # 3 value",
44: 'title' => 'Post # 3 title'
45: );
46: return $plugin_data;
47: }
48: }
49: /* End of file example.php */
</code></pre>
<br />
<b>How to use this?</b><br />
Using this is very simple. You just have to paste following code in view file. It will show post titles in the form of a list.<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> {{ example:myposts }}
<strong>{{ name }}:</strong> {{ value }}<br />
{{ /example:myposts }}
</code></pre>
<br />
Although this is a very simple explanation of how to handle arrays in pyrocms, but after ready and understanding this example, you can easily modify this or even can develop your own complex plugin.<br />
<br />
Please feel to post comments on this.<br />
<br />
Thanks
</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com2tag:blogger.com,1999:blog-5960817260039131230.post-4441734585962298812012-05-02T00:12:00.003-07:002012-05-02T00:12:29.290-07:00Tips to Improve Self Confidence<div dir="ltr" style="text-align: left;" trbidi="on">
<h4 style="text-align: left;">
<b>1. Groom yourself</b></h4>
<div class="separator" style="float: right; text-align: right;">
<a href="http://4.bp.blogspot.com/-78R1A48UUHo/T6DRd27ODjI/AAAAAAAACdk/bQ-02TKUfhk/s1600/skin-big.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="130" src="http://4.bp.blogspot.com/-78R1A48UUHo/T6DRd27ODjI/AAAAAAAACdk/bQ-02TKUfhk/s200/skin-big.jpg" width="200" /></a></div>
This seems like such an obvious one, but
it’s amazing how much of a difference a shower and a shave can make in your
feelings of self-confidence and for your self-image. There have been days when
I turned my mood around completely with this one little thing.<br />
<br />
<br />
<br />
<h4 style="text-align: left;">
2. Dress nicely</h4>
<div style="text-align: left;">
<div class="separator" style="float: right; text-align: right;">
<a href="http://1.bp.blogspot.com/-giXDaT9HGs4/T6DTMhUTFYI/AAAAAAAACds/wScuunVSqoc/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="http://1.bp.blogspot.com/-giXDaT9HGs4/T6DTMhUTFYI/AAAAAAAACds/wScuunVSqoc/s200/images.jpg" width="200" /></a></div>
A corollary of the first item above … if you
dress nicely, you’ll feel good about yourself. You’ll feel successful and
presentable and ready to tackle the world. Now, dressing nicely means something
different for everyone … it doesn’t necessarily mean wearing a $500 outfit, but
could mean casual clothes that are nice looking and presentable.</div>
<br />
<br />
<h4 style="text-align: left;">
3. Photoshop your self-image</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://3.bp.blogspot.com/-jT9As8pl7uM/T6DUbngkOHI/AAAAAAAACd0/nZ9r2ml1M5Q/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="http://3.bp.blogspot.com/-jT9As8pl7uM/T6DUbngkOHI/AAAAAAAACd0/nZ9r2ml1M5Q/s200/images.jpg" width="200" /></a></div>
Our self-image means so much to
us, more than we often realize. We have a mental picture of ourselves, and it
determines how confident we are in ourselves. But this picture isn’t fixed and
immutable. You can change it. Use your mental Photoshopping skills, and work on
your self-image. If it’s not a very good one, change it. Figure out why you see
yourself that way, and find a way to fix it.<br />
<br />
<h4 style="text-align: left;">
4. Think positive.</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://1.bp.blogspot.com/-9Mr-rirCp18/T6DVtD6-xeI/AAAAAAAACd8/ooL1vb1-5cE/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="149" src="http://1.bp.blogspot.com/-9Mr-rirCp18/T6DVtD6-xeI/AAAAAAAACd8/ooL1vb1-5cE/s200/images.jpg" width="200" /></a></div>
One of the things I learned when I started
running, about two years ago, what how to replace negative thoughts (see next
item) with positive ones. How I can actually change my thoughts, and by doing
so make great things happened. With this tiny little skill, I was able to train
for and run a marathon within a year. It sounds so trite, so Norman Vincent
Peale, but my goodness this works. Seriously. Try it if you haven’t.<br />
<br />
<h4 style="text-align: left;">
5. Kill negative thoughts</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://4.bp.blogspot.com/-Nko1lds13us/T6DXGcMjGDI/AAAAAAAACeE/oDeQp8PbD-I/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="http://4.bp.blogspot.com/-Nko1lds13us/T6DXGcMjGDI/AAAAAAAACeE/oDeQp8PbD-I/s200/images.jpg" width="200" /></a></div>
Goes hand-in-hand with the above
item, but it’s so important that I made it a separate item. You have to learn
to be aware of your self-talk, the thoughts you have about yourself and what
you’re doing. When I was running, sometimes my mind would start to say, “This
is too hard. I want to stop and go watch TV.” Well, I soon learned to recognize
this negative self-talk, and soon I learned a trick that changed everything in
my life: I would imagine that a negative thought was a bug, and I would
vigilantly be on the lookout for these bugs. When I caught one, I would stomp
on it (mentally of course) and squash it. Kill it dead. Then replace it with a
positive one. (”C’mon, I can do this! Only one mile left!”)<br />
<br />
<h4 style="text-align: left;">
6. Get to know yourself</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://2.bp.blogspot.com/-C44pz6Tx030/T6DYA49aDBI/AAAAAAAACeM/AdG_DPOgir4/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="http://2.bp.blogspot.com/-C44pz6Tx030/T6DYA49aDBI/AAAAAAAACeM/AdG_DPOgir4/s200/images.jpg" width="200" /></a></div>
When going into battle, the wisest
general learns to know his enemy very, very well. You can’t defeat the enemy
without knowing him. And when you’re trying to overcome a negative self-image
and replace it with self-confidence, your enemy is yourself. Get to know
yourself well. Start listening to your thoughts. Start writing a journal about
yourself, and about the thoughts you have about yourself, and analyzing why you
have such negative thoughts. And then think about the good things about
yourself, the things you can do well, the things you like. Start thinking about
your limitations, and whether they’re real limitations or just ones you’ve
allowed to be placed there, artificially. Dig deep within yourself, and you’ll
come out (eventually) with even greater self-confidence.<br />
<br />
<h4 style="text-align: left;">
7. Act positive</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://1.bp.blogspot.com/-xDSlOk1CKpQ/T6DYk67f5eI/AAAAAAAACeU/s2edPWTOgy8/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="136" src="http://1.bp.blogspot.com/-xDSlOk1CKpQ/T6DYk67f5eI/AAAAAAAACeU/s2edPWTOgy8/s200/images.jpg" width="200" /></a></div>
More than just thinking positive, you have to
put it into action. Action, actually, is the key to developing self-confidence.
It’s one thing to learn to think positive, but when you start acting on it, you
change yourself, one action at a time. You are what you do, and so if you
change what you do, you change what you are. Act in a positive way, take action
instead of telling yourself you can’t, be positive. Talk to people in a
positive way, put energy into your actions. You’ll soon start to notice a
difference.<br />
<br />
<h4 style="text-align: left;">
8. Be kind and generous</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://1.bp.blogspot.com/-AFtn9x76lxE/T6DZAm-vkDI/AAAAAAAACec/p18yBl1Ym80/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="144" src="http://1.bp.blogspot.com/-AFtn9x76lxE/T6DZAm-vkDI/AAAAAAAACec/p18yBl1Ym80/s200/images.jpg" width="200" /></a></div>
Oh, so corny. If this is too corny
for you, move on. But for the rest of you, know that being kind to others, and
generous with yourself and your time and what you have, is a tremendous way to
improve your self-image. You act in accordance with the Golden Rule, and you
start to feel good about yourself, and to think that you are a good person. It
does wonders for your self-confidence, believe me.<br />
<br />
<h4 style="text-align: left;">
9. Get prepared</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://1.bp.blogspot.com/-FmX5RHsk1u0/T6DanBhClmI/AAAAAAAACek/rSr2aW_CJkQ/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="http://1.bp.blogspot.com/-FmX5RHsk1u0/T6DanBhClmI/AAAAAAAACek/rSr2aW_CJkQ/s200/images.jpg" width="200" /></a></div>
It’s hard to be confident in yourself if you
don’t think you’ll do well at something. Beat that feeling by preparing
yourself as much as possible. Think about taking an exam: if you haven’t
studied, you won’t have much confidence in your abilities to do well on the
exam. But if you studied your butt off, you’re prepared, and you’ll be much
more confident. Now think of life as your exam, and prepare yourself.<br />
<br />
<h4 style="text-align: left;">
10. Know your principles and live them</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://4.bp.blogspot.com/-o3iGZ8OMF9w/T6DbBhCnqKI/AAAAAAAACes/LHVu84f4i0M/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="146" src="http://4.bp.blogspot.com/-o3iGZ8OMF9w/T6DbBhCnqKI/AAAAAAAACes/LHVu84f4i0M/s200/images.jpg" width="200" /></a></div>
What are the
principles upon which your life is built? If you don’t know, you will have
trouble, because your life will feel directionless. For myself, I try to live
the Golden Rule (and fail often). This is my key principle, and I try to live
my life in accordance with it. I have others, but they are mostly in some way
related to this rule (the major exception being to “Live my Passion”). Think
about your principles … you might have them but perhaps you haven’t given them
much thought. Now think about whether you actually live these principles, or if
you just believe in them but don’t act on them.<br />
<br />
<h4 style="text-align: left;">
11. Speak slowly</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://2.bp.blogspot.com/-yxC8eKPPQGo/T6DbXZ1ANuI/AAAAAAAACe0/TTisRaa2uYY/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="133" src="http://2.bp.blogspot.com/-yxC8eKPPQGo/T6DbXZ1ANuI/AAAAAAAACe0/TTisRaa2uYY/s200/images.jpg" width="200" /></a></div>
Such a simple thing, but it can have a big
difference in how others perceive you. A person in authority, with authority,
speaks slowly. It shows confidence. A person who feels that he isn’t worth
listening to will speak quickly, because he doesn’t want to keep others waiting
on something not worthy of listening to. Even if you don’t feel the confidence
of someone who speaks slowly, try doing it a few times. It will make you feel
more confident. Of course, don’t take it to an extreme, but just don’t sound
rushed either.<br />
<br />
<h4 style="text-align: left;">
12. Stand tall</h4>
I have horrible posture, so it will sound
hypocritical for me to give this advice, but I know it works because I try it
often. When I remind myself to stand tall and straight, I feel better about
myself. I imagine that a rope is pulling the top of my head toward the sky, and
the rest of my body straightens accordingly. As an aside, people who stand tall
and confident are more attractive. That’s a good thing any day, in my book.<br />
<br />
<h4 style="text-align: left;">
13. Increase competence</h4>
<div class="separator" style="float: right; text-align: center;">
<a href="http://3.bp.blogspot.com/-GRm4_zCId7M/T6Dd6bo3aTI/AAAAAAAACfA/zuGcthQwVD4/s1600/images222.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="123" src="http://3.bp.blogspot.com/-GRm4_zCId7M/T6Dd6bo3aTI/AAAAAAAACfA/zuGcthQwVD4/s200/images222.jpg" width="200" /></a></div>
<span id="goog_670813758"></span><span id="goog_670813759"></span>How do you feel more competent? By
becoming more competent. And how do you do that? By studying and practicing.
Just do small bits at a time. If you want to be a more competent writer, for example,
don’t try to tackle the entire profession of writing all at once. Just begin to
write more. Journal, blog, write short stories, do some freelance writing. The
more you write, the better you’ll be. Set aside 30 minutes a day to write (for
example), and the practice will increase your competence.<br />
<br />
please share your thoughts about "how to improve self confidence"...keep reading :) </div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com6tag:blogger.com,1999:blog-5960817260039131230.post-55162762390499099212012-04-30T04:13:00.002-07:002012-04-30T04:13:46.794-07:00Downloading a file forcibly using php<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
This is a very important and useful topic and we
programmers normally need this kind of script in our websites etc. I wrote this
scripts and now I am going to share you this to my blog readers.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The idea behind this is to use php header parameters to do
this. Whenever you try to open some file which browser cant open (files like
.doc, .docx etc ) itself, browser prompts you a download window and will ask
you to download the file. This thing is done automatically by browser for some
file formats. But what will happen when you open a .html, or .php file using a
url? The answer to this is that browser will open or try to run these files in
the browser window. But if you want to just download the files and not to open them
in browser, then you have to tell php that download these files. This can be
done by using some php header settings. The class that I am using for this
thing is shown below.</div>
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
session_start();
$path="";
$filename = $path.$_GET['file'];
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
// addition by Jorg Weske
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if( $filename == "" )
{
echo "<html><body>ERROR: download file NOT SPECIFIED. USE force-download.php?file=filepath</body></html>";
exit;
} elseif ( ! file_exists( $filename ) )
{
echo "<html><body>ERROR: File not found. USE force-download.php?file=filepath</body></html>";
exit;
};
switch( $file_extension )
{
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "docx": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "xlsx": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "pptx": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
?>
</code></pre>
<br />
you can download this script using this url<br />
<a href="http://dl.dropbox.com/u/37908711/public_scripts/php_downloadfile.rar" rel="nofollow" target="_blank">http://dl.dropbox.com/u/37908711/public_scripts/php_downloadfile.rar</a></div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-33296227801266312052012-04-30T00:02:00.000-07:002012-04-30T00:03:31.942-07:00How to resolve 1045 error when installing xamp<div dir="ltr" style="text-align: left;" trbidi="on">
Some times whenever we install xamp on our system we get 1045 error in phpmyadmin. Here is the screen shot of that error,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-tDDZpJ0Ztnw/T544MqndqNI/AAAAAAAACdY/1arThaWZfwA/s1600/error1phpadmin.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="http://4.bp.blogspot.com/-tDDZpJ0Ztnw/T544MqndqNI/AAAAAAAACdY/1arThaWZfwA/s640/error1phpadmin.jpg" width="640" /></a></div>
<br />
I have found the solution of this error. Just <span class="commentBody" data-jsid="text">un-comment //<wbr></wbr><span class="word_break"></span> $cfg['Servers'][$i]['AllowNoP<wbr></wbr><span class="word_break"></span>assword'] = TRUE; in phpmyadmin/config.inc.php file. Enjoyee....</span></div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com0tag:blogger.com,1999:blog-5960817260039131230.post-41369702172778911812012-04-29T05:54:00.000-07:002012-04-29T05:58:20.007-07:00How to search within a defined radius using MySql and PHP<div dir="ltr" style="text-align: left;" trbidi="on">
Hey guys, today my manager assigned me a task to search property listing withing a specific radius like within 10 km or 10 miles. I did it very easily because I have done this already in one of my project. But first time this task was very hard to do and I did a lot of research and goggled the internet to find out the solution. Well that is an old and long story. Today after doing my task I thought why not I post my work in the form of an article on my blog. So here is the article...<br />
<br />
<a name='more'></a><br />
I will consider example of searching properties within a defined radius. This example needs a MySQL table with some records already inserted in that. Each record represents an individual property and reach property has its own latitude and longitude. These latitude and longitude are very important and playing a role of back bone of this article. My property listings table contains title, address, description, lat, long, and some attributes of property like number of bedrooms and bathrooms etc. But for simplicity i removed unnecessary fields. Now simple table will have title, address, latitude, longitude. So just run following query in your mysql server.<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> CREATE TABLE IF NOT EXISTS `my_listings` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(555) COLLATE utf8_unicode_ci NOT NULL,
`latitude` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`longitude` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listing of property' AUTO_INCREMENT=7 ;
INSERT INTO `my_listings` (`id`, `title`, `address`, `latitude`, `longitude`) VALUES
(2, 'Property #1', 'address 1', '33.7133348', '73.0619261'),
(3, 'Property #2', 'address 2', '33.6676974', '73.0752068'),
(4, 'Property #3', 'address 3', '34.1764355', '73.2278335'),
(5, 'Property #4', 'address 4', '34.1764355', '73.2278335');
</code></pre>
<br />
You are done with database design and now time comes to do some programming and make the script alive. In order to do so we need an html form which sends request to php server to search the properties. Here is that form's html,
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="get" name="searchform" id="searchform">
<input type="text" name="address" />
<input type="text" name="radius" />
<input type="submit" name="submit" value="Search" />
</form>
</body>
</html>
</code></pre>
<br />
Ok you are done with html form. Now add some php code in it. Put the following code at the tope of above code,<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
$con = mysql_connect("localhost","myusername","mypassword");
mysql_select_db('mydatabse');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($con);
?>
</code></pre>
<br />
This code connects you to database server. In my case my database server name is localhost, username is myusername, password is mypassword and database name is mydatabase. You can change this to any name you want.<br />
<br />
Now add some more code which will find out the minimum and maximum latitudes and longitudes, and on the bases of those latitude and longitude fetch records from database which lies within that radius,<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
function getlatlang($location)
{
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='. urlencode($location) .'&sensor=false');
$output= json_decode($geocode);
return $output->results[0]->geometry->location;
}
if( isset($_POST ) )
{
$con = mysql_connect("localhost","myusername","mypassword");
mysql_select_db('mydatabse');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($con);
$objlocation = getlatlang($_POS['address']);
$latitude = $objlocation->lat;
$longitude = $objlocation->lng;
$range = $_POST['radius'];
if($latitude != "" && $longitude != "")
{
// Find Max - Min Lat / Long for Radius and zero point and query
$lat_range = $range/69.172;
$lon_range = abs($range/(cos($latitude) * 69.172));
$min_lat = number_format($latitude - $lat_range, "4", ".", "");
$max_lat = number_format($latitude + $lat_range, "4", ".", "");
$min_lon = number_format($longitude - $lon_range, "4", ".", "");
$max_lon = number_format($longitude + $lon_range, "4", ".", "");
$sqlstr = mysql_query("SELECT * FROM my_listings
latitude BETWEEN '".$min_lat."' AND '".$max_lat."' AND
longitude BETWEEN '".$min_lon."' AND '".$max_lon."' ");
if (mysql_numrows($sqlstr) != 0) {
while ($row = mysql_fetch_array($sqlstr)) {
?>
<p><?= $row['title'] ?></p>
<p><?= $row['address'] ?></p>
<?php
}
}
}
}
?>
</code></pre>
<br />
That's it. This script is just displaying the records in the form of list for simplicity of article. You can extend this script and can add more code to make it working with google map and can show the records on google map. Whole script file looks like this,<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
function getlatlang($location)
{
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='. urlencode($location) .'&sensor=false');
$output= json_decode($geocode);
return $output->results[0]->geometry->location;
}
if( isset($_POST ) )
{
$con = mysql_connect("localhost","myusername","mypassword");
mysql_select_db('mydatabse');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($con);
$objlocation = getlatlang($_POS['address']);
$latitude = $objlocation->lat;
$longitude = $objlocation->lng;
$range = $_POST['radius'];
if($latitude != "" && $longitude != "")
{
// Find Max - Min Lat / Long for Radius and zero point and query
$lat_range = $range/69.172;
$lon_range = abs($range/(cos($latitude) * 69.172));
$min_lat = number_format($latitude - $lat_range, "4", ".", "");
$max_lat = number_format($latitude + $lat_range, "4", ".", "");
$min_lon = number_format($longitude - $lon_range, "4", ".", "");
$max_lon = number_format($longitude + $lon_range, "4", ".", "");
$sqlstr = mysql_query("SELECT * FROM my_listings
latitude BETWEEN '".$min_lat."' AND '".$max_lat."' AND
longitude BETWEEN '".$min_lon."' AND '".$max_lon."' ");
if (mysql_numrows($sqlstr) != 0) {
while ($row = mysql_fetch_array($sqlstr)) {
?>
<p><?= $row['title'] ?></p>
<p><?= $row['address'] ?></p>
<?php
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="get" name="searchform" id="searchform">
<input type="text" name="address" />
<input type="text" name="radius" />
<input type="submit" name="submit" value="Search" />
</form>
</body>
</html>
</code></pre>
<br />
please feel free to post your comments,</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com15tag:blogger.com,1999:blog-5960817260039131230.post-42899437421314195542012-04-24T04:17:00.001-07:002012-04-24T04:25:27.002-07:00How to develop a "Hello World" plugin in wordpress<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Hi all, hope you all are doing well and enjoying best of your healths.<br />
<br />
Today i had been searching word-press official website for any tutorial for "how to develop a hello world plugin" and i couldn't find any good tutorial for this. Then i studied some other tutorials and asked my friends about it and thought that why not i should post this on my blog with very simple words, so that others can find a good tutorial on this. So here we go for the tutorial....<br />
<br />
<a name='more'></a><h4 style="text-align: left;">
Step 1</h4>
<div style="text-align: left;">
Create a directory with name “hello-world-plugin” under wp-content/plugins, then create a file “hello-world-plugin.php”. put the following code to this file and save it.</div>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: <?php
2: /*
3: Plugin Name: Hello world plugin
4: Plugin URI: http://localhost/wordpress/
5: Description: Add HTML snippets to posts and/or page footer.
6: Version: 0.1
7: Author: me
8: Disclaimer: No warranty, use this in your own risk.
9: */
10: ?>
</code></pre>
<br />
You have successfully created your first "Hello world" plugin and you can now activate this like other plugins from word-press admin panel. But for now this plugin wont do anything because we haven't put any logic behind this. so lets add some working code.<br />
<br />
<h4 style="text-align: left;">
Step 2</h4>
<div style="text-align: left;">
for now “hello-world-plugin.php” file contains just plugin info. Let us open this and put below code under plugin info and save.</div>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: add_action('wp_footer', 'hello_world_plugin_wp_footer');
2: function hello_world_plugin_wp_footer(){
3: echo '<div>Hello world! '. get_option('blogname') .'</div>';
4: }
</code></pre>
<br />
<br />
after adding this, just refresh your page and see "Hello World" printed in footer of your page. But make sure you have activated the plugin from admin panel.<br />
<br />
In above code you can see add_action() function. Actually this is called action. Word-press follows hook architecture and this is the way to bind our function with word-press hooks. Word-press hooks is another topic and you can read this topic <a href="http://our-knowledge-base.blogspot.com/2012/04/learning-wordpress-hooks-simple.html" target="_blank">here</a>.<br />
<br />
That is all and we have now developed very simple "hello world" plugin in word-press. The whole code looks something like this, </div>
<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: <?php
2: /*
3: Plugin Name: Hello world plugin
4: Plugin URI: http://localhost/wordpress/
5: Description: Add HTML snippets to posts and/or page footer.
6: Version: 0.1
7: Author: me
8: Disclaimer: No warranty, use this in your own risk.
9: */
10: add_action('wp_footer', 'hello_world_plugin_wp_footer');
11: function hello_world_plugin_wp_footer(){
12: echo '<div>Hello world! '. get_option('blogname') .'</div>';
13: }
14: ?>
</code></pre>
<br />
Although this is a very simple plugin, but this teaches you how to take initiative for developing a plugin in word-press.<br />
<br />
Please feel free to post your comments and feedback.</div>Asadhttp://www.blogger.com/profile/09579112810634963663noreply@blogger.com5