tag:blogger.com,1999:blog-54028514570437702672024-03-07T18:26:33.553-08:00Sharing PHPA project started to share my PHP experiences and the content from the web to give the user one stop search for the PHP resources. And always working for the betterment :)Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-5402851457043770267.post-58428936397793734352011-05-21T20:46:00.000-07:002011-05-21T20:46:20.570-07:00PHP: Cookies<div dir="ltr" style="text-align: left;" trbidi="on"> <br />
A cookie is a message given to a Web browser by a Web server. The browser stores the message in a small text file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, the cookie is sent back to the server too. <br />
There are a wide variety of things you can do with cookies. They are used to store information about user, visited pages, poll results and etc. The main purpose of cookies is to identify users and possibly prepare customized Web pages for them. <br />
<ul class="square"><li>How to Create a Cookie? </li>
<li>How to Retrieve a Cookie Data? </li>
<li>How to Delete a Cookie? </li>
</ul>Normally cookies are used only to store small amounts of data. Websites can read the values from the cookies and use the information as desired. In addition to the information it stores, each cookie has a set of attributes that helps ensure the browser sends the correct cookie when a request to a server is made. <br />
Even though cookies are not harmful some people do not permit cookies due to concerns about their privacy. In this case you have to use Sessions.<br />
<br />
<a name='more'></a><br />
<br />
<div class="articleheader"><a href="" name="create"></a><span style="font-weight: bold;">How to Create a Cookie?</span></div>PHP cookies can be set using the setcookie() function. The syntax is as follows:<br />
<div class="phpcode">setcookie(name[, value[, expire[, path[, domain[, security]]]]])</div><ul class="square"><li><span class="smallfont"><b>[name]</b></span> The cookie name. The name of each cookie sent is stored in the superglobal array $_COOKIE. </li>
<li><span class="smallfont"><b>[value]</b></span> The cookie value. It is associated with the cookie name. </li>
<li><span class="smallfont"><b>[expire]</b></span> The time after which the cookie should expire in seconds </li>
<li><span class="smallfont"><b>[path]</b></span> Specifies the exact path on the domain that can use the cookies. </li>
<li><span class="smallfont"><b>[domain]</b></span> The domain that the cookie is available. If not domain is specified, the default value is the value of the domain in which cookie was created. </li>
<li><span class="smallfont"><b>[security]</b></span> Specifies whether the cookie will be sent via HTTPS. A value of 1 specifies that the cookie is sent over a secure connection but it doesn't mean that the cookie is secure. It's just a text file like every other cookie. A value of 0 denotes a standard HTTP transmission.</li>
</ul>In the example below, we will create a cookie named "myCookie" and assign the value "PHP Tutorial" to it. We also specify that the cookie should expire after one hour and that the cookie is available for all pages within a Tutorials directory.<br />
<div class="phpcode"></div>There's one important item to mention about using cookies. Because of the way cookies work within HTTP, it's important that you send all cookies before any output from your script. This requires that you place calls to this function before any output, including tags as well as any whitespace. If you don't, PHP will give you a warning and your cookies will not be sent.<br />
<br />
<br />
<div class="articleheader"><a href="" name="retrieve"></a><span style="font-weight: bold;">How to Retrieve a Cookie Date?</span></div>Now the cookie is set and we need to retrieve the information. As mentioned above the name of each cookie sent by your server accessed with the superglobal array $_COOKIE. In the example below we retrieve the value of the cookie and print out its value on the screen.<br />
<div class="phpcode" style="text-align: left;"></div><div></div><div style="text-align: left;">This would show up on the page as: "myCookie value is PHP Tutorial".</div><div style="text-align: left;"><br />
</div><div class="articleheader"><a href="" name="delete"></a><span style="font-weight: bold;">How to Delete a Cookie?</span></div>By default, the cookies are set to be deleted when the browser is closed. We can override that default by setting a time for the cookie's expiration but there may be occasions when you need to delete a cookie before the user closes his browser, and before its expiration time arrives. To do so, you should assure that the expiration date is in the past. The example below demonstrates how to do it (setting expiration time 1 minute ago):<br />
<br />
<div class="phpcode"></div></div>Abihttp://www.blogger.com/profile/03070759103585239028noreply@blogger.com10tag:blogger.com,1999:blog-5402851457043770267.post-67774712295282252422011-05-14T20:55:00.000-07:002011-05-14T20:55:58.233-07:00What is an IDE<div dir="ltr" style="text-align: left;" trbidi="on">In short, an IDE provides a one-stop shop for your coding work. An IDE contains an editor in which you can edit the code, debug the code, view your code in a browser (often embedded), and check in and out of source code control. To support that functionality, an IDE has a set of features you don't find in a basic editor, such as Notepad or Vim. Again, you can extend editors to do a lot of these things, but IDEs have all this functionality in one tidy package -- typically preconfigured:<br />
<br />
<b>Projects</b> <br />
A key distinguishing feature of an IDE is that it looks at a PHP application as a project, not just a set of files. That containing concept -- the project -- maintains extra information, such as the configuration of the source code control, the database settings for debugging purposes, and the location of certain key directories.<br />
<br />
<b>Debugging</b> <br />
Another handy feature is integrated debugging. With this functionality, you can set breakpoints in the editor at which the PHP interpreter stops during execution of the script. From there, you can inspect the values of local variables to diagnose issues in the code. It's a healthy alternative to sprinkling echo statements through your code to check values or using the error log to get the values of variables.<br />
<br />
<a name='more'></a><br />
<br />
<b>Code intelligence</b> <br />
PHP is a very regular programming language, which means that it follows simple patterns. Not only do these patterns make it easy to write, they make it easy for an IDE to inspect the code in your project. In addition, they help you while writing by displaying the results of their inspection. For example, if you define a class with the name MyClass in your project, the IDE then provides a pop-up window that includes MyClass as an option as soon as you type the keyword new. As you use the object of that type, the IDE shows its available methods and instance variables. When you start typing a function call, the IDE helps you by displaying the available arguments. Honestly, this is the No. 1 reason you should use an IDE and not a text editor. This type of code intelligence can save you hours of mistyped class names, method names, and wrong arguments.<br />
<br />
<b>Class view</b> <br />
A side effect of having a code intelligence engine in the IDE is that the IDE can produce a class view of the project. Instead of showing the files, the system can show you the different classes you have defined, regardless of the file they're in. As you click the classes, your editor is taken to that file and the selection placed on the class, method, or instance variable. It's a much nicer way of navigating around big projects.<br />
<br />
<b>Support for multiple languages </b><br />
Each IDE covered here supports not just PHP but a collection of the related languages: JavaScript, Structured Query Language (SQL), Hypertext Markup Language (HTML), and Cascading Style Sheets (CSS). Support for HTML and CSS are often the best, because it's simpler. The support for JavaScript often comes down to syntax highlighting, but something is better than nothing.<br />
<br />
<b>Source code control </b><br />
All the IDEs evaluated here support some connection to a source code control system, which allows you to maintain versions of the files in your project over time. You can mark particular versions of the files as a release, then revert to them when you want to roll out changes you've made. It's critical in team environments to use a source code control system, but it's important for individuals to use one, as well. A good source code control system can save you when a disk blows up or when the customer suddenly wants the version before last, rather than what you have today. Most of the IDEs support Concurrent Version System (CVS) and Subversion, which are open source control systems. One IDE supports Perforce, a commercial source code control system.<br />
<br />
<b>FTP/SFTP integration</b> <br />
Related to source code control is the ability to use FTP for the most recent code to the server. This is a lot easier than using an FTP client or packing up the files yourself, sending them to the server, and unpacking them.<br />
<br />
<b>Database navigation</b> <br />
A helpful but not essential feature is database navigation. With this feature, you can browse the database your application talks to, find out the table and field names, and run queries. Some systems even automate writing some of the database access code for you.<br />
<br />
<b>Integrated Web browser </b><br />
Some of the IDEs support an integrated Web browser that can navigate directly to the page you're editing with additional arguments you specify, the browser being hosted within the IDE or invoked externally. To be honest, I'm not a huge fan of the integrated browser because I don't mind switching between editing the code and viewing the result in two separate applications. But I can see the attraction, and it's not required that you use it.<br />
<br />
<b>Snippets</b> <br />
The last feature I found in all these IDEs was support for both canned and custom code snippets. Snippets are little fragments of code that perform small tasks, such as running a regular expression on some input, connecting to the database, and querying the database.<br />
<br />
That sums up the core features you can expect from a purchased or open source IDE today. From here, we look at some popular IDEs. We'll show some pictures of what they look like; and explain what they support, and how much they cost, if anything</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0tag:blogger.com,1999:blog-5402851457043770267.post-60195531273352553492011-05-14T20:20:00.000-07:002011-05-14T20:25:44.038-07:00Email sending Via PHP - Text and HTML<div dir="ltr" style="text-align: left;" trbidi="on">Email is the most popular Internet service today. A plenty of emails are sent and delivered each day. The goal of this tutorial is to demonstrate how to generate and send emails in PHP. <br />
<br />
So, you want to send automated email messages from your PHP application. This can be in direct response to a user's action, such as signing up for your site, or a recurring event at a set time, such as a monthly newsletter. Sometimes email contains file attachments, both plain text and HTML portions, and so on. To understand how to send each variation that may exist on an email, we will start with the simple example and move to the more complicated.<br />
<ol style="text-align: left;"><li><a href="http://sharingphp.blogspot.com/2011/05/email-sending-via-php-text-and-html.html#simple-text-email-php">Sending TEXT email with PHP</a></li>
<li><a href="http://sharingphp.blogspot.com/2011/05/email-sending-via-php-text-and-html.html#html-email-php">Sending HTML email with PHP</a> </li>
</ol><ol style="text-align: left;"></ol>Note that to send email with PHP you need a working email server that you have permission to use: for Unix machines, this is often Sendmail; for Windows machines, you must set the SMTP directive in your php.ini file to point to your email server.<br />
<br />
<a name='more'></a><br />
<a name="simple-text-email-php"></a><br />
<b><span style="font-size: large;">Sending a Simple Text Email</span></b><br />
<br />
<span style="font-size: small;">At first let's consider how to send a simple text email messages. PHP includes the mail() function for sending email, which takes three basic and two optional parameters. These parameters are, in order, the email address to send to, the subject of the email, the message to be sent, additional headers you want to include and finally an additional parameter to the Sendmail program. The mail() function returns True if the message is sent successfully and False otherwise. Have a look at the example:</span><b><span style="font-size: large;"> </span></b><br />
<br />
<pre class="brush:php"><?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
</pre><br />
As you can see, it very easy to send an email. You can add more receivers by either adding their addresses, comma separated, to the $to variable, or by adding cc: or bcc: headers. If you don't receive the test mail, you have probably installed PHP incorrectly, or may not have permission to send emails.<br />
<br />
<a name="html-email-php"></a><br />
<span style="font-size: large;"><b>Sending HTML Email</b></span><br />
<br />
The next step is to examine how to send HTML email. However, some mail clients cannot understand HTML emails. Therefore it is best to send any HTML email using a multipart construction, where one part contains a plain-text version of the email and the other part is HTML. If your customers have HTML email turned off, they will still get a nice email, even if they don't get all of the HTML markup. Have a look at the example:<br />
<br />
<pre class="brush:php"><?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
</pre><br />
In the preceding example we add one additional header of Content-type:multipart/alternative and boundary string that marks the different areas of the email. Note that the content type of the message itself is sent as a mail header, while the content types of the individual parts of the message are embedded in the message itself. This way, mail clients can decide which part of the message they want to display.<br />
<br />
</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0tag:blogger.com,1999:blog-5402851457043770267.post-74338749309308531062011-05-06T08:43:00.000-07:002011-05-06T08:43:19.754-07:00PHP - Session Security, Tips to keep the session secure<div dir="ltr" style="text-align: left;" trbidi="on">As Explained in earlier post about the<a href="http://sharingphp.blogspot.com/2011/05/php-session-starting-session-modifying.html"> PHP Session - Starting Session, Modifying Session and Deleting Session</a>,session stores important information. Most of the times Session have very important information about the user. User data, like Id, username, and many more.<br />
Session might also have the Shopping Cart information. All these information are very valuable and sensitive. So proper methods are need to implemented to keep the session secure.<br />
<br />
Here are some of the ways you can keep your session safe.<br />
<br />
<ol><li>Use SSL when authenticating users or performing sensitive operations.</li>
<li>Regenerate the session id whenever the security level changes (such as logging in). You can even regenerate the session id every request if you wish.</li>
<li>Have sessions time out</li>
<li>Don't use register globals<a name='more'></a></li>
<li>Store authentication details on the server. That is, don't send details such as username in the cookie.</li>
<li>Check the <code>$_SERVER['HTTP_USER_AGENT']</code>. This adds a small barrier to session hijacking. You can also check the IP address. But this causes problems for users that have changing IP address due to load balancing on multiple internet connections etc (which is the case in our environment here).</li>
<li>Lock down access to the sessions on the file system or use custom session handling</li>
<li>For sensitive operations consider requiring logged in users to provide their authenication details again</li>
</ol></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com1tag:blogger.com,1999:blog-5402851457043770267.post-19988907024127521212011-05-06T08:33:00.000-07:002011-05-06T08:34:38.300-07:00PHP Session - Starting Session, Modifying Session and Deleting Session<div dir="ltr" style="text-align: left;" trbidi="on">In the context of PHP, a <b>"session"</b> is the time that a user spends on a web site. Users may view many other Web pages between the time they enter this particular site and then leave it. Often, information for the complete session is very desirable. Beginning with version 4.0, PHP provides a way to do this.<br />
<br />
A PHP Session allows certain data to be preserved across an access span, by assigning a unique ID called <b>"Session ID"</b>, to each visitor to the site. This Session ID can be stored as a cookie at the client end, or passed through a URL. A PHP Session also enables the registration of arbitrary numbers of variables to be preserved across requests.<br />
PHP allows a session to be set up and session variables to be stored. After the session is created, session variables are available to the page visitor on other pages. To make this session information available, PHP does the following:<br />
<ul><li> PHP assigns a session ID number. </li>
<li> The number is a really long alphanumeric number that is unique to the user and that cannot possibly be guessed by anyone else. The session ID is stored in a PHP system variable named PHPSESSID. </li>
<li> PHP stores the variables to be saved for the session in a file on the server. </li>
<li> The file is named with the session ID number. It is stored in a directory specified by session.save_path in the php.ini file. The session directory must exist before session files can be saved in it. </li>
</ul>PHP passes the session ID number to every page.<br />
If the user has cookies turned on, PHP passes the session ID by using cookies. If the user has cookies turned off, the session can also be tracked by passing PHPSESSID as a GET variable to every page that participates in that session.<br />
PHP gets the variables from the session file for each new session page.<br />
Whenever a user opens a new page that is part of the session, PHP gets the variables from the file by using the session ID number that was passed from the previous page. The variables are available in the $_SESSION array.<br />
<br />
<a name='more'></a><br />
<br />
A session is a way to store information (in the form of variables) to be used across multiple pages. Unlike a <a href="http://sharingphp.blogspot.com/2011/05/php-cookies-explaing-php-cookie-with.html">cookie</a>, specific variable information is not stored on the users computer. It is also unlike other variables in the sense that we are not passing them individually to each new page, but instead retrieving them from the session we open at beginning of each page.<br />
<br />
Call this code mypage.php<br />
<br />
<pre class="brush:php"><?php
// this starts the session
session_start();
// this sets variables in the session
$_SESSION['color']='red';
$_SESSION['size']='small';
$_SESSION['shape']='round';
print "Done";
?> </pre><br />
The first thing we do with this code, is open the session using <a href="http://php.net/manual/en/function.session-start.php" rel="nofollow">session_start()</a>. We then set our first session variables (color, size and shape) to be red, small and round respectively.<br />
Just like with our cookies, the <i>session_start()</i> code must be in the header and you can not send anything to the browser before it. It's best to just put it directly after the <i><b>"<?php"</b></i> to avoid potential problems.<br />
So how will it know it's me? Most sessions set a cookie on your computer to uses as a key... it will look something like this: 350401be75bbb0fafd3d912a1a1d5e54. Then when a session is opened on another page, it scans your computer for a key. If there is a match, it accesses that session, if not it starts a new session for you.<br />
<br />
Now we are going to make a second page. We again will start with session_start() (we need this on every page) - and we will access the session information we set on our first page. Notice we aren't passing any variables, they are all stored in the session.<br />
Call this code mypage2.php<br />
<pre class="brush:php"><?php
// this starts the session
session_start();
// echo variable from the session, we set this on our other page
echo "Our color value is ".$_SESSION['color'];
echo "Our size value is ".$_SESSION['size'];
echo "Our shape value is ".$_SESSION['shape'];
?> </pre><br />
All of the values are stored in the $_SESSION array, which we access here. Another way to show this is to simply run this code:<br />
<br />
<pre class="brush:php"><?php
session_start();
Print_r ($_SESSION);
?> </pre><br />
You can also store an array within the session array. Let's go back to our mypage.php file and edit it slightly to do this:<br />
<pre class="brush:php"><?php
session_start();
// makes an array
$colors=array('red', 'yellow', 'blue');
// adds it to our session
$_SESSION['color']=$colors;
$_SESSION['size']='small';
$_SESSION['shape']='round';
print "Done";
?> </pre><br />
Now let's run this on mypage2.php to show our new information:<br />
<pre class="brush:php"><?php
session_start();
Print_r ($_SESSION);
echo "<p>";
//echo a single entry from the array
echo $_SESSION['color'][2];
?> </pre><br />
<pre class="brush:php"><?php
// you have to open the session to be able to modify or remove it
session_start();
// to change a variable, just overwrite it
$_SESSION['size']='large';
//you can remove a single variable in the session
unset($_SESSION['shape']);
// or this would remove all the variables in the session, but not the session itself
session_unset();
// this would destroy the session variables
session_destroy();
?> </pre><br />
The code above demonstrates how to edit or remove individual session<br />
variables, or the entire session. To change a session variable we just<br />
reset it to something else. We can use <a href="http://in3.php.net/unset" rel="nofollow">unset()</a> to remove a single variable, or session_unset() to remove all variables for a session. We can also use <a href="http://in3.php.net/session_destroy" rel="nofollow">session_destroy()</a> to destroy the session completely.<br />
<br />
By default a session lasts until the user closes their browser. This can be changed in the php.ini file by change the 0 in <i>session.cookie_lifetime = 0</i> to be the number of seconds you want the session to last, or by using <a href="http://in3.php.net/session_set_cookie_params" rel="nofollow">session_set_cookie_params()</a>.</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0tag:blogger.com,1999:blog-5402851457043770267.post-91075847474027850382011-05-05T08:54:00.000-07:002011-05-05T08:54:59.387-07:00PHP Cookies - Explaing PHP Cookie with example<div dir="ltr" style="text-align: left;" trbidi="on"><div align="justify">In the course of developing highly interactive web sites it is necessary to deal with large amount of data flow between client browswer and web server. It is quite cumbersome handling such large amount of data using hidden fiels in HTML forms. This problem can be overcomed by using HTTP cookies. HTTP cookies are the bunch of data/text sent by the server to the web browswer. Web browser store this data locally and send back to the server each time it accesses the server before it expires. Note that now a days Most browsers allow users choice to accept cookies or not, sometime rejection causes web site to not work properly.</div><div align="justify"><br />
</div><div align="justify"><a href="http://in3.php.net/manual/en/function.setcookie.php"><b>setcookie() function</b></a>.<br />
This function in PHP Language is used to work with HTTP cookies. setcookie() defines a cookie to be sent along with the rest of the HTTP headers. This must be called before sending any output to the browser because cookies are part of the HTTP header. On successful it will return TRUE. But this does not mean that client browser has ccepted cookie.</div><div align="justify"><br />
<a name='more'></a><br />
</div><div align="justify"><b>setcookie() syntax.</b></div><div align="justify"><br />
<pre class="brush:php">bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])</pre><br />
</div><ul><li><b>name</b>: This argument sets the name of the cookie.<br />
for example <pre class="brush:php">setcookie(‘mycookie’, …)</pre>will set mycookie and is called $_COOKIE['mycookie'] at server side.</li>
<li><b>value</b>: This will set the value of the cookie. Since this values is stored on the client browser extra care must be taken that it does not store some secure information e.g passwords. The values is accessed by $_COOKIE['mycookie'] at the web server.</li>
<li><b>expire</b>: Sets the expire time of cookie. It is Unix timestamp so generally it is used with time() function. For example time()+60*30. This will set the cookie to expire in 30 minutes. If not set the cookie is not persistent and will expire when the browser closes.</li>
<li><b>path</b>: The path of cookies are used to organise cookies based on the path at web server. If set to ‘/’ this cookie is availabe to all directories. If set to ‘/dir1/’ this cookie is availabe to dir1 only and all sub directories of /dir1 i.e /dir1/sub1. Note that the default value is the current directory so if the current directory is ‘/dir1/’ and you want to set it for all directories it must be ‘/’</li>
<li><b>domain</b>: This argument will decide in which domain cookie is accesible. Value ‘www.mydomin.com’<br />
makes it accesible to www sub-domain only. To make it accessible to all subdomains of mydomin.com a value<br />
‘.mydomin.com’ must be set.</li>
<li><b>secure</b>: Value 1 indicates the cookie must be used on secure (https) connection. Default value is 0.</li>
</ul><div align="justify"><b>setcookie() Examples.</b></div><div align="justify"><b><br />
</b><br />
<pre class="brush:php">setcookie(‘mycookie’, ‘Test mycookie’);\\This will set ‘mycookie’ with value ‘Test mycookie’ will expire when browser closes.</pre></div><div align="justify"><pre class="brush:php">setcookie(‘mycookie’, ‘Test mycookie’, time()+3600*24); \\ This will expire in 1 day.</pre></div><br />
<div align="justify"><pre class="brush:php">setcookie(‘mycookie’, ‘Test mycookie’, time()+3600*24, “/dir1/”); \\Available to /dir1 directory and all subdirectories under it.</pre></div><div align="justify"><br />
</div><div align="justify"><b>Accessing cookie values at server.<br />
</b>At server in PHP script, cookies sent from the client browser will be turned into PHP variables. After PHP 4.1.0 the global array variable $_COOKIE is set for cookies from the client. $HTTP_COOKIE_VARS is also present which is availabe before PHP 4.1.0. See example below.<br />
<i>echo $_COOKIE["mycookie"];</i> This will output “Test mycookie” in our example.</div><div align="justify"><br />
</div><div align="justify"><b>Testing cookie.<br />
</b>On successful return of setcookie() does not mean that client browser has accepted the cookie or cookie is set successfully. It must be checked on next loading of the page if a cookie was successfully set or not. This can be done by using PHP function print_r($_COOKIE) function. This will show weather the cookie is set or not.</div><div align="justify"><br />
</div><div align="justify"><b>Deleting a cookie.<br />
</b>Cookies can be deleted by setting its value to “” and all other parameters must be the same as they were set at the time of sending the cookie. We must ensure that the expiration date is in the past when deleting the cookie. See examples below.</div><pre class="brush:php">setcookie (“mycookie”, “”, time() – 3600);
setcookie (“mycookie”, “”, time() – 3600, “/dir1/”);</pre><div align="justify"><br />
</div><div align="justify"><b>Multiple cookies.<br />
</b>Multiple cookies can be set using following.<br />
<pre class="brush:php">setcookie(‘mycookie1′, ‘Test mycookie1′);
setcookie(‘mycookie2′, ‘Test mycookie2′);
setcookie(‘mycookie3′, ‘Test mycookie3′);
setcookie(‘mycookie4′, ‘Test mycookie4′);</pre></div>And can be accessed by following.<br />
<pre class="brush:php">echo $_COOKIE["mycookie1"];
echo $_COOKIE["mycookie2"];
echo $_COOKIE["mycookie3"];
echo $_COOKIE["mycookie4"];
</pre><div align="justify"><br />
</div><div align="justify"><b>Cookies Array.<br />
</b>We can use PHP array in cookies. see example below<br />
<br />
<pre class="brush:php">setcookie(“mycookie[0]“, “value1″);
setcookie(“mycookie[1]“, “value2″);
setcookie(“mycookie1['one']“, “value11″);
setcookie(“mycookie1['five']“, “value15″);</pre></div>This is similar of setting many cookies but the values are placed in the PHP array at the<br />
receing PHP script.<br />
<br />
<pre class="brush:php">foreach ($_COOKIE['mycookie'] as $key => $value) {
echo “$key:$value “;
}
//This will print 0:value1 1:value2 And
foreach ($_COOKIE['mycookie1'] as $key => $value) {
echo “$key:$value “;
}</pre><br />
Will print print one:value11 five:value15</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com2tag:blogger.com,1999:blog-5402851457043770267.post-87408969993643612462011-05-02T21:01:00.000-07:002011-05-02T21:02:10.358-07:00Creating a Word Density Checker Function - PHP<div dir="ltr" style="text-align: left;" trbidi="on">I was looking for some help of writing my keyword density checker class and found this function and it is worth sharing. Have a look at it. <br />
<br />
<br />
Function Code for calculating the word density goes as Follows: <br />
<br />
<a name='more'></a><br />
<br />
<pre class="brush:php"><?php
function calculate_word_popularity($string, $min_word_char = 2, $exclude_words = array())
{
$string = strip_tags($string);
$initial_words_array = str_word_count($string, 1);
$total_words = sizeof($initial_words_array);
$new_string = $string;
foreach($exclude_words as $filter_word)
{
$new_string = preg_replace("/\b".$filter_word."\b/i", "", $new_string); // strip excluded words
}
$words_array = str_word_count($new_string, 1);
$words_array = array_filter($words_array, create_function('$var', 'return (strlen($var) >= '.$min_word_char.');'));
$popularity = array();
$unique_words_array = array_unique($words_array);
foreach($unique_words_array as $key => $word)
{
preg_match_all('/\b'.$word.'\b/i', $string, $out);
$count = count($out[0]);
$percent = number_format((($count * 100) / $total_words), 2);
$popularity[$key]['word'] = $word;
$popularity[$key]['count'] = $count;
$popularity[$key]['percent'] = $percent.'%';
}
function cmp($a, $b)
{
return ($a['count'] > $b['count']) ? +1 : -1;
}
usort($popularity, "cmp");
return $popularity;
}
?></pre><br />
<br />
"This is a function that is meant to calculate the density of the words from a text. Since there are many words that have less then 3 characters, I’ve decided to add a filter that will not take into account words that aren’t bigger then (X) characters (examples: if, or, is, it etc.). Also, you can setup an array with a list of words that you do not want to add in the ranking calculation." - from <a href="http://www.bitrepository.com/word-popularity-script.html" rel="nofollow">http://www.bitrepository.com/word-popularity-script.html</a><br />
<br />
Thanks. </div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com2tag:blogger.com,1999:blog-5402851457043770267.post-16550108518928772062011-04-30T11:42:00.000-07:002011-04-30T11:42:42.474-07:00PHP Simple HTML DOM Parser - an Intoduction<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://sourceforge.net/projects/simplehtmldom/" rel="nofollow" title="PHP Simple HTML DOM Parser">PHP Simple HTML DOM Parser</a>, is one of the easiest DOM manipulation script written in PHP5+. Being Open source, it is free to use under the MIT License. Supporting invalid HTML, this parser is better then other PHP scripts that use complicated regexes to extract information from web pages. It helps to find tags on an HTML page with selectors just like <a href="http://jquery.com/" rel="nofollow" title="jQuery">jQuery</a>.<br />
<br />
<b><span style="font-size: large;">Some of the Usage examples are:</span></b><br />
<br />
<a name='more'></a><br />
<br />
<span style="font-size: large;"><b>Extracting all the Images and Links from a Web page:</b></span><br />
<pre class="brush:php">// Create DOM from URL or file
$html = file_get_html('http://www.microsoft.com/');
// Extract links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
// Extract images
foreach($html->find('img') as $element)
echo $element->src . '<br>';</pre><br /><br />
<b><span style="font-size: large;">Retrieving just plain text of a Web page:</span></b><br />
<br />
<pre class="brush:php">echo file_get_html('http://www.yahoo.com/')->plaintext;</pre><br /><br />
And there are lots of more things that can be done with it.<br />
Thanks for reading this. I'll be writing more about it in future, because as the title suggests, it is just an introduction and there is lot more to come :).</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com23tag:blogger.com,1999:blog-5402851457043770267.post-57506942356593562632011-04-29T10:54:00.000-07:002011-04-29T19:37:39.658-07:00Cleaning and Validating user input with htmLawed<div dir="ltr" style="text-align: left;" trbidi="on"><div class="entry"><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/" rel="nofollow" target="_blank">htmLawed</a> is a highly customizable single-file PHP script to make text secure, standard and admin policy-compliant for use in the body of HTML 4, XHTML 1 or 1.1, or generic XML documents. It is thus a configurable input (X)HTML filter, processor, purifier, sanitizer, beautifier, etc., and an alternative to the <a href="http://tidy.sourceforge.net/" rel="nofollow" target="_blank">HTMLTidy</a> application.<br />
<br />
The lawing in of input text is needed to ensure that HTML code in the text is standard-compliant, does not introduce security vulnerabilities, and does not break the aesthetics, design or layout of web-pages. htmLawed tries to do this by, for example, making HTML well-formed with balanced and properly nested tags, neutralizing code that may be used for cross-site scripting (XSS) attacks, and allowing only specified HTML elements/tags and attributes<br />
<a name='more'></a>.<br />
<b><span style="font-size: large;">Features</span></b><br />
<ul><li>Make HTML markup in text secure and standard-compliant</li>
<li>Process text for use in HTML, XHTML or XML documents</li>
<li>Restrict HTML elements, attributes or URL protocols using black- or white-lists</li>
<li>Balance tags, check element nesting, transform deprecated attributes and tags, make relative URLs absolute, etc.</li>
<li>Fast, highly customizable, well-documented</li>
<li>Single, 47 kb file</li>
<li>Simple HTML Tidy alternative</li>
<li>Use to filter, secure & sanitize HTML in blog comments or forum posts, generate XML-compatible feed items from web-page excerpts, convert HTML to XHTML, pretty-print HTML, scrape web-pages, reduce spam, remove XSS code, etc.</li>
</ul>Using htmLawed is as simple as it gets. You can either include() the htmLawed.php file or copy-paste the entire code. htmLawed should work with PHP 4.3 and higher.<br />
htmLawed is free and open-source software licensed under GPL license version 3, and copyrighted by Santosh Patnaik. You can find further information, demo & download on <a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/" rel="nofollow" target="_blank">htmLawed Websiter</a>.<br />
<br />
Some of the Example Usage are::<br />
<br />
<code class="code"> $config = array('safe'=>1);</code> <br />
<code class="code"> $out = htmLawed($in);</code> <br />
<br />
Simplest, allowing all valid HTML markup except <span class="term">javascript:</span> --<br />
<br />
<code class="code"> $out = htmLawed($in);</code> <br />
<br />
Allowing all valid HTML markup including <span class="term">javascript:</span> --<br />
<br />
<code class="code"> $config = array('schemes'=>'*:*');</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Allowing only <span class="term">safe</span> HTML and the elements <span class="term">a</span>, <span class="term">em</span>, and <span class="term">strong</span> --<br />
<br />
<code class="code"> $config = array('safe'=>1, 'elements'=>'a, em, strong');</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Not allowing elements <span class="term">script</span> and <span class="term">object</span> --<br />
<br />
<code class="code"> $config = array('elements'=>'* -script -object');</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Not allowing attributes <span class="term">id</span> and <span class="term">style</span> --<br />
<br />
<code class="code"> $config = array('deny_attribute'=>'id, style');</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Permitting only attributes <span class="term">title</span> and <span class="term">href</span> --<br />
<br />
<code class="code"> $config = array('deny_attribute'=>'* -title -href');</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Remove bad/disallowed tags altogether instead of converting them to entities --<br />
<br />
<code class="code"> $config = array('keep_bad'=>0);</code> <br />
<code class="code"> $out = htmLawed($in, $config);</code> <br />
<br />
Allowing attribute <span class="term">title</span> only in <span class="term">a</span> and not allowing attributes <span class="term">id</span>, <span class="term">style</span>, or scriptable <i>on*</i> attributes like <span class="term">onclick</span> --<br />
<br />
<code class="code"> $config = array('deny_attribute'=>'title, id, style, on*');</code> <br />
<code class="code"> $spec = 'a=title';</code> <br />
<code class="code"> $out = htmLawed($in, $config, $spec);</code> <br />
<br />
<b> Some case-studies.</b><br />
<br />
<b>1.</b> A blog administrator wants to allow only <span class="term">a</span>, <span class="term">em</span>, <span class="term">strike</span>, <span class="term">strong</span> and <span class="term">u</span> in comments, but needs <span class="term">strike</span> and <span class="term">u</span> transformed to <span class="term">span</span> for better XHTML 1-strict compliance, and, he wants the <span class="term">a</span> links to be to <span class="term">http</span> or <span class="term">https</span> resources:<br />
<br />
<code class="code"> $processed = htmLawed($in, array('elements'=>'a, em, strike, strong, u', 'make_tag_strict'=>1, 'safe'=>1, 'schemes'=>'*:http, https'), 'a=href');</code> <br />
<br />
<b>2.</b> An author uses a custom-made web application to load content on his web-site. He is the only one using that application and the content he generates has all types of HTML, including scripts. The web application uses htmLawed primarily as a tool to correct errors that creep in while writing HTML and to take care of the occasional <i>bad</i> characters in copy-paste text introduced by Microsoft Office. The web application provides a preview before submitted input is added to the content. For the previewing process, htmLawed is set up as follows:<br />
<br />
<code class="code"> $processed = htmLawed($in, array('css_expression'=>1, 'keep_bad'=>1, 'make_tag_strict'=>1, 'schemes'=>'*:*', 'valid_xhtml'=>1));</code> <br />
<br />
For the final submission process, <span class="term">keep_bad</span> is set to <span class="term">6</span>. A value of <span class="term">1</span> for the preview process allows the author to note and correct any HTML mistake without losing any of the typed text.<br />
<br />
<b>3.</b> A data-miner is scraping information in a specific table of similar web-pages and is collating the data rows, and uses htmLawed to reduce unnecessary markup and white-spaces:<br />
<br />
<code class="code"> $processed = htmLawed($in, array('elements'=>'tr, td', 'tidy'=>-1), 'tr, td =');</code> </div></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com47tag:blogger.com,1999:blog-5402851457043770267.post-10865245463724947332011-04-28T09:33:00.000-07:002011-04-28T09:33:34.285-07:00PHP CLI script and Command line arguments<div dir="ltr" style="text-align: left;" trbidi="on">One of the advantages of PHP is that, it can be run from the command line like a c program. Sometimes scripts are made to run behind the browser to give faster response to the user, and some time to run the bulky operations. (video conversion, cron, backups).<br />
<br />
There are to ways to get the arguments in the script, while running it from command line:<br />
<br />
<a name='more'></a><br />
<br />
<ol style="text-align: left;"><li><b>$_SERVER['argv']</b><br />
<br />
The command itself (i.e. your script filename) and the command line arguments are stored in an array in the $_SERVER variables called 'argv'. It is possible to access the command line arguments from here but it's easier to getopt() because you can then access the arguments by flag and in any order. Running the command "<b>php myscript.php foo bar</b>" and then doing print_r($_SERVER['argv']) would output this:<br />
<br />
<pre class="brush:php">Array
(
[0] => myscript.php
[1] => foo
[2] => bar
)</pre><br />
</li>
<li><b>getopt()</b>The getopt() function returns the list of command line arguments in an associative array. It returns the arguments passed in based on the parameters passed to it. For example, to get the values for the flags -a -b and -c you would do this:<br />
<br />
<pre class="brush:php">$arguments = getopt("a:b:c:");</pre><br />
If you called the script like this (the first example has spaces between the flag and the value, the second has no spaces but both will return the values):<br />
<br />
<pre>php myscript.php -a foo -b bar -c baz
OR
php myscript.php -afoo -bbar -cbaz</pre><br />
Then doing print_r($arguments) would return this:<br />
<br />
<pre class="brush:php">Array
(
[a] => foo
[b] => bar
[c] => baz
)</pre><br />
Note that the colons after the value are required; if you don't use them and a flag is passed on the command line with that letter then it won't be returned in the array.<br />
Another thing to note is that if it one of the values you are looking for is not passed on the command line, then it won't be added to the array return from getopt(). Calling the same $arguments = getopt("a:b:c:") script as in the above example, calling the script like so:<br />
<br />
<pre class="brush:php">php myscript.php -a foo</pre><br />
and then doing print_r($arguments) would show this:<br />
<br />
<pre class="brush:php">Array
(
[a] => foo
)</pre><br />
</li>
</ol>Thanks you.. Hope You like it. <br />
<ol style="text-align: left;"></ol></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com9tag:blogger.com,1999:blog-5402851457043770267.post-17721043873536741702011-04-25T08:35:00.000-07:002011-04-25T21:13:59.820-07:00File Upload via CURL in PHP<div dir="ltr" style="text-align: left;" trbidi="on">Most of us must have used CURL in PHP, But have you uploaded file using it. If not I must say it is very easy .<br />
<br />
Here is the simplest way to upload the file via CURL.<br />
<br />
<a name='more'></a><br />
<pre class="brush:php"><?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://someurl_will_go.here/test.php");
curl_setopt($ch, CURLOPT_POST, true);
// same as <input type="file" name="file">
$post_array = array(
"file"=>"@/full_path/of_the_file/with.extension",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$response = curl_exec($ch);
?>
]]>
</pre><br />
Please note "@" in front of the file name.<br />
You can get the file in same way i.e is using "$_FILES". so you can get file in test.php in $_FILES['file']<br />
<br />
Thanks.<br />
<span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 'Times New Roman'; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span class="Apple-style-span" style="color: #333333; font-family: arial; font-size: 13px; line-height: 15px; text-align: left;"></span></span></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com2tag:blogger.com,1999:blog-5402851457043770267.post-49331815199176572182011-04-24T09:27:00.000-07:002011-04-24T20:04:25.134-07:00Nice silde show about the PHP 5 Magic Methods<div dir="ltr" style="text-align: left;" trbidi="on"><span style="display: block; margin: 12px 0pt 4px;">I was looking to my bookmarks and wow found this very nice slides show about the PHP 5 Magic function. I think it is worth sharing, and is quite help full for the PHP OOPs beginners </span><br />
<a name='more'></a><br />
<div align="center"><div id="__ss_3145725" style="width: 600px;"><iframe frameborder="0" height="355" marginheight="0" marginwidth="0" scrolling="no" src="http://www.slideshare.net/slideshow/embed_code/3145725" width="600"></iframe> </div>Content from: <a href="http://www.slideshare.net/dstockto/php-5-magic-methods" rel="nofollow">http://www.slideshare.net/dstockto/php-5-magic-methods</a></div></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com1tag:blogger.com,1999:blog-5402851457043770267.post-66819115575651553982011-04-24T09:00:00.000-07:002011-04-25T21:15:24.558-07:00Search engine friendly re-direct with php headers<div dir="ltr" style="text-align: left;" trbidi="on">Many times we need to re-direct a page to another page, due to lots of reasons like:<br />
<ol style="text-align: left;"><li>You changed your URL patterns to new patterns.</li>
<li>The Old links are dead.</li>
<li>You simply moved your site to new domain,</li>
</ol>And might be lots of other issues... But have you ever thought will search engine follow these links...<br />
Here are simple PHP headers to re-direct the page to new location.<br />
<a name='more'></a><br />
<pre class="brush:php"><?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.newurl-to-forward.com" );
?>
</pre><span class="defaultfont">And alternatively if you want to manage re-direct in <b>.htaccess</b> file then you can do the following steps </span><br />
<br />
<blockquote>Options +FollowSymlinks<br />
RewriteEngine on<br />
rewritecond %{http_host} ^old_domain.com [nc]<br />
rewriterule ^(.*)$ http://www.new_domain.com/$1 [r=301,nc] <span class="defaultfont"> </span></blockquote><br />
<span class="defaultfont">Thanks.</span><br />
<span class="defaultfont"> </span> </div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0tag:blogger.com,1999:blog-5402851457043770267.post-66126537853252999282011-04-21T21:03:00.000-07:002011-04-21T21:03:03.972-07:00A Wonderful Image upload and manipulation class "class.upload.php"<div dir="ltr" style="text-align: left;" trbidi="on">Just found a great Image uploading and manipulation class written in PHP, by <a href="http://verot.net/" rel="nofollow">Verot.net</a><br />
<br />
Description as provided by the supplier::<br />
"The perfect script to generate thumbnails or create a photo gallery! It can convert, resize and work on uploaded images in many ways, apply effects, add labels, watermarks and reflections and other image editing features. You can use it for files uploaded through an HTML form, a Flash uploader, or on local files. It uses the GD library."<br />
<br />
You can Download it from: <a href="http://www.verot.net/php_class_upload.htm" rel="nofollow">http://www.verot.net/php_class_upload.htm</a> </div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com1tag:blogger.com,1999:blog-5402851457043770267.post-33167025977205083672011-04-19T10:16:00.000-07:002011-04-19T10:19:17.751-07:00Image resize and thubnail with PHP - functions<div dir="ltr" style="text-align: left;" trbidi="on">As websites are getting more and more feature enabled and fully loaded with the multimedia, the need of managing the media like, Music, Images, Videos is increasing day by day. One of the most used media is Images. Image gallerias, Slideshows, light-boxes are common every site. Each of this task is going to need the image resize or creating smaller thumbnails to display. So here is a small function with which you can easily create thumbnails from the image. The following function can resize and crop the image dimensionally or just creating a perfect square.<br />
<a name='more'></a><br />
/**<br />
* Gets the jpeg contents of the resized version of an already uploaded image<br />
* (Returns false if the file was not an image)<br />
*<br />
* @param string $input_name The name of the file on the disk<br />
* @param int $maxwidth The desired width of the resized image<br />
* @param int $maxheight The desired height of the resized image<br />
* @param bool $square If set to true, takes the smallest of maxwidth and<br />
* <span class="Apple-tab-span" style="white-space: pre;"> </span> maxheight and use it to set the dimensions on the new image.<br />
* If no crop parameters are set, the largest square that fits<br />
* in the image centered will be used for the resize. If square,<br />
* the crop must be a square region.<br />
* @param int $x1 x coordinate for top, left corner<br />
* @param int $y1 y coordinate for top, left corner<br />
* @param int $x2 x coordinate for bottom, right corner<br />
* @param int $y2 y coordinate for bottom, right corner<br />
* @param bool $upscale Resize images smaller than $maxwidth x $maxheight?<br />
*<br />
* @return false|mixed The contents of the resized image, or false on failure<br />
*/<br />
<b style="background-color: yellow;">function get_resized_image_from_existing_file($input_name, $maxwidth, $maxheight, $square = FALSE,</b><br />
<b style="background-color: yellow;">$x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0, $upscale = FALSE)</b> {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// Get the size information from the image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$imgsizearray = getimagesize($input_name);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($imgsizearray == FALSE) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$width = $imgsizearray[0];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$height = $imgsizearray[1];<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$accepted_formats = array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'image/jpeg' => 'jpeg',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'image/pjpeg' => 'jpeg',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'image/png' => 'png',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'image/x-png' => 'png',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'image/gif' => 'gif'<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// make sure the function is available<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$load_function = "imagecreatefrom" . $accepted_formats[$imgsizearray['mime']];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!is_callable($load_function)) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// get the parameters for resizing the image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$options = array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'maxwidth' => $maxwidth,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'maxheight' => $maxheight,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'square' => $square,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'upscale' => $upscale,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'x1' => $x1,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'y1' => $y1,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'x2' => $x2,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'y2' => $y2,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params = <a href="http://sharingphp.blogspot.com/2011/04/image-resize-and-thubnail-with-php.html#get_image_resize_parameters">get_image_resize_parameters</a>($width, $height, $options);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($params == FALSE) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// load original image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$original_image = $load_function($input_name);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!$original_image) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// allocate the new image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_image = imagecreatetruecolor($params['newwidth'], $params['newheight']);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!$new_image) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$rtn_code = imagecopyresampled(<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_image,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$original_image,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['xoffset'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['yoffset'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['newwidth'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['newheight'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['selectionwidth'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params['selectionheight']);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!$rtn_code) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// grab a compressed jpeg version of the image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ob_start();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>imagejpeg($new_image, NULL, 90);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$jpeg = ob_get_clean();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>imagedestroy($new_image);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>imagedestroy($original_image);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return $jpeg;<br />
}<br />
<br />
/**<br />
* Calculate the parameters for resizing an image<br />
*<br />
* @param int $width Width of the original image<br />
* @param int $height Height of the original image<br />
* @param array $options See $defaults for the options<br />
*<br />
* @return array or FALSE<br />
*/<br />
<a href="http://www.blogger.com/post-edit.g?blogID=5402851457043770267&postID=3316702597720508367#" name="get_image_resize_parameters"></a><br />
<b style="background-color: yellow;">function get_image_resize_parameters($width, $height, $options)</b> {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$defaults = array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'maxwidth' => 100,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'maxheight' => 100,<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'square' => FALSE,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'upscale' => FALSE,<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'x1' => 0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'y1' => 0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'x2' => 0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'y2' => 0,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$options = array_merge($defaults, $options);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>extract($options);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// crop image first?<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$crop = TRUE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 == 0) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$crop = FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// how large a section of the image has been selected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($crop) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$selection_width = $x2 - $x1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$selection_height = $y2 - $y1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// everything selected if no crop parameters<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$selection_width = $width;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$selection_height = $height;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// determine cropping offsets<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($square) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// asking for a square image back<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// detect case where someone is passing crop parameters that are not for a square<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($crop == TRUE && $selection_width != $selection_height) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return FALSE;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// size of the new square image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = $new_height = min($maxwidth, $maxheight);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// find largest square that fits within the selected region<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$selection_width = $selection_height = min($selection_width, $selection_height);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// set offsets for crop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($crop) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$widthoffset = $x1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$heightoffset = $y1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$width = $x2 - $x1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$height = $width;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// place square region in the center<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$widthoffset = floor(($width - $selection_width) / 2);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$heightoffset = floor(($height - $selection_height) / 2);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// non-square new image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = $maxwidth;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = $maxheight;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// maintain aspect ratio of original image/crop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (($selection_height / (float)$new_height) > ($selection_width / (float)$new_width)) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = floor($new_height * $selection_width / (float)$selection_height);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = floor($new_width * $selection_height / (float)$selection_width);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// by default, use entire image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$widthoffset = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$heightoffset = 0;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($crop) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$widthoffset = $x1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$heightoffset = $y1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!$upscale && ($selection_height < $new_height || $selection_width < $new_width)) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// we cannot upscale and selected area is too small so we decrease size of returned image<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($square) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = $selection_height;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = $selection_width;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($selection_height < $new_height && $selection_width < $new_width) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = $selection_height;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = $selection_width;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$params = array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'newwidth' => $new_width,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'newheight' => $new_height,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'selectionwidth' => $selection_width,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'selectionheight' => $selection_height,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'xoffset' => $widthoffset,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'yoffset' => $heightoffset,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return $params;<br />
}<br />
<br />
Enjoy guys.. And please don't forget to comment back if it helps you..<br />
Thanks</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com2tag:blogger.com,1999:blog-5402851457043770267.post-26162989433176120932011-04-18T10:26:00.000-07:002011-04-18T10:26:23.583-07:00The difference between the "isset", "empty" and "is_null"<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Most the times I have noticed the beginners are confused in testing the variable, whether it contains some data or not. Most of the time these checks fail as the wrong function is being used to assert the correct value. While it is important to be checking values, it is equally important to understand the difference between the different methods of checking and testing values for empty, null, or if they are set. <br />
<br />
The following difference chart between "<a href="http://www.blogger.com/">isset</a>", "<a href="http://in3.php.net/empty">empty</a>" and "<a href="http://in3.php.net/is_null">is_null</a>" will be quite helpful for everyone.<br />
<a name='more'></a><br />
<br />
</div><table style="border: 1px solid black; width: 100%;"><tbody>
<tr style="text-align: left;"><th>TEST</th><th>Not Set</th><th>NULL</th><th>Zero</th><th>FALSE</th><th>Numeric Value</th><th>Empty String</th></tr>
</tbody><tfoot>
<tr><td colspan="6">Comparison Table</td></tr>
</tfoot> <tbody>
<tr><td>isset()</td><td>bool(false)<br />
<br />
</td><td>bool(false)</td><td>bool(true)</td><td>bool(true)</td><td>bool(true)</td><td>bool(true)</td></tr>
<tr><td>empty()</td><td>bool(true)</td><td>bool(true)</td><td>bool(true)</td><td>bool(true)</td><td>bool(false)</td><td>bool(true)</td></tr>
<tr><td>is_null()</td><td>bool(true)</td><td>bool(true)<br />
<br />
</td><td>bool(false)</td><td>bool(false)<br />
<br />
</td><td>bool(false)</td><td>bool(false)</td></tr>
</tbody> </table></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com5tag:blogger.com,1999:blog-5402851457043770267.post-49251963742394489212011-04-17T20:17:00.000-07:002011-04-17T20:18:36.166-07:00PHP Tutorial for Beginners - by WebmonkeyJust found a great PHP tutorial for Beginners at Webmonkey. It is indeed a very well written and explained tutorial for the beginners who are completely new to PHP. It covers almost everything Basic syntax, Variables, HTML Forms, Arrays, Loops, Functions and lot more.<br />
<br />
<a href="http://www.webmonkey.com/2010/02/php_tutorial_for_beginners/">Read it here</a><br />
<br />
Enjoy reading it. Thanks.Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0tag:blogger.com,1999:blog-5402851457043770267.post-41216355884292766032011-04-17T09:22:00.000-07:002011-04-17T09:38:38.308-07:00PHP type comparison tables<div dir="ltr" style="text-align: left;" trbidi="on">It is sometimes hard to determine the type of the given variable while comparing it. So this table might help lot in such cases.<br />
<a name='more'></a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ofYYLC-hcZ51TZWxRtDAtiUY0T4bYEzSNnCDzwd7psk4_WBKmS5c0clxO7LtcW2mlirxzHqQhhzuk84iwCOP0IGqp0pZL7fxR0hPHUy7ftMWS_7p7AXWM0-xmxSAvNEI9D3M5TUG8on2/s1600/PHP+type+comparison+tables.png" imageanchor="1" style="margin-left: auto; margin-right: auto;" title=" - Click to enlarge"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ofYYLC-hcZ51TZWxRtDAtiUY0T4bYEzSNnCDzwd7psk4_WBKmS5c0clxO7LtcW2mlirxzHqQhhzuk84iwCOP0IGqp0pZL7fxR0hPHUy7ftMWS_7p7AXWM0-xmxSAvNEI9D3M5TUG8on2/s1600/PHP+type+comparison+tables.png" width="620" alt="PHP type comparison tables - Images provided by http://sharingphp.blogspot.com/" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Type comparison table for PHP Variables</td></tr>
</tbody></table><br />
More info at <a href="http://photoforu.blogspot.com/p/display-image.html?image=http://www.php.net/manual/en/types.comparisons.php" title=" - Click to enlarge">http://www.php.net/manual/en/types.comparisons.php</a></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com9tag:blogger.com,1999:blog-5402851457043770267.post-44952434810359102182011-04-16T23:37:00.000-07:002011-04-16T23:38:16.547-07:0010 Best PHP Coding Style Practices<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;">One the major problem for the beginners is the <b>STYLE OF CODING</b>, as it was for me as well. For some of the first few months I was stuck with the standards of different Frameworks and was following them and extracting the best of their styles. But short after I felt that, although they all are very different from each other but they have something in common, their Coding patterns. </span><br />
<br />
<span style="font-size: x-large;">Lets Start.</span><br />
<ol style="text-align: left;"><li><span style="font-size: small;"> First of all <b>Choose your favorite IDE</b>. There are lots of PHP IDE in the markte, like <a href="http://netbeans.org/index.html">NetBeans</a>, <a href="http://www.eclipse.org/">Eclipse</a>, <a href="http://www.phpedit.com/en">PHPEdit</a>, and lots more, Just Google :). As per my favorite I user NetBeans.<br />
<br />
<a name='more'></a></span></li>
<li><span style="font-size: small;"><b>Always user <?php ?>, </b></span>to delimit PHP code, <b>not the <tt class="literal"><? ?></tt></b> shorthand.<br />
<br />
<br />
<span style="font-size: small;"><b> </b></span></li>
<li><span style="font-size: small;"><b>Use Space instead of Tabs</b>. Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, SVN history and annotations. Moreover Tabs behave differently in different places.<br />
<br />
</span></li>
<li><span style="font-size: small;"><b>Always write comments</b> where ever possible, it helps your code to be more friendly for others and for you as well, when ever you read the code again. </span>C style comments (/* */) and standard C++ comments (//) are both fine. <br />
<blockquote class="">/*<br />
Some comment will go here<br />
*/<br />
<br />
// this is also a comment</blockquote></li>
<li><b>Use Meaningful, Consistent Naming Conventions. </b>Naming this isn’t just for your own good. There’s nothing worse than trying to find your way through some other programmer’s nonsensical naming conventions. Help yourself <i>and</i> others by using names that make sense for your classes and functions.<br />
<br />
</li>
<li class=""><b>Don' create extra vaiables</b>. Never define unnecessary variables. e.g<span class="vars"> </span><blockquote class=""><span class="vars">// bad </span><br />
<span class="vars">$description</span> = <span class="func">strip_tags</span>(<span class="vars">$_POST</span>[<span class="string">'description'</span>]); <span class="func"></span><br />
<span class="func">echo</span> <span class="vars">$description</span>;<br />
<br />
// good<br />
<span class="func">echo</span> <span class="func">strip_tags</span>(<span class="vars">$_POST</span>[<span class="string">'description'</span>]); <br />
</blockquote></li>
<li><b>Use UPPER case for the GLOBAL_CONSTANTS</b>, and use "_" for word separators.<br />
<br />
</li>
<li><b>Align the Declaration blocks for more readability</b>. e.g. <br />
<br />
<pre style="margin-left: 40px;">var $mDate;
var& $mrDate;
var& $mrName;
var $mName;
$mDate = 0;
$mrDate = NULL;
$mrName = 0;
$mName = NULL;</pre></li>
<li><b>Always use the proper directory structure</b> for placing the files. The structure can be any, but must be very handy and self descriptive. i.e Classes should be placed in classes folder only, similarly for the files containing functions in functions folder or what ever name you like. The core idea is always bunch the similar files in folders.<br />
<br />
</li>
<li>Last but not the least, <b>Always Turn on Error Reporting</b>. <a href="http://www.php.net/manual/en/function.error-reporting.php">Error reporting in PHP</a> is very helpful. You’ll find bugs in your code that you might not have spotted earlier, as not all bugs keep the application from working. There are different levels of strictness in the reporting that you can use, but E_ALL will show you the most errors, critical and warnings alike.</li>
</ol><blockquote> That's all for today. Thanks Guys. </blockquote></div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com18tag:blogger.com,1999:blog-5402851457043770267.post-66550147812400665582011-04-13T10:44:00.000-07:002011-04-13T10:44:32.859-07:00What is this blog for<div dir="ltr" style="text-align: left;" trbidi="on">Wow.. Finally writing for the blog. Sharing PHP, name itself describes the purpose of the blog. Well this blog is started to share the PHP resources I know, and I'll found on web.<br />
<br />
It happened to me so many time, that I want to find something about the some basic or advance stuff about PHP, what I do is just GOOGLE, but I end up lots of sites, around 30 mins of wasted time, and reading not what I exactly wanted but lots of other stuff. And I am sure most of the beginner do the same thing. So me and my Pals decided to launch a site for the beginners as well as advance users to make a one stop search for the PHP programmers.<br />
<br />
So as result this Blog is started, Sharing PHP. Its just a another blog, hosted at <a href="http://www.blogspot.com/">blogspot </a>currently, but let me make clear that we have lot to come and much bigger plans to share ahead. So guys Keep on looking back and enjoy the Blog.<br />
<br />
Thanks.. and WELCOME TO THE NEW WORLD. :)</div>Just a PHP Programmerhttp://www.blogger.com/profile/12575439406238906739noreply@blogger.com0