<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5536882164120371052</id><updated>2026-03-27T03:36:17.200-07:00</updated><category term="PHP"/><category term="Php hacking techniques"/><category term="php Interview question"/><category term="PHP and object oriented concepts"/><category term="Php security issues"/><category term="String functions"/><category term="Uploading Vulnerabilities"/><category term="php uploading security issue"/><category term="Advantages and disadvantages of php"/><category term="Array Functions"/><category term="Configure Curl in PHP"/><category term="Configure virtual host in apache"/><category term="Cropping"/><category term="Cropping in PHP"/><category term="Curl"/><category term="DCL Commands"/><category term="DDL commands"/><category term="DML commands"/><category term="DTD"/><category term="Database functions"/><category term="Error Handling in PHP"/><category term="Explode"/><category term="File exists"/><category term="Files"/><category term="Frame works"/><category term="Html dtd"/><category term="Http"/><category term="Implode"/><category term="Introduction of SOAP"/><category term="Joomla Events structure"/><category term="MVC architecture in php"/><category term="MVC in PHP"/><category term="Model view controller"/><category term="Mquery"/><category term="PHP Configuration"/><category term="PHP Curl"/><category term="PHP Mquery"/><category term="PHP Paging"/><category term="PHP Red Hat installation"/><category term="PHP SOAP"/><category term="PHP XML"/><category term="PHP cropping"/><category term="PHP download script"/><category term="PHP file realted functions"/><category term="PHP image uploading"/><category term="PHP installation in Red hat linux"/><category term="PHP mail"/><category term="Php 5.3 features"/><category term="Php 5.3 new features"/><category term="Php Error"/><category term="Php error handling"/><category term="Php watermarking text"/><category term="Read post array data"/><category term="SQL"/><category term="Soap Architecture"/><category term="TCL Commands"/><category term="Uploading Image php"/><category term="XML in PHP"/><category term="abstract php oops keywords"/><category term="arrays php"/><category term="associative array examples"/><category term="cookies in PHP"/><category term="download script in PHP"/><category term="final"/><category term="implements"/><category term="improved features in php 5.3"/><category term="index array"/><category term="interface"/><category term="jomla events"/><category term="joomla event methods"/><category term="magic methods in php"/><category term="oops in php"/><category term="pho check file exists"/><category term="php Read post array data"/><category term="php associative arrays"/><category term="php cookies"/><category term="php downloads"/><category term="php explode and implode"/><category term="php file exists"/><category term="php files"/><category term="php magic methods"/><category term="php oops"/><category term="polymorphism in php"/><category term="read and write xml files in php"/><category term="read xml files in php"/><category term="sending mail in php"/><category term="smtp mail"/><category term="static"/><category term="uploading PHP"/><category term="virtual host in php"/><category term="why me"/><category term="working with files"/><title type='text'>Your solutions....</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>78</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-323443687810528304</id><published>2014-04-21T14:44:00.001-07:00</published><updated>2014-04-21T14:52:09.735-07:00</updated><title type='text'>Create new role in wordpress</title><content type='html'>By default we have list of roles present in wordpress like administrator, editor, author etc. BY default we cannot add a new role to the current roles displayed in the wordpress system. We have so many pluggins which we need to check and find the suitable.

The below solution provides you a quick and better access to add a new role.&lt;br /&gt;
&lt;br /&gt;
1. Open the wordpress folder&lt;br /&gt;
2. Select the themes folder and select your current theme.&lt;br /&gt;
3. If you have functions.php file open the file, If you dont have functions.php file copy the file from the other theme / base 
   theme and paste in your current theme.&lt;br /&gt;
4. At the last line of function.php file add the below lines.
    &quot;add_role(&#39;Role Name&#39;, &#39;Role Display Name&#39;, array( &#39;Capabilities&#39;));&quot;&lt;br /&gt;
&lt;br /&gt;
Just by the above steps you would be able to add the New roles to your current system without any external plugins installation.

</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/323443687810528304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2014/04/create-new-role-in-wordpress.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/323443687810528304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/323443687810528304'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2014/04/create-new-role-in-wordpress.html' title='Create new role in wordpress'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3465348585131227006</id><published>2014-02-03T23:14:00.002-08:00</published><updated>2014-02-03T23:15:50.494-08:00</updated><title type='text'>Remove spaces between two string</title><content type='html'>In PHP we have so many functions which are related to strings. The below examples explains how to remove the spaces between string.
&lt;br/&gt;&lt;br/&gt;
1. str_replace
&lt;br/&gt;&lt;br/&gt;
2. preg_replace.
&lt;br/&gt;&lt;br/&gt;
str_replace:
&lt;br/&gt;&lt;br/&gt;
This replaces the empty spaces. this can be used partially.&lt;br/&gt;
Example:&lt;br/&gt;
   $string = str_replace(&#39; &#39;, &#39;&#39;, $string);
&lt;br/&gt;&lt;br/&gt;
preg_replace:&lt;br/&gt;
&lt;br/&gt;&lt;br/&gt;
This will replace the nth spaces and removes the white spaces within all the string.
&lt;br/&gt;&lt;br/&gt;
Example:&lt;br/&gt;
&lt;br/&gt;&lt;br/&gt;
$string = preg_replace(&#39;/\s+/&#39;, &#39;&#39;, $string);

</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3465348585131227006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2014/02/remove-spaces-between-two-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3465348585131227006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3465348585131227006'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2014/02/remove-spaces-between-two-string.html' title='Remove spaces between two string'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-6523699811663156816</id><published>2010-11-20T21:32:00.001-08:00</published><updated>2010-11-20T21:32:22.242-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php hacking techniques"/><title type='text'>Php hacking techniques part 1</title><content type='html'>Techniques for securing user input, then extended those techniques to applications where database input and output is required, looking at some SQL security issues. next is to deal with file operations and file uploads, looking specifically at the security issues involved with accessing files based on some user supplied filename, and user-supplied files (uploaded files). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What Are Sessions?&lt;br /&gt;Sessions are a PHP construct allowing persistent data to be retained across HTTP connections. In English, sessions allow you to store the values of certain variables across page visits. This is achieved by serializing the data (converting it to some binary representation) and writing it out to a file (or a database, or wherever you tell it), when a page is finished processing in PHP. When the next page (or that same page some time later) is processed, and PHP is told to start a session, it will check if the user already has a session, and read their data back in, unserializing it and assigning the variables. This allows you to keep track of a user across multiple visits, or while browsing multiple pages on your site.&lt;br /&gt;&lt;br /&gt;For example, you can create a shopping cart using sessions, storing an array of items added to the cart in a session variable, and loading it on every page. When the user clicks &#39;Add to cart&#39; you can add the item to the array, and it will be saved for the next page the user goes to. The whole array can be fetched on your checkout page and appropriate processing will take place.&lt;br /&gt;&lt;br /&gt;How Do Sessions Work?&lt;br /&gt;As many probably know, HTTP is a stateless protocol. By stateless, I mean that any HTTP connection is unaware of previous connections made by the same client, to the same server (persistent connections excepting). There are two useful ways in which PHP can pass identification information between pages in order to uniquely associate a user with a session.&lt;br /&gt;&lt;br /&gt;PHP can use cookies to store a session ID. The cookie value is sent on every request, so PHP can match that up to its session data and retrieve the correct set of variables for that user. Another way is to pass the session ID in URLs. In order to do this, URL rewriting must be enabled.&lt;br /&gt;&lt;br /&gt;Passing session data in URLs is not recommended since it is possible to pass your session onto another user if you give them a link which contains your session ID, and the session ID data is more easily attackable than in a cookie. URL-based session tracking should be used only where cookies cannot.&lt;br /&gt;&lt;br /&gt;Using $_SESSION&lt;br /&gt;PHP provides a super-global variable named $_SESSION. By super-global I mean it is a global variable which you may access without going via $_GLOBALS or stating global $_SESSION within a function. In this way, it behaves like $_GET and $_POST.&lt;br /&gt;&lt;br /&gt;$_SESSION is, in fact, an associative array. The keys are variable names, and the values are the stored session data for that variable name.&lt;br /&gt;&lt;br /&gt;Using $_SESSION is preferred over the use of session_register() to register ordinary global variables as session variables, especially when register_globals is enabled, since global variables may be more easily changed inadvertently than the contents of $_SESSION. It is still possible to alias ordinary global variables to their equivalents within $_SESSION,&lt;br /&gt;&lt;br /&gt;$username = &amp;$_SESSION[&quot;username&quot;];&lt;br /&gt;&lt;br /&gt;Here, the &amp; indicates a reference, or alias. It is then possible to use $username instead of $_SESSION[&quot;username&quot;], but note that $username is an ordinary variable, and you will have to access as $_GLOBALS[&quot;username&quot;] or global $username from within a function.&lt;br /&gt;&lt;br /&gt;Trusting Session Data&lt;br /&gt;Since a session ID can be spoofed, it is always wise to perform some extra validation where possible. The simplest mechanism would be to store the IP address of the client to whom the session ID was issued, and compare the client IP against that stored IP every session. This will prevent the basic security problems associated with passing links between computers (though not if the computers are on a private network and share a single public IP address).&lt;br /&gt;&lt;br /&gt;Session data is also stored in files on the server. The default location is /tmp on UNIX, or the system temporary file directory on Windows. If /tmp is world-writable (or, in some cases, world-readable), or there are multiple websites hosted on a single server, storing session data in a public location is not secure. PHP provides a way to change the way session data is stored.&lt;br /&gt;&lt;br /&gt;Changing The Session File Path&lt;br /&gt;The location in which PHP saves session data can be set using the php.ini directive session.save_path, or the string below in httpd.conf or a virtual host configuration.&lt;br /&gt;&lt;br /&gt;php_value session.save_path &quot;/home/test/sessions/&quot;&lt;br /&gt;&lt;br /&gt;It is important to ensure that your session data path is included in the paths allowed by open_basedir, if you have open_basedir settings or PHP Safe Mode enabled.&lt;br /&gt;&lt;br /&gt;The data representation used for saving session data to files can be controlled with the session.serialize_handler directive in php.ini. By default, PHP uses its own built in format, but the WDDX ( http://www.wddx.org ) format can be used also. Set the type using one of the lines below.&lt;br /&gt;&lt;br /&gt;(in php.ini ...)&lt;br /&gt;&lt;br /&gt;    session.serialize_handler wddx&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;    session.serialize_handler php&lt;br /&gt;&lt;br /&gt;(or in httpd.conf ...)&lt;br /&gt;&lt;br /&gt;    php_value session.serialize_handler wddx&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;    php_value session.serialize_handler php&lt;br /&gt;&lt;br /&gt;Storing Session Data In A Database&lt;br /&gt;When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database.&lt;br /&gt;&lt;br /&gt;Unfortunately, there is no direct way to store session data in a database using the php.ini directives, but luckily PHP provides a mechanism for customised session storage handlers. The function session_set_save_handler() allows you to register handler functions for session management. These functions must be written in PHP (or made available as a PHP extension).&lt;br /&gt;&lt;br /&gt;session_set_save_handler(open_fn, close_fn, read_fn, write_fn,&lt;br /&gt;&lt;br /&gt;destroy_fn, gc_fn)&lt;br /&gt;&lt;br /&gt;To use these user-supplied session storage handlers, you must set session.save_handler to the value user, and the value of session.save_path should be the name of the database into which you&#39;re saving session data (so that the session save handler functions you define can locate and use that database). The value of session.name can be used as the name of the table within the database.&lt;br /&gt;&lt;br /&gt;(httpd.conf)&lt;br /&gt;&lt;br /&gt;&lt;Location &quot;/&quot;&gt;&lt;br /&gt;&lt;br /&gt;    php_value session.save_handler user&lt;br /&gt;&lt;br /&gt;    php_value session.save_path dbname&lt;br /&gt;&lt;br /&gt;    php_value session.name session_data&lt;br /&gt;&lt;br /&gt;&lt;/Location&gt;&lt;br /&gt;&lt;br /&gt;Next, a table for storing session data must exist in the database. At the minimum, your session handler should keep track of the session ID, the expiration time, and the serialized session data. The SQL below creates a simple table for storing this data.&lt;br /&gt;&lt;br /&gt;CREATE TABLE session_data (&lt;br /&gt;&lt;br /&gt;    sessionid text not null PRIMARY KEY,&lt;br /&gt;&lt;br /&gt;    expiration timestamp,&lt;br /&gt;&lt;br /&gt;    sessiondata text not null&lt;br /&gt;&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;The final task is to create the functions which manage this session store, and register them with session_set_save_handler(). The open_fn must open the database connection, the close_fn must close it and perform any associated cleanup tasks, and the read_fn and write_fn functions must read and write session data respectively. destroy_fn is called when a session ends and is destroyed, and gc_fn is called when session data is garbage collected. These operations must be mapped into database queries by your PHP code. The prototypes for the functions are given below, and parameters passed are explained.&lt;br /&gt;&lt;br /&gt;function open_fn($save_path, $session_name)&lt;br /&gt;&lt;br /&gt;    $save_path is the value of session.save_path, $session_name is the value of session.name&lt;br /&gt;&lt;br /&gt;function close_fn()&lt;br /&gt;&lt;br /&gt;    Takes no arguments&lt;br /&gt;&lt;br /&gt;function read_fn($session_id, $data)&lt;br /&gt;&lt;br /&gt;    $session_id is the session ID for which PHP requests the associated session data to be returned&lt;br /&gt;&lt;br /&gt;function write_fn($session_id)&lt;br /&gt;&lt;br /&gt;    $session_id is the session ID for which PHP requests that $data be associated with in the session store (database)&lt;br /&gt;&lt;br /&gt;function destroy_fn($session_id)&lt;br /&gt;&lt;br /&gt;    $session_id is the ID of a session which may be removed from the store&lt;br /&gt;&lt;br /&gt;function gc_fn($max_time)&lt;br /&gt;&lt;br /&gt;    $max_time is the oldest last modified time to retain in the session store. Sessions with an older modified time than this are to be removed from the store.&lt;br /&gt;                                              -- Continued in Next pPrt</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/6523699811663156816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/11/php-hacking-techniques-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/6523699811663156816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/6523699811663156816'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/11/php-hacking-techniques-part-1.html' title='Php hacking techniques part 1'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-1366065766600687437</id><published>2010-11-20T21:30:00.001-08:00</published><updated>2010-11-20T21:30:23.707-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php hacking techniques"/><title type='text'>Php hacking techniques part 2</title><content type='html'>Implementing the above functions, you are not limited simply to database connections. You could, for instance, connect to some other data storage application, or store the session data in an encrypted virtual filesystem, or on a network file server.&lt;br /&gt;&lt;br /&gt;Further Securing Sessions&lt;br /&gt;There are a few remaining PHP directives for controlling sessions, several of these have security implications. Firstly, the session name (set with session.name) should be changed from the default to avoid collisions, especially on servers with multiple users.&lt;br /&gt;&lt;br /&gt;The session.cookie_path directive determines the default cookie path, the path for which cookies will be sent in an HTTP request. If you have a forum at somedomain.com/forum, and somedomain.com/ does not require session management, you can change session.cookie_path as shown below.&lt;br /&gt;&lt;br /&gt;&lt;Location &quot;/forum&quot;&gt;&lt;br /&gt;&lt;br /&gt;    php_value session.cookie_path /forum/&lt;br /&gt;&lt;br /&gt;&lt;/Location&gt;&lt;br /&gt;&lt;br /&gt;This prevents sections of your site which do not require the session cookie from being sent it, and limits exposure of the session IDs to those parts of a site where sessions are actually being used. This is especially important if some sections of your site have pages provided by other users, who could use those pages to steal session IDs from your visitors.&lt;br /&gt;&lt;br /&gt;Setting session.use_only_cookies to true disables the passing of session IDs in URLs, at the cost of losing sessions support for users with cookies disabled, or on browsers not supporting cookies. Setting session.cookie_domain to the most restrictive domain name possible (e.g. forum.somesite.com instead of somesite.com) also helps to minimise exposure of session IDs. Of course, if you have a single login for an entire range of subdomains, you will have to set the domain as somedomain.com to ensure that the sessions are correctly managed across all of the subdomains.&lt;br /&gt;&lt;br /&gt;Finally, it is possible to set the hash function used when creating session IDs. The default is to use MD5 (hash function 0), but SHA1 may also be used (hash function 1). SHA1 is a 160-bit hash function, whereas MD5 is only a 128-bit hash function, so using SHA1 for session hashes improves security slightly over using MD5. You can set the hash function using This setting was introduced in PHP 5.&lt;br /&gt;&lt;br /&gt;php_value session.hash_function 1&lt;br /&gt;&lt;br /&gt;Beyond PHP Security&lt;br /&gt;Everything I&#39;ve covered so far has been directly related to PHP and SQL security. The best situation we can manage here is PHP Safe Mode, which uses self-imposed restrictions to improve security. That this is the best we can achieve is due to the server architecture currently in use. There are, however, a few options for taking security a little further, and imposing the restrictions at a lower level than PHP itself. To conclude this series, I&#39;ll mention some of these briefly here.&lt;br /&gt;&lt;br /&gt;Chroot&lt;br /&gt;Chroot changes the &quot;root&quot; directory that a process can see. This effectively locks it into a certain directory structure within the overall filesystem. With this approach, you can lock a web server into some directory such as /home/www and it will not be able to access anything outside of that structure.&lt;br /&gt;&lt;br /&gt;There are several advantages to doing this. The first is that the web server, PHP, any user scripts, and also any attackers, will be contained within this chroot &quot;jail&quot;, unable to access files outside of it. Furthermore, you can remove all but the most essential software from the chroot environment. Removing any shells from the environment prevents a large number of exploits which attempt to invoke a remote shell. The minimal environment inside a chroot makes life very difficult for attackers, no matter whether their method of attack is through a vulnerability in your PHP code, or a vulnerability in the underlying web server.&lt;br /&gt;&lt;br /&gt;Apache mod_security and mod_chroot&lt;br /&gt;mod_security and mod_chroot are extension modules specifically for the Apache web server. These two modules provide chroot support for Apache without externally applying a chroot technique. mod_security also provides several other security features. Further information is available at http://www.modsecurity.org/ for mod_security and at http://core.segfault.pl/~hobbit/mod_chroot/ for mod_chroot.&lt;br /&gt;&lt;br /&gt;suEXEC and Multiple Server Instances&lt;br /&gt;Using a chroot to lock your web server into a restricted environment helps to prevent some security problems, but one of the big issues is shared hosting. Running multiple websites on the same server requires that the web server process has access to each user&#39;s files. If the web server has access, so do the other users (subject to PHP Safe Mode restrictions, of course). There are two ways around this, one which is Apache specific, and one which may be deployed on any server environment.&lt;br /&gt;&lt;br /&gt;suEXEC, specific to Apache, switches an Apache process to be owned by the same user as the script it is executing, losing any escalated permissions. This locks that Apache instance into the permissions held by that user, rather than the permissions held by the master web server process itself. This mechanism allows a return to the more traditional permissions system, and each user can be reasonably sure his or her files are protected. The cost of this is that an Apache process may not then be promoted back to regain permissions and switch user again to serve a different user&#39;s files. This system works best when there will be many requests for pages owned by the same user. suEXEC is explained in more detail at http://httpd.apache.org/docs/1.3/suexec.html&lt;br /&gt;&lt;br /&gt;The alternative is to use multiple instances of the web server, each one running with the permissions of a different user. Each server then only has the permissions it needs to serve a single website, so a reverse proxy must be used as a front to all of these server instances, redirecting requests for a virtually hosted website to the Apache instance responsible for actually serving that site. This solution is the most secure, but also the most resource-hungry. Information about using Apache as a reverse proxy is available at http://httpd.apache.org/docs/1.3/mod/mod_proxy.html&lt;br /&gt;&lt;br /&gt;How to check for PHP vulnerabilities&lt;br /&gt;The best way to check whether your web site &amp; applications are vulnerable to PHP security attacks is by using a Web Vulnerability Scanner. A Web Vulnerability Scanner crawls your entire website and automatically checks for vulnerabilities to PHP attacks. It will indicate which scripts are vulnerable so that you can fix the vulnerability easily. Besides PHP security vulnerabilities, a web application scanner will also check for SQL injection, Cross site scripting &amp; other web vulnerabilities.&lt;br /&gt;&lt;br /&gt;The Acunetix Web Vulnerability Scanner scans for SQL injection, Cross site scripting (XSS), Google hacking and many more vulnerabilities. For more information &amp; a trial download click here.&lt;br /&gt;&lt;br /&gt;Check if your website is vulnerable to attack with Acunetix Web Vulnerability Scanner&lt;br /&gt;&lt;br /&gt;Acunetix Web Vulnerability Scanner ensures website security by automatically checking for SQL injection, Cross site scripting and other vulnerabilities. It checks password strength on authentication pages and automatically audits shopping carts, forms, dynamic content and other web applications. As the scan is being completed, the software produces detailed reports that pinpoint where vulnerabilities exist. Take a product tour or download the evaluation version today!&lt;br /&gt;&lt;br /&gt;Scanning for XSS vulnerabilities with Acunetix WVS Free Edition!&lt;br /&gt;To check whether your website has cross site scripting vulnerabilities, download the Free Edition from http://www.acunetix.com/cross-site-scripting/scanner.htm. This version will scan any website / web application for XSS vulnerabilities and it will also reveal all the essential information related to it, such as the vulnerability location and remediation techniques. Scanning for XSS is normally a quick exercise (depending on the size of the web-site).&lt;br /&gt;&lt;br /&gt;Final Words&lt;br /&gt;This concludes the tour of PHP and SQL security. There is much more information available on the web about each security issue covered in this series, and many other issues also. In particular, several Apache modules exist for improving security through chrooting, reverse proxies, or simply checking requests for attacks such as directory traversal.&lt;br /&gt;&lt;br /&gt;The PHP manual over at php.net points out any security concerns relating to most functions, and the comments posted by users below the reference pages often contain useful security hints and code samples</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/1366065766600687437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/11/php-hacking-techniques-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1366065766600687437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1366065766600687437'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/11/php-hacking-techniques-part-2.html' title='Php hacking techniques part 2'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-8529161044655148612</id><published>2010-06-29T05:09:00.000-07:00</published><updated>2010-06-29T05:19:25.042-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cookies in PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="php cookies"/><title type='text'>Cookies in PHP</title><content type='html'>The better and simple solution for sending the user input values from one page to another page is using COOKIES. We can send data easily from page to page and can be easily retrieved and used.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Setting Cookies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;setcookie():This method is used for creating the Cookies. Important note is that Cookies are sent with the HTTP headers,so setcookie() must be called  before any output is generated.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;setcookie(&#39;Variable&#39;,&#39;Value&#39;);&lt;br /&gt;&lt;br /&gt;This is the default syntax declaration, We have another parameters which has its own importance but they are not mandatory.&lt;br /&gt;&lt;br /&gt;The third argument to setcookie() is an expiration time,expressed as an epoch timestamp.For example, this cookie expires at noon GMT on December 3, 2004:&lt;br /&gt;&lt;br /&gt;setcookie(&#39;flavor&#39;,&#39;chocolate chip&#39;,1102075200);&lt;br /&gt;&lt;br /&gt;If the third argument to setcookie() is missing (or empty),the cookie expires when&lt;br /&gt;the browser is closed. Also,many systems can’t handle a cookie expiration time&lt;br /&gt;greater than 2147483647,because that’s the largest epoch timestamp that fits in a&lt;br /&gt;32-bit integer&lt;br /&gt;&lt;br /&gt;The fourth argument to setcookie() is a path. The cookie is sent back to the server&lt;br /&gt;only when pages whose path begin with the specified string are requested. For example, the following cookie is sent back only to pages whose path begins with /products/:&lt;br /&gt;&lt;br /&gt;setcookie(&#39;flavor&#39;,&#39;chocolate chip&#39;,&#39;&#39;,&#39;/products/&#39;);&lt;br /&gt;&lt;br /&gt;The page that’s setting this cookie doesn’t have to have a URL that begins with /products/, but the following cookie is sent back only to pages that do.&lt;br /&gt;&lt;br /&gt;The fifth argument to setcookie() is a domain. The cookie is sent back to the server&lt;br /&gt;only when pages whose hostname ends with the specified domain are requested. For&lt;br /&gt;example,the first cookie in the following code is sent back to all hosts in the example.com domain,but the second cookie is sent only with requests to the host test.example.com:&lt;br /&gt;setcookie(&#39;variable&#39;,&#39;value&#39;,&#39;&#39;,&#39;&#39;,&#39;.example.com&#39;);&lt;br /&gt;setcookie(&#39;variable&#39;,&#39;value&#39;,&#39;&#39;,&#39;&#39;,&#39;test.example.com&#39;);&lt;br /&gt;&lt;br /&gt;If the first cookie’s domain was just example.com instead of .example.com,it would&lt;br /&gt;be sent only to the single host example.com (and not www.example.com or test.&lt;br /&gt;example.com).&lt;br /&gt;&lt;br /&gt;The last optional argument to setcookie() is a flag that if set to 1,instructs the&lt;br /&gt;browser only to send the cookie over an SSL connection. This can be useful if the&lt;br /&gt;cookie contains sensitive information,but remember that the data in the cookie is&lt;br /&gt;stored in the clear on the user’s computer.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Reading Cookie Values&lt;/span&gt;&lt;br /&gt;A cookie’s value isn’t available in $_COOKIE during the request in which the cookie isset. In other words,the setcookie() function doesn’t alter the value of $_COOKIE. On subsequent requests,however,each cookie is stored in $_COOKIE. If register_globals&lt;br /&gt;is on, cookie values are also assigned to global variables.&lt;br /&gt;&lt;br /&gt;When a browser sends a cookie back to the server,it sends only the value. You can’t&lt;br /&gt;access the cookie’s domain,path,expiration time,or secure status through $_COOKIE&lt;br /&gt;because the browser doesn’t send that to the server.&lt;br /&gt;To print the names and values of all cookies sent in a particular request,loop&lt;br /&gt;through the $_COOKIE array:&lt;br /&gt;&lt;br /&gt;foreach ($_COOKIE as $cookie_name =&gt; $cookie_value) {&lt;br /&gt;print &quot;$cookie_name = $cookie_value&lt;br&gt;&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Deleting Cookies&lt;/span&gt;&lt;br /&gt;Call setcookie() with no value for the cookie and an expiration time in the past:&lt;br /&gt;&lt;br /&gt;setcookie(&#39;flavor&#39;,&#39;&#39;,time()-86400);&lt;br /&gt;&lt;br /&gt;It’s a good idea to make the expiration time a few hours or an entire day in the past,in case your server and the user’s computer have unsynchronized clocks. For example,if your server thinks it’s 3:06 P.M. and a user’s computer thinks it’s 3:02 P.M.,a cookie with an expiration time of 3:05 P.M. isn’t deleted by that user’s computer even though the time is in the past for the server.&lt;br /&gt;The call to setcookie() that deletes a cookie has to have the same arguments (except&lt;br /&gt;for value and time) that the call to setcookie() that set the cookie did,so include the path, domain, and secure flag if necessary.&lt;br /&gt;&lt;br /&gt;Different browsers handle cookies in slightly different ways,especially with regard to how strictly they match path and domain strings and how they determine priority&lt;br /&gt;between different cookies of the same name.</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/8529161044655148612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/06/cookies-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8529161044655148612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8529161044655148612'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/06/cookies-in-php.html' title='Cookies in PHP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-2621689186119731417</id><published>2010-06-16T04:24:00.000-07:00</published><updated>2010-06-16T05:08:47.728-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP file realted functions"/><category scheme="http://www.blogger.com/atom/ns#" term="working with files"/><title type='text'>PHP working with Files and Directory</title><content type='html'>Below are some of the important methods used when working or manipulating the files or folders&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;parse_ini_file($filename)&lt;/span&gt;&lt;br /&gt;parse_ini_file() loads in the ini file specified in filename, and returns the settings in it in an associative array. &lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;// Parse without sections&lt;br /&gt;$ini_array = parse_ini_file(&quot;sample.ini&quot;);&lt;br /&gt;print_r($ini_array);&lt;br /&gt;&lt;br /&gt;// Parse with sections&lt;br /&gt;$ini_array = parse_ini_file(&quot;sample.ini&quot;, true);&lt;br /&gt;print_r($ini_array);&lt;br /&gt;O/P&lt;br /&gt;Array&lt;br /&gt;(&lt;br /&gt;    [one] =&gt; 1&lt;br /&gt;    [five] =&gt; 5&lt;br /&gt;    [animal] =&gt; Dodo bird&lt;br /&gt;    [path] =&gt; /usr/local/bin&lt;br /&gt;    [URL] =&gt; http://www.example.com/~username&lt;br /&gt;    [phpversion] =&gt; Array&lt;br /&gt;        (&lt;br /&gt;            [0] =&gt; 5.0&lt;br /&gt;            [1] =&gt; 5.1&lt;br /&gt;            [2] =&gt; 5.2&lt;br /&gt;            [3] =&gt; 5.3&lt;br /&gt;        )&lt;br /&gt;&lt;br /&gt;)&lt;br /&gt;Array&lt;br /&gt;(&lt;br /&gt;    [first_section] =&gt; Array&lt;br /&gt;        (&lt;br /&gt;            [one] =&gt; 1&lt;br /&gt;            [five] =&gt; 5&lt;br /&gt;            [animal] =&gt; Dodo bird&lt;br /&gt;        )&lt;br /&gt;&lt;br /&gt;    [second_section] =&gt; Array&lt;br /&gt;        (&lt;br /&gt;            [path] =&gt; /usr/local/bin&lt;br /&gt;            [URL] =&gt; http://www.example.com/~username&lt;br /&gt;        )&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;basename($path)&lt;/span&gt;&lt;br /&gt;Given a string containing a path to a file, this function will return the base name of the file. &lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;$path = &quot;/home/httpd/html/index.php&quot;;&lt;br /&gt;$file = basename($path);         // $file is set to &quot;index.php&quot;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt; dirname($path)&lt;/span&gt;&lt;br /&gt;Given a string containing a path to a file, this function will return the name of the directory. &lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;example&lt;/span&gt;&lt;br /&gt;$path = &quot;/etc/passwd&quot;;&lt;br /&gt;$file = dirname($path); // $file is set to &quot;/etc&quot;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;pathinfo($_SERVER[&#39;PHP_SELF&#39;])&lt;/span&gt;&lt;br /&gt;pathinfo() returns an associative array containing information about path. &lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;$path_parts = pathinfo(&#39;/www/htdocs/inc/lib.inc.php&#39;);&lt;br /&gt;&lt;br /&gt;echo $path_parts[&#39;dirname&#39;], &quot;\n&quot;;   //www/htdocs/inc&lt;br /&gt;echo $path_parts[&#39;basename&#39;], &quot;\n&quot;;  //lib.inc.php&lt;br /&gt;echo $path_parts[&#39;extension&#39;], &quot;\n&quot;;  //php&lt;br /&gt;echo $path_parts[&#39;filename&#39;], &quot;\n&quot;; // lib.inc&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;realpath($path)&lt;/span&gt;&lt;br /&gt;realpath() expands all symbolic links and resolves references to &#39;/./&#39;, &#39;/../&#39; and extra &#39;/&#39; characters in the input path and return the canonicalized absolute pathname&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;echo realpath(&#39;/windows/system32&#39;); //C:\WINDOWS\System32&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;getcwd()&lt;/span&gt;&lt;br /&gt;Gets the current working directory. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;file_exists&lt;/span&gt;&lt;br /&gt;hecks whether a file or directory exists</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/2621689186119731417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-working-with-files-and-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/2621689186119731417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/2621689186119731417'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-working-with-files-and-directory.html' title='PHP working with Files and Directory'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-1541305095082210174</id><published>2010-06-15T03:34:00.000-07:00</published><updated>2010-06-15T05:08:24.499-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="magic methods in php"/><category scheme="http://www.blogger.com/atom/ns#" term="php magic methods"/><title type='text'>PHP Magic Methods</title><content type='html'>These are the following magic methods available &lt;br /&gt;&lt;br /&gt;__construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __toString, __invoke, __set_state and __clone  are magical in PHP classes. &lt;br /&gt;&lt;br /&gt;PHP reserves all function names starting with __ as magical.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;__sleep&lt;/span&gt;&lt;br /&gt;serialize() checks if your class has a function with the magic name __sleep. If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;__wakeup&lt;/span&gt;&lt;br /&gt;Conversely, unserialize() checks for the presence of a function with the magic name __wakeup. If present, this function can reconstruct any resources that the object may have.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;class Connection {&lt;br /&gt;    protected $link;&lt;br /&gt;    private $server, $username, $password, $db;&lt;br /&gt;    &lt;br /&gt;    public function __construct($server, $username, $password, $db)&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;server = $server;&lt;br /&gt;        $this-&gt;username = $username;&lt;br /&gt;        $this-&gt;password = $password;&lt;br /&gt;        $this-&gt;db = $db;&lt;br /&gt;        $this-&gt;connect();&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    private function connect()&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;link = mysql_connect($this-&gt;server, $this-&gt;username, $this-&gt;password);&lt;br /&gt;        mysql_select_db($this-&gt;db, $this-&gt;link);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public function __sleep()&lt;br /&gt;    {&lt;br /&gt;        return array(&#39;server&#39;, &#39;username&#39;, &#39;password&#39;, &#39;db&#39;);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public function __wakeup()&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;connect();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;__tostring&lt;/span&gt;&lt;br /&gt;The __toString method allows a class to decide how it will react when it is converted to a string.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;class Member&lt;br /&gt;{&lt;br /&gt;    private $m_szEmail;&lt;br /&gt;    private $m_szUsername;&lt;br /&gt;    &lt;br /&gt;    public function __construct($szUsername, $szEmail)&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;m_szUsername = $szUsername;&lt;br /&gt;        $this-&gt;m_szEmail = $szEmail;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$pMember = new Member(&#39;Karl&#39;, &#39;karl@talkphp.com&#39;);&lt;br /&gt;&lt;br /&gt;echo $pMember;  &lt;br /&gt;&lt;br /&gt;O/P  is object.&lt;br /&gt;&lt;br /&gt;Usually, most people would achieve this with code like:&lt;br /&gt;&lt;br /&gt;echo $pMember-&gt;getUsername() . &quot; (&quot; . $pMember-&gt;getEmail() . &quot;)&quot;;  &lt;br /&gt;&lt;br /&gt;However, what we can do is use the __toString() function to change the default behaviour of the object to string conversion. This would allow us to specify exactly&lt;br /&gt;Add this method in your class&lt;br /&gt;&lt;br /&gt;public function __toString()&lt;br /&gt;{&lt;br /&gt;    return sprintf(&#39;%s (%s)&#39;, $this-&gt;m_szUsername, $this-&gt;m_szEmail);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; __set() is run when writing data to inaccessible properties.&lt;br /&gt;&lt;br /&gt;__get() is utilized for reading data from inaccessible properties.&lt;br /&gt;&lt;br /&gt;__isset() is triggered by calling isset() or empty() on inaccessible properties.&lt;br /&gt;&lt;br /&gt;__unset() is invoked when unset() is used on inaccessible properties. &lt;br /&gt;&lt;br /&gt; __call() is triggered when invoking inaccessible methods in an object context.&lt;br /&gt;&lt;br /&gt;__callStatic() is triggered when invoking inaccessible methods in a static context. &lt;br /&gt;&lt;br /&gt;__invoke()  this method is called when a script tries to call an object as a function. &lt;br /&gt;&lt;br /&gt;__set_state()  This static method is called for classes exported by var_export() since PHP 5.1.0.&lt;br /&gt;&lt;br /&gt;The only parameter of this method is an array containing exported properties in the form array(&#39;property&#39; =&gt; value, ...).</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/1541305095082210174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-magic-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1541305095082210174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1541305095082210174'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-magic-methods.html' title='PHP Magic Methods'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3372624723068625578</id><published>2010-06-01T05:05:00.000-07:00</published><updated>2010-06-01T05:09:30.786-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="abstract php oops keywords"/><category scheme="http://www.blogger.com/atom/ns#" term="final"/><category scheme="http://www.blogger.com/atom/ns#" term="implements"/><category scheme="http://www.blogger.com/atom/ns#" term="interface"/><category scheme="http://www.blogger.com/atom/ns#" term="static"/><title type='text'>PHP 5 OOPS concepts Key Words</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;Extends&lt;/span&gt;&lt;br /&gt;In PHP a class a class can inherit methods, functions and members of other class by using the extends keyword in the declaration. In PHP it is not possible to inherit from multiple classes, a class can inherit from only one base class.&lt;br /&gt;&lt;br /&gt;The class from which inheritance is done is called the parent class or base class and the class which inherits is called the child class. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Final&lt;/span&gt;&lt;br /&gt;The final keyword prevents the child classes from overriding a method. This can be done by prefixing the method with the keyword final. If the complete class is being defined as final then that class cannot be extended. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Abstract&lt;/span&gt;&lt;br /&gt;A new concept of abstract classes and methods has been introduced in PHP5. When a class is defined as abstract then it is not allowed to create the instance of that class. A class that contains at least one abstract method must also be abstract. The methods defined as abstract cannot define the implementation; they just declare the method’s signature.&lt;br /&gt;&lt;br /&gt;When a child class is inheriting from an abstract parent class, then all the methods marked abstract in parent class declaration must also be additionally defined by the child class. These methods must be defined with the same or weaker access. This means that if an abstract method is declared as protected in the parent class then it must be declared either as protected or public in the child class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Static &lt;/span&gt;&lt;br /&gt;When class members or methods are declared as static then there is no need to instantiate that class. These members and methods are accessible without the instantiation of the class. If a member is declared as static then it cannot be accessed by an instantiated class object, but a method declared as static can be accessed by an instantiated class object.&lt;br /&gt;&lt;br /&gt;The static declaration of a class must be after the visibility declaration (means that after the member or method has been declared as public, protected, or private).&lt;br /&gt;&lt;br /&gt;The static method calls are resolved at compile time and static properties cannot be accessed through the object through the arrow operator (-&gt;). &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Interfaces&lt;/span&gt;&lt;br /&gt;Object interfaces allow the creation of a code which specifies that which method a class must implement, without having to define how these methods have to be handled.&lt;br /&gt;&lt;br /&gt;Interfaces are defined in the same way as a class is defined. These interfaces are defined with the keyword “interface”. In the interface the contents of the methods do not have to be defined and all the methods declared in the interface must be declared as public. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Implementation of Interfaces&lt;/span&gt;&lt;br /&gt;To implement an interface, the implements operator is used. The methods must be defined before implementation and all the methods in the interface must be implemented within a class.</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3372624723068625578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-5-oops-concepts-key-words.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3372624723068625578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3372624723068625578'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/06/php-5-oops-concepts-key-words.html' title='PHP 5 OOPS concepts Key Words'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-560579292864029519</id><published>2010-04-28T05:01:00.001-07:00</published><updated>2010-06-11T05:23:28.862-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction of SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="Soap Architecture"/><title type='text'>Introduction of SOAP Architecture</title><content type='html'>Simplified Object Access Protocol (SOAP) is a specification that enables applications to communicate with other applications.  It provides a framework for connecting Web sites and applications to create Web services.  These Web services link different sites and applications together to perform functions that the individual components or sites are not capable of.  SOAP provides a mechanism by which each service can expose its features and communicate with other services. Using SOAP, one can link services offered by different systems together as components and use these components to build a complex information system application in a much shorter timeframe.&lt;br /&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 154px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY0vNBCT50mSYR91IA55eDsIdi9KUqSUm0f8Iyjwu24VNbK4YaXbP4RM_wKKy-5C_2eA1qcEwD2pHGENghYcN0KfKvdDRXZ5uk5K5s7MIiaTMUiO8XvRZ68UUieQbaT_xHXOnyn6ju7jU/s320/soap.h4.gif&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5481489236087891554&quot; /&gt;&lt;br /&gt;   High-Level diagram of SOAP in a distributed system&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Advantages of SOAP &lt;/span&gt;&lt;br /&gt;1. SOAP is an open standard that is built upon open technologies such as XML and HTTP.  It is not vendor-specific and therefore less intimidating to smaller players in the industry.  As a result it is being accepted uniformly by the industry, thus improving its chances of being the de-facto standard for true distributed interoperability.&lt;br /&gt;2.   SOAP based distributed systems are loosely-coupled.  As a result they are easier to maintain because they can be modified independently of other systems. &lt;br /&gt;3. When used over HTTP protocol, SOAP packets can easily bypass firewalls if their content is not deemed malicious.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Disadvantages of SOAP &lt;/span&gt;&lt;br /&gt;1. SOAP’s relied on HTTP for transport of XML data in the version 1.0 of its specification.  HTTP requires a stateless request/response architecture that is not appropriate under all circumstances.  While one can work around the state problem it requires additional coding.&lt;br /&gt;2. All SOAP data is serialized and passed by value and currently there is no provision for passing data by reference.  This could lead to synchronization problems if multiple copies of the same object are being passed at the same time.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;SOAP Architecture &lt;/span&gt;&lt;br /&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 159px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfHrnIIZfWD2mfiLRL6JFRcweCNHBo-dqo35SrICOFq1eiQX27ZEH62208ftXpnudYlwYvJLfhZuyeDcRfyzbGB34ccSiAk6vISaNT93UNTofcHN-6tUfOCYWHOB-_iMPw40rKXfFCVAI/s320/soap.h5.gif&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5481489952978994994&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/560579292864029519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/intriduction-of-soap-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/560579292864029519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/560579292864029519'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/intriduction-of-soap-architecture.html' title='Introduction of SOAP Architecture'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY0vNBCT50mSYR91IA55eDsIdi9KUqSUm0f8Iyjwu24VNbK4YaXbP4RM_wKKy-5C_2eA1qcEwD2pHGENghYcN0KfKvdDRXZ5uk5K5s7MIiaTMUiO8XvRZ68UUieQbaT_xHXOnyn6ju7jU/s72-c/soap.h4.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-12846694414131259</id><published>2010-04-27T00:01:00.001-07:00</published><updated>2010-05-22T13:38:34.904-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configure virtual host in apache"/><category scheme="http://www.blogger.com/atom/ns#" term="virtual host in php"/><title type='text'>Configure Virual host in Apache</title><content type='html'>Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. This allows one machine to share its resources, such as memory and processor cycles, to use its resources more efficiently.&lt;br /&gt;&lt;br /&gt;One widely used application is shared web hosting. Shared web hosting prices are lower than a dedicated web server, because this allows many customers to be hosted on a single server.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Setting Up A Virtual Host in Apache&lt;/span&gt;&lt;br /&gt;Setting up a virtual host in the Apache web server is not exactly a PHP topic, but many PHP developers use the Apache web server to test web pages on their development machine.&lt;br /&gt;&lt;br /&gt;There is a lot of information around on how to do this, but the first time I tried it, I found the existing information to be more confusing than helpful. Hopefully, this page will simplify the process a bit. Please note that this information pertains to setting up a virtual host in Apache on a Windows machine for use as a local testing server.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Configuring Apache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first file we&#39;ll need to edit is the Apache httpd.conf file. If you installed the Apache software using the download from the Apache web site, you should have a menu item that will open this file for editing. Click Start-&gt;Programs-&gt;Apache HTTP Server-&gt;Configure Apache Server-&gt;Edit the Apache httpd.conf Configuration File. If you don&#39;t have that start menu item, start your text editor and open the file. It will be in a sub-folder named conf of your Apache folder. For example, mine is here:&lt;br /&gt;&lt;br /&gt;C:\Program Files\Apache Group\Apache\conf\httpd.conf&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Notes for Apache Server Versions Since 2.2 Configuration&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that Apache changed the preferred method for configuring the Apache server with the release of Apache 2.2. For versions beginning with 2.2, the peferred configuration is more modular. Setting up a virtual host as described here will still work with the newer versions, but to follow the modular approach, the editing of httpd.conf is only to uncomment (remove the # from the beginning of the following line:&lt;br /&gt;&lt;br /&gt;#Include conf/extra/httpd-vhosts.conf&lt;br /&gt;&lt;br /&gt;Everything else is entered in the file httpd-vhosts.conf, which will be located in the extra folder below the below the folder containing httpd.conf. As mentioned, the method described here will still work.&lt;br /&gt;Security&lt;br /&gt;&lt;br /&gt;Version 2.2 also changed some of the default security configuration parameters. To set things up the way you&#39;ll need them, you&#39;ll need to add the following block to either your httpd.conf file, just above the virtual hosts, or to your httpd-vhosts.conf file:&lt;br /&gt;&lt;br /&gt;&amp;#60Directory &quot;C:\ My Sites &quot;&amp;#62&lt;br /&gt;  Order Deny,Allow&lt;br /&gt;  Allow from all&lt;br /&gt;&amp;#60/Directory&amp;#62&lt;br /&gt;&lt;br /&gt;Simple Steps are:&lt;br /&gt;&lt;br /&gt;1. Open the vhosts file in the apache folder and create a virtual path and the name which will be map the related folder and the server name for example&lt;br /&gt;&lt;br /&gt;&amp;#60VirtualHost 127.0.0.1&amp;#62&lt;br /&gt;   DocumentRoot &quot;C:\My Sites\Site1&quot;&lt;br /&gt;   ServerName original&lt;br /&gt;&amp;#60/VirtualHost&amp;#62&lt;br /&gt;&lt;br /&gt;&amp;#60VirtualHost 127.0.0.1&amp;#62&lt;br /&gt;   DocumentRoot &quot;C:\My Sites\Site2&quot;&lt;br /&gt;   ServerName testing&lt;br /&gt;&amp;#60/VirtualHost&amp;#62&lt;br /&gt;&lt;br /&gt;2. Open &#39;hosts&#39; file which is present in path &quot;C:\WINNT\system32\drivers\etc\hosts&quot;&lt;br /&gt;   add the server name to them. This will tell the apache that both the server     &lt;br /&gt;   names should be responded For example&lt;br /&gt;   &lt;br /&gt;   127.0.0.1   original&lt;br /&gt;   127.0.0.1   testing&lt;br /&gt;&lt;br /&gt;Restart the apache server and your done</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/12846694414131259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/configure-virual-host-in-apache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/12846694414131259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/12846694414131259'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/configure-virual-host-in-apache.html' title='Configure Virual host in Apache'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-9068093451073791206</id><published>2010-04-20T07:01:00.000-07:00</published><updated>2010-04-20T07:05:08.324-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php Interview question"/><category scheme="http://www.blogger.com/atom/ns#" term="php oops"/><category scheme="http://www.blogger.com/atom/ns#" term="polymorphism in php"/><title type='text'>PHP OOPS - Polymorphism</title><content type='html'>What is Polymorphism?&lt;br /&gt;Polymorphism in PHP5 is a technique where the function to be called is detected based on the class object calling it at runtime. The basis of Polymorphism is Inheritance and function overridden.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example – Basic Polymorphism&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;class BaseClass&lt;br /&gt;{&lt;br /&gt;    public function myMethod()&lt;br /&gt;    {&lt;br /&gt;         echo &quot;BaseClass method called&quot;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;class DerivedClass extends BaseClass&lt;br /&gt;{&lt;br /&gt;      public function myMethod()&lt;br /&gt;      {&lt;br /&gt;           echo &quot;DerivedClass method called&quot;;&lt;br /&gt;      }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;function processClass(BaseClass $c)&lt;br /&gt;{&lt;br /&gt;      $c-&gt;myMethod();&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;$c = new DerivedClass();&lt;br /&gt;processClass($c);&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Output:&lt;/span&gt; &lt;br /&gt;DerivedClass method called&lt;br /&gt;&lt;br /&gt;Here i am declaring BaseClass and DerivedClass but i am calling the the processClass with the Derived Class Object.</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/9068093451073791206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/php-oops-polymorphism.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/9068093451073791206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/9068093451073791206'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/php-oops-polymorphism.html' title='PHP OOPS - Polymorphism'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3241948770502292822</id><published>2010-04-19T13:35:00.000-07:00</published><updated>2010-04-19T13:37:13.567-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jomla events"/><category scheme="http://www.blogger.com/atom/ns#" term="joomla event methods"/><category scheme="http://www.blogger.com/atom/ns#" term="Joomla Events structure"/><title type='text'>Jooma Events</title><content type='html'>The events triggered in Joomla! are:&lt;br /&gt;&lt;br /&gt;These are the related methods trigged when a particular event occurs&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Authentication&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onAuthenticate&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Content&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onPrepareContent&lt;br /&gt;    * onAfterDisplayTitle&lt;br /&gt;    * onBeforeDisplayContent&lt;br /&gt;    * onBeforeContentSave (new in 1.5.4)&lt;br /&gt;    * onAfterContentSave (new in 1.5.4)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Editors&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onInit&lt;br /&gt;    * onGetContent&lt;br /&gt;    * onSetContent&lt;br /&gt;    * onSave&lt;br /&gt;    * onDisplay&lt;br /&gt;    * onGetInsertMethod&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;br /&gt;Editors XTD (Extended)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onDisplay&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Seach&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onSearch&lt;br /&gt;    * onSearchAreas&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;System&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onAfterInitialise&lt;br /&gt;    * onAfterRoute&lt;br /&gt;    * onAfterDispatch&lt;br /&gt;    * onAfterRender&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;User&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onLoginUser&lt;br /&gt;    * onLoginFailure&lt;br /&gt;    * onLogoutUser&lt;br /&gt;    * onLogoutFailure&lt;br /&gt;    * onBeforeStoreUser&lt;br /&gt;    * onAfterStoreUser&lt;br /&gt;    * onBeforeDeleteUser&lt;br /&gt;    * onAfterDeleteUser&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;XML-RPC&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * onGetWebServices</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3241948770502292822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/jooma-events.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3241948770502292822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3241948770502292822'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/jooma-events.html' title='Jooma Events'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-6133883766335443321</id><published>2010-04-19T13:26:00.000-07:00</published><updated>2010-04-19T13:30:04.952-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DTD"/><category scheme="http://www.blogger.com/atom/ns#" term="Html dtd"/><category scheme="http://www.blogger.com/atom/ns#" term="php Interview question"/><title type='text'>What is DTD? Types of DTD?</title><content type='html'>The doctype declaration should be the very first thing in an HTML document, before the html tag.&lt;br /&gt;&lt;br /&gt;The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.&lt;br /&gt;&lt;br /&gt;The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers can render the content correctly.&lt;br /&gt;&lt;br /&gt;Doctypes Available in the W3C Recommendations&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;HTML 4.01 Strict&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;HTML 4.01 Transitional&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;HTML 4.01 Frameset&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;br /&gt;XHTML 1.0 Strict&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;XHTML 1.0 Transitional&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;XHTML 1.0 Frameset&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content.</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/6133883766335443321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/what-is-dtd-types-of-dtd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/6133883766335443321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/6133883766335443321'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/what-is-dtd-types-of-dtd.html' title='What is DTD? Types of DTD?'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3787261182422223732</id><published>2010-04-17T06:47:00.000-07:00</published><updated>2010-04-17T06:56:18.789-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Http"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="php Interview question"/><title type='text'>What is Http? Types of Headers in HTTP</title><content type='html'>The Hypertext Transfer Protocol (HTTP) is an Application Layer protocol for distributed, collaborative, hypermedia information systems.&lt;br /&gt;&lt;br /&gt;HTTP is a request-response standard typical of client-server computing. In HTTP, web browsers or spiders typically act as clients, while an application running on the computer hosting the web site acts as a server. The client, which submits HTTP requests, is also referred to as the user agent. The responding server, which stores or creates resources such as HTML files and images, may be called the origin server. In between the user agent and origin server may be several intermediaries, such as proxies, gateways, and tunnels.&lt;br /&gt;&lt;br /&gt;HTTP is not constrained in principle to using TCP/IP, although this is its most popular implementation platform. Indeed HTTP can be &quot;implemented on top of any other protocol on the Internet, or on other networks.&quot; HTTP only presumes a reliable transport; any protocol that provides such guarantees can be used.&lt;br /&gt;&lt;br /&gt;Resources to be accessed by HTTP are identified using Uniform Resource Identifiers (URIs)—or, more specifically, Uniform Resource Locators (URLs)—using the http or https URI schemes.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Requests Headers:&lt;/span&gt;&lt;br /&gt;These are the following request headers:&lt;br /&gt;Accept           Content-Types that are acceptable&lt;br /&gt;Accept-Charset   Character sets that are acceptable&lt;br /&gt;Accept-Encoding  Acceptable encodings&lt;br /&gt;Accept-Language  Acceptable languages for response&lt;br /&gt;Cache-Control   Used to specify directives that MUST be obeyed by all caching  &lt;br /&gt;                 mechanisms along the request/response chain&lt;br /&gt;Content-Type  The mime type of the body of the request (used with POST and PUT &lt;br /&gt;                requests)&lt;br /&gt;Host            The domain name of the server (for virtual hosting), mandatory since &lt;br /&gt;                HTTP/1.1 &lt;br /&gt;Pragma          Implementation-specific headers that may have various effects &lt;br /&gt;                anywhere along the request-response chain.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Responses&lt;/span&gt;&lt;br /&gt;These are the response headers&lt;br /&gt;&lt;br /&gt;Accept           Content-Types that are acceptable&lt;br /&gt;Accept-Charset   Character sets that are acceptable&lt;br /&gt;Accept-Encoding  Acceptable encodings&lt;br /&gt;Accept-Language  Acceptable languages for response&lt;br /&gt;Cache-Control   Used to specify directives that MUST be obeyed by all caching  &lt;br /&gt;                 mechanisms along the request/response chain&lt;br /&gt;Content-Type  The mime type of the body of the request (used with POST and PUT &lt;br /&gt;                requests)&lt;br /&gt;Host            The domain name of the server (for virtual hosting), mandatory since &lt;br /&gt;                HTTP/1.1 &lt;br /&gt;Pragma          Implementation-specific headers that may have various effects &lt;br /&gt;                anywhere along the request-response chain.&lt;br /&gt;WWW-Authenticate Indicates the authentication scheme that should be used to access &lt;br /&gt;                 the requested entity.&lt;br /&gt;Set-Cookie       an HTTP cookie</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3787261182422223732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/what-is-http-types-of-headers-in-http.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3787261182422223732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3787261182422223732'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/what-is-http-types-of-headers-in-http.html' title='What is Http? Types of Headers in HTTP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-2015662726456224707</id><published>2010-04-17T06:46:00.000-07:00</published><updated>2013-09-16T05:08:35.856-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="smtp mail"/><title type='text'>Send Mail using SMTP Authentication</title><content type='html'>Sending Mail from PHP Using SMTP Authentication - Example
&lt;br /&gt;
&lt;br /&gt;
require_once &quot;Mail.php&quot;;
&lt;br /&gt;
&lt;br /&gt;
$from = &quot;Sandra Sender &lt;sender example.com=&quot;&quot;&gt;&quot;;
&lt;br /&gt; $to = &quot;Ramona Recipient &lt;recipient example.com=&quot;&quot;&gt;&quot;;
&lt;br /&gt; $subject = &quot;Hi!&quot;;
&lt;br /&gt; $body = &quot;Hi,\n\nHow are you?&quot;;
&lt;br /&gt; 
&lt;br /&gt; $host = &quot;mail.example.com&quot;;
&lt;br /&gt; $username = &quot;smtp_username&quot;;
&lt;br /&gt; $password = &quot;smtp_password&quot;;
&lt;br /&gt; 
&lt;br /&gt; $headers = array (&#39;From&#39; =&amp;gt; $from,
&lt;br /&gt;   &#39;To&#39; =&amp;gt; $to,
&lt;br /&gt;   &#39;Subject&#39; =&amp;gt; $subject);
&lt;br /&gt; $smtp = Mail::factory(&#39;smtp&#39;,
&lt;br /&gt;   array (&#39;host&#39; =&amp;gt; $host,
&lt;br /&gt;     &#39;auth&#39; =&amp;gt; true,
&lt;br /&gt;     &#39;username&#39; =&amp;gt; $username,
&lt;br /&gt;     &#39;password&#39; =&amp;gt; $password));
&lt;br /&gt; 
&lt;br /&gt; $mail = $smtp-&amp;gt;send($to, $headers, $body);
&lt;br /&gt; 
&lt;br /&gt; if (PEAR::isError($mail)) {
&lt;br /&gt;   echo(&quot;&lt;/recipient&gt;&lt;/sender&gt;&lt;br /&gt;
&quot; . $mail-&amp;gt;getMessage() . &quot;&lt;br /&gt;
&quot;);
&lt;br /&gt;  } else {
&lt;br /&gt;   echo(&quot;Message successfully sent!&lt;br /&gt;
&quot;);
&lt;br /&gt;  }
&lt;br /&gt; ?&amp;gt;
&lt;br /&gt;
&lt;br /&gt;Sending Mail from PHP Using SMTP Authentication and SSL Encryption - Example
&lt;br /&gt;
&lt;br /&gt; require_once &quot;Mail.php&quot;;
&lt;br /&gt; 
&lt;br /&gt; $from = &quot;Sandra Sender &lt;sender example.com=&quot;&quot;&gt;&quot;;
&lt;br /&gt; $to = &quot;Ramona Recipient &lt;recipient example.com=&quot;&quot;&gt;&quot;;
&lt;br /&gt; $subject = &quot;Hi!&quot;;
&lt;br /&gt; $body = &quot;Hi,\n\nHow are you?&quot;;
&lt;br /&gt; 
&lt;br /&gt; $host = &quot;ssl://mail.example.com&quot;;
&lt;br /&gt; $port = &quot;465&quot;;
&lt;br /&gt; $username = &quot;smtp_username&quot;;
&lt;br /&gt; $password = &quot;smtp_password&quot;;
&lt;br /&gt; 
&lt;br /&gt; $headers = array (&#39;From&#39; =&amp;gt; $from,
&lt;br /&gt;   &#39;To&#39; =&amp;gt; $to,
&lt;br /&gt;   &#39;Subject&#39; =&amp;gt; $subject);
&lt;br /&gt; $smtp = Mail::factory(&#39;smtp&#39;,
&lt;br /&gt;   array (&#39;host&#39; =&amp;gt; $host,
&lt;br /&gt;     &#39;port&#39; =&amp;gt; $port,
&lt;br /&gt;     &#39;auth&#39; =&amp;gt; true,
&lt;br /&gt;     &#39;username&#39; =&amp;gt; $username,
&lt;br /&gt;     &#39;password&#39; =&amp;gt; $password));
&lt;br /&gt; 
&lt;br /&gt; $mail = $smtp-&amp;gt;send($to, $headers, $body);
&lt;br /&gt; 
&lt;br /&gt; if (PEAR::isError($mail)) {
&lt;br /&gt;   echo(&quot;&quot; . $mail-&amp;gt;getMessage() . &quot;&lt;br /&gt;
&quot;);
&lt;br /&gt;  } else {
&lt;br /&gt;   echo(&quot;Message successfully sent!&lt;br /&gt;
&quot;);
&lt;br /&gt;  }
&lt;br /&gt; ?&amp;gt;&lt;/recipient&gt;&lt;/sender&gt;

Reference URL is http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/2015662726456224707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/04/send-mail-using-smtp-authentication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/2015662726456224707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/2015662726456224707'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/04/send-mail-using-smtp-authentication.html' title='Send Mail using SMTP Authentication'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-7288899692835990120</id><published>2010-01-20T04:51:00.000-08:00</published><updated>2010-01-20T05:05:06.151-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DCL Commands"/><category scheme="http://www.blogger.com/atom/ns#" term="DDL commands"/><category scheme="http://www.blogger.com/atom/ns#" term="DML commands"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="TCL Commands"/><title type='text'>Sql Comands DDL , DML ,DCL , TCL</title><content type='html'>In Sql(Structured Query Language) we have different type of commands available:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DDL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;DDL (Data Definition Language)&lt;br /&gt;&lt;br /&gt;These statements are used to define the database structure or schema. Some examples:&lt;br /&gt;&lt;br /&gt;    * CREATE - to create objects in the database&lt;br /&gt;    * ALTER - alters the structure of the database&lt;br /&gt;    * DROP - delete objects from the database&lt;br /&gt;    * TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed&lt;br /&gt;    * COMMENT - add comments to the data dictionary&lt;br /&gt;    * RENAME - rename an object&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DML&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:&lt;br /&gt;&lt;br /&gt;    * SELECT - retrieve data from the a database&lt;br /&gt;    * INSERT - insert data into a table&lt;br /&gt;    * UPDATE - updates existing data within a table&lt;br /&gt;    * DELETE - deletes all records from a table, the space for the records remain&lt;br /&gt;    * MERGE - UPSERT operation (insert or update)&lt;br /&gt;    * CALL - call a PL/SQL or Java subprogram&lt;br /&gt;    * EXPLAIN PLAN - explain access path to data&lt;br /&gt;    * LOCK TABLE - control concurrency&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DCL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Data Control Language (DCL) statements. Some examples:&lt;br /&gt;&lt;br /&gt;    * GRANT - gives user&#39;s access privileges to database&lt;br /&gt;    * REVOKE - withdraw access privileges given with the GRANT command&lt;br /&gt;&lt;br /&gt;&lt;b&gt;TCL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.&lt;br /&gt;&lt;br /&gt;    * COMMIT - save work done&lt;br /&gt;    * SAVEPOINT - identify a point in a transaction to which you can later roll back&lt;br /&gt;    * ROLLBACK - restore database to original since the last COMMIT&lt;br /&gt;    * SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/7288899692835990120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/01/sql-comands-ddl-dml-dcl-tcl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/7288899692835990120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/7288899692835990120'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/01/sql-comands-ddl-dml-dcl-tcl.html' title='Sql Comands DDL , DML ,DCL , TCL'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-7700606718316611439</id><published>2010-01-15T01:40:00.000-08:00</published><updated>2010-01-15T01:44:53.039-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Mquery"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP Mquery"/><title type='text'>PHP &amp; MQUERY</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;br /&gt;MQUERY&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;mQuery is a dynamic image generation script written in PHP with heavy bindings to ImageMagick. I insist that anyone be able to use it, which is why I&#39;ve decided to make available under an open source BSD 2-clause license.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Why&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I often found myself having to strugle with the GUIs of a certain pair of industry standard vector and scalar graphics editors to generate relatively simple images, mQuery aims to streamline the generation of images used within CSS to produce complex designs without the need for an editor.&lt;br /&gt;&lt;br /&gt;It&#39;s not a complete replacement, especially for heavy path-based designs and artwork that requires constant visual feedback, but in most cases a finely crafted URI can produce the same results with much less effort, while minimizing the grunt work that coincides with evolutionary-design to a simple query tweak.&lt;br /&gt;&lt;br /&gt;mQuery is arguably even more useful for manipulating images that must be generated dynamically, such as user-submitted photos.&lt;br /&gt;&lt;br /&gt;Known Issues&lt;br /&gt;&lt;br /&gt;mQuery is currently in pre-alpha. Not ready for production use. Some vital features are not fully implemented. Here is a list of known issues:&lt;br /&gt;&lt;br /&gt;    * stroke() on groups strokes all subshapes, rather than the collective group.&lt;br /&gt;          ImageMagick&#39;s stroking is limited to only a center-aligned variable width stroke. To make aligned, offset, inner and outer strokes I composite multiple center strokes of different width together. It&#39;s hacky and creates a lot of problems. I should be able to make this work with groups but I will have to rewrite the stroke algorithm when I get the time.&lt;br /&gt;    * 1 pixel strokes are too wide or too thin.&lt;br /&gt;          Again the stroke() implementation is hacky. I think this is a rounding error in ImageMagick. The only workaround right now is to use decimal widths like 1.1 or 0.9 to get it looking right. I am still debating weather or not to do this number fudging in the implementation.&lt;br /&gt;    * Text gets cut off&lt;br /&gt;          Apparently some fonts don&#39;t respect their bounding box and exceed the clipping region. Please let me know if you have a particular font that does this a lot, as it would help me debug the problem. I attemped to fix this by painting into a buffer 1 pixel too large on each side and correcting if any of the sides were not empty, but it was too slow, and tended to make the resulting font size incredibly small (explains why the fonts do it). I think the best solution may be to allow the overflow and then give text shapes special treatment for painting, but this is complicated and requires some architectural changes. It will also create new corner cases in certain brushes.&lt;br /&gt;    * No multiline text&lt;br /&gt;          I have to implement this on my side because ImageMagick&#39;s implementation is buggy. Different text alignments paint strokes in the wrong position.&lt;br /&gt;    * contrast() has a limited range&lt;br /&gt;          For some reason this is how ImageMagick is. I might be able to make this work with composition, or if need be an fx expression. It&#39;s on the list.&lt;br /&gt;    * rotate()&lt;br /&gt;          The ImageMagick rotate API doesn&#39;t take an origin, so I need to do the math myself and haven&#39;t gotten to it yet.&lt;br /&gt;&lt;br /&gt;For futher Details Please visit &lt;a href=&quot;http://mquery.emerydenuccio.me/&quot;&gt;Mquery&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/7700606718316611439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2010/01/php-mquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/7700606718316611439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/7700606718316611439'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2010/01/php-mquery.html' title='PHP &amp; MQUERY'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3928602519023549082</id><published>2009-12-24T01:12:00.000-08:00</published><updated>2010-01-09T20:09:25.944-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Error Handling in PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="Php Error"/><category scheme="http://www.blogger.com/atom/ns#" term="Php error handling"/><title type='text'>Error Handing in PHP</title><content type='html'>Here are some of the Error Handling Techniques &lt;br /&gt;&lt;br /&gt;It is important to configure PHP&#39;s error reporting settings depending on which phase of development the web application is currently in. Generally, the programmer wants to see all warnings and errors in the web browser during the initial phase of development, and later, once the site has launched, send error messages to a log file so that visitors do not see them.&lt;br /&gt;Error Reporting for Development&lt;br /&gt;&lt;br /&gt;During development, you want to display all errors and warnings to the browser.&lt;br /&gt;&lt;br /&gt;// Report all PHP errors&lt;br /&gt;ini_set(&#39;error_reporting&#39;, E_ALL);&lt;br /&gt; &lt;br /&gt;// Set the display_errors directive to On&lt;br /&gt;ini_set(&#39;display_errors&#39;, 1);&lt;br /&gt;&lt;br /&gt;Error Reporting for Production&lt;br /&gt;&lt;br /&gt;In production, you may want to lower the error reporting level and not display errors to the browser.&lt;br /&gt;&lt;br /&gt;// Report simple running errors&lt;br /&gt;ini_set(&#39;error_reporting&#39;, E_ALL ^ E_NOTICE);&lt;br /&gt; &lt;br /&gt;// Set the display_errors directive to Off&lt;br /&gt;ini_set(&#39;display_errors&#39;, 0);&lt;br /&gt; &lt;br /&gt;// Log errors to the web server&#39;s error log&lt;br /&gt;ini_set(&#39;log_errors&#39;, 1);&lt;br /&gt;&lt;br /&gt;Logging errors&lt;br /&gt;&lt;br /&gt;You can use the PHP function error_log() to send errors to your own log file or an e-mail address. This is particularly important since most developers on campus do not have access to the web servers logs. Used in conjunction with a custom error handler, error_log() is especially useful.&lt;br /&gt;&lt;br /&gt;// Destinations&lt;br /&gt;define(&quot;ADMIN_EMAIL&quot;, &quot;test@test.com&quot;);&lt;br /&gt;define(&quot;LOG_FILE&quot;, &quot;/error/errors.log&quot;);&lt;br /&gt; &lt;br /&gt;// Destination types&lt;br /&gt;define(&quot;DEST_EMAIL&quot;, &quot;1&quot;);&lt;br /&gt;define(&quot;DEST_LOGFILE&quot;, &quot;3&quot;);&lt;br /&gt; &lt;br /&gt;/* Examples */&lt;br /&gt; &lt;br /&gt;// Send an e-mail to the administrator&lt;br /&gt;error_log(&quot;Please fix this!&quot;, DEST_EMAIL, ADMIN_EMAIL);&lt;br /&gt; &lt;br /&gt;// Write the error to our log file&lt;br /&gt;error_log(&quot;Error&quot;, DEST_LOGFILE, LOG_FILE);&lt;br /&gt;&lt;br /&gt;Create a custom error handler&lt;br /&gt;&lt;br /&gt;It is possible to override PHP&#39;s default mechanism for handling errors. This option gives the programmer full control over what actions to take when an error is raised. Note that since this method completely replaces PHP&#39;s native functionality, it is important to pay special care when writing a custom error handler.&lt;br /&gt;&lt;br /&gt;// Destinations&lt;br /&gt;define(&quot;ADMIN_EMAIL&quot;, &quot;test@test.com&quot;);&lt;br /&gt;define(&quot;LOG_FILE&quot;, &quot;/error/errors.log&quot;);&lt;br /&gt; &lt;br /&gt;// Destination types&lt;br /&gt;define(&quot;DEST_EMAIL&quot;, &quot;1&quot;);&lt;br /&gt;define(&quot;DEST_LOGFILE&quot;, &quot;3&quot;);&lt;br /&gt; &lt;br /&gt;/**&lt;br /&gt;  * my_error_handler($errno, $errstr, $errfile, $errline)&lt;br /&gt;  *&lt;br /&gt;  * Author(s): thanosb, ddonahue&lt;br /&gt;  * Date: May 11, 2008&lt;br /&gt;  * &lt;br /&gt;  * custom error handler&lt;br /&gt;  *&lt;br /&gt;  * Parameters:&lt;br /&gt;  *  $errno:   Error level&lt;br /&gt;  *  $errstr:  Error message&lt;br /&gt;  *  $errfile: File in which the error was raised&lt;br /&gt;  *  $errline: Line at which the error occurred&lt;br /&gt;  */&lt;br /&gt; &lt;br /&gt;function my_error_handler($errno, $errstr, $errfile, $errline)&lt;br /&gt;{  &lt;br /&gt;  switch ($errno) {&lt;br /&gt;    case E_USER_ERROR:&lt;br /&gt;      // Send an e-mail to the administrator&lt;br /&gt;      error_log(&quot;Error: $errstr \n Fatal error on line $errline in file $errfile \n&quot;, DEST_EMAIL, ADMIN_EMAIL);&lt;br /&gt; &lt;br /&gt;      // Write the error to our log file&lt;br /&gt;      error_log(&quot;Error: $errstr \n Fatal error on line $errline in file $errfile \n&quot;, DEST_LOGFILE, LOG_FILE);&lt;br /&gt;      break;&lt;br /&gt; &lt;br /&gt;    case E_USER_WARNING:&lt;br /&gt;      // Write the error to our log file&lt;br /&gt;      error_log(&quot;Warning: $errstr \n in $errfile on line $errline \n&quot;, DEST_LOGFILE, LOG_FILE);&lt;br /&gt;      break;&lt;br /&gt; &lt;br /&gt;    case E_USER_NOTICE:&lt;br /&gt;      // Write the error to our log file&lt;br /&gt;      error_log(&quot;Notice: $errstr \n in $errfile on line $errline \n&quot;, DEST_LOGFILE, LOG_FILE);&lt;br /&gt;      break;&lt;br /&gt; &lt;br /&gt;    default:&lt;br /&gt;      // Write the error to our log file&lt;br /&gt;      error_log(&quot;Unknown error [#$errno]: $errstr \n in $errfile on line $errline \n&quot;, DEST_LOGFILE, LOG_FILE);&lt;br /&gt;      break;&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  // Don&#39;t execute PHP&#39;s internal error handler&lt;br /&gt;  return TRUE;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;// Use set_error_handler() to tell PHP to use our method&lt;br /&gt;$old_error_handler = set_error_handler(&quot;my_error_handler&quot;);&lt;br /&gt;&lt;br /&gt;Error Report levels&lt;br /&gt;&lt;br /&gt;These error report levels are the different types of error the user-defined error handler can be used for:&lt;br /&gt;Value  Constant  Description&lt;br /&gt;2  E_WARNING  Non-fatal run-time errors. Execution of the script is not halted&lt;br /&gt;8  E_NOTICE  Run-time notices. The script found something that might be an error, but could also happen when running a script normally&lt;br /&gt;256  E_USER_ERROR  Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()&lt;br /&gt;512  E_USER_WARNING  Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error()&lt;br /&gt;1024  E_USER_NOTICE  User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error()&lt;br /&gt;4096  E_RECOVERABLE_ERROR  Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())&lt;br /&gt;8191  E_ALL  All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0)</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3928602519023549082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/12/error-handing-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3928602519023549082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3928602519023549082'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/12/error-handing-in-php.html' title='Error Handing in PHP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-8831076244858459957</id><published>2009-12-07T05:33:00.000-08:00</published><updated>2009-12-24T01:11:30.346-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configure Curl in PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="Curl"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP Curl"/><title type='text'>Curl Setting in PHP</title><content type='html'>Below are the steps to configure the CURL option&lt;br /&gt;&lt;br /&gt;1. Locate XAMPP install directory&lt;br /&gt;2. open php/php.ini (probably C:\xampp\php\php.ini&lt;br /&gt; or C:\ program files\apachefriends\xampp\php\php.ini)&lt;br /&gt;3. do a search for the word ‘curl’ and uncomment (remove the leading semicolon) that line&lt;br /&gt;before removing ;extension=php_curl.dll&lt;br /&gt;after removing: extension=php_curl.dll&lt;br /&gt;4. save &amp; close&lt;br /&gt;5. open apache/bin/php.ini (probably C:\xampp\apache\php.ini&lt;br /&gt; or C:\ program files\apachefriends\xampp\apache\php.ini)&lt;br /&gt;6. search for curl, uncomment as before (step 3)&lt;br /&gt;7. save &amp; close&lt;br /&gt;8. Do not forget!javascript:void(0) restart apache</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/8831076244858459957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/12/curl-setting-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8831076244858459957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8831076244858459957'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/12/curl-setting-in-php.html' title='Curl Setting in PHP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-8092495788148538073</id><published>2009-10-12T03:56:00.000-07:00</published><updated>2009-10-12T05:07:04.870-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP XML"/><category scheme="http://www.blogger.com/atom/ns#" term="read and write xml files in php"/><category scheme="http://www.blogger.com/atom/ns#" term="read xml files in php"/><category scheme="http://www.blogger.com/atom/ns#" term="XML in PHP"/><title type='text'>Using SimpleXML To Read &amp; Parse XML in PHP</title><content type='html'>Using PHP we can read and execute the XML files. We can use the XML files to store the information as we do with the database.&lt;br /&gt;&lt;br /&gt;PHP provides all the methods needed for the reading, writing and executing the XML files.Before that we need to know the XML.&lt;br /&gt;&lt;br /&gt;An XML document comprises elements, attributes, processing instructions, comments, and entities&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Element:&lt;/span&gt; Text delimited by an opening and a closing tag. A tag is a name enclosed within angle brackets.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Attribute:&lt;/span&gt; A piece of qualifying information for an element. An attribute consists of a name, an equals sign, and an attribute value delimited by either single-quotes or double-quotes.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Processing instruction:&lt;/span&gt; The software that is reading an XML document is referred to as a processor. A processing instruction is additional information embedded in the document to inform the processor and possibly change its behaviour.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Comment:&lt;/span&gt; An XML comment begins with the characters: less-than, exclamation mark, minus, minus; and ends with the characters: minus, minus, greater-than. Any text within a comment is intended for a human reader and is ignored by the processor.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Entity:&lt;/span&gt; An entity is a compact form that represents other text. Entities are used to specify problematic characters and to include slabs of text defined elsewhere. An entity reference consists of an ampersand, a name, and a semi-colon.&lt;br /&gt;&lt;br /&gt;A simple XML file we will&lt;br /&gt;&lt;br /&gt;&amp;#60?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;#62&lt;br /&gt;&lt;br /&gt;&amp;#60people title=&quot;students&quot;&lt;br /&gt;&amp;#62&lt;br /&gt; &lt;br /&gt;&amp;#60name1&amp;#62 student name 1&lt;br /&gt;&amp;#60/name1&amp;#62&lt;br /&gt; &lt;br /&gt;&amp;#60name2&amp;#62 student name 2&lt;br /&gt;&amp;#60/name2&amp;#62&lt;br /&gt; &lt;br /&gt;&amp;#60name3&amp;#62 student name 3&lt;br /&gt;&amp;#60/name3&amp;#62&lt;br /&gt;&lt;br /&gt;&amp;#60/people&amp;#62&lt;br /&gt;&lt;br /&gt;Steps for reading this simple XML file is:&lt;br /&gt;&lt;br /&gt;$xml = simplexml_load_file(&#39;names.xml&#39;);&lt;br /&gt;This step will load the xml files. It Interprets an XML file into an object.Returns an object of class SimpleXMLElement with properties containing the data held within the XML document. On errors, it will return FALSE.  &lt;br /&gt;&lt;br /&gt;To read the data from the simple xml file we write code as&lt;br /&gt;$xml = simplexml_load_file(&#39;names.xml&#39;);&lt;br /&gt;print $xml-&gt;name1;&lt;br /&gt;# Seperates outputs (easier to read &amp; understand)&lt;br /&gt;print &quot;&lt;p&gt;&lt;/p&gt;&quot;;&lt;br /&gt;# You call an attribute just like you would with an array: $array[&#39;arrayname/number&#39;]&lt;br /&gt;print $xml[&#39;title&#39;];&lt;br /&gt;&lt;br /&gt;outputs : student name 1   ##     Title output is  --  name1 &lt;br /&gt;&lt;br /&gt;For an XML with multiple Items we write code as&lt;br /&gt;&lt;br /&gt;&amp;#60?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;#62&lt;br /&gt;&amp;#60student title=&quot;students&quot;&amp;#62&lt;br /&gt; &lt;br /&gt; &amp;#60item id=&quot;1&quot;&amp;#62&lt;br /&gt;  &amp;#60name&amp;#62&lt;br /&gt;   &amp;#60first&amp;#62ram&amp;#60/first&amp;#62&lt;br /&gt;   &amp;#60last&amp;#62test&amp;#60/last&amp;#62&lt;br /&gt;  &amp;#60/name&gt;&lt;br /&gt;  &amp;#60age&amp;#6242&amp;#60/age&amp;#62&lt;br /&gt; &amp;#60/item&gt;&lt;br /&gt; &lt;br /&gt; &amp;#60item id=&quot;2&quot;&amp;#62&lt;br /&gt;  &amp;#60name&amp;#62&lt;br /&gt;   &amp;#60first&amp;#62prince&amp;#60/first&amp;#62&lt;br /&gt;   &amp;#60last&amp;#62kumar&amp;#60/last&amp;#62&lt;br /&gt;  &amp;#60/name&gt;&lt;br /&gt;  &amp;#60age&amp;#6211&lt;/age&amp;#62&lt;br /&gt; &amp;#60/item&gt;&lt;br /&gt; &lt;br /&gt; &amp;#60item id=&quot;3&quot;&amp;#62&lt;br /&gt;  &amp;#60name&amp;#62&lt;br /&gt;   &amp;#60first&amp;#62raju&amp;#60/first&amp;#62&lt;br /&gt;   &amp;#60last&amp;#62ramesh&amp;#60/last&amp;#62&lt;br /&gt;  &amp;#60/name&amp;#62&lt;br /&gt;  &amp;#60age&amp;#6221&amp;#60/age&amp;#62&lt;br /&gt; &amp;#60/item&amp;#62&lt;br /&gt; &lt;br /&gt;&amp;#60/student&amp;#62&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Load the test.xml file&lt;br /&gt;$xml = simplexml_load_file(&#39;test.xml&#39;);&lt;br /&gt;# Start a foreach loop. Translation: for every &lt;item&gt; in the xml file put it into the var $item. &lt;br /&gt;# now the $item can display all the elements inside the &lt;item&gt;&lt;br /&gt;foreach($xml-&gt;item as $item) {&lt;br /&gt; # These three print&#39;s will display the attribute of the &lt;item&gt; (ID), display the first and last name joined together&lt;br /&gt; # and then the age. The &lt;/br&gt; and &lt;p&gt;&lt;/p&gt; are for spacing out the results&lt;br /&gt; print &quot;ID: &quot; . $item[&#39;id&#39;] . &quot;&lt;br/&gt;&quot;;&lt;br /&gt; print &quot;Name: &quot; . $item-&gt;name-&gt;first . &quot; &quot; . $item-&gt;name-&gt;last . &quot;&lt;/br&gt;&quot;;&lt;br /&gt; print &quot;Age: &quot; . $item-&gt;age . &quot;&lt;p&gt;&lt;/p&gt;&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;If we want to provide the conditions when executing the XML files then the code will be&lt;br /&gt;&lt;br /&gt;# Load the test.xml file&lt;br /&gt;$xml = simplexml_load_file(&#39;test.xml&#39;);&lt;br /&gt;# Start a foreach loop. Translation: for every &lt;item&gt; in the xml file put it into the var $item. &lt;br /&gt;# now the $item can display all the elements inside the &lt;item&gt;&lt;br /&gt;foreach($xml-&gt;item as $item) {&lt;br /&gt; $age = $item-&gt;age;&lt;br /&gt; if ($age &gt;= 10) {&lt;br /&gt;  if ($age &lt;= 21) {&lt;br /&gt;   # These three print&#39;s will display the attribute of the &lt;item&gt; (ID), display the first and last name joined together&lt;br /&gt;   # and then the age. The &lt;/br&gt; and &lt;p&gt;&lt;/p&gt; are for spacing out the results&lt;br /&gt;   print &quot;ID: &quot; . $item[&#39;id&#39;] . &quot;&lt;br/&gt;&quot;;&lt;br /&gt;   print &quot;Name: &quot; . $item-&gt;name-&gt;first . &quot; &quot; . $item-&gt;name-&gt;last . &quot;&lt;/br&gt;&quot;;&lt;br /&gt;   print &quot;Age: &quot; . $item-&gt;age . &quot;&lt;p&gt;&lt;/p&gt;&quot;;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/8092495788148538073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/10/using-simplexml-to-read-parse-xml-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8092495788148538073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/8092495788148538073'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/10/using-simplexml-to-read-parse-xml-in.html' title='Using SimpleXML To Read &amp; Parse XML in PHP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-4599146808615246918</id><published>2009-10-05T05:09:00.000-07:00</published><updated>2009-10-05T05:18:45.153-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="download script in PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP download script"/><category scheme="http://www.blogger.com/atom/ns#" term="php downloads"/><title type='text'>Download functionality in PHP</title><content type='html'>The common usable component in any of the website is to provide the user with the download option. when providing the download option we cannot restrict the user with one the specific type like doc or ppt or pdf... We need to provide the most convenient way to the user so that the user can easily download the files.&lt;br /&gt;&lt;br /&gt;Below is such script where we can have the multiple options provided.&lt;br /&gt;&lt;br /&gt;$filename is the file name which we want to download&lt;br /&gt;&lt;br /&gt;$file_extension = strtolower(substr(strrchr($filename,&quot;.&quot;),1));&lt;br /&gt;&lt;br /&gt;$folderpath=&quot;foldername/&quot;.$filename;&lt;br /&gt;&lt;br /&gt;if( $filename == &quot;&quot; ) &lt;br /&gt;{&lt;br /&gt;  echo &quot;No File Found&quot;;&lt;br /&gt;  exit;&lt;br /&gt;} elseif ( ! file_exists( $folderpath ) ) &lt;br /&gt;{&lt;br /&gt;  echo &quot;File Not Found&quot;;&lt;br /&gt;  exit;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;// If file exits then it is ready for download.&lt;br /&gt;&lt;br /&gt;switch( $file_extension )&lt;br /&gt;{&lt;br /&gt;  case &quot;pdf&quot;: $ctype=&quot;application/pdf&quot;; break;&lt;br /&gt;  case &quot;exe&quot;: $ctype=&quot;application/octet-stream&quot;; break;&lt;br /&gt;  case &quot;zip&quot;: $ctype=&quot;application/zip&quot;; break;&lt;br /&gt;  case &quot;doc&quot;: $ctype=&quot;application/msword&quot;; break;&lt;br /&gt;  case &quot;xls&quot;: $ctype=&quot;application/vnd.ms-excel&quot;; break;&lt;br /&gt;  case &quot;ppt&quot;: $ctype=&quot;application/vnd.ms-powerpoint&quot;; break;&lt;br /&gt;  case &quot;gif&quot;: $ctype=&quot;image/gif&quot;; break;&lt;br /&gt;  case &quot;png&quot;: $ctype=&quot;image/png&quot;; break;&lt;br /&gt;  case &quot;jpeg&quot;:&lt;br /&gt;  case &quot;jpg&quot;: $ctype=&quot;image/jpg&quot;; break;&lt;br /&gt;  default: $ctype=&quot;application/force-download&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Decides the header... which type if download you are providing to the user.&lt;br /&gt;&lt;br /&gt;header(&quot;Pragma: public&quot;); // required&lt;br /&gt;header(&quot;Expires: 0&quot;);&lt;br /&gt;header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);&lt;br /&gt;header(&quot;Cache-Control: private&quot;,false); // required for certain browsers &lt;br /&gt;header(&quot;Content-Type: $ctype&quot;);&lt;br /&gt;// change, added quotes to allow spaces in filenames, by Rajkumar Singh&lt;br /&gt;header(&quot;Content-Disposition: attachment; filename=\&quot;&quot;.basename($filename).&quot;\&quot;;&quot; );&lt;br /&gt;header(&quot;Content-Transfer-Encoding: binary&quot;);&lt;br /&gt;header(&quot;Content-Length: &quot;.filesize($filename));&lt;br /&gt;readfile(&quot;$folderpath&quot;);&lt;br /&gt;exit();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy the above code if you want to download any type of the file in the given options</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/4599146808615246918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/10/download-functionality-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/4599146808615246918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/4599146808615246918'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/10/download-functionality-in-php.html' title='Download functionality in PHP'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-1520564927056914019</id><published>2009-09-25T02:39:00.000-07:00</published><updated>2009-09-25T04:24:17.347-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arrays php"/><category scheme="http://www.blogger.com/atom/ns#" term="associative array examples"/><category scheme="http://www.blogger.com/atom/ns#" term="index array"/><category scheme="http://www.blogger.com/atom/ns#" term="php associative arrays"/><title type='text'>Php Arrays</title><content type='html'>An array is a data structure that stores one or more values in a single value.An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible&lt;br /&gt;&lt;br /&gt;Each element in the array has its own index so that it can be easily accessed.&lt;br /&gt;&lt;br /&gt;In PHP, there are three kind of arrays:&lt;br /&gt;&lt;br /&gt;    * Numeric array - An array with a numeric index&lt;br /&gt;    * Associative array - An array where each ID key is associated with a value&lt;br /&gt;    * Multidimensional array - An array containing one or more arrays&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Numeric array&lt;/span&gt;&lt;br /&gt;A numeric array stores each array element with a numeric index.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;General:&lt;/span&gt;&lt;br /&gt;$example=array(&quot;abc&quot;,123,&quot;xyz&quot;,&quot;test&quot;); &lt;br /&gt;&lt;br /&gt;In the following example we assign the index manually:&lt;br /&gt;$example[0]=&quot;abc&quot;;&lt;br /&gt;$example[1]=123;&lt;br /&gt;$example[2]=&quot;xyz&quot;;&lt;br /&gt;$example[3]=&quot;test&quot;; &lt;br /&gt;&lt;br /&gt;we call the Indexed array as&lt;br /&gt;echo $example[0] . &quot; and &quot; . $example[1] ;&lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;foreach ($example as $i =&gt; $value) {&lt;br /&gt;    echo $value;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Associative Array&lt;/span&gt;&lt;br /&gt;An associative array, each ID key is associated with a value.&lt;br /&gt;&lt;br /&gt;Initializing an Associative Array&lt;br /&gt;&lt;br /&gt;The following code creates an associative array with product names as keys and prices as values.&lt;br /&gt;&lt;br /&gt;$prices = array( &#39;test1&#39;=&gt;100, &lt;br /&gt;&#39;test2&#39;=&gt;10, &#39;test3&#39;=&gt;4,&#39;test4&#39;=&gt;5 );&lt;br /&gt;&lt;br /&gt;There are different ways we can initialize the associative array&lt;br /&gt;&lt;br /&gt;$prices = array( &#39;test1&#39;=&gt;100 );&lt;br /&gt;$prices[&#39;test2&#39;] = 10;&lt;br /&gt;$prices[&#39;test3&#39;] = 4; &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Using Loops with Associative Arrays&lt;/span&gt;&lt;br /&gt;Because the indices in this associative array are not numbers, we cannot use a simple counter in a for loop to work with the array. We can use the foreach loop or the list() and each() constructs.&lt;br /&gt;&lt;br /&gt;The foreach loop has a slightly different structure when using associative arrays. We can use it exactly as we did in the previous example, or we can incorporate the keys as well:&lt;br /&gt;&lt;br /&gt;foreach ($prices as $key =&gt; $value)&lt;br /&gt; echo $key.&#39;=&gt;&#39;.$value.&#39;&lt;br /&gt;&#39;;&lt;br /&gt;&lt;br /&gt;The following code lists the contents of our $prices array using the each() construct:&lt;br /&gt;&lt;br /&gt;while( $element = each( $prices ) )&lt;br /&gt;{&lt;br /&gt; echo $element[ &#39;key&#39; ];&lt;br /&gt; echo &#39; - &#39;;&lt;br /&gt; echo $element[ &#39;value&#39; ];&lt;br /&gt; echo &#39;&lt;br /&gt;&#39;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Some of the Usefull methods are:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;$b = array_values($a);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will assign the the array a to the b and b will be considered as a array.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;unset($arr[5]);&lt;/span&gt;&lt;br /&gt;This will removes the particular element in the array</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/1520564927056914019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/09/php-arrays.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1520564927056914019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/1520564927056914019'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/09/php-arrays.html' title='Php Arrays'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-3192793091414183549</id><published>2009-09-11T04:55:00.000-07:00</published><updated>2009-09-11T05:14:31.640-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php security issues"/><category scheme="http://www.blogger.com/atom/ns#" term="php uploading security issue"/><category scheme="http://www.blogger.com/atom/ns#" term="Uploading Vulnerabilities"/><title type='text'>Why File Upload Forms are a major security threat part2</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 4: Double extensions (part 1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This case’s security measures, as a concept are very similar to that one used in case 3. Though instead of simply checking the extension string present in the filename, the developer is extracting the file extension by looking for the ‘.’ character in the filename, and extracting the string after the dot character.&lt;br /&gt;&lt;br /&gt;The method used to bypass this approach is a bit more complicated, but still realistic. First, let’s have a look at how Apache handles files with multiple extensions. A quote from the Apache manual states:&lt;br /&gt;&lt;br /&gt;“Files can have more than one extension, and the order of the extensions is normally irrelevant. For example, if the file welcome.html.fr maps onto content type text/html and language French then the file welcome.fr.html will map onto exactly the same information. If more than one extension is given which maps onto the same type of meta-information, then the one to the right will be used, except for languages and content encodings. For example, if .gif maps to the MIME-type image/gif and .html maps to the MIME-type text/html, then the file welcome.gif.html will be associated with the MIME-type text/html.”&lt;br /&gt;&lt;br /&gt;Therefore a file named ‘filename.php.123’, will be interpreted as a PHP file and will be executed. This only works if the last extension (in our case .123), is not specified in the list of mime-types known to the web server. Web developers, usually are not aware of such ‘feature’ in Apache, which can be very dangerous for a number of reasons. Knowing this, an attacker can upload a file named shell.php.123 and bypass the file upload form protection. The script will compute the last extension (.123), and concludes that this extension is not in the list of dangerous extension. Having said that, it is impossible to predict all the possible random extensions a malicious user will use to be able to upload a file on your web server.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 5: Double extensions (part 2)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A better approach to securing file upload forms is the white list approach. In this case, the developer defines a list of known/accepted extensions and does not allow extensions that are not specified in the list.&lt;br /&gt;&lt;br /&gt;However, in some cases this approach will not work as expected. When Apache is configured to execute PHP code, there are 2 ways one can specify this: to use the AddHandler directive, or to use the AddType directive. If AddHandler directive is used, all filenames containing the ‘.php’ extension (e.g. ‘.php’, ‘.php.jpg’) will be executed as a PHP script. Therefore, if your Apache configuration file contains the following line, you may be vulnerable:&lt;br /&gt;&lt;br /&gt;AddHandler php5-script .php&lt;br /&gt;&lt;br /&gt;An attacker can upload a file named ‘filename.php.jpg’ and bypass the protection, and will be able to execute the code.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 6: Checking the image header&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When images only are allowed to be uploaded, developers usually validate the image header by using the PHP function called getimagesize. When called, this function will return the size of an image. If the image validation is invalid, which means that the header is incorrect, the function will return a false. Therefore a developer typically checks if the function returns a true or false, and validate the uploaded file using this information. So, if a malicious user tries to upload a simple PHP shell embedded in a jpg file, the function will return false and he won’t be allowed to upload the file. However, even this approach can be easily bypassed. If a picture is opened in an image editor, like Gimp, one can edit the image comment, where PHP code is inserted, as shown below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimXKXybqxBn20fFf3b5SWuTvNiHbEYycCR10C-NUZqYkp-ooOcd7KLNXXaix6WOjEAf5JNw_jnYzwSaJyI4w24uQ67cQJ1enXucjhnMQm8w_138_rHUImN8WqaMmKQFBIMSD3g4t5bWJ4/s1600-h/case6.png&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 319px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimXKXybqxBn20fFf3b5SWuTvNiHbEYycCR10C-NUZqYkp-ooOcd7KLNXXaix6WOjEAf5JNw_jnYzwSaJyI4w24uQ67cQJ1enXucjhnMQm8w_138_rHUImN8WqaMmKQFBIMSD3g4t5bWJ4/s320/case6.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5380181346925980834&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The image will still have a valid header; therefore it bypasses the getimagesize PHP check. As seen in the screen shot below, the PHP code inserted in the image comments still gets executed when the image is requested from a normal web browser:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_CMIxjtx5BIwJzSCXMLQiXsdJ50sksHo9eThIyRiPAGvVGmCZtWVLVYheM-F78BY6ASxJdrldMvl7kwcLZJncwCzJQohpIxYb1cF3eKEuEPqqYot57S0VJxcVb9JhADomuFKSLNCzpLg/s1600-h/case6_2.png&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 167px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_CMIxjtx5BIwJzSCXMLQiXsdJ50sksHo9eThIyRiPAGvVGmCZtWVLVYheM-F78BY6ASxJdrldMvl7kwcLZJncwCzJQohpIxYb1cF3eKEuEPqqYot57S0VJxcVb9JhADomuFKSLNCzpLg/s320/case6_2.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5380181597681605634&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 7: Protecting the upload folder with .htaccess&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another popular way of securing file upload forms, is to protect the folder where the files are uploaded using .htaccess file. The idea is to restrict execution of script files in this folder. A .htaccess file typically contains the below code when used in this kind of scenario:&lt;br /&gt;&lt;br /&gt;AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi&lt;br /&gt;Options –ExecCGI&lt;br /&gt;&lt;br /&gt;The above is another type of blacklist approach, which in itself is not very secure. In the PHP manual, in the move_uploaded_file section, there is a warning which states ‘If the destination file already exists, it will be overwritten.’&lt;br /&gt;&lt;br /&gt;Because uploaded files can and will overwrite the existing ones, a malicious user can easily replace the .htaccess file with his own modified version. This will allows him to execute specific scripts which can help him compromise the server.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 8: Client-side validation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another common type of security used in file upload forms, is client-side validation of files to be uploaded. Typically, such approach is more common in ASP.NET applications, since ASP.NET offers easy to use validation controls.&lt;br /&gt;                    A malicious user can easily bypass this type of validation. It is possible to write a short client side script that will do the validation instead of the script provided by the web application. Without using a web browser, the attacker can use an application that allows sending of HTTP POST requests to be able to upload the file.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Suggested Solution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Below is a list of best practices that should be enforced when file uploads are allowed on websites and web applications. These practices will help you securing file upload forms used in web applications;&lt;br /&gt;&lt;br /&gt;    *&lt;br /&gt;      Define a .htaccess file that will only allow access to files with allowed extensions.&lt;br /&gt;    *&lt;br /&gt;      Do not place the .htaccess file in the same directory where the uploaded files will be stored. It should be placed in the parent directory.&lt;br /&gt;    *&lt;br /&gt;      A typical .htaccess which allows only gif, jpg, jpeg and png files should include the following (adapt it for your own need). This will also prevent double extension attacks.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;deny from all&lt;br /&gt;&lt;br /&gt;&amp;#60Files ~ &quot;^\w+\.(gif|jpe?g|png)$&quot;&amp;#62&lt;br /&gt;&lt;br /&gt;order deny,allow&lt;br /&gt;&lt;br /&gt;allow from all&lt;br /&gt;&lt;br /&gt;&amp;#60/Files&amp;#62&lt;br /&gt;&lt;br /&gt;    *&lt;br /&gt;      If possible, upload the files in a directory outside the server root.&lt;br /&gt;    *&lt;br /&gt;      Prevent overwriting of existing files (to prevent the .htaccess overwrite attack).&lt;br /&gt;    *&lt;br /&gt;      Create a list of accepted mime-types (map extensions from these mime types).&lt;br /&gt;    *&lt;br /&gt;      Generate a random file name and add the previously generated extension.&lt;br /&gt;    *&lt;br /&gt;      Don’t rely on client-side validation only, since it is not enough. Ideally one should have both server-side and client-side validation implemented.</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/3192793091414183549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/09/why-file-upload-forms-are-major_11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3192793091414183549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/3192793091414183549'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/09/why-file-upload-forms-are-major_11.html' title='Why File Upload Forms are a major security threat part2'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimXKXybqxBn20fFf3b5SWuTvNiHbEYycCR10C-NUZqYkp-ooOcd7KLNXXaix6WOjEAf5JNw_jnYzwSaJyI4w24uQ67cQJ1enXucjhnMQm8w_138_rHUImN8WqaMmKQFBIMSD3g4t5bWJ4/s72-c/case6.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-829720138136326836</id><published>2009-09-10T04:24:00.000-07:00</published><updated>2009-09-10T04:38:47.125-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php security issues"/><category scheme="http://www.blogger.com/atom/ns#" term="php uploading security issue"/><category scheme="http://www.blogger.com/atom/ns#" term="Uploading Vulnerabilities"/><title type='text'>Why File Upload Forms are a major security threat</title><content type='html'>To allow an end user to upload files to your website, is like opening another door for a malicious user to compromise your server.  Even though, in today’s modern internet web applications, it is a common requirement, because it helps in increasing your business efficiency.  File uploads are allowed in social network web applications, such as Facebook and Twitter.  They are also allowed in blogs, forums, e-banking sites, YouTube and also in corporate support portals, to give the opportunity to the end user to efficiently share files with corporate employees. &lt;br /&gt;&lt;br /&gt; Users are allowed to upload images, videos, avatars and many other types of files.&lt;br /&gt;The more functionality provided to the end user, the greater is the risk of having a vulnerable web application and the chance that such functionality will be abused from malicious users, to gain access to a specific website, or to compromise a server is very high.&lt;br /&gt;&lt;br /&gt;While testing several web applications, we noticed that a good number of well known web applications, do not have secure file upload forms.  Some of these vulnerabilities were easily exploited, and we could gain access to the file system of the server hosting these web applications.  In this whitepaper, we present you with 8 common ways we encountered of securing file upload forms.  We also show how a malicious user, can easily bypass such security measures.&lt;br /&gt;&lt;br /&gt;Below are the sample cases:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 1: Simple file upload form with no validation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#60form enctype=&quot;multipart/form-data&quot; action=&quot;uploader.php&quot; method=&quot;POST&quot;&amp;#62&lt;br /&gt;&amp;#60input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;100000&quot; /&amp;#62&lt;br /&gt;Choose a file to upload: &amp;#60input name=&quot;uploadedfile&quot; type=&quot;file&quot; /&amp;#62 &lt;br /&gt;&amp;#60input type=&quot;submit&quot; value=&quot;Upload File&quot; /&amp;#62&lt;br /&gt;&amp;#60/form&amp;#62&lt;br /&gt;&lt;br /&gt;we use php code for saving the uploaded file is&lt;br /&gt;    * $_FILES[‘uploadedfile’][‘name’]: The original name of the file on the client machine&lt;br /&gt;    * $_FILES[‘uploadedfile’][‘type’]: The mime type of the file&lt;br /&gt;    * $_FILES[‘uploadedfile’][‘size’]: The size of the file in bytes&lt;br /&gt;    * $_FILES[‘uploadedfile’][‘tmp_name’]: The temporary filename in which the uploaded file was stored on the server.&lt;br /&gt;&lt;br /&gt;In this simple example, there are no restrictions about the type of files allowed for upload and therefore an attacker can upload a PHP or .NET file with malicious code that can lead to a server compromise.&lt;br /&gt;&lt;br /&gt;This might look like a naïve example, but we did encounter such code in a number of web applications.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 2: Mime Type validation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another common mistake web developers do when securing file upload forms, is to only check for mime type returned from PHP. When a file is uploaded to the server, PHP will set the variable $_FILES[‘uploadedfile’][‘type’] to the mime-type provided by the web browser the client is using. However, a file upload form validation cannot depend on this value only. A malicious user can easily upload files using a script or some other automated application that allows sending of HTTP POST requests, which allow him to send a fake mime-type.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Case 3: Block dangerous extensions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In other cases, we encountered file upload forms using a blacklist approach, as a security measure. A list of dangerous extensions is compiled from the developer, and the access is denied if the extension of the file being uploaded is on the compiled list.&lt;br /&gt;&lt;br /&gt;One main disadvantage of using black listing of file extensions, is that it is almost impossible to compile a list that includes all possible extensions that an attacker can use. E.g. If the code is running in a hosted environment, usually such environments allow a large number of scripting languages, such as Perl, Python, Ruby etc, and the list can be endless.&lt;br /&gt;&lt;br /&gt;A malicious user can easily bypass such check by uploading a file called “.htaccess”, which contains a line of code similar to the below:&lt;br /&gt;&lt;br /&gt;AddType application/x-httpd-php .jpg&lt;br /&gt;&lt;br /&gt;The above line of code, instructs Apache web server to execute jpg images as if they were PHP scripts. The attacker can now upload a file with a jpg extension, which contains PHP code. As seen in the screen shot below, requesting a jpg file which includes the PHP command phpinfo() from a web browser, it is still executed from the web server:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ_e3rzhubtyxamf3VxkUnyOHg15Eic4APJrikD9U2mBLV2OV3YYvfD5-AaBu-Fj3ntn1l8WLLaoOrOksJQogHcLnqtU5ldFSGNRsvK2JAWQLd1b3-EWwAjTznlzHZh2F6XmQ-z_9lzfc/s1600-h/case3.png&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 173px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ_e3rzhubtyxamf3VxkUnyOHg15Eic4APJrikD9U2mBLV2OV3YYvfD5-AaBu-Fj3ntn1l8WLLaoOrOksJQogHcLnqtU5ldFSGNRsvK2JAWQLd1b3-EWwAjTznlzHZh2F6XmQ-z_9lzfc/s320/case3.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5379801019258072626&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h6&gt;Source taken from http://www.acunetix.com &lt;/h6&gt;</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/829720138136326836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/09/why-file-upload-forms-are-major.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/829720138136326836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/829720138136326836'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/09/why-file-upload-forms-are-major.html' title='Why File Upload Forms are a major security threat'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ_e3rzhubtyxamf3VxkUnyOHg15Eic4APJrikD9U2mBLV2OV3YYvfD5-AaBu-Fj3ntn1l8WLLaoOrOksJQogHcLnqtU5ldFSGNRsvK2JAWQLd1b3-EWwAjTznlzHZh2F6XmQ-z_9lzfc/s72-c/case3.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5536882164120371052.post-5889784602203230820</id><published>2009-09-08T01:41:00.001-07:00</published><updated>2009-09-10T04:21:25.697-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="improved features in php 5.3"/><category scheme="http://www.blogger.com/atom/ns#" term="Php 5.3 new features"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP and object oriented concepts"/><title type='text'>New features in PHP 5.3 &amp; Improvements in Object oriented concepts</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;Late static binding&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the more annoying things about PHP before V5.3 is how static methods and members are dealt with. Up until now, static references, such as those made with self or __CLASS__, are resolved in the class scope in which the function was defined. The problem is that the reference would be incorrect if the class was extended and the call was made from the new child class. Late static binding has been added in PHP V5.3 to alleviate this problem. To better illustrate, let&#39;s create a class with a static method below.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt; Class Foo with static method test()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;class Foo &lt;br /&gt;{ &lt;br /&gt;    protected static $name = &#39;Foo&#39;; &lt;br /&gt;&lt;br /&gt;    public static function test() &lt;br /&gt;    { &lt;br /&gt;        return self::$name; &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let&#39;s extend this class. We&#39;ll redefine the member $name in this child class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt; Child class Bar that extends parent class Foo&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;    class Bar extends Foo&lt;br /&gt;    {&lt;br /&gt;       protected static $name = &#39;Bar&#39;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We make the static call below example.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt; Static method call test()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;echo Bar::test(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What is output from that call would be the string Foo. This is because the self::$name reference made in the test() method is done with the Foo class. The binding occurs this way because this is where the function is defined.&lt;br /&gt;&lt;br /&gt;PHP V5.3 has added the keyword static to allow you to make a reference against the current class. So you will change the Foo class above to use this keyword in next example, and we&#39;ll see that Bar will instead be output.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Using the static keyword&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;class Foo &lt;br /&gt;{ &lt;br /&gt;    protected static $name = &#39;Foo&#39;; &lt;br /&gt;&lt;br /&gt;    public static function test() &lt;br /&gt;    { &lt;br /&gt;        return static::$name; &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;class Bar &lt;br /&gt;{ &lt;br /&gt;    protected static $name = &#39;Bar&#39;; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;echo Bar::test(); // outputs &#39;Bar&#39;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One thing to note about the static keyword is that it doesn&#39;t work the same as how this works in the nonstatic context. This means that the normal inheritance rules do not apply to static calls. The static keyword will simply try to resolve the call in the current class instead of the class the function was defined in. This is an important thing to note.&lt;br /&gt;&lt;br /&gt;Now that we have seen some enhancements with static methods and members, let&#39;s take a look at some new classes added to a very useful part of PHP V5: the Standard PHP Library.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;br /&gt;Standard PHP Library&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Standard PHP Library (SPL) is a collection of interfaces and classes added in PHP V5 designed to solve standard problems. These problems include having an object be iterateable, letting an object behave as if it was an array, or implementing a linked list. The advantage of using these classes and methods is that they are native to PHP, which means they are faster than if they were implemented in PHP itself. They also, in many instances, allow many of the internal functions of PHP to use these objects directly, such as how the Iterator interface allows you to use the foreach construct to iterate over the object.&lt;br /&gt;&lt;br /&gt;PHP V5.3 adds a few more classes to SPL. One we referenced earlier is the implementation of a doubly linked list in the SPL class SplDoublyLinkedList. It is used by two other new SPL classes: SplStack, which implements a stack, and SplQueue, which implements a queue.&lt;br /&gt;&lt;br /&gt;Let&#39;s take a look at how you can use the SplStack class to implement a stack.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Using SplStack&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$stack = new SplStack(); &lt;br /&gt;&lt;br /&gt;// push a few new items on the stack &lt;br /&gt;$stack-&gt;push(&#39;a&#39;); &lt;br /&gt;$stack-&gt;push(&#39;b&#39;); &lt;br /&gt;$stack-&gt;push(&#39;c&#39;); &lt;br /&gt;&lt;br /&gt;// see how many items are on the stack &lt;br /&gt;echo count($stack); // returns 3 &lt;br /&gt;&lt;br /&gt;// iterate over the items in the stack &lt;br /&gt;foreach ( $stack as $item ) &lt;br /&gt;    echo &quot;[$item],&quot;;   &lt;br /&gt;// the above outputs: [c],[b],[a]&lt;br /&gt;&lt;br /&gt;// pop an item off the stack &lt;br /&gt;echo $stack-&gt;pop(); // returns &#39;c&#39; &lt;br /&gt;&lt;br /&gt;// now see how many items are on the stack &lt;br /&gt;echo count($stack); // returns 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The SqlQueue works in a similar fashion, but it works like a queue would (first item in, first item out; instead of last item in, first item out, like the stack). In addition, a heap implementation exists (SplHeap), as well as specific queue and heap implementations for certain situations (SplMinHeap, SplMaxHeap, and SplPriorityQueue).&lt;br /&gt;&lt;br /&gt;Another useful addition is the SplFixedArray class, which, as the name implies, is a fixed-size array implementation. It is, however, rather fast — actually so fast that it&#39;s been benchmarked to be 10-30 percent faster than the built-in array implementation in PHP. This speedup is due to the fact that the array is a fixed size, not a variable-sized one like the default PHP one is, and that non-numeric indexes are not allowed. Listing 10 shows how it&#39;s used.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt; SplFixedArray&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$array = new SplFixedArray(3); &lt;br /&gt;$array[0] = &#39;dog&#39;; &lt;br /&gt;$array[1] = &#39;cat&#39;; &lt;br /&gt;$array[2] = &#39;bird&#39;; &lt;br /&gt;$a-&gt;setSize(4); // increase the size on the fly &lt;br /&gt;$array[3] = &#39;mouse&#39;; &lt;br /&gt;foreach ( $array as $value ) &lt;br /&gt;    echo &quot;[$value],&quot;;&lt;br /&gt;&lt;br /&gt;Output: &lt;br /&gt;[dog],[cat],[bird],[mouse] &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In addition, a few new iterator classes have been added: FilesystemIterator and GlobIterator. These work the same as the other iterator classes in PHP, but they are specially designed for certain instances.&lt;br /&gt;&lt;br /&gt;One other change with SPL is that it is always enabled now in PHP V5.3. In previous versions of PHP V5, you could disable SPL at compile time, but as of PHP V5.3, this is no longer possible.&lt;br /&gt;&lt;br /&gt;The new additions to SPL add some useful functionality to PHP that is easy to use, as well as implementations of data structures, such as doubly linked lists, stacks, heaps, and queues. These classes can be used to replace user space implementations you may have, which will gain increased speed and better integration with various PHP functions and constructs.&lt;br /&gt;&lt;br /&gt;Now that we have seen some new additions to SPL, let&#39;s see how OOP in PHP V5.3 has gained an important performance and memory usage improvement with the addition of circular garbage collection.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Circular garbage collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One problem PHP developers run into from a performance standpoint is garbage collection. PHP has a pretty simple garbage collector, which basically will garbage collect an object when it no longer is in scope. The way it does this internally is by using a reference counter, so that when the counter reaches zero (meaning no more references to this object are available), the object will be garbage collected and expunged from memory.&lt;br /&gt;&lt;br /&gt;This works fairly well, but can become a problem in situations where one object references another in a parent-child relationship. In this situation, the reference counter for those object are not collected, so the memory used by these objects stays in unreferenced memory and is not unallocated until the end of the request. Let&#39;s take a look at an example of when this problem occurs.&lt;br /&gt;&lt;br /&gt; Parent-child class relationship not properly garbage collected in PHP V5.2 and earlier&lt;br /&gt;&lt;br /&gt;class Parent &lt;br /&gt;{ &lt;br /&gt;    public function __construct() &lt;br /&gt;    { &lt;br /&gt;        $this-&gt;child = new Child($this); &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;class Child &lt;br /&gt;{ &lt;br /&gt;    public function __construct( &lt;br /&gt;        Parent $parent &lt;br /&gt;        ) &lt;br /&gt;    { &lt;br /&gt;        $this-&gt;parent = $parent; &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this instance, every time you create an instance of the Parent class and then subsequently the instance goes out of scope, the memory is never released, so the script will grow and grow in memory usage. There are a few user space solutions to this problem, such as creating a destructor for the parent class that will release the child object directly. This destructor would have to be called specifically before unsetting the parent class reference. While doing all of this works, it complicates your code quite a bit.&lt;br /&gt;&lt;br /&gt;In PHP V5.3, the garbage collector will detect these circular references and is able to free up the memory used by them, so the PHP memory usage will remain flat as the script is executed. As each reference to the Parent class is removed, the Child class reference inside the Parent class will also be garbage collected.&lt;br /&gt;&lt;br /&gt;&lt;h6&gt; This article is taken from https://www.ibm.com/ &lt;/h6&gt;</content><link rel='replies' type='application/atom+xml' href='http://findmysolution.blogspot.com/feeds/5889784602203230820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://findmysolution.blogspot.com/2009/09/new-features-in-php-53_08.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/5889784602203230820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5536882164120371052/posts/default/5889784602203230820'/><link rel='alternate' type='text/html' href='http://findmysolution.blogspot.com/2009/09/new-features-in-php-53_08.html' title='New features in PHP 5.3 &amp; Improvements in Object oriented concepts'/><author><name>ravikumar</name><uri>http://www.blogger.com/profile/04440859078979491225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>