tag:blogger.com,1999:blog-84885398322793322372024-03-17T22:36:37.663-07:00PHP, Ajax, Javascript , HTML, MysqlYou can get PHP tutorials, ajax codings, free html,javascript tips & tricks, making webpages faster with minimizing mysql query, create your site through xml, helpful tips & tricks for creating websites, control the site through xml, get ajax codings using get & post method in ajax method, convert videos to any format using FFMPEG PHP, create multilanguage website, create content in chinese, send mail in chinese language, Iframe virus removal, free sms using php webservice,Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-8488539832279332237.post-17093840574738623362011-12-19T10:19:00.000-08:002011-12-19T10:19:53.493-08:00Documentation on handling larger database<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<br />
<div class="MsoNormal"><span lang="EN-US" style="font-size: 13pt; line-height: 115%;">Hi Techies,</span></div><div class="MsoNormal"><span lang="EN-US" style="font-size: 13pt; line-height: 115%;"> I created a documentation for handling larger database. Make use of it & share any other tips which I missed out.</span></div><div class="MsoNormal"><span lang="EN-US" style="font-size: 13pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b style="font-size: 13pt; line-height: 115%;">Database server: </b><span style="font-size: 13pt; line-height: 115%;">Buy a server that can handle larger data's</span></div><div class="MsoNormal"><span lang="EN-US" style="font-size: 13pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Database engine:</span></b><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"> We can use either MyISAM or INNODB. <o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><b><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Stick to your basics right:<o:p></o:p></span></b></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">1)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Create table with proper indexing & primary key<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">2)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Don't use COUNT * on Innodb tables for every search, do it a few times and/or summary tables, or if you need it for the total # of rows, use SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">3)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Avoid using IN(...) when selecting on indexed fields, It will kill the performance of SELECT query.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">4)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use index to filter rows while searching<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">5)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Don’t use * in select when you’re not going to retrieve 60% of the columns. Make it specific like (userid, username, doj, lastlogin etc)<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">6)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Don't Index Everything<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">7)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">A NULL data type can take more room to store than NOT NULL<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">8)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use mysql_pconnect instead of mysql_connect in PHP<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">9)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Don’t use parenthesis in the select query instead use the table name as prefix for the column name.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">10)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"> In the pagination don’t use offset, Just use Limit N. It makes pagination faster.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">E.g.: With offset Select * from pages limit 10,20 <o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Without offset Select * from pages where id > 10 limit 20<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">11)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"> Use INET_ATON and INET_NTOA for IP addresses<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;"><span style="font-size: 17px; line-height: 19px;"><br />
</span></div><div class="MsoNormal"><b><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Optimization Tips:<o:p></o:p></span></b></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">1)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use OPTIMIZE for each table<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 72.0pt; mso-list: l1 level2 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">a.<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">E.g. OPTIMIZE Table tablename<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -108.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;"><span style="font: 7.0pt "Times New Roman";"> </span>i.<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">This will work only in MYISAM Engine.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -108.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -108.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;"><span style="font: 7.0pt "Times New Roman";"> </span>ii.<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">While optimizing the entire table will be locked, so it should be done only when the site is offline & maintenance period<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -108.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">2)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">To test the server speed, Just execute the following query in mysql<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 72.0pt; mso-list: l1 level2 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">a.<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">SELECT BENCHMARK(1000000,10+10);<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 72.0pt; mso-list: l1 level2 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 72.0pt; mso-list: l1 level2 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">b.<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">The above command executes the expression 10 + 10 one million times. This will return 0 as result, but the execution time should be noted.<br />
This command as to run different time of the day to check how the server handles the request.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 72.0pt; mso-list: l1 level2 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">3)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Create index for the table, we should make proper indexing to the fields which we’re going to search for the results.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">4)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Before making a select query check it with Explain function & check whether the query is optimized to its best. This will be very useful when we use for complex queries.<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">5)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use stored procedures to avoid bandwidth wastage<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">6)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Partition your database/table <o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">7)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Delete data that you don’t need. Tables will grow, so monitor table sizes regularly. <o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;"><br />
</span></div><div class="MsoNormal"><b><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Secure the Data’s:<o:p></o:p></span></b></div><div class="MsoNormal"><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">While inserting or fetching data’s from the website, we need to be careful. We should follow the steps mentioned below<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">1)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use mysql_real_escape_string() for the datas that has user interaction like Inserting fields & query strings<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">2)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Use POST method as much as possible<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">3)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Filter each inputs to make it secure. Use strip_tags().<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">4)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">When you're getting the values from query string, use (int) function for getting integer values & if you want to get a string or characters use substring to get the values to a certain limit (For example: An hacker can pass ascii code to the query string & can access the database. So, we can limit upto 10 characters in the query string. If we do so, sql injection will be prevented).<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">5)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">If you're using AJAX, pass the values by post method.<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">6)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">Don't allow php files & other executable files in the file upload option. If you do so, the hackers can write their script in php file & upload it to your server & can access any data’s that they want.<br />
<br />
<o:p></o:p></span></div><div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo3; text-indent: -18.0pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt;">7)<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span lang="EN-US" style="font-size: 13.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">In production path don't print the mysql error code or sql query. If any error displayed then the hackers can find out the table structure for the website & can use it accordingly.<o:p></o:p></span></div><br />
</div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com160tag:blogger.com,1999:blog-8488539832279332237.post-30084523136672381082010-08-02T05:30:00.000-07:002010-09-13T09:17:27.889-07:00Database Class using PHPHi PHP Developers,<br /> I wrote a Database utility class, which is used mostly in any projects. If you've this class, then you don't need to write queries each & every time when a new project comes. You can just copy this file & paste it in your class directory & can call it anytime. The class written below is very simple & it can be understood to the novice also. There will be a way to minimize the functions & statements inside the class too, if so, don't regret to post it in comments.<br /><pre class="php" name="code"><br /><?php<br />/*-----------------------------------------------------------------------<br />Created By: Sathish Kumar.R<br />Date: 30 July 2010<br />E-mail: smart2raise[at]gmail[dot]com<br />Purpose: Database Manipulation<br /><br /><br />Functions Available:<br />db: Constructor (for mysql connect)<br />query: Executing query(mysql_query)<br />num_rows: Finding total rows(mysql_num_rows)<br />fetch_object: Fetch results in Object (mysql_fetch_object)<br />fetch_array: Fetch results in Array (mysql_fetch_array)<br />fetch_assoc: Fetch results in Array (mysql_fetch_assoc)<br />insert: Insert query (Insert into...)<br />insert_id: Gets last inserted ID (mysql_insert_id)<br />update Update query (Update ...)<br />delete Delete query (Delete ...)<br />countof: Count function in mysql<br />maxof: Max function in mysql<br />sumof: Sum function in mysql<br />avgof: AVG function in mysql<br />last_query: Displays the query which you executed last<br />throw_error: If any mysql error occurs & you set $debug = true then it will show the query & the mysql error<br />-------------------------------------------------------------------------*/<br />class db{<br />var $debug = false;<br />var $query = array();<br />var $prefix = "";<br />function db($server,$username,$pwd,$db){<br /> mysql_connect($server,$username,$pwd) or die('Please check your database connection');<br /> mysql_select_db($db);<br />}<br />function query($qry){<br /> $this->query[] = $qry;<br /> $res = mysql_query($qry);<br /> if(mysql_error()){<br /> $this->throw_error();<br /> }<br /> return $res;<br />}<br />function num_rows($res){<br /> return mysql_num_rows($res);<br />}<br />function fetch_object($res){<br /> $fet = mysql_fetch_object($res);<br /> return $fet;<br />}<br />function fetch_array($res){<br /> $fet = mysql_fetch_array($res);<br /> return $fet;<br />}<br />function fetch_assoc($res){<br /> $fet = mysql_fetch_assoc($res);<br /> return $fet;<br />}<br />function insert($val,$table){<br /> $query = 'INSERT INTO '.$table.' (';<br /> foreach ($val AS $key => $value)<br /> $query .= '`'.$key.'`,';<br /> $query = rtrim($query, ',').') VALUES (';<br /> foreach ($val AS $key => $value){<br /> if(get_magic_quotes_gpc())<br /> $query .= '\''.$value.'\',';<br /> else<br /> $query .= '\''.mysql_real_escape_string($value).'\',';<br /> }<br /> $query = rtrim($query, ',').')';<br /> return $this->query($query);<br />}<br />function insert_id(){<br /> return mysql_insert_id();<br />}<br />function update($val,$table,$con){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else<br /> {<br /> $where = "";<br /> }<br /> $query = 'update '.$table.' set ';<br /> foreach ($val AS $key => $value){<br /> if(get_magic_quotes_gpc())<br /> $query .= $key."=".'\''.$value.'\',';<br /> else<br /> $query .= '\''.mysql_real_escape_string($value).'\',';<br /> }<br /> $query = rtrim($query, ',')." ".$where;<br /> return $this->query($query);<br />}<br />function delete($table,$con){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else {<br /> $where = "";<br /> }<br /> return $this->query("delete from {$table} {$where}");<br />}<br />function countof($col,$table,$con="",$group=""){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else {<br /> $where = "";<br /> }<br /> if($group!="")<br /> $groupby = "group by ".$group;<br /> else<br /> $groupby = "";<br /> $query = $this->query("select count({$col}) from {$table} {$where} {$groupby}");<br /> $fet = $this->fetch_array($query);<br /> return $fet[0];<br />}<br />function maxof($col,$table,$con="",$group=""){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else {<br /> $where = "";<br /> }<br /> if($group!="")<br /> $groupby = "group by ".$group;<br /> else<br /> $groupby = "";<br /> $query = $this->query("select max({$col}) from {$table} {$where} {$groupby}");<br /> $fet = $this->fetch_array($query);<br /> return $fet[0];<br />}<br />function sumof($col,$table,$con="",$group=""){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else {<br /> $where = "";<br /> }<br /> if($group!="")<br /> $groupby = "group by ".$group;<br /> else<br /> $groupby = "";<br /> $query = $this->query("select sum({$col}) from {$table} {$where} {$groupby}");<br /> $fet = $this->fetch_array($query);<br /> return $fet[0];<br />}<br />function avgof($col,$table,$con="",$group=""){<br /> if($con!=""){<br /> $where = "where ";<br /> $lastitem = end($con);<br /> foreach ($con AS $key => $value){<br /> if($value!=$lastitem){<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."' && ";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."' && ";<br /> }<br /> else{<br /> if(get_magic_quotes_gpc())<br /> $where .= $key."='".$value."'";<br /> else<br /> $where .= $key."='".mysql_real_escape_string($value)."'";<br /> }<br /> }<br /> }<br /> else {<br /> $where = "";<br /> }<br /> if($group!="")<br /> $groupby = "group by ".$group;<br /> else<br /> $groupby = "";<br /> $query = $this->query("select avg({$col}) from {$table} {$where} {$groupby}");<br /> $fet = $this->fetch_array($query);<br /> return $fet[0];<br />}<br />function last_query(){<br /> return end($this->query);<br />}<br />function throw_error(){<br /> if($this->debug==true){<br /> $qry = "<span style="color: rgb(0, 0, 0);">".end($this->query)."</span><br>";<br /> }<br /> else{<br /> $qry = "";<br /> }<br /> die("<div style='width:500px; margin:auto; text-align:left; color:red; font-size:12px;border:2px solid #FFD700;vertical-align:middle; line-height:19px;background:#FFFFDD;font-family:verdana;padding:3px;'>".$qry."Mysql Error: ".mysql_error());<br />}<br />}<br />?><br /><br /><?php<br />//Usage of Class:<br /><br /><br />$hostname = "hostname";<br />$username = "username";<br />$password = "";<br />$database = "dbname";<br />$db = new db($hostname,$username,$password,$database);<br />$db->debug = true;<br />//If it is set to true, then mysql error will shown the query which throws the error.<br /><br />$qry = $db->query("select columnname from tablename"); //Executing query<br />$db->num_rows($qry); //Finding total rows<br /><br />$val = array("a"=>123,"b"=>"sathish","c"=>"kumar");<br /><br />$a = $db->insert($val,"tablename");<br />/*Note: $val should be an array, else it will throw error Key in an array should be the column name in the table & value can be any value */<br /><br />$db->insert_id(); //returns the last inserted ID in the database<br /><br />$val1 = array("a"=>123,"b"=>"Sathish","c"=>"Kumar");<br /><br />$db->update($val1,"tablename",array("id"=>2));<br />/*<br />Update query same as insert query, you can pass multiple conditions in the 3rd argument i.e array("id"=>2,"a"=>'123')<br />*/<br /><br />$db->delete("tablename",array("id"=>4));<br />//You can pass multiple conditions in 2nd argument<br /><br /><br />$db->countof("id","tablename",array("a"=>123123));<br /><br /><br />$db->maxof("id","tablename",array("a"=>123123));<br /><br /><br />$db->avgof("id","tablename",array("a"=>123123));<br /><br />/*<br /> for countof(),maxof(),avgof() you can pass additional argument group by<br /><br /><br />$db->countof("id","tablename",array("a"=>123123),"c");<br /><br />this will result as "select count(id) where a = '123123' group by c"<br />*/<br /><br />$db->last_query() //This will return last executed query<br />?><br /></pre>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com23tag:blogger.com,1999:blog-8488539832279332237.post-40177420376884416432010-07-26T09:54:00.000-07:002010-09-13T09:11:40.140-07:00Detect Firebug console using JavascriptHi Developers,<br /> Nowadays Firebug console is one of the best tool to debug html or javascript or AJAX or css. In the same time it allows any user to see the datas passed in between the pages. It is not a secure method for our website. Gmail has blocked firebug console because of this activities. You can able to login to gmail with firebug console but it will say that "If your firebug console is ON, then gmail will become slow". So you definitely switch off your firebug console. So in the same way, we save our website from firebug. <br /><br />You can prevent this using javascript.<br /><br />In your page load call this function<br /><pre name="code" class="jscript"> <br /><script type='text/javascript'><br />function blockfirebug(){<br /> if(window.console.firebug!=""){<br /> document.location.href="firebug_error.html";<br /> return false;<br /> }<br />}<br /><script><br /></pre><br /><pre name='code' class='php'><br /><body onload='return blockfirebug()'><br /></pre>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com125tag:blogger.com,1999:blog-8488539832279332237.post-23572567287505553912009-09-01T22:27:00.000-07:002009-09-01T23:26:16.490-07:00Mysql Query Tips & TricksFor Mysql Novice, this topic would be useful for you to build a website with minimizing number of queries.<br /><br /><span style="font-weight:bold;">1) Mysql for getting Date,Day, Monthname & year:</span><br /> <br /> select MONTHNAME(datefield),DAYNAME(datefield), YEAR(datefield), DAY(datefield), MONTH(datefield) from tablename<br /><br /><span style="font-weight:bold;">USAGE: </span><br /> This query will be useful for displaying date, day, year, monthname etc. By using this query we can avoid PHP arrays & PHP split functions<br /><br /><span style="font-weight:bold;">Explanation:</span><br /> MONTHNAME: Shows full name of the month(i.e January, February)<br /> DAYNAME: Shows full name of the Day(i.e Monday, Tuesday)<br /> Year: Shows year(i.e 2009,2010)<br /> Day: shows date(ie 1,2,3)<br /> Month: Shows month(ie 12,11,10)<br /> <br /><span style="font-weight:bold;">Tips:</span><br /> If you need just 2 or 3 characters from the monthname or dayname you can use substring function<br />i.e: select substr(MONTHNAME(datefield),1,3) as mon from tablename<br /> <br /><span style="font-weight:bold;">Note:</span> datefield should have a datatype as Date only<br /><br /><span style="font-weight:bold;">2) Concatination Using mysql Query:</span><br /> select CONCAT('http://mycodings.blogspot.com/','2009/05/remove-malwareiframeinf-virus-from-your.html') as link from tablename;<br /><br /><span style="font-weight:bold;">USAGE: </span><br /> This query will be useful for concatinating two fields dynamically using mysql. In any case if you need to join two fields or need to add extra characters to your value then concatination function is best to save the execution time.<br /><br /><span style="font-weight:bold;">Explanation:</span><br /> CONCAT() is mysql in-built function<br /> It is used concat more than 2 strings or fields<br /> The above query will result in <a href="http://mycodings.blogspot.com/2009/05/remove-malwareiframeinf-virus-from-your.html">http://mycodings.blogspot.com/2009/05/remove-malwareiframeinf-virus-from-your.html</a><br /> <br /><span style="font-weight:bold;">3) For mysqldump using commandline argument</span><br /> mysqldump --user=yourusername --password=yourpassword yourdatabase > filenametobesaved;<br /><br /><span style="font-weight:bold;">Usage:</span><br /> It can be used in mysql command prompt or you can use it as a commandline argument in php<br /> i.e: exec(mysqldump --user=yourusername --password=yourpassword yourdatabase > filenametobesaved);<br /><br /> Output will be saved in the path where you've run this commandline.<br /> <br /> The argument will export the whole database to your system.<br /><br /><span style="font-weight:bold;">Explanation:</span><br /> mysqldump - In-built function<br /> yourusername - Username for the database<br /> yourpassword - Password for the database<br /> yourdatabase - Databasename which is to be exported<br /> filenametobesaved - Filename which the exported to be savedSathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com2tag:blogger.com,1999:blog-8488539832279332237.post-44492440010014335672009-08-18T04:08:00.000-07:002009-08-18T04:37:24.739-07:00Avoid ugly border around images & links using cssEvery web developer would come across this issue. In Firefox, when you'd clicked a image or link there you'll see a dotted border around the image or link. It makes ugly to the website. I googled around this issue & found a way to resolve it. If you see the image below you could easily identify the bug.<br /><img style="cursor:pointer; cursor:hand;width: 400px; height: 76px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiptpNAawK42ShNOBL0Iyvs_6xkUoxaF_7yDp2ZLlpb8M92L_UQyw23kX6vhmxINtm4MqWFetE7JwTZhaTkgrd0VsANnOhBsR4tocEzV-b6_EcnpPc1m47Gkyn5Vpv_hYwpo18Xbd1YTGhO/s400/google_border.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5371263145194335202" /><br><br /><img style="cursor:pointer; cursor:hand;width: 400px; height: 111px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYz0T7XZ6RDTjsSjW67i9SlaU_RJVtlh4VeSQTjbgaO_lmx_r6g0MQC9kgzZz7ak5EzRtC53zspUxUHt_PtPxvsPBi1j6Bp3y3QySzj-g07JqBwfb-y99YZg14IvypGOTzEVYOes0kUjE7/s400/mycodings.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5371264391535586322" /><br /><br />To resolve this issue just a single line css is enough. <br /><br><br /><code><br /><style type="text/css"><br />a:active, a:focus{outline: 0;}<br /></style><br /></code>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com5tag:blogger.com,1999:blog-8488539832279332237.post-90657577315352410932009-06-10T01:43:00.000-07:002012-01-04T11:43:20.405-08:00Send Free SMS using PHP<div dir="ltr" style="text-align: left;" trbidi="on">Hi Friends,<br />
Yesterday i read one article for sending free sms using php(<a href="http://www.aswinanand.com/2008/07/send-free-sms-web-service/" target="_blank">http://www.aswinanand.com/2008/07/send-free-sms-web-service/</a>). Using SOAP method they are sending sms using <a href="http://way2sms.com/" target="_blank">WAY2SMS.COM</a><br />
<br />
You just need to have the following requirements<br />
1) Need to register your mobile number to WAY2SMS.COM<br />
2) Other person's(whom you want to send sms) mobile number<br />
3) A message which you need to send<br />
<br />
You need to pass your values to this link:<br />
http://www.aswinanand.com/sendsms.php?uid=XXXXXXXXX&pwd=password&phone=XXXXXXXXX;XXXXXXXXX&msg=mycodings<br />
<br />
In UID = "Your way2sms userid(only mobile number)"<br />
In PWD = "Your way2sms password"<br />
In PHONE = "Friends phone number(Note for the last number there should not be any semicolon';' for more numbers you need to seperate using comma ',')"<br />
In Msg = "Your Msg"<br />
<br />
Thats it. Now you can also send sms from your website. If you're not novice in PHP make a Form to submit the values and send it<br />
<br />
For downloading sms package: <a href="http://sourceforge.net/project/platformdownload.php?group_id=57663">Click Here</a><br />
<br />
For Deployment in your own server : <a href="http://www.aswinanand.com/2008/07/send-free-sms-web-service/">Click Here</a></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com13tag:blogger.com,1999:blog-8488539832279332237.post-85381142319397644212009-05-07T11:21:00.000-07:002010-05-28T05:03:20.044-07:00Remove malware,iframe.inf virus from your websiteHi Developers,<br /> For the past few months you would be plucking your hair for removing some of the malwares from your site. I too suffered a lot with these and now i learnt the lesson from them how to safeguard our website from these hackers.<br /><br /><span id=”fullpost”><br /> The iframe virus are redirecting to chinese domain which was severely affected by malwares which will lead to theft of secured datas from your system. If you dint care for these virus then the virus will eat your whole site. <br /><br /><span style="font-weight:bold;">How to Remove Iframe virus?</span><br /> Iframe tags will be written just below the body tag. Follow the steps to remove virus.<br />1. Login to your FTP & edit the file which you've got iframe tag. <br /><br />2. Look for the iframe tag just below the Body or Head tag.<br /><br />3. Remove the coding & overwrite the file.<br /><br />4. Now right click the file and click properties/File attributes and make it to "444". So that no hackers have privilege to write the file with iframe code.<br /><br />5. Once you've cleaned this, the other type of virus will slowly raise, that is it will search the files that are included on the index.php file (ie dbconnect.php, general.php, configure.php, common.php, functions.php, classes.php etc) and it will write a php coding at the top of the page where it will dynamically write the javascript code at the time of execution of the file in the web - browser. The script will redirect the page to <span style="font-weight:bold;">gumblar.cn/rss?id=2</span><br /><br />6. To remove these type of error carefully look into the above mentioned filename, you can easily find out the php coding at the top of the page. Just remove the coding and make sure it is write protected, so that the php coding wont be written.<br /><br />7. Still you cant find the solution, just comment to this section. I'll reply ASAP.<br /></span><br /><br /><span style="font-weight:bold;">Update:</span><br />Godaddy hosting had some security issues on the wordpress which they have installed. Please upgrade all your wordpress under the Godaddy hosting (Wordpress older version is having a security hole by which the malicious code will be injected in all the php files. For further information regarding the virus removal, please send a mail to smart2raise@gmail.comSathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com126tag:blogger.com,1999:blog-8488539832279332237.post-4142798730698905932009-05-01T03:28:00.000-07:002009-05-01T04:41:36.427-07:00Easy Multi-Language for your websiteHi Friends & Techies,<br /> I came after a long back time with more tips & i'll share you more frequently in coming months. Now in the post i'll start sharing about how to create Multi-language website using php. <br /><span id=”fullpost”><br />First we must plan for the multilingual website<br />1) Every time when we add new language it should support the website without anymore alteration in the Web pages<br />2) Must have unique variable for each & every page for the content [so there wont be redeclaring].<br />3) For more user friendly use more text and design your pages with css. Avoid using images [Until you need it].<br />4) After designing your template, put all the contents in main language. Make it aligned and look out for browser compatibility<br />5) Going for Multi-language option <br />6) Create a file called "defines.php"<br />7) In the defines.php you define language for file<br /> if($_COOKIE['language']==""){<br /> $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];//Detecting Default Browser language<br /> }<br /> else {<br /> $lang = $_COOKIE['language'];//Detecting if cookie was set<br /> }<br /> switch($lang){<br /> case "en":<br /> require("lang/english.php"); // where the content in english is stored<br /> break;<br /> case "cn":<br /> require("lang/chinese.php"); // where the content in chinese is stored<br /> break;<br /> case "zh-CN":<br /> require("lang/chinese.php");<br /> break;<br /> case "zh-cn":<br /> require("lang/chinese.php");<br /> break;<br /> default:<br /> require("lang/english.php");<br /> break;<br /> }<br />8) Include the above file in all the webpages in your website <br /><br /> include('includes/defines.php');<br /><br />9) In all the webpages you must change/add the meta tag information<br /> <1meta http-equiv="content-type" content="text/html; charset=UTF-8"> //Remove 1 in the meta tag<br /> <br />10) for creating a new language you must save the file in UTF-8 format.<br /> Follow the steps to save it in UTF-8<br /> a. Open the notepad (start->run->type "notepad")<br /> b. Save the file as "chinese.php".<br /> c. In the save option Enter file name as "chinese.php" , Save as Type as "All Files", In encoding as "UTF-8" ;<br />11) Now with as usual PHP Syntax create some unique variable.<br />12) For chinese translation Go to <a href="http://translate.google.com/translate_t?hl=en&sl=en&tl=zh-CN#" target='_blank'>Google Translation</a>.<br />13) Copy the translated text and paste it in notepad for a particular variable.<br />14) Create a webpage, include the defines.php file, print the variable defined in chinese.php file <br /><br />For Demo: <a href="http://www.rainbowgp.com" target='_blank'>Multilingual Website</a><br /><br />Thats it, you've created multilingual website. If you've any doubt, just comment to this post i'll reply as soon as possible.<br /><br /></span>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com64tag:blogger.com,1999:blog-8488539832279332237.post-7890989985576085902008-10-10T00:13:00.000-07:002008-10-10T00:32:31.469-07:00Video Conversion Dynamically Using FFMPEG,PHP<span id="”fullpost”">Every programmer has an idea to convert the video file types dynamically into any formats on the fly. They all know there is a tool called FFMPEG to convert video formats to their desired formats which they want. In this tutorial i'll let you know how to use the FFMPEG tool during file upload dynamically.<br /><br />1. Download FFMPEG.EXE from <a href="http://sourceforge.net/project/showfiles.php?group_id=205275&package_id=248632">here</a><br />2. Extract the FFMPEG.EXE from the archive.<br />3. Place the FFMPEG.EXE in the webdirectory.<br />4. As you all know how to upload a file (So i'm moving to the next step).<br />5. After the file uploaded just put the below line<br /> exec("ffmpeg -i recipe_videos/$path -f flv recipe_videos/$test[0].flv");<br /> //Format exec("ffmpeg -i pathofthevideouploaded -f towhichformat wherethefiletobesavedwithextension");<br />6. If you want delete the old file.<br />7. Now you can view the video in the desired format.<br /> <br /></span>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com20tag:blogger.com,1999:blog-8488539832279332237.post-80229328417420477432008-08-29T21:25:00.000-07:002008-09-12T23:49:06.403-07:00FAQ<span style="font-weight:bold;">Frequently Asked Questions</span><br />1. <a href="http://mycodings.blogspot.com/2008/08/s.html">How to create multiple rows using javascript?</a><br />2. <a href="http://mycodings.blogspot.com/2008/05/highslide-works.html">Is it possible to integrate Highslide codings in the website?</a><br />3. <a href="http://mycodings.blogspot.com/2008/08/get-current-page-url-using-php.html">What is the syntax for getting the url value?</a><br />4. <a href="http://mycodings.blogspot.com/2008/08/read-xml-using-php-dom.html">What is the procedure to read the xml file using php?</a><br />5. How to create rss feeds using php?<br />6. <a href="http://mycodings.blogspot.com/2008/06/simple-ajax-coding.html">How to use post method in Ajax?</a><br />7. How to configure php in IIS?<br />8. Is there any Free source to configure php5 in IIS?<br />9. How to use div concepts in php?<br />10. <a href="http://myinnovativeidea.blogspot.com/">Dont you know how to use peel effect in website?</a><br />11. <a href="http://myinnovativeidea.blogspot.com/2008/07/flash-php-feedback-form.html">How to submit flash values to php?</a><br />12. <a href="http://myinnovativeidea.blogspot.com">Where can i get free photoshop,flash,Dream weaver,actionscript tips & tricks ?</a><br />13. <a href="http://mycodings.blogspot.com/2008/08/get-current-page-url-using-php.html">Which method in php should i use to get the value of the url?</a><br />14. <a href="http://mycodings.blogspot.com">How to make a website rich,userfriendly & browser compatability using php?</a><br />15. <a href="http://mycodings.blogspot.com/2008/07/installing-apache-2-and-php-5-and-mysql.html">Will PHP5 work in IIS?</a>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com3tag:blogger.com,1999:blog-8488539832279332237.post-53869469874733560012008-08-29T00:26:00.001-07:002008-09-24T04:13:36.792-07:00Add Multiple rows dynamically by clicking Add New ButtonCopy the javascript coding & paste it in head.<br /><br /><1script type="text/javascript"><br />function AddRow()<br />{<br /><br />var dcname =document.getElementById("dcname");<br />var dqty =document.getElementById("dqty");<br />var dstype =document.getElementById("dstype");<br />var dnature =document.getElementById("dnature");<br />var morerow=document.getElementById("tbl")<br />var newtr = document.createElement("tr");<br /><br />var newtd1 = document.createElement("td");<br /> newtd1.innerHTML = dcname.innerHTML;<br /> newtr.appendChild(newtd1);<br />var newtd2 = document.createElement("td");<br /> newtd2.innerHTML = dqty.innerHTML;<br /> newtr.appendChild(newtd2);<br />morerow.appendChild(newtr);<br />var newtd3 = document.createElement("td");<br /> newtd3.innerHTML = dstype.innerHTML;<br /> newtr.appendChild(newtd3);<br /><br />var newtd4 = document.createElement("td");<br />newtd4.innerHTML = dnature.innerHTML;<br />newtr.appendChild(newtd4);<br />}<br /><1/script><br /><br />Paste the below content in the body section<br /><1table width="100%"><br /><1tbody id="tbl"><br /><1tr><br /><1td><1div align="center">Chemical Name <1/div><1/td><br /><1td><1div align="center">Quantity<1/div><1/td><br /><1td><1div align="center">Storage Type <1/div><1/td><br /><1td><1div align="center">Nature Of <1/div><1/td><br /><1td> <1/td><br /><br /><1tr><br /><1td><1input name="cname[]" type="text" id="cname" style="font-size:10;"><br /><1td><1input type="text" name="qty[]" id="qty" style="font-size:10;"><br /><1td><1input name="stype[]" type="text" id="stype" size="10"><br /><1td><1input type="text" name="natureof[]" id="natureof" style="font-size:10;"><br /><1td><1input name="Add" type="button" value="add" onclick="return AddRow();"><br /><1/tr><br /><1/tbody><br /><br /><1div id="dcname" style="display:none; visibility:hidden"><1input name="cname[]" type="text" id="cname" size="10"><1/div><br /><1div id="dqty" style="display:none; visibility:hidden"><1input type="text" name="qty[]" id="qty" size="10"><1/div><br /><1div id="dstype" style="display:none; visibility:hidden"><1input type="text" name="stype[]" id="stype"><1/div><br /><1div id="dnature" style="display:none; visibility:hidden"><p></p><p><1input type="text" name="natureof[]" id="natureof" size="10"><1/div><br /><br />That's it now you have created a single row and by clicking add new it will add any number of rows dynamically<br /><br /><span style="font-weight:bold;">Note : Remove 1 on every html tag</span>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com7tag:blogger.com,1999:blog-8488539832279332237.post-71207830325384533252008-08-28T06:17:00.000-07:002008-09-12T23:49:06.406-07:00Read XML Using PHP DOMThis tutorial is for PHP starters as well as for those who are using XML parser functions to read/write XML files. This tutorial will not go into details on XML. The focus will be more on the Document Object Model (DOM) extension.<br /><br /><br />This should not be confused with DOM XML extension, which is not packaged into PHP5 and will never be (according to php.net). DOM extension allows PHP users to use the DOM functions. The function then allow users to read, write, rename tags and do all types of crazy stuff with XML documents.<br /><br /><br /><br />First we need a XML document to experiment with. I have created a simple XML document and named it readfromxml.xml<br /><br /><br />readfromxml.xml<br /><br /><br /><1?xml version="1.0" encoding="ISO-8859-1"?><br /><br /><1html><br /><br /><1head><br /><br /><1pagename>Current page name<1/pagename><br /><br /><1title>Title for Pagename<1/title><br /><br /><1keyword>meta keyword for current page<1/keyword><br /><br /><1description>meta Description for current page<1/description><br /><br /><1/head><br /><br /><1/html><br /><br /><br />This XML document stores pagename,title of the page,keyword for the page and description for the page. You can create one for any type of webpage to create keywords, description dynamically & manage for every single page. Every note in this XML file beings < with and ends with >. Within the tab I have created a tab for the keyword ( ),description ( ),title ( ),pagename ().<br /><br /><br /><br />Next step is to read this XML and display the results on a web page.<br /><br /><br />Create another file and call it readfromxml.php. Copy the following code into it and run it.<br /><br /><br /><br /><? <br /> // DOMElement->getElementsByTagName() -- Gets elements by tagname <br /> // nodeValue : The value of this node, depending on its type. <br /> // Load XML File. You can use loadXML if you wish to load XML data from a string <br /><br /> $objDOM = new DOMDocument(); <br /> $objDOM->load("readfromxml.xml"); //make sure path is correct <br /><br /><br /> $note = $objDOM->getElementsByTagName("head"); <br /> // for each note tag, parse the document and get values for <br /> // tasks and details tag. <br /><br /> foreach( $note as $value ) <br /> { <br /> <br /> $page = $value->getElementsByTagName("pagename"); <br /> $page = $page->item(0)->nodeValue;<br /> if($page == $pagename)<br /> {<br /> $title = $value->getElementsByTagName("title"); <br /> $title = $title->item(0)->nodeValue;<br /> <br /> $keywords = $value->getElementsByTagName("keyword"); <br /> $keywords = $keywords->item(0)->nodeValue; <br /> <br /> $description = $value->getElementsByTagName("description");<br /> $description = $description->item(0)->nodeValue;<br /> }<br /> } <br /><br /><br />?><br /><br />create a webpage as index.php and copy the following content and paste it in index.php<br /><br /><? <br />$pagename = "index.php";<br />require("readfromxml.php");<br />?><br /><1!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><1html xmlns="http://www.w3.org/1999/xhtml"><br /><1head><br /><1meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><br /><1META NAME="DESCRIPTION" CONTENT="<? echo $description;?>" /><br /><1META NAME="KEYWORDS" CONTENT="<? echo $keywords;?>" /><br /><br /><1title><? echo $title;?><1/title><br /><1/head><br /><br /><1body><br /><1/body><br /><1/html><br /> <br /><br /><br />This tutorial is a kick start for beginners. You can retreive data from a database and create a XML document on-the-fly with DOM functions, rename tabs in an existing XML document and validate format.<br /><br /><span style="font-weight:bold;">Note : Remove 1 on every tag</span><br /><br /><div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com6tag:blogger.com,1999:blog-8488539832279332237.post-5343347771064659432008-08-28T04:15:00.000-07:002008-09-12T23:49:06.409-07:00Get the current page url using php<?php<br />//This function returns the full url of the current page<br />function getcurrentpageurl() {<br /> $pageURL = 'http';<br /> if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}<br /> $pageURL .= "://";<br /> if ($_SERVER["SERVER_PORT"] != "80") {<br /> $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];<br /> } else {<br /> $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];<br /> }<br /> return $pageURL;<br />}<br />echo getcurrentpageurl();<br />?><br /><br /><?php<br />//This function returns the filename alone<br />function getcurrentpagename() {<br /> return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);<br />}<br /><br />echo "The current page name is ".getcurrentpageurl();<br />?><br /><div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com2tag:blogger.com,1999:blog-8488539832279332237.post-22149312656319629952008-07-21T05:02:00.000-07:002008-09-12T23:49:06.414-07:00Installing Apache 2 and PHP 5 (and MySQL) on Windows XP<div id="maincontainer"><h1>Installing Apache 2 and PHP 5 <span style="font-size:smaller;">(and MySQL)</span> on Windows XP<br /></h1><h1>Contents<br /></h1><ol start="0"><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#intro">Introduction</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#dirsetup">Set up a directory structure</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#getApache">Download and Install Apache 2.0</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#getPHP">Download and Install PHP 5</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#ConfigApache">Configuring Apache</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#extras">Some extra steps: Setting up a development environment and installing MySQL</a></li><br /><li><a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#conclude">Conclusion</a><br /></li></ol><br /><a name="intro"></a><h2>0. Introduction<br /></h2><p>First, a couple short notes on whom this tutorial is for. First, it's for people who want to install<br />PHP <b>5</b> and Apache <b>2</b>; other versions will follow similar procedures, but they will by no means be identical, and these instructions will not work with them. Second, I've written this mostly with the beginner in mind, with the objective being to walk you through installation and setup of your own local web server to use as a learning and testing tool.That said, the instructions here should serve as useful information for the more experienced web developer/administrator who needs a refresher on installation, or runs into a problem along the way. If you're planning on connecting your server to the internet and serving files to the World, as usual, make sure you know what you're doing first -- you'll get very little sympathy if something goes wrong because you didn't.<br /></p><p>On business: In this tutorial, I'll show you how to install Apache and PHP on Windows XP, as well as how to set up a nice working environment. As a bonus, I'll also show you how to install MySQL if you're interesed.</p><p>Below are some words of encouragement for those who might not know what all of this means. If you're already convinced, skip ahead to the <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#dirsetup">next section</a>. :-)<br /></p><div class="codelisting"><p><strong>Note:</strong> If you're a little unsure of what a web server is, it can mean two things: (1) a computer that serves web pages and other content to web browsers and other client programs (this is the definition most people learn first), or (2) a program on a computer<br />that enables it to serve such content. Apache is a web server as defined in the second sense, i.e. it is software. Once you install it on your computer, you will be able to view web pages, PHP pages, etc, on your local machine as if they were on a site on the internet. In fact, other computers connected to your local network will be able to access the content you serve, and if you choose, you can even make your server available on the internet.<br /></p></div><p>Many people think they need to buy web hosting in order to learn PHP and test their scripts.<br />You can learn a lot by having some space on a remote server, and they often have many modules and extensions installed and configured, so you can focus on your programming and not have to worry about the details. I learned to program on a remote server, and I picked up a lot of skills, like using the Linux shell, along the way. But you don't have to do it this way. Inevitably, you will eventually want to run a <a href="http://wikipedia.org/wiki/Web_server">web server</a> on your local machine so you can test scripts quickly and easily, and you might be surprised at how much faster you can actually program if you do this. My advice is, <i>start early and install a web server and PHP on your local machine today!<br /></i> Like learning to program remotely, it will teach you useful skills. It allows you to program more quickly, to play with different configurations both on- and offline, and best of all, if the web server is free it doesn't cost you a dime. In this tutorial, I will show you how to install one of the most popular web servers, Apache 2.0, and PHP 5 on your Windows XP machine. I'm choosing the Windows environment simply because a lot of people, especially people who are learning to program, have it and I'd like this to be useful to as many people as possible.<br />Apache and PHP can be installed on other versions of Windows and other operating systems as well. I've chosen Apache because it is immensely popular, and because it is free.<br /></p><a name="dirsetup"></a><h2>1. Set up a directory structure<br /></h2><p>First, let's make a directory where you can put PHP and Apache (and maybe other programs such as Perl in the future).<br />To avoid any potential problems, it's best to create this directory on a path that does not have any spaces. I put mine on a second partition, in the <code>WebServer</code> directory of the <code>Web</code> folder where I keep all my web development data:<br /></p><p><code>D:\Web\WebServer</code><br /></p><p>Pick something similar for yourself, and create your folder.<br /><br />Inside that folder, create a folder called <code>PHP</code>. Simple enough: now on to the good stuff.<br /></p><a name="getApache"></a><h2>2. Download and Install Apache 2.0<a name="apache2-2Note"></a><br /></h2><div class="codelisting"><p><strong>Note:</strong> I've gotten a couple questions about installing PHP 5 with <strong>Apache 2.2</strong>.<br />When I first wrote this tutorial, that would not work, because the <code>php5apache2.dll</code><br />that came with PHP 5 was incompatible with Apache 2.2. However, PHP 5.2.5 (the latest version as of this revision) includes an <code>php5apache2_2.dll</code> file that is compatible with Apache 2.2. If you want to install Apache 2.2, use this DLL instead when following the instructions in this article. Thanks to Wouter Smit for pointing this out.<br /></p><p>First, download the Win32 Binary (MSI Installer — see the note immediately below) from <a href="http://httpd.apache.org/download.cgi#apache20">the Apache download page</a>. To the right of the download link, you will see a link called "[MD5]". Follow this link after your file has downloaded, and you will see some text that looks like<br /></p></div><div class="codelisting"><strong>Note</strong>: If your Windows Installer (<a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/msiexec.mspx?mfr=true">msiexec</a>) is not up to date, using an MSI installer may not work properly. In that case (or if you're unsure), you are better off using the EXE installer instead, which you can download from one of Apache's <a href="http://www.mirrorgeek.com/apache.org/httpd/binaries/win32/">binary mirror sites</a>. <code>44358b283212d5c144524231fc0cb562 apache_1.3.34-win32-x86-no_src.exe</code><br /></div><p>Leave this page open - we will use it in a minute to verify the integrity of the<br />installer we just downloaded.<br /></p><p>Next, go to <a href="http://www.pc-tools.net/win32/md5sums/">pc-tools.net</a><br />and download the <code>md5sums-1.2.zip</code> file to the same folder where you saved the Apache installer<br />(the desktop is fine), and unzip it. Make a new text file in the same folder and put the following in it:<br /></p><p><code>md5sums -p -n -b apache_2.0.55-win32-x86-no_ssl.msi</code><br /></p><p>(if you have downloaded a slighly different version of the installer, change the name of the file to match yours).<br />Save the file as <code>check_Apache_md5.bat</code>, and run (open) it. The screen that pops up should look something like </p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkV22yJXILF8Ash9VZ3bxLcFu_EDDVBY4rT6tBGGSVmv-8FW6aJArLoeEuER24j3lguJEGFB3AMGZwnzbvRFccdc_n_6LCq7R91nDXXj6IIzRsDRmyPvpAMyW0DvCtyqDqewLdA9Nm9ACo/s1600-h/md5cmd.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 421px; height: 205px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkV22yJXILF8Ash9VZ3bxLcFu_EDDVBY4rT6tBGGSVmv-8FW6aJArLoeEuER24j3lguJEGFB3AMGZwnzbvRFccdc_n_6LCq7R91nDXXj6IIzRsDRmyPvpAMyW0DvCtyqDqewLdA9Nm9ACo/s320/md5cmd.png" alt="" id="BLOGGER_PHOTO_ID_5225501643306815938" border="0" /></a><br /><br /><p>Compare the code in the red box to the code on the page opened by the "[MD5]" link. If it is the same, then your file integrity is good, and you can proceed. If it is different, the file is damaged and you should download it again, probably from a different mirror (see the top of the Apache download page).<br /></p><p>Once you have a file that is authenticated, you can delete the <code>check_Apache_md5.bat</code>, the<br /><code>md5sums-1.2.zip</code> file, and the <code>md5sums.exe</code> and <code>md5sums.txt</code> files (although you may want to keep the md5sums program for future use).<br /></p><p>Now we're ready to install. Double-click on the installer. Read the agreements and information, clicking next to move through each screen. On the fourth screen, you will see the following: </p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmOd4ZGlawrGa7uaqfyx3B3eh-auVqncLovF9Cwt29RQr_dWuEHy6pFoFUDmCqVzxrI8EG8X-fO_rUi-nN8v-H2V6SP8qIsL5Z9grvmO1dKlkwzOyPWSapRN_rV7P9JWZqqWVrxtgkzdX4/s1600-h/Apachescrn4.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmOd4ZGlawrGa7uaqfyx3B3eh-auVqncLovF9Cwt29RQr_dWuEHy6pFoFUDmCqVzxrI8EG8X-fO_rUi-nN8v-H2V6SP8qIsL5Z9grvmO1dKlkwzOyPWSapRN_rV7P9JWZqqWVrxtgkzdX4/s400/Apachescrn4.png" alt="" id="BLOGGER_PHOTO_ID_5225502267357584930" border="0" /></a><br /><br /><p>I'll quote the explanation of each of these settings directly from the <a href="http://httpd.apache.org/docs/2.0/platform/windows.html#inst">Apache documentation</a>:<br /></p><div class="codelisting"><code></code># Network Domain. Enter the DNS domain in which your server is or will be registered in. For example, if your server's full DNS name is server.mydomain.net, you would type mydomain.net here.<br /><pre># Server Name. Your server's full DNS name. From the example above, you<br />would type server.mydomain.net here.<br /><br /># Administrator's Email Address. Enter the server administrator's or<br />webmaster's email address here. This address will be displayed along<br />with error messages to the client by default.<br /><br /># For whom to install Apache Select for All Users, on Port 80, as a<br />Service - Recommended if you'd like your new Apache to listen at port<br />80 for incoming traffic. It will run as a service (that is, Apache will<br />run even if no one is logged in on the server at the moment) Select<br />only for the Current User, on Port 8080, when started Manually if you'd<br />like to install Apache for your personal experimenting or if you already<br />have another WWW server running on port 80.<br /></pre></div><p>Here you have a few options:<br /></p><ul><li><p><i>If you are going to be using Apache only for testing scripts on your own machine</i>, you can enter <code>localhost</code> for the first two values and anything you'd like for the email<br />address (e.g. <code>admin@localhost</code>). If you're only going to be using Apache sometimes and<br />only when you are logged on, it does not make sense to run it as a service, because it will eat up system resources and potentially pose a security risk. Select "only for the Current User, on Port 8080, when started Manually". Press "Next" and <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#ApacheSetupType">skip ahead.</a><br /></p> </li><li><p><i>If you would like to install Apache to be used as a local area network server</i>, you should set your router to assign the computer you are installing Apache on to have a static LAN ip address (if it does not already have one. This issue is beyond the scope of this article; refer to your router's documentation, or consult the person in charge of your network). Enter either this IP address, or a network name that you will use to acess the server from within your network in the first two boxes (if you choose a name, you will need to update the<br /><a href="http://wikipedia.org/wiki/Hosts_file">Hosts file</a> of the users on your network so that when they type the name in a browser, it maps to your computer's IP addresss). Enter an appropriate email address in the<br />third box, and choose "for All Users, on Port 80, as a Service - Recommended". Press "Next" and <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#ApacheSetupType">skip ahead.</a><br /></p></li><li><p><i>If you would like your server to be accessible through the internet</i>, you will need your computer to either have a static internet IP address and set up a domain name server<br />(<a href="http://wikipedia.org/wiki/Domain_name_system">DNS</a>) to point your domain name to your computer's IP (this is beyond the scope of this article). If you do not have a static IP, you can set up your computer to have a static <em>local</em> IP as described in the last paragraph, and use a <a href="http://wikipedia.org/wiki/Dynamic_dns">dynmaic DNS</a> service such as<br /><a href="http://www.dyndns.com/">dyndns.com</a> to keep your current IP up to date on the DNS. A good router<br />will allow you to automatically update the dynamic DNS when the router acquires an IP address. You will also need to set up port forwarding so that all incoming traffic on port 80 is forwarded to your computers static local IP address. Enter the dynamic DNS domain name, e.g. mysite.dnydns.org, for the first two entries, and an appropriate email adress for the third. choose "for All Users, on Port 80, as a Service - Recommended". Press "Next" and <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#ApacheSetupType">skip ahead.</a><br /></p></li></ul><div class="codelisting"><p><strong>Note:</strong><br />If the last paragraph does not make sense, you should probably not do it yet, because there are important security issues you are most likely not aware of. Before setting up a web server to run on the internet, make sure you have educated yourself about all the factors involved. You make your computer available to outsiders at your own risk; if you make it available in ignorance, you do so at your peril.<a name="ApacheSetupType"></a><br /></p></div><p>The next screen you see will look like this:</p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH33iMHvFuBd41Y9mQydNs-_Hkcva9QBKu7Fm7QTU3HzPo3jnv6vn03f4RKnyy2yJSfEfFVMEMP7GsjqvtukTLpHpeOZ5AUOwu_uJP6-AtC0jjt74GRiDy6VrfcC2lYnLfheopDXF8XSHW/s1600-h/Apachescrn5.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH33iMHvFuBd41Y9mQydNs-_Hkcva9QBKu7Fm7QTU3HzPo3jnv6vn03f4RKnyy2yJSfEfFVMEMP7GsjqvtukTLpHpeOZ5AUOwu_uJP6-AtC0jjt74GRiDy6VrfcC2lYnLfheopDXF8XSHW/s400/Apachescrn5.png" alt="" id="BLOGGER_PHOTO_ID_5225503548536353602" border="0" /></a><br /><br /><p>Choose "Custom" and press "Next". On the following screen<br />you will see the default path Apache installs to:</p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhs4LEycaomVqANv2w9QRGCRfg2TYg76WZofNjPtdWl_BbeWpVBqXH4u__sQT54y8AaKIhd7eOo-TEa9K-z2qmq9YUWYhvR0yPp1P-xIGEee3DyvZGDPID5pgXq9EzwSqor5ao86b7Q-vk/s1600-h/Apachescrn6.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhs4LEycaomVqANv2w9QRGCRfg2TYg76WZofNjPtdWl_BbeWpVBqXH4u__sQT54y8AaKIhd7eOo-TEa9K-z2qmq9YUWYhvR0yPp1P-xIGEee3DyvZGDPID5pgXq9EzwSqor5ao86b7Q-vk/s400/Apachescrn6.png" alt="" id="BLOGGER_PHOTO_ID_5225503822838031938" border="0" /></a><br /><br /><p>Click the "Change..." button (boxed in red in the picture), and choose the <code>WebServer</code> folder (or<br />whatever other name you chose) you made when you created the directory structure above. Click "Next".<br /></p><p>On the next screen click "Install". After it installs click "Finish". Congratulations, you just installed Apache.<br />It is located in your <code>WebServer</code> folder in the <code>Apache2</code> directory.<br /></p><p>Let's make sure it worked. Go to your programs folder in the Start menu and find the Apache HTTP Server folder.<br />Go to the Control Apache Server folder, and start Apache</p><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpwMPPHbD-qlbZKQFjuHX9frVHoXA2bZIur_3jr_bcoy60oxKtOXRkdQ-6Z6uGM9jWnwwcPNeSiwkJ5-XgjV6lEWHk8KfRP1x63a-zVnMg_HbUWsBF3zXDYPU4nf46hbV7eMXowIf3XVr/s1600-h/startapache.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpwMPPHbD-qlbZKQFjuHX9frVHoXA2bZIur_3jr_bcoy60oxKtOXRkdQ-6Z6uGM9jWnwwcPNeSiwkJ5-XgjV6lEWHk8KfRP1x63a-zVnMg_HbUWsBF3zXDYPU4nf46hbV7eMXowIf3XVr/s400/startapache.png" alt="" id="BLOGGER_PHOTO_ID_5225504245886631954" border="0" /></a><br /><br /><br /><br /><br /><p>If you installed Apache as a service, you can also start it by double-clicking on the Apache Service Monitor<br />tray icon (which looks like: <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRnxWqf8aQPAipKjamzka-Ydj_8Hur8P0nvvgcAYeAgteJfy3b3MJxoNnmM3ihz9tHuhO5fShIZ06VhMRU2KHQ2UB0HLyrvmFqWSo-x3ead7yCOj2DS6LEVjQN65eEG8IIpojyrpILDkzs/s1600-h/apachetray.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRnxWqf8aQPAipKjamzka-Ydj_8Hur8P0nvvgcAYeAgteJfy3b3MJxoNnmM3ihz9tHuhO5fShIZ06VhMRU2KHQ2UB0HLyrvmFqWSo-x3ead7yCOj2DS6LEVjQN65eEG8IIpojyrpILDkzs/s400/apachetray.png" alt="" id="BLOGGER_PHOTO_ID_5225504247087983266" border="0" /></a>) and pressing the "Start" button in the window that appears.<br />If you did not install it as a service, you will see a blank command prompt window appear while Apache is running.<br />This is normal.<br /></p><p>The first time you run Apache, you will probably see a security warning pop up:</p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjz8SCaVWqLOy2W6pIuuY6gY5av7l-N-WqFVPtv4pjPQWSUsStGzjlShfzHp7xQPJDkKaNmSa08jhwqUCVG-J688f5bRviTwFZVKXxqSeN7rCp3IUBuDXVFd9KaTgctc1FTzVAny5ivqVM-/s1600-h/securitywarning.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjz8SCaVWqLOy2W6pIuuY6gY5av7l-N-WqFVPtv4pjPQWSUsStGzjlShfzHp7xQPJDkKaNmSa08jhwqUCVG-J688f5bRviTwFZVKXxqSeN7rCp3IUBuDXVFd9KaTgctc1FTzVAny5ivqVM-/s400/securitywarning.png" alt="" id="BLOGGER_PHOTO_ID_5225504618335393330" border="0" /></a><br /><br /><br /><p>This is because windows has detected that Apache is opening a port on your computer, and it is checking with you about whether it should let Apache continue. Click the "Unblock" button to allow Apache to function.</p><p><br /><strong>Note</strong>: While we're talking about these security warnings, it's worth noting that the Winows XP firewall is far from ideal, especially for advanced users. Even compared to most free alternatives, the best you can usually say is that it's <a href="http://netsecurity.about.com/od/firewalls/a/aa081804b.htm">better than nothing</a>. Especially if you're considering connecting your web server to the internet, you ought to get a separate firewall program.<br />Some good freeware/shareware alternatives are <a href="http://www.zonelabs.com/store/content/catalog/products/sku_list_za.jsp?dc=12bms&ctry=US&lang=en">ZoneAlarm</a>,<br /><a href="http://www.sunbelt-software.com/kerio.cfm">Kerio Personal Firewall</a>,<br /><a href="http://www.agnitum.com/products/outpostfree/download.php">Agnitum</a>, and<br /><a href="http://www.docsdownloads.com/spf.htm">Sygate Personal Firewall</a>.<br /></p><p>Now, let's open up a web browser and make sure Apache is running. Type in the name of your server (e.g. <code>localhost</code>, or your domain name or IP address) in the location bar of the browser. If you did not install Apache as a service, follow the server name with <code>:8080</code> (for example, if you are running the server as localhost, you would type <code>localhost:8080</code>. If Apache is working, you should see a page that looks like<br /></p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3iTjp1cDtRkB0aDJCf8Ai28XTmgWFe4xFcCId-73YcQivX5QQzGU2gqU4OKe2AK9-ODLcqfFxPmN5VkYoT_JJE200MFXJFzWXBt90zt1k1ooh_g-sTGmv7Tr4rJuujbBPBz1y9yeTAB5Z/s1600-h/defaultpage.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3iTjp1cDtRkB0aDJCf8Ai28XTmgWFe4xFcCId-73YcQivX5QQzGU2gqU4OKe2AK9-ODLcqfFxPmN5VkYoT_JJE200MFXJFzWXBt90zt1k1ooh_g-sTGmv7Tr4rJuujbBPBz1y9yeTAB5Z/s400/defaultpage.png" alt="" id="BLOGGER_PHOTO_ID_5225504616814970130" border="0" /></a><br /><br /><p>If so, you're ready to move on. If not, something is wrong. It is hard to be sure what, but it might help to ask for assistance in the <a href="http://www.expertsrt.com/phpBB2/">ERT forum</a>. Otherwise, your best<br />bet is to uninstall Apache and try again.</p><strong>Note if you did not install Apache as a service:</strong><br /><div class="codelisting"><p>Unless you have some reason for Apache to run on port 8080, it is far more convenient to run it on port 80 instead so that you do not have to add on :8080 to your server name every time you type it (port 80 is the default HTTP port). Go to your Apache2 folder, and open the file <code>httpd.conf</code> in the conf folder. On around line 956, you will see<br /></p><p><code>Listen 8080</code><br /></p><p>change that to<br /></p><p><code>Listen 80</code><br /></p><p>Save the httpd.conf file, and restart Apache (in the Service Monitor, or manually quit and<br />start it again if you have not installed Apache as a service). We'll do more configuration of Apache later.<br /></p></div><a name="getPHP"></a><h2>3. Download and Install PHP 5<br /></h2><p>The <a href="http://www.php.net/manual/install.windows.php">PHP documentation</a> is very good,<br />I encourage you to read it over a bit before proceeding, or if you get stuck/confused below.<br /></p><p>Start by going to the PHP.net <a href="http://www.php.net/downloads.php">download page</a> and getting the<br />PHP 5.x.x zip package under the "Windows Binaries" heading. It may seem easier to use the installer, but as you work with PHP, you will probably want to enable several extensions that are not enabled by default, and this is much simpler if you have installed PHP manually.<br /></p><p>After the zip file downloads, place it in your <code>WebServer\PHP</code> directory, and unzip it there. When<br />it is done decompressing all the files, you can delete the zip file. Notice that there are a few executables:<br /></p><ol><li><code>php-cgi.exe</code>: This is used when you run PHP through your webserver as a CGI executable.<br /></li><li><code>php-win.exe</code>: Executes scripts without having to have an open command prompt. You can drag your php scripts onto this program to execute them. You'll use this for local command line (command line interface, or CLI) programs.<br /></li><li><code>php.exe</code>: the CLI interface for command line scripting. You'll use this from the command prompt to execute PHP.<br /></li></ol><p>For PHP to work with Apache and to make the CLI available from any command prompt window, we need to add the PHP folder to the <code><i>PATH</i></code> environment variable. To do this,<br />right click on your "My Computer" icon (either on your desktop or the start menu) and select "Properties." In the window that pops up, select the advanced tab, and click on the "Environment Variables" button.<br /></p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCjk5OTTBbNSvkpcMyeuhI02UsHLJkFRHgd6I3RSVJqugcKcDcI9msj9TJuYRdS9aZ86VTfJC7G0ZddZdlZfaDNgnUm3d-hkiNuzlVkg-ViGiLVzHO6LYPG_f7hSgePKtr16f-l1V2670O/s1600-h/envvars.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCjk5OTTBbNSvkpcMyeuhI02UsHLJkFRHgd6I3RSVJqugcKcDcI9msj9TJuYRdS9aZ86VTfJC7G0ZddZdlZfaDNgnUm3d-hkiNuzlVkg-ViGiLVzHO6LYPG_f7hSgePKtr16f-l1V2670O/s400/envvars.png" alt="" id="BLOGGER_PHOTO_ID_5225505668668050210" border="0" /></a><br /><br /><br /><p>In the window that appears, select the "Path" variable line from the "System Variables" menu, and click edit:</p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA7gQv1MS_1LatrKMAYCjOXzVl5ETb-XSS_-GzkwYqSBe058RT9VfmQRq7z3J6VytMLdAXnpKcMKGe6sJbDUfAV_wlJFKSf9lXUJdeYv5jWKLSkTJeZw9uhanB_Hc4i6G_-qrtWX79jsqZ/s1600-h/envvarpath.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA7gQv1MS_1LatrKMAYCjOXzVl5ETb-XSS_-GzkwYqSBe058RT9VfmQRq7z3J6VytMLdAXnpKcMKGe6sJbDUfAV_wlJFKSf9lXUJdeYv5jWKLSkTJeZw9uhanB_Hc4i6G_-qrtWX79jsqZ/s400/envvarpath.png" alt="" id="BLOGGER_PHOTO_ID_5225505671376805474" border="0" /></a><br /><br /><p>At the end of the "Variable Value" field, type a semicolon (;) and the type in the full path to your<br />PHP folder. For me, this means typing the following at the end of the "Variable Value" field:<br /><code>;D:\Web\WebServer\PHP</code>. </p><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheDSnei6lXn_GHt_arS65Wh5nYVRe7bDi7tWS1779TlGtPhVN08S8Y7UKsS0FyuDmwo4LTIuZfKsbccwr9LCliGvbPanHrJiRNPDIlNFnWHMCGteygPcURiHmEyLCGs8p2MzWKDYhj9tCF/s1600-h/addpath.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheDSnei6lXn_GHt_arS65Wh5nYVRe7bDi7tWS1779TlGtPhVN08S8Y7UKsS0FyuDmwo4LTIuZfKsbccwr9LCliGvbPanHrJiRNPDIlNFnWHMCGteygPcURiHmEyLCGs8p2MzWKDYhj9tCF/s400/addpath.png" alt="" id="BLOGGER_PHOTO_ID_5225505669828808498" border="0" /></a><br /><p>Hit OK in each window until they have all closed, and restart your computer.<br />Pick up back here when you've restarted.<br /></p><p>OK, you restarted and you're back. Let's make sure PHP is working. Go to Start->Run and type <code>cmd </code>and press OK to bring up a command window. At the command prompt, type <code>php -v</code> and press Enter. If you updated the <code><i>PATH</i></code> varaible correctly, you should see something like:<br /></p><div class="codelisting"><code></code><pre><br />PHP 5.1.2 (cli) (built: Jan 11 2006 16:40:00)<br />Copyright (c) 1997-2006 The PHP Group<br />Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies<br /></pre>If you get an error message like,<br /></div><p>"<code>php is not recognized as an internal or external command,<br />operable program or batch file</code>" go back and check to make sure you completed all the steps<br />of adding your PHP folder to your PATH variable, and that you typed the file path correctly.<br /></p><p>Now open you PHP folder, and change the name of the file <code>php.ini-recommended</code><br />to <code>php.ini</code>. The settings in this file are all pretty much exactly as they should be.<br />If you are installing Apache and PHP on your own system for testing purposes, it is probably a good idea to open your <code>php.ini</code> file in a text editor, and change the setting on or about line<br />357 from <code>display_errors = Off</code> to <code>display_errors = On</code> so that you will see any errors generated by your scripts and will be able to easily debug them. If you are planning on making<br />your server public, it is best to leave this setting <code>Off</code>, because displaying errors can expose information about your file system, databases, and server configuration that should be kept private. Either way, the setting on line 367, <code>log_errors = On</code> will ensure that you will have a log of errors that you can review.<br /></p>Make the following changes to the file:<br /><p>Line 512: <code>doc_root = D:\Web\WebServer\Apache2\htdocs</code><br /></p><p>Line 519: <code>extension_dir = D:\Web\WebServer\PHP\ext</code><br /></p><p>Save the <code>php.ini</code> file and close it. You can find more information about<br />configuring PHP in the <a href="http://www.php.net/manual/configuration.php">Runtime Configuration</a> section<br />of the PHP manual.<br /></p><a name="ConfigApache"></a><h2>4. Configuring Apache<br /></h2><p>Now that we've got PHP and Apache working separately, we need to get get them to work together.<br />Go to your <code>Apache2/conf</code> folder, and open up the <code>httpd.conf</code> file in a text<br />editor. You can get Apache to run PHP as either a CGI binary, or an Apache Module. Generally speaking,<br />it is faster and more secure to do the latter, which you do by adding the following to your<br /><code>httpd.conf</code> file:<br /></p><ol><li><p> At the top of the LoadModule section, starting around line 130, add the line<br /></p><p><code>LoadModule php5_module "D:/Web/WebServer/PHP/php5apache2.dll"</code><br /></p><p>(note those are foward slashes, not backslashes, in the path) where you<br />replace <code>"D:/Web/WebServer/PHP/php5apache2.dll"</code> with the path to <code>php5apache2.dll</code> on your computer (note: if you are installing Apache 2.2, you should use the <code>php5apache2_2.dll</code> file instead). You can actually add settings anywhere you would like, but putting the similar ones together helps keep things organized.<br /></p></li><li><p> In the AddType section around line 754, add the following line:<br /></p><p><code>AddType application/x-httpd-php .php</code><br /></p><p>You can add other extensions besides <code>.php</code> if you want PHP to parse other file types as well. For example, if you want to be able to include PHP in <code>.html</code> documents:<br /></p><p><code>AddType application/x-httpd-php .php .html</code><br /></p></li><li><p>Finally, add the following line, somewhere that seems sensible to you:<br /></p><p><code>PHPIniDir "D:/Web/WebServer/PHP/"</code><br /></p><p>(again, replace the path I used with the one you chose on your computer).<br /></p></li></ol><div class="codelisting"><p><strong>Note</strong>: If Apache does not seem to recognize your <code>PHPIniDir</code> directive,<br />make sure you have the trailing slash (i.e. <strong>not</strong> <code>PHPIniDir "D:/Web/WebServer/PHP"</code>), as mentioned in the <a href="http://www.php.net/manual/en/install.windows.apache2.php#54389">user comments</a> in the PHP manual<br /></p></div><p>Save the <code>httpd.conf</code> file, and start Apache as discussed above (or restart it if it is running).<br /></p><p>If for some reason you need to run PHP as a CGI binary, add these lines to your <code>httpd.conf</code> file instead.<br /></p><div class="codelisting"><pre>ScriptAlias /php/ "D:/Web/WebServer/PHP/"<br />AddType application/x-httpd-php .php<br />Action application/x-httpd-php "/PHP/php-cgi.exe"<br /></pre></div>Note that you cannot run PHP as a module and a CGI at the same time. If you are switching between the two types of setups, you'll need to comment-out (with a hash sign <code>#</code>) or delete the existing configuration lines before adding the new ones. Each time you change the server configuration by editing <code>httpd.conf</code>, you'll need to restart Apache for the changes to take effect.<br /><p>Open your <code>Apache2htdocs</code> folder. This is the root folder for all of your web server documents that you will view in your web browser. Start by erasing all the default files currently in there. Next, make a file called <code>phpinfo.php</code> that contains the following:<br /></p><p><code><?php phpinfo(); ?></code></p><p><code></code>and save it in your <code>htdocs</code> folder. Now open a web browser and go to <code></code></p><p><code>http://localhost/phpinfo.php</code>. You should see a page that looks like<br /></p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA6O6b3_d7FpQOLETpSAZTeFX_tTdD-QYiLfR7jg1DEct1Yc9GEtuhAXEG3Zgg_Kh658uQedom5P6S4epaQcZ4c807eSPobfM_sIUYqT_SuZ5DmYKOaCG1ER7T1AL6LtjqTYhvMJSHl9dn/s1600-h/phpinfo.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA6O6b3_d7FpQOLETpSAZTeFX_tTdD-QYiLfR7jg1DEct1Yc9GEtuhAXEG3Zgg_Kh658uQedom5P6S4epaQcZ4c807eSPobfM_sIUYqT_SuZ5DmYKOaCG1ER7T1AL6LtjqTYhvMJSHl9dn/s400/phpinfo.png" alt="" id="BLOGGER_PHOTO_ID_5225507404249929730" border="0" /></a><br /><br /><p>If not, make sure that all the lines that you added to your httpd.conf file are exactly as they appear above (including the trailing slashes where applicable), and that all paths are correct.<br /></p><br /><a name="extras"></a><h2>5. Some extra steps: Setting up a development environment and installing MySQL<br /></h2><p>In principle, we're done. You can now start writing your own PHP scripts in your <code>htdocs</code> folder<br />and viewing them in your web browser (when Apache is running, of course) at <code>http://localhost</code> or whatever URL where you have chosen to locate your webserver. There are a couple more things that are good to do in practice in order to set yourself up with a nice working environment.<br /></p><ul><li> <p>Place some shortcuts on your desktop. Add one for your <code>htdocs</code> folder for easy access, and another to start Apache (if you're running Apache as a module, you can just as easily use the service monitor).<br /></p><p>Add a folder called <code>PHPCLI</code> to your <code>WebServer</code> directory, where you can will keep you command line PHP scripts. Place a shortcut to this on your desktop too, and make a file called <code>PHPFolder.bat</code> on your desktop that contains the following lines:<br /></p><p><code>D:<br />cmd /k cd D:\Web\WebServer\PHPCLI</code><br /></p><p>This will open a command prompt in your <code>PHPCLI</code> folder so that you can easily test and run your CLI scripts.<br /></p></li><li> <p>Enable some extensions. Open up your php.ini file again, and go to abou line 620. There are a whole bunch of lines that look like<br /></p><div class="codelisting"><pre>;extension=php_mbstring.dll<br />;extension=php_bz2.dll<br />;extension=php_curl.dll<br />;extension=php_dba.dll<br />;extension=php_dbase.dll<br />;extension=php_exif.dll<br />;extension=php_fdf.dll<br />;extension=php_filepro.dll<br />;extension=php_gd2.dll<br />;extension=php_gettext.dll<br />;extension=php_ifx.dll<br />;extension=php_imap.dll<br />;extension=php_interbase.dll<br />;extension=php_ldap.dll<br />;extension=php_mcrypt.dll<br />;extension=php_mhash.dll<br /></pre></div><p>The semicolon (<code>;</code>) is the comment symbol in the <code>php.ini</code> (don't confuse it with the <code>#</code><br />in the <code>httpd.conf</code>), and thus these lines are commented-out, and the extensions are not running. To enable any extensions that you want, just remove the semicolon at the beginning of the line.<br /></p></li></ul><p>Some of the extensions, such as MySQL, require that you have other software installed. In fact, as an added bonus, here's how to install MySQL:<br /></p><a name="InstallMySQL"></a><h3>Installing MySQL Server<br /></h3><ol><li> <p>Go to <a href="http://dev.mysql.com/downloads/mysql/5.0.html">the MySQL website</a> and download the installer.<br />You want the Windows (x86) version (you'll have to scroll down a bit to see it -- don't confuse it with the Windows Essentials version). Note the MD5 checksum, which<br />we'll use in step 2. Choose a mirror that is a close to you a possible and download the zip file (or just click "Download" and one will be chosen for you).<br /></p> </li><li> <p>Check the MD5 checksum with the value they have next to the download link on the site.<br />You do this in the same way you did for Apache <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#getApache">above</a>, but this time using the name of the zip file, e.g.<br /></p><p><code>md5sums -p -n -b mysql-5.0.18-win32.zip</code><br /></p><p>If it checks out, unzip the file (this will produce a file called <code>Setup.exe</code>), and delete the zip file after it's done. If the checksum does not match, download again from another mirror.<br /></p></li><li> <p>Make a <code>MySQL</code> folder in your <code>WebServer</code> directory. Run <code>Setup.exe</code>.<br />Click "Next" at the first screen.<br />At the second screen, choose "Custom" for the installation type and click "Next". Click on the "Change" button in the lower left to change the installation directory, and point it to the <code>MySQL</code> folder youjust created:</p><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCihu9JYzu1veySDc_EHg-aFCS1ehaRZ7uxpYyjYKxeIchxljhHMFCqbkMJyqOH3BuRcFiCCjonAUy14wWRyCTf9qHLvPDWz64EG9Cnj5drtp1hnbLXLNeZa7ftOWmMOQjgtNK1Q4VqdtK/s1600-h/MySQL.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCihu9JYzu1veySDc_EHg-aFCS1ehaRZ7uxpYyjYKxeIchxljhHMFCqbkMJyqOH3BuRcFiCCjonAUy14wWRyCTf9qHLvPDWz64EG9Cnj5drtp1hnbLXLNeZa7ftOWmMOQjgtNK1Q4VqdtK/s400/MySQL.png" alt="" id="BLOGGER_PHOTO_ID_5225509092363944002" border="0" /></a><br /><br /><p>Then click "Install" and let it do its thing. When it's done, you can sign up for a MySQL.com account if you want to. Otherwise, choose "Skip Sign-Up" in the bottom left and press Next, and then press Finish on the next screen.<br /></p></li><li> <p>The MySQL Server Instance Configuration Wizard will pop up. Click "Next". Choose "Detailed Configuration"<br />and click "Next". Answer the questions according to what kind of machine your computer is. The instructions are fairly straight forward. On the Windows Options Page, you may want to un-check the "Launch MySQLServer automatically" option, and check the Include Bin Directory in Windows <code><i>PATH</i></code> so that you can use the MySQL server from the windows command line. It is easiest to Run MySQL as a Windows service.</p><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrjKWmzhIuWGjirwFywm_u_a18B4mBInzseLaRD3A1srWSHNwPbQGd-yY1v_owjIce20jiUytB_xiggJbo6a7C5aAfFfRzvmT3BKH5lXNuZQHTZ-uj15YpJwEn5Tm3ac6vDnrJrsvneYWj/s1600-h/MySQL2.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrjKWmzhIuWGjirwFywm_u_a18B4mBInzseLaRD3A1srWSHNwPbQGd-yY1v_owjIce20jiUytB_xiggJbo6a7C5aAfFfRzvmT3BKH5lXNuZQHTZ-uj15YpJwEn5Tm3ac6vDnrJrsvneYWj/s400/MySQL2.png" alt="" id="BLOGGER_PHOTO_ID_5225507414788852194" border="0" /></a><br /><br /><br /><p>Note that you can use the Apache Service monitor to start and stop MySQL (and other services).<br /></p><p>On the next screen, pick a root password. This is the main "superuser" password for your server:<br /></p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCBaF2JIxZwhlI4hNaeMYlavEoJfzLRmigfQ1P6r6N_tJKiUpBN7oKGVh2PDtq7RG8qhdqcQRfVHQVDoJforyz5devkBvcRKblYBZFf2Xo-iXB2SlEaqgnPXLTLyPS8H-DpnSwzR3wjWeM/s1600-h/MySQL3.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCBaF2JIxZwhlI4hNaeMYlavEoJfzLRmigfQ1P6r6N_tJKiUpBN7oKGVh2PDtq7RG8qhdqcQRfVHQVDoJforyz5devkBvcRKblYBZFf2Xo-iXB2SlEaqgnPXLTLyPS8H-DpnSwzR3wjWeM/s400/MySQL3.png" alt="" id="BLOGGER_PHOTO_ID_5225507419222066306" border="0" /></a><br /><br /><p>Finally, click the "Execute" button to configure your MySQL server:</p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3ug4qQWfo4zFp6paY6U_jlbAsqZZEqMqeULzFmCUs1lV5zTtIjR09JjWt5946Bhmt98ktoOsFRkjQndzYOTB5ajLrLVimDLPp3k_qSaSAEv-Z4G1ZD90hTmZKO15Q9qCWr1A7-R3JCWaW/s1600-h/MySQL4.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3ug4qQWfo4zFp6paY6U_jlbAsqZZEqMqeULzFmCUs1lV5zTtIjR09JjWt5946Bhmt98ktoOsFRkjQndzYOTB5ajLrLVimDLPp3k_qSaSAEv-Z4G1ZD90hTmZKO15Q9qCWr1A7-R3JCWaW/s400/MySQL4.png" alt="" id="BLOGGER_PHOTO_ID_5225507417698447538" border="0" /></a><br /><br /><br /><a name="reconfigMySQL"></a><p>Its not a big deal if you do not configure your server right at first, you can always run the config wizard again later. It is in your <code>MySQLbin</code> folder, <code>MySQLInstanceConfig.exe</code>.<br /></p></li><li>Restart (this is so your <code><i>PATH</i></code> variable gets updated).<br /></li><li> <p>Uncomment the line <code>extension=php_mysql.dll</code> (around line 650) in your <code>php.ini</code><br />and (re)start Apache.<br /></p></li><li> <p>Have a look at your <code>phpinfo.php</code> file. If you sucessfully set up MySQL, it should have a section that looks like this:<br /></p><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ikOxvQIaVRLUVWo4FnJDY_DLLSWVBjobgqWJBLYODNbse8ew8CLAO-WAPQfwZJsiCcAuVTLT_ULA3voFE6ebbT37gdrSbWQjmMnbmeEc1jf8pkO48o4yqbaHIAvsRD0lC-9Xp7iZ9oGR/s1600-h/mysqlphpinfo.png"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ikOxvQIaVRLUVWo4FnJDY_DLLSWVBjobgqWJBLYODNbse8ew8CLAO-WAPQfwZJsiCcAuVTLT_ULA3voFE6ebbT37gdrSbWQjmMnbmeEc1jf8pkO48o4yqbaHIAvsRD0lC-9Xp7iZ9oGR/s400/mysqlphpinfo.png" alt="" id="BLOGGER_PHOTO_ID_5225507409461918754" border="0" /></a><br /></li><br /></ol>That's all. Remember to use MySQL with PHP, it has to be running, and you need to create users, tables etc. for PHP to work with. Once MySQL is running, you can access it via the command line by typing <code>mysql -u root -p</code> and entering your root password (which you set during the MySQL installation) when prompted. You can also access the <code>mysqladmin</code> command this way to add other users to your databases (there is also a command line connection option in the MySQL section of your program list in the Start menu).<br /><br /><h3>MySQL Administrator: A Graphical Interface<br /></h3><p> If you're not comfortable with using MySQL from the command line (or even if you are), you might want to get yourself a graphical administration tool. Several GUIs are available; I use the one made by MySQL, called the <a href="http://dev.mysql.com/downloads/administrator/1.1.html">MySQL Administrator</a>. Just download it<br />(be sure to check the MD5 checksum), and run the installer choosing the "Complete" installation type. You can install it anywhere you'd like (I put mine in my <code>Program Files</code> folder). Have a look at the <a href="http://dev.mysql.com/doc/administrator/en/index.html">documentation</a> for more information about using MySQL Administrator.<br /></p><div class="codelisting"><p><strong>Note:</strong> A couple times when I've installed MySQL Server and Administrator, I had trouble connecting to MySQL using the Administrator, even though it worked fine from the command line. I spent a very long time trying to figure out why this happened, and was never able to figure it out for sure. If this happens to you, try reconfiguring MySQL as described <a href="http://www.blogger.com/post-edit.g?blogID=8488539832279332237&postID=2214931265631962995#reconfigMySQL">above</a> (maybe you made a mistake the first time). If that doesn't work, the problem has always been solved for me by simply uninstalling both the Server and the Administrator (use the Add and Remove Programs option in your Windows XP Control Panel) and reinstalling.<br /></p></div><a name="conclude"></a><h2>6. Conclusion<br /></h2><p>Congratulations! You've got a great environment set up for building an testing websites and web applications. Hopefully you didn't find the process too painful. Have fun with it!</p></div><br /><div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com7tag:blogger.com,1999:blog-8488539832279332237.post-85793059775263850262008-07-15T10:26:00.000-07:002008-09-12T23:49:06.415-07:00PHP-Mysql Interview Questions<strong>Q:1</strong><br /><strong>How can we submit a form without a submit button? </strong><br /><br /><strong>A:1</strong><br />The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you<br />can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).<br /><br /><strong>Q:2</strong><br /><strong>In how many ways we can retrieve the data in the result set of MySQL using PHP? </strong><br /><br /><strong>A:2</strong><br />You can do it by 4 Ways<br />1. mysql_fetch_row.<br /><br />2. mysql_fetch_array<br /><br />3. mysql_fetch_object<br /><br />4. mysql_fetch_assoc<br /><br /><strong>Q:3</strong><br /><strong>What is the difference between mysql_fetch_object and mysql_fetch_array? </strong><br /><br /><strong>A:3</strong><br /><strong>mysql_fetch_object()</strong> is similar to<strong>mysql_fetch_array()</strong>, with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).<br /><br /><strong>Q:4</strong><br /><strong>What is the difference between $message and $$message? </strong><br /><strong>A:4</strong><br />It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan<br />with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.<br /><br /><strong>Q:5</strong><br /><strong>How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’<br />using regular expression of PHP? </strong><br /><br /><strong>A:5</strong><br />preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);<br /><br />echo $found[1];<br /><br /><strong>Q:6</strong><br /><strong>How can we create a database using PHP and MySQL? </strong><br /><br /><strong>A:6</strong><br />We can create MySQL database with the use of<br /><br />mysql_create_db(“Database Name”)<br /><br /><strong>Q:7</strong><br /><strong>What are the differences between require and include, include_once and require_once? </strong><br /><br /><strong>A:7</strong><br />The <strong>include()</strong> statement includes and evaluates the specified file.The documentation below also applies to <strong>require()</strong>. The two constructs are identical in every way except how they handlefailure. <strong>include()</strong> produces a Warning while <strong>require()</strong> results in a Fatal Error. In other words, use <strong>require()</strong> if you want a missingfile to halt processing of the page.<br /><p class="sect1"><strong>include()</strong> does not behave this way, the script will continue regardless.</p>The <strong>include_once()</strong> statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the <strong>include()</strong> statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.<strong>include_once()</strong> should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.<strong><br />require_once()</strong> should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.<br /><br /><p><strong>Q:8</strong><br /><strong>Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?<br /></strong></p><p><strong></strong><strong>A:8</strong><br />Yes we can use include() more than one time in any page though it is not a very good practice.</p><br /><br /><p><strong>Q:9</strong><br /><strong>What are the different tables present in MySQL, which type of table is generated when we are creating a table in the following syntax:<br />create table employee (eno int(2),ename varchar(10)) ? </strong><br /><br /><strong>A:9</strong><br />Total 5 types of tables we can create<br />1. MyISAM<br />2. Heap<br />3. Merge<br />4. INNO DB<br />5. ISAM<br /><br />MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.<br /><br /><strong>Q:10</strong><br /><strong>How can we encrypt the username and password using PHP? </strong><br /><strong>A:10</strong><br />The functions in this section perform encryption and decryption, and compression and uncompression:<br /><span class="bold"><strong><span style="font-size:85%;">encryption</span></strong></span><span class="bold"><strong><span style="font-size:85%;"> decryption</span></strong></span><br /></p><p><span style="font-size:85%;">AES_ENCRYT() </span><span style="font-size:85%;">AES_DECRYPT()</span><span style="font-family:monospace;"><br /></span></p><p>ENCODE() DECODE()</p><pre id="line548">DES_ENCRYPT() DES_DECRYPT()<br /><br />ENCRYPT() Not available<br /><br />MD5() Not available<br /><br />OLD_PASSWORD() Not available<br /><br />PASSWORD() Not available<br /><br />SHA() or SHA1() Not available<br /><br />Not available UNCOMPRESSED_LENGTH() </pre><br /><br /><div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com185tag:blogger.com,1999:blog-8488539832279332237.post-91724712167611855022008-07-15T06:09:00.000-07:002008-09-12T23:49:06.417-07:00Get Flash Designing tipsYou can get Flash Designing tips,Slideshow using flash & XML, Highslides using accordian in <a href="http://myinnovativeidea.blogspot.com/">myinnovativeidea.blogspot.com</a><br /><br /><div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com1tag:blogger.com,1999:blog-8488539832279332237.post-37244635111857238372008-06-19T02:25:00.000-07:002008-09-12T23:49:06.419-07:00Simple Ajax Coding<div style="TEXT-ALIGN: right"><a href="http://www.odesk.com/users/~~57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div><br />var xmlHttp // xmlHttp variable<br />function GetXmlHttpObject() { var objXMLHttp = null;<br />if( window.XMLHttpRequest ) {<br />try {<br />objXMLHttp = new XMLHttpRequest();<br />}<br />catch( e ) {<br />objXMLHttp = false; }<br />}<br />else if( window.createRequest ) {<br />try {<br />objXMLHttp = new window.createRequest();<br />}<br />catch( e ) {<br />objXMLHttp = false;<br />}<br />}<br />else if( window.ActiveXObject ) {<br />try {<br />objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");<br />}<br />catch( e ) {<br />try {<br />objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch( e ) {<br />objXMLHttp = false;<br />}<br />}<br />}<br />return objXMLHttp;<br />}<br />function search_subcategory(){<br />//alert('sdfsdf');<br />document.getElementById('subcategory_label').style.display="none";<br />xmlHttp=GetXmlHttpObject()<br />if (xmlHttp==null){<br />alert ("Browser does not support HTTP Request")<br />return<br />}<br />var val = document.getElementById('category').value;<br />var url="dropdown.php?val="+val;//alert(url);<br />xmlHttp.onreadystatechange = response;xmlHttp.open("GET",url,true);<br />xmlHttp.send(null);<br />function response(){<br />if (xmlHttp.readyState == 4) {<br />var x =xmlHttp.responseText;<br />document.getElementById('subcategory_label').style.display="block"; document.getElementById('subcategory_label').innerHTML = x; }<br />else {<br />document.getElementById(y).style.display = "block";<br />document.getElementById(y).innerHTML ="Loading...";<br />}<br />}<br />}Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com3tag:blogger.com,1999:blog-8488539832279332237.post-76079315364400136992008-05-27T01:37:00.000-07:002008-09-12T23:49:06.421-07:00HighSlide works<div style="text-align: right;"><a href="http://www.odesk.com/users/%7E%7E57f8774744970b17" target="_blank"><img alt="oDesk Certified Software Testing Engineer" src="http://www.odesk.com/api/exams/16611/image" border="0" /></a><br /></div>Place the below coding in any HTML file<br />------------------------------------------------------------------------------------<br />Place it in header<br />------------------------------------------------------------------------------------<br /><1script type="text/javascript" src="highslide.js"><1/script><br /><1script type="text/javascript"><br />hs.graphicsDir = 'js/graphics/';<br />hs.outlineType = 'rounded-white';<br />hs.outlineWhileAnimating = true;<br /><1/script><br />------------------------------------------------------------------------------------<br /><1div class="highslide-html-content" id="highslide-html-newsletter"><br /><1div class="highslide-header"><br /> <1ul><br /> <1li class="highslide-move"><br /> <1ahref="http://www.blogger.com/post-create.g?blogid=8488539832279332237#" onclick="return false">Move<br /> <1/li><br /> <1li class="highslide-close"><br /> <1a href="http://www.blogger.com/post-create.g?blogID=8488539832279332237#" onclick="return hs.close(this)">Close <br /> <1/ul><br /><1/div><br /><1div class="highslide-body"><br /><1!--><br /><1/div><br /><1div class="highslide-footer"><br /><1div><br /> <1span class="highslide-resize" title="Resize"><br /> <1/span> <1/div><br /><1/div><br /><1/div><br /><br />Remove 1 in every html tag<br />------------------------------------------------------------------------------------<br />Style sheet<br />Save the coding as slide.css<br />------------------------------------------------------------------------------------<br />* {<br />font-family: Verdana, Helvetica;<br />font-size: 10pt;<br />}<br />.highslide-html {<br />background-color:#FFC1FF;<br /><br /><br /><br />}<br />.highslide-html-blur {<br />}<br />.highslide-html-content {<br />position: absolute;<br />display: none;<br />}<br />.highslide-loading {<br />display: block;<br />color: black;<br />font-size: 8pt;<br />font-family: sans-serif;<br />font-weight: bold;<br />text-decoration: none;<br />padding: 2px;<br />border: 1px solid black;<br />background-color: white;<br /><br />padding-left: 22px;<br />background-image: url(highslide/graphics/loader.white.gif);<br />background-repeat: no-repeat;<br />background-position: 3px 1px;<br />}<br />a.highslide-credits,<br />a.highslide-credits i {<br />padding: 2px;<br />color: silver;<br />text-decoration: none;<br />font-size: 10px;<br />}<br />a.highslide-credits:hover,<br />a.highslide-credits:hover i {<br />color: white;<br />background-color: gray;<br />}<br /><br /><br />/* Styles for the popup */<br />.highslide-wrapper {<br />background-color: white;<br />}<br />.highslide-wrapper .highslide-html-content {<br />width: 350px;<br />padding: 5px;<br />}<br />.highslide-wrapper .highslide-header div {<br />}<br />.highslide-wrapper .highslide-header ul {<br />margin: 0;<br />padding: 0;<br />text-align: right;<br />}<br />.highslide-wrapper .highslide-header ul li {<br />display: inline;<br />padding-left: 1em;<br />}<br />.highslide-wrapper .highslide-header ul li.highslide-previous, .highslide-wrapper .highslide-header ul li.highslide-next {<br />display: none;<br />}<br />.highslide-wrapper .highslide-header a {<br />font-weight: bold;<br />color: red;<br />text-transform: uppercase;<br />text-decoration: none;<br />}<br />.highslide-wrapper .highslide-header a:hover {<br />color: black;<br />}<br />.highslide-wrapper .highslide-header .highslide-move a {<br />cursor: move;<br />}<br />.highslide-wrapper .highslide-footer {<br />height: 11px;<br />}<br />.highslide-wrapper .highslide-footer .highslide-resize {<br />float: right;<br />height: 11px;<br />width: 11px;<br />background: url(highslide/graphics/resize.gif);<br />}<br />.highslide-wrapper .highslide-body {<br />}<br />.highslide-move {<br />cursor: move;<br />}<br />.highslide-resize {<br />cursor: nw-resize;<br />}<br /><br />/* These must be the last of the Highslide rules */<br />.highslide-display-block {<br />display: block;<br />}<br />.highslide-display-none {<br />display: none;<br />}<br /><br />------------------------------------------------------------------------------<br />Now the highslide.js<br /><br /><br />var hs = {<br /><br />// Apply your own settings here, or override them in the html file.<br />graphicsDir : 'highslide/graphics/',<br />restoreCursor : 'zoomout.cur', // necessary for preload<br />expandSteps : 10, // number of steps in zoom. Each step lasts for duration/step milliseconds.<br />expandDuration : 250, // milliseconds<br />restoreSteps : 10,<br />restoreDuration : 250,<br />marginLeft : 15,<br />marginRight : 15,<br />marginTop : 15,<br />marginBottom : 15,<br />zIndexCounter : 1001, // adjust to other absolutely positioned elements<br /><br />restoreTitle : 'Click to close image, click and drag to move. Use arrow keys for next and previous.',<br />loadingText : 'Loading...',<br />loadingTitle : 'Click to cancel',<br />loadingOpacity : 0.75,<br />focusTitle : 'Click to bring to front',<br />allowMultipleInstances: true,<br />numberOfImagesToPreload : 5,<br />captionSlideSpeed : 1, // set to 0 to disable slide in effect<br />padToMinWidth : false, // pad the popup width to make room for wide caption<br />outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only<br />outlineStartOffset : 3, // ends at 10<br />fullExpandTitle : 'Expand to actual size',<br />fullExpandPosition : 'bottom right',<br />fullExpandOpacity : 1,<br />showCredits : true, // you can set this to false if you want<br />creditsText : 'Powered by Highslide JS',<br />creditsHref : 'http://vikjavev.no/highslide/',<br />creditsTitle : 'Go to the Highslide JS homepage',<br />enableKeyListener : true,<br /><br /><br />// These settings can also be overridden inline for each image<br />captionId : null,<br />spaceForCaption : 30, // leaves space below images with captions<br />slideshowGroup : null, // defines groups for next/previous links and keystrokes<br />minWidth: 200,<br />minHeight: 200,<br />allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight<br />outlineType : 'drop-shadow', // set null to disable outlines<br />wrapperClassName : 'highslide-wrapper', // for enhanced css-control<br /><br />// END OF YOUR SETTINGS<br /><br /><br />// declare internal properties<br />preloadTheseImages : [],<br />continuePreloading: true,<br />expanders : [],<br />overrides : [<br />'allowSizeReduction',<br />'outlineType',<br />'outlineWhileAnimating',<br />'spaceForCaption',<br />'captionId',<br />'captionText',<br />'captionEval',<br /><br />'wrapperClassName',<br />'minWidth',<br />'minHeight',<br />'slideshowGroup',<br />'easing',<br />'easingClose',<br />'fadeInOut'<br />],<br />overlays : [],<br />faders : [],<br /><br />pendingOutlines : {},<br />clones : {},<br />ie : (document.all && !window.opera),<br />safari : /Safari/.test(navigator.userAgent),<br />geckoMac : /Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),<br /><br />$ : function (id) {<br />return document.getElementById(id);<br />},<br /><br />push : function (arr, val) {<br />arr[arr.length] = val;<br />},<br /><br />createElement : function (tag, attribs, styles, parent, nopad) {<br />var el = document.createElement(tag);<br />if (attribs) hs.setAttribs(el, attribs);<br />if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0});<br />if (styles) hs.setStyles(el, styles);<br />if (parent) parent.appendChild(el);<br />return el;<br />},<br /><br />setAttribs : function (el, attribs) {<br />for (var x in attribs) el[x] = attribs[x];<br />},<br /><br />setStyles : function (el, styles) {<br />for (var x in styles) {<br />try {<br />if (hs.ie && x == 'opacity')<br />el.style.filter = (styles[x] == 1) ? '' : 'alpha(opacity='+ (styles[x] * 100) +')';<br />else el.style[x] = styles[x];<br />}<br />catch (e) {}<br />}<br />},<br /><br />ieVersion : function () {<br />var arr = navigator.appVersion.split("MSIE");<br />return arr[1] ? parseFloat(arr[1]) : null;<br />},<br /><br />getPageSize : function () {<br />var iebody = document.compatMode && document.compatMode != "BackCompat"<br />? document.documentElement : document.body;<br /><br />var width = hs.ie ? iebody.clientWidth :<br />(document.documentElement.clientWidth || self.innerWidth),<br />height = hs.ie ? iebody.clientHeight : self.innerHeight;<br /><br />return {<br />width: width,<br />height: height,<br />scrollLeft: hs.ie ? iebody.scrollLeft : pageXOffset,<br />scrollTop: hs.ie ? iebody.scrollTop : pageYOffset<br />}<br />},<br /><br />position : function(el) {<br />var p = { x: el.offsetLeft, y: el.offsetTop };<br />while (el.offsetParent) {<br />el = el.offsetParent;<br />p.x += el.offsetLeft;<br />p.y += el.offsetTop;<br />if (el != document.body && el != document.documentElement) {<br />p.x -= el.scrollLeft;<br />p.y -= el.scrollTop;<br />}<br />}<br />return p;<br />},<br /><br />expand : function(a, params, custom) {<br />if (a.getParams) return params;<br /><br />try {<br />new hs.Expander(a, params, custom);<br />return false;<br />} catch (e) { return true; }<br />},<br /><br />focusTopmost : function() {<br />var topZ = 0, topmostKey = -1;<br />for (var i = 0; i <> topZ) {<br />topZ = hs.expanders[i].wrapper.style.zIndex;<br /><br />topmostKey = i;<br />}<br />}<br />}<br />if (topmostKey == -1) hs.focusKey = -1;<br />else hs.expanders[topmostKey].focus();<br />},<br /><br />getAdjacentAnchor : function(key, op) {<br />var aAr = document.getElementsByTagName('A'), hsAr = {}, activeI = -1, j = 0;<br />for (var i = 0; i < slideshowgroup ="=" activei =" j;" getparams =" a.onclick;" p =" a.getParams" getparams =" null;" src =" hs.getParam(a," node =" hs.$(id)," clone =" hs.clones[id]," a =" {};" clone =" node.cloneNode(true);" id =" '';" a =" d.attributes," l =" a.length;" i =" 0;" n =" a[i].name;" a =" d.childNodes;" l =" a.length;" i =" 0;" exp =" hs.last" adj =" hs.upcoming" e =" window.event;" target =" e.srcElement;" op =" null;" op =" 1;" op =" -1;" op =" 0;" returnvalue =" false;" op ="=" re =" /^highslide-wrapper-([0-9]+)$/;" el =" element;" el =" el.parentNode;" el =" element;" key =" 0;" exp =" hs.expanders[key];" a ="=" el =" el.parentNode;" el ="=" el ="=" el ="=" el =" hs.$(el);" i =" 0;" e =" window.event;"> 1) return true;<br />if (!e.target) e.target = e.srcElement;<br /><br />var el = e.target;<br />while (el.parentNode<br />&& !(/highslide-(image|move|html|resize)/.test(el.className)))<br />{<br />el = el.parentNode;<br />}<br />var exp = hs.getExpander(el);<br />if (exp && (exp.isClosing || !exp.isExpanded)) return true;<br /><br />if (exp && e.type == 'mousedown') {<br />if (e.target.form) return true;<br />var match = el.className.match(/highslide-(image|move|resize)/);<br />if (match) {<br />hs.dragArgs = { exp: exp , type: match[1], left: exp.x.min, width: exp.x.span, top: exp.y.min,<br />height: exp.y.span, clickX: e.clientX, clickY: e.clientY };<br /><br />//if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move';<br /><br />hs.addEventListener(document, 'mousemove', hs.dragHandler);<br />if (e.preventDefault) e.preventDefault(); // FF<br /><br />if (/highslide-(image|html)-blur/.test(exp.content.className)) {<br />exp.focus();<br />hs.hasFocused = true;<br />}<br />return false;<br />}<br />} else if (e.type == 'mouseup') {<br /><br />hs.removeEventListener(document, 'mousemove', hs.dragHandler);<br /><br />if (hs.dragArgs) {<br />if (hs.dragArgs.type == 'image')<br />hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;<br />var hasDragged = hs.dragArgs.hasDragged;<br /><br />if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) {<br />exp.close();<br />}<br />else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)) {<br />hs.dragArgs.exp.redoShowHide();<br />}<br /><br />hs.hasFocused = false;<br />hs.dragArgs = null;<br /><br />} else if (/highslide-image-blur/.test(el.className)) {<br />el.style.cursor = hs.styleRestoreCursor;<br />}<br />}<br />return false;<br />},<br /><br />dragHandler : function(e)<br />{<br />if (!hs.dragArgs) return true;<br />if (!e) e = window.event;<br />var a = hs.dragArgs, exp = a.exp;<br /><br />a.dX = e.clientX - a.clickX;<br />a.dY = e.clientY - a.clickY;<br /><br />var distance = Math.sqrt(Math.pow(a.dX, 2) + Math.pow(a.dY, 2));<br />a.hasDragged = (a.type != 'image' && distance > 0)<br />|| (distance > (hs.dragSensitivity || 5));<br /><br />if (a.hasDragged) {<br />exp.move(a);<br />}<br />return false;<br />},<br /><br />addEventListener : function (el, event, func) {<br />try {<br />el.addEventListener(event, func, false);<br />} catch (e) {<br />try {<br />el.detachEvent('on'+ event, func);<br />el.attachEvent('on'+ event, func);<br />} catch (e) {<br />el['on'+ event] = func;<br />}<br />}<br />},<br /><br />removeEventListener : function (el, event, func) {<br />try {<br />el.removeEventListener(event, func, false);<br />} catch (e) {<br />try {<br />el.detachEvent('on'+ event, func);<br />} catch (e) {<br />el['on'+ event] = null;<br />}<br />}<br />},<br /><br />preloadFullImage : function (i) {<br />if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') {<br />var img = document.createElement('img');<br />img.onload = function() { hs.preloadFullImage(i + 1); };<br />img.src = hs.preloadTheseImages[i];<br />}<br />},<br />preloadImages : function (number) {<br />if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;<br />var a, re, j = 0;<br /><br />var aTags = document.getElementsByTagName('A');<br />for (var i = 0; i < a =" aTags[i];" re =" hs.isHsAnchor(a);" cur =" hs.createElement('img'," container =" hs.createElement('div'," loading =" hs.createElement('a'," lineartween =" function" easeinquad =" function" i ="=" dur =" 250;" i =" hs.faders.length;" dir =" oFinal"> o ? 1 : -1;<br />var step = (25 / (dur - dur % 25)) * Math.abs(o - oFinal);<br />}<br />o = parseFloat(o);<br />el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; if (o < dir ="="> oFinal)) return;<br />if (el.fading && el.fading.i != i) { // reverse<br />clearTimeout(hs.faders[el.fading.i]);<br />o = el.fading.o;<br />}<br />el.fading = {i: i, o: o, step: (step || el.fading.step)};<br />el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; hs.setStyles(el, { opacity: o }); hs.faders[i] = setTimeout(function() { hs.fade(el, o + el.fading.step * dir, oFinal, null, i, dir); }, 25); }, close : function(el) { try { hs.getExpander(el).close(); } catch (e) {} return false; } }; // end hs object //----------------------------------------------------------------------------- hs.Outline = function (outlineType, onLoad) { this.onLoad = onLoad; this.outlineType = outlineType; var v = hs.ieVersion(), tr; this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < table =" hs.createElement(" tbody =" hs.createElement('tbody'," td =" [];" i =" 0;" 3 ="=" tr =" hs.createElement('tr'," style =" i" classname =" outlineType;" prototype =" {" src =" hs.graphicsDir" appendto =" hs.safari" graphic =" hs.createElement('img'," pthis =" this;" onload =" function()" src =" src;" o =" this.offset" pos =" [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]]," dim =" {" i =" 0;" w =" (i" i ="=" div =" hs.createElement('div'," sizingmethod="scale," src="'" i ="=" i ="=" visibility =" (h">= 4 * this.offset)<br />? 'visible' : 'hidden';<br />this.table.style.left = (x - this.offset) +'px';<br />this.table.style.top = (y - this.offset) +'px';<br />this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px';<br />w += 2 * (exp.offsetBorderW - this.offset);<br />h += + 2 * (exp.offsetBorderH - this.offset);<br />this.td[4].style.width = w >= 0 ? w +'px' : 0;<br />this.td[4].style.height = h >= 0 ? h +'px' : 0;<br />if (this.hasAlphaImageLoader) this.td[3].style.height<br />= this.td[5].style.height = this.td[4].style.height;<br />},<br /><br />destroy : function(hide) {<br />if (hide) this.table.style.visibility = 'hidden';<br />else {<br />hs.purge(this.table);<br />try { this.table.parentNode.removeChild(this.table); } catch (e) {}<br />}<br />}<br />};<br /><br />//-----------------------------------------------------------------------------<br />// The expander object<br />hs.Expander = function(a, params, custom, contentType) {<br />this.a = a;<br />this.custom = custom;<br />this.contentType = contentType || 'image';<br />this.isImage = !this.isHtml;<br /><br />hs.continuePreloading = false;<br />hs.genContainer();<br />var key = this.key = hs.expanders.length;<br /><br />// override inline parameters<br />for (var i = 0; i < name =" hs.overrides[i];" el =" this.thumb" thumbsusersetid =" el.id" i =" 0;" a ="=" i =" 0;" overlays =" [];" pos =" hs.position(el);" thumbwidth =" el.width" thumbheight =" el.height" thumbleft =" pos.x;" thumbtop =" pos.y;" thumboffsetborderw =" (this.thumb.offsetWidth" thumboffsetborderh =" (this.thumb.offsetHeight" wrapper =" hs.createElement(" onmouseover =" function" onmouseout =" function" contenttype ="=" outlinewhileanimating ="=" outlinewhileanimating =" 0;" exp =" this;" prototype =" {" w =" hs.pendingOutlines[this.outlineType];" objoutline =" w;" zindex =" this.wrapper.style.zIndex;" originalcursor =" this.a.style.cursor;" cursor =" 'wait';" loading =" hs.loading;" exp =" this;" onclick =" function()" top =" (this.thumbTop" exp =" this," left =" (this.thumbLeft" left =" left" exp =" this;" img =" document.createElement('img');" content =" img;" onload =" function" oncontextmenu =" function()" classname =" 'highslide-image';" visibility =" 'hidden';" display =" 'block';" position =" 'absolute';" maxwidth =" 'none';" zindex =" 3;" title =" hs.restoreTitle;" src =" null;" src =" hs.getSrc(this.a);" onloadstarted =" true;" left =" '-9999px';" loading =" null;" cursor =" this.originalCursor" marginbottom =" hs.marginBottom;" newwidth =" this.content.width;" newheight =" this.content.height;" fullexpandwidth =" this.newWidth;" fullexpandheight =" this.newHeight;" width =" this.thumbWidth" height =" this.thumbHeight" position =" 'relative';" left =" this.thumbLeft" top =" this.thumbTop" offsetborderw =" (this.content.offsetWidth" offsetborderh =" (this.content.offsetHeight" modmarginright =" hs.marginRight" ratio =" this.newWidth" minwidth =" this.allowSizeReduction" minheight =" this.allowSizeReduction" justify =" {" page =" hs.getPageSize();" x =" {" oldright =" this.x.min" x =" this.justify(this.x);" y =" {" oldbottom =" this.y.min" y =" this.justify(this.y);" x =" this.x;" y =" this.y;" href =" hs.getSrc(this.a);" dim =" p" hasmovedmin =" false;" allowreduce =" true;" min =" Math.round(p.min" min =" p.scroll" hasmovedmin =" true;" span =" p.minSpan;" allowreduce =" false;"> p.scroll + p.clientSpan - p.marginMax) {<br />if (hasMovedMin && allowReduce) {<br /><br />p.span = p.clientSpan - p.marginMin - p.marginMax; // can't expand more<br /><br />} else if (p.span < min =" p.scroll" min =" p.scroll" span =" p.clientSpan" span =" p.minSpan;" allowreduce =" false;" tmpmin =" p.min;" min =" p.marginMin;" span =" p.span" x =" this.x;" y =" this.y;" changed =" false;"> ratio) { // width greater<br />var tmpWidth = x.span;<br />x.span = y.span * ratio;<br />if (x.span < imgspan =" x.span;" span =" x.minSpan;" span =" x.span" changed =" true;" tmpheight =" y.span;" span =" x.span" changed =" true;" min =" parseInt(this.thumbLeft)" minspan =" x.span;" x =" this.justify(x);" min =" parseInt(this.thumbTop)" minspan =" y.span;" y =" this.justify(y);" imgpos =" {x:" hideselects =" (hs.ie" hideiframes =" ((window.opera" vendor ="=" margin =" '0" n =" this.wrapper.childNodes.length;" i =" n">= 0 ; i--) {<br />var child = this.wrapper.childNodes[i];<br />if (child != this.content) {<br />hs.purge(child);<br />this.wrapper.removeChild(child);<br />}<br />}<br />}<br /><br />if (this.fadeInOut) {<br />from.op = up ? 0 : 1;<br />to.op = up;<br />}<br />var t,<br />exp = this,<br />easing = Math[this.easing] || Math.easeInQuad;<br />if (!up) easing = Math[this.easingClose] || easing;<br /><br />for (var i = 1; i <= steps; i++) { t = Math.round(i * (dur / steps)); (function(){ var pI = i, size = {}; for (var x in from) size[x] = easing(t, from[x], to[x] - from[x], dur); setTimeout ( function() { if (up && pI == 1) { exp.content.style.visibility = 'visible'; exp.a.className += ' highslide-active-anchor'; } exp.setSize(size); }, t); })(); } if (up) { setTimeout(function() { if (exp.objOutline) exp.objOutline.table.style.visibility = "visible"; }, t); setTimeout(function() { if (exp.caption) exp.writeCaption(); exp.afterExpand(); }, t + 50); } else setTimeout(function() { exp.afterClose(); }, t); }, setSize : function (to) { try { this.wrapper.style.width = (to.w + 2*this.offsetBorderW) +'px'; this.content.style.width = ((to.imgW && !isNaN(to.imgW)) ? to.imgW : to.w) +'px'; if (hs.safari) this.content.style.maxWidth = this.content.style.width; this.content.style.height = to.h +'px'; if (to.op) hs.setStyles(this.wrapper, { opacity: to.op }); if (this.objOutline && this.outlineWhileAnimating) { var o = this.objOutline.offset - to.o; this.objOutline.setPosition(this, to.x + o, to.y + o, to.w - 2 * o, to.h - 2 * o, 1); } hs.setStyles ( this.wrapper, { 'visibility': 'visible', 'left': to.x +'px', 'top': to.y +'px' } ); } catch (e) { window.location.href = hs.getSrc(this.a); } }, afterExpand : function() { this.isExpanded = true; this.focus(); this.createOverlays(); if (hs.showCredits) this.writeCredits(); if (this.isImage && this.fullExpandWidth > this.x.span) this.createFullExpand();<br />if (!this.caption) this.prepareNextOutline();<br />},<br /><br /><br />prepareNextOutline : function() {<br />var key = this.key;<br />var outlineType = this.outlineType;<br />new hs.Outline(outlineType,<br />function () { try { hs.expanders[key].preloadNext(); } catch (e) {} });<br />},<br /><br /><br />preloadNext : function() {<br />var next = hs.getAdjacentAnchor(this.key, 1);<br />if (next.onclick.toString().match(/hs\.expand/))<br />var img = hs.createElement('img', { src: hs.getSrc(next) });<br />},<br /><br />cancelLoading : function() {<br />hs.expanders[this.key] = null;<br />this.a.style.cursor = this.originalCursor;<br />if (this.loading) hs.loading.style.left = '-9999px';<br />},<br /><br />writeCredits : function () {<br />var credits = hs.createElement('a',<br />{<br />href: hs.creditsHref,<br />className: 'highslide-credits',<br />innerHTML: hs.creditsText,<br />title: hs.creditsTitle<br />}<br />);<br />this.createOverlay({ overlayId: credits, position: 'top left'});<br />},<br /><br />getCaption : function() {<br />if (!this.captionId && this.thumbsUserSetId)<br />this.captionId = 'caption-for-'+ this.thumbsUserSetId;<br />if (this.captionId) this.caption = hs.getNode(this.captionId);<br />if (!this.caption && !this.captionText && this.captionEval) try {<br />this.captionText = eval(this.captionEval);<br />} catch (e) {}<br />if (!this.caption && this.captionText) this.caption = hs.createElement('div',<br />{ className: 'highslide-caption', innerHTML: this.captionText } );<br /><br />if (!this.caption) {<br />var next = this.a.nextSibling;<br />while (next && !hs.isHsAnchor(next)) {<br />if (/highslide-caption/.test(next.className || null)) {<br />this.caption = next.cloneNode(1);<br />break;<br />}<br />next = next.nextSibling;<br />}<br />}<br />if (this.caption) {<br />this.marginBottom += this.spaceForCaption;<br />}<br /><br />},<br /><br />writeCaption : function() {<br />try {<br />hs.setStyles(this.wrapper, { width: this.wrapper.offsetWidth +'px',<br />height: this.wrapper.offsetHeight +'px' } );<br />hs.setStyles(this.caption, { visibility: 'hidden', marginTop: hs.safari ? 0 : '-'+ this.y.span +'px'});<br />this.caption.className += ' highslide-display-block';<br /><br />var height, exp = this;<br />if (hs.ie && (hs.ieVersion() < compatmode ="=" height =" this.caption.offsetHeight;" temp =" hs.createElement('div'," innerhtml =" '';" height =" this.caption.childNodes[0].offsetHeight;" innerhtml =" this.caption.childNodes[0].innerHTML;" height =" 'auto';" step =" (Math.round(height/50)" h =" height" t =" 0;" ph =" h," end =" (h" height =" height" visibility =" 'visible';" span =" this.wrapper.offsetHeight" o =" this.objOutline;" height =" (this.wrapper.offsetHeight" height =" o.td[5].style.height" els =" document.getElementsByTagName(tagName);" prop =" tagName" i =" 0;" prop ="=" hiddenby =" els[i].getAttribute('hidden-by');" visibility ="=" hiddenby =" hiddenBy.replace('['+" visibility ="=" elpos =" hs.position(els[i]);" w =" els[i].offsetWidth;" h =" els[i].offsetHeight;" clearsx =" (elPos.x"> imgPos.x + imgPos.w);<br />var clearsY = (elPos.y + elPos.h <> imgPos.y + imgPos.h);<br />var wrapperKey = hs.getWrapperKey(els[i]);<br />if (!clearsX && !clearsY && wrapperKey != this.key) { // element falls behind image<br />if (!hiddenBy) {<br />els[i].setAttribute('hidden-by', '['+ this.key +']');<br />els[i].origProp = els[i].style[prop];<br />els[i].style[prop] = 'hidden';<br />} else if (!hiddenBy.match('['+ this.key +']')) {<br />els[i].setAttribute('hidden-by', hiddenBy + '['+ this.key +']');<br />}<br />} else if (hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey) { // on move<br />els[i].setAttribute('hidden-by', '');<br />els[i].style[prop] = els[i].origProp || '';<br />} else if (hiddenBy && hiddenBy.match('['+ this.key +']')) {<br />els[i].setAttribute('hidden-by', hiddenBy.replace('['+ this.key +']', ''));<br />}<br /><br />}<br />}<br />}<br />},<br /><br />focus : function() {<br />this.wrapper.style.zIndex = hs.zIndexCounter++;<br />// blur others<br />for (var i = 0; i < hs.expanders.length; i++) {<br />if (hs.expanders[i] && i == hs.focusKey) {<br />var blurExp = hs.expanders[i];<br />blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';<br /><br />if (blurExp.caption) {<br />blurExp.caption.className += ' highslide-caption-blur';<br />}<br /><br />blurExp.content.style.cursor = hs.ie ? 'hand' : 'pointer';<br />blurExp.content.title = hs.focusTitle;<br />}<br />}<br /><br />// focus this<br />if (this.objOutline) this.objOutline.table.style.zIndex<br />= this.wrapper.style.zIndex;<br /><br />this.content.className = 'highslide-'+ this.contentType;<br /><br />if (this.caption) {<br />this.caption.className = this.caption.className.replace(' highslide-caption-blur', '');<br />}<br /><br />this.content.title = hs.restoreTitle;<br /><br />hs.styleRestoreCursor = window.opera ? 'pointer' : 'url('+ hs.graphicsDir + hs.restoreCursor +'), pointer';<br />if (hs.ie && hs.ieVersion() < 6) hs.styleRestoreCursor = 'hand';<br />this.content.style.cursor = hs.styleRestoreCursor;<br /><br />hs.focusKey = this.key;<br />hs.addEventListener(document, 'keydown', hs.keyHandler);<br />},<br /><br />move : function (e) {<br />this.x.min = e.left + e.dX;<br />this.y.min = e.top + e.dY;<br /><br />if (e.type == 'image') this.content.style.cursor = 'move';<br />hs.setStyles(this.wrapper, { left: this.x.min +'px', top: this.y.min +'px' });<br /><br />if (this.objOutline)<br />this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);<br /><br />},<br /><br />close : function() {<br />if (this.isClosing || !this.isExpanded) return;<br />this.isClosing = true;<br /><br />hs.removeEventListener(document, 'keydown', hs.keyHandler);<br /><br />try {<br /><br />this.content.style.cursor = 'default';<br /><br />this.changeSize(<br />0,<br />{<br />x: this.x.min,<br />y: this.y.min,<br />w: this.x.span,<br />h: parseInt(this.content.style.height),<br />imgW: this.x.imgSpan,<br />o: this.objOutline ? this.objOutline.offset : 0<br />},<br />{<br />x: this.thumbLeft - this.offsetBorderW + this.thumbOffsetBorderW,<br />y: this.thumbTop - this.offsetBorderH + this.thumbOffsetBorderH,<br />w: this.thumbWidth,<br />h: this.thumbHeight,<br />imgW: this.thumbWidth,<br />o: hs.outlineStartOffset<br />},<br />hs.restoreDuration,<br />hs.restoreSteps<br />);<br /><br />} catch (e) { this.afterClose(); }<br />},<br /><br />createOverlay : function (o) {<br />var el = o.overlayId;<br />if (typeof el == 'string') el = hs.getNode(el);<br />if (!el || typeof el == 'string') return;<br /><br /><br />var overlay = hs.createElement(<br />'div',<br />null,<br />{<br />'left' : 0,<br />'top' : 0,<br />'position' : 'absolute',<br />'zIndex' : 3,<br />'visibility' : 'hidden'<br />},<br />this.wrapper,<br />true<br />);<br />if (o.opacity) hs.setStyles(el, { opacity: o.opacity });<br />el.style.styleFloat = 'none';<br />el.className += ' highslide-display-block';<br />overlay.appendChild(el);<br /><br />overlay.hsPos = o.position;<br />this.positionOverlay(overlay);<br /><br />if (o.hideOnMouseOut) overlay.setAttribute('hideOnMouseOut', true);<br />if (!o.opacity) o.opacity = 1;<br />overlay.setAttribute('opacity', o.opacity);<br />hs.fade(overlay, 0, o.opacity);<br /><br />hs.push(this.overlays, overlay);<br />},<br /><br />positionOverlay : function(overlay) {<br />var left = this.offsetBorderW;<br />var dLeft = this.x.span - overlay.offsetWidth;<br />var top = this.offsetBorderH;<br />var dTop = parseInt(this.content.style.height) - overlay.offsetHeight;<br /><br />var p = overlay.hsPos || 'center center';<br />if (/^bottom/.test(p)) top += dTop;<br />if (/^center/.test(p)) top += dTop / 2;<br />if (/right$/.test(p)) left += dLeft;<br />if (/center$/.test(p)) left += dLeft / 2;<br />overlay.style.left = left +'px';<br />overlay.style.top = top +'px';<br />},<br /><br />createOverlays : function() {<br />for (var i = 0; i < hs.overlays.length; i++) {<br />var o = hs.overlays[i], tId = o.thumbnailId, sg = o.slideshowGroup;<br />if ((!tId && !sg) || tId == this.thumbsUserSetId<br />|| sg === this.slideshowGroup) {<br />this.createOverlay(o);<br />}<br />}<br />},<br /><br /><br />createFullExpand : function () {<br />var a = hs.createElement(<br />'a',<br />{<br />href: 'javascript:hs.expanders['+ this.key +'].doFullExpand();',<br />title: hs.fullExpandTitle,<br />className: 'highslide-full-expand'<br />}<br />);<br /><br />this.fullExpandLabel = a;<br />this.createOverlay({ overlayId: a, position: hs.fullExpandPosition,<br />hideOnMouseOut: true, opacity: hs.fullExpandOpacity });<br />},<br /><br />doFullExpand : function () {<br />try {<br />hs.purge(this.fullExpandLabel);<br />this.fullExpandLabel.parentNode.removeChild(this.fullExpandLabel);<br />this.focus();<br /><br />this.x.min = parseInt(this.wrapper.style.left) - (this.fullExpandWidth - this.content.width) / 2;<br />if (this.x.min < hs.marginLeft) this.x.min = hs.marginLeft;<br />this.wrapper.style.left = this.x.min +'px';<br /><br />hs.setStyles(this.content, { width: this.fullExpandWidth +'px',<br />height: this.fullExpandHeight +'px'});<br /><br />this.x.span = this.fullExpandWidth;<br />this.wrapper.style.width = (this.x.span + 2*this.offsetBorderW) +'px';<br /><br />this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;<br /><br />if (this.objOutline)<br />this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);<br /><br />for (var i = 0; i < this.overlays.length; i++)<br />this.positionOverlay(this.overlays[i]);<br /><br />this.redoShowHide();<br /><br /><br /><br />} catch (e) {<br />window.location.href = this.content.src;<br />}<br />},<br /><br /><br />// on end move and resize<br />redoShowHide : function() {<br />var imgPos = {<br />x: parseInt(this.wrapper.style.left) - 20,<br />y: parseInt(this.wrapper.style.top) - 20,<br />w: this.content.offsetWidth + 40,<br />h: this.content.offsetHeight + 40<br />+ this.spaceForCaption<br />};<br />if (hs.hideSelects) this.showHideElements('SELECT', 'hidden', imgPos);<br />if (hs.hideIframes) this.showHideElements('IFRAME', 'hidden', imgPos);<br />if (hs.geckoMac) this.showHideElements('*', 'hidden', imgPos);<br /><br />},<br /><br />wrapperMouseHandler : function (e) {<br />if (!e) e = window.event;<br />var over = /mouseover/i.test(e.type);<br />if (!e.target) e.target = e.srcElement; // ie<br />if (hs.ie) e.relatedTarget =<br />over ? e.fromElement : e.toElement; // ie<br />if (hs.getExpander(e.relatedTarget) == this || hs.dragArgs) return;<br />for (var i = 0; i < this.overlays.length; i++) {<br />var o = this.overlays[i];<br />if (o.getAttribute('hideOnMouseOut')) {<br />var from = over ? 0 : o.getAttribute('opacity'),<br />to = over ? o.getAttribute('opacity') : 0;<br />hs.fade(o, from, to);<br />}<br />}<br />},<br /><br />afterClose : function () {<br />this.a.className = this.a.className.replace('highslide-active-anchor', '');<br /><br />if (hs.hideSelects) this.showHideElements('SELECT', 'visible');<br />if (hs.hideIframes) this.showHideElements('IFRAME', 'visible');<br />if (hs.geckoMac) this.showHideElements('*', 'visible');<br />if (this.objOutline && this.outlineWhileAnimating) this.objOutline.destroy();<br />hs.purge(this.wrapper);<br />if (hs.ie && hs.ieVersion() < 5.5) this.wrapper.innerHTML = ''; // crash<br />else this.wrapper.parentNode.removeChild(this.wrapper);<br />hs.expanders[this.key] = null;<br />hs.cleanUp();<br />}<br />};<br />// history<br />var HsExpander = hs.Expander;<br /><br />// set handlers<br />hs.addEventListener(document, 'mousedown', hs.mouseClickHandler);<br />hs.addEventListener(document, 'mouseup', hs.mouseClickHandler);<br />hs.addEventListener(window, 'load', hs.preloadImages);<br /><br />------------------------------------------------------------------------------Sathish Kumarhttp://www.blogger.com/profile/06326828004950668369noreply@blogger.com6