<?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-1032797411830546131</id><updated>2011-12-26T02:48:20.887-08:00</updated><title type='text'>PHP Programming, Study, Dictionary, Script...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>PHP Blog</name><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>48</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1032797411830546131.post-1603420726629727276</id><published>2010-09-15T20:41:00.000-07:00</published><updated>2010-09-15T20:48:45.593-07:00</updated><title type='text'>How to install CKEditor and CKFinder !</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_QqY2agbaXcI/TJGSW0sL81I/AAAAAAAAAAM/NhZ-TfBKAAk/s1600/ckeditor.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 91px;" src="http://2.bp.blogspot.com/_QqY2agbaXcI/TJGSW0sL81I/AAAAAAAAAAM/NhZ-TfBKAAk/s320/ckeditor.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5517351939304321874" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As we all know there is no built-in rich text editor in default Drupal ike other CMS platforms, so what do we do? Well there is a solution in the form of Modules!!! those are CKEditor and CKFinder.&lt;br /&gt;&lt;br /&gt;Today I'm going to show you how to setup CKEditor and CKFinder modules successfully.&lt;br /&gt;&lt;br /&gt;First of all let's download all the necessary modules to our Computer. Open your web browser and type the URL &lt;a href="http://drupal.org/project/ckeditor"&gt;http://drupal.org/project/ckeditor&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And download the latest version of CKEditor module. Next open an another tab on your web browser and type the URL &lt;a href="http://ckeditor.com/download"&gt;http://ckeditor.com/download&lt;/a&gt;  and download the main files of CKEditor. the last module we need is file browser module so open one more tab on your web browser and type the URL &lt;a href="http://ckfinder.com/download"&gt;http://ckfinder.com/download&lt;/a&gt; and download the PHP version of CKFinder. OK now we have all the necessary modules.&lt;br /&gt;&lt;br /&gt; Now let's unzip (extract) the first downloaded CKEditor module from &lt;a href="http://drupal.org/project/ckeditor"&gt;http://drupal.org/project/ckeditor&lt;/a&gt; and then open the unzipped  CKEditor folder&lt;br /&gt;where you can see an another folder named same CKEditor which has only one text file in it (&lt;span style="font-weight:bold;"&gt;CKEditor/CKEditor/COPY_HERE.txt&lt;/span&gt;), if you open and read this text file you will understand that this the place where we have to put the CKEditor file which we have downloaded from http://ckeditor.com/download. So let's unzip the second CKEditor file and open the unzipped file then copy everything within this folder and paste into the CKEditor/CKEditor folder.&lt;br /&gt;&lt;br /&gt;Now we have one more file to unzip which is CKFinder so let's unzip the CKFinder module and drag and drop or copy and paste to CKEditor folder (&lt;span style="font-weight:bold;"&gt;CKEditor/CKFinder&lt;/span&gt;). Now we have unzipped and arranged everything in order. Next we have to change some configurations to work CKFinder properly.&lt;br /&gt;&lt;br /&gt;So let's open config.php (&lt;span style="font-weight:bold;"&gt;CKEditor/CKFinder/config.php&lt;/span&gt;) and then un-comment or delete the line from 21 to 34.&lt;br /&gt;&lt;code&gt;&lt;br /&gt; function CheckAuthentication()&lt;br /&gt;{&lt;br /&gt;    // WARNING : DO NOT simply return "true". By doing so, you are allowing&lt;br /&gt;    // "anyone" to upload and list the files in your server. You must implement&lt;br /&gt;    // some kind of session validation here. Even something very simple as...&lt;br /&gt;&lt;br /&gt;    // return isset($_SESSION['IsAuthorized']) &amp;&amp; $_SESSION['IsAuthorized'];&lt;br /&gt;&lt;br /&gt;    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the&lt;br /&gt;    // user logs in your system.&lt;br /&gt;    // To be able to use session variables don't forget to add session_start().&lt;br /&gt;&lt;br /&gt;    return false;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Note: To un-comment these codes just add /* at the beginning and */ at the end.(same as CSS comment)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next in the same config.php file on line 61 (&lt;span style="font-weight:bold;"&gt;$baseUrl = '/ckfinder/userfiles/';&lt;/span&gt;)define the path to CKFinder userfiles.&lt;br /&gt;&lt;br /&gt;Something like this &lt;span style="font-weight:bold;"&gt;$baseUrl = '/public_html/yoursitename.com/sites/all/modules/ckeditor/ckfinder/userfiles/';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next step is to add this code &lt;span style="font-weight:bold;"&gt;require_once '../../../../includes/filemanager.config.php';&lt;/span&gt; below the line 78 ($baseDir = resolveUrl($baseUrl);)&lt;br /&gt;&lt;br /&gt;OK that's all we have to do with CKFinder/config.php.  &lt;br /&gt;&lt;br /&gt;The last step is to edit some sttings in settings.php, so go to drupal/sites/default/settings.php and on line 169 (&lt;span style="font-weight:bold;"&gt;# $cookie_domain = 'example.com';&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;un-comment this line by removing # mark and change example.com to your domain name. Like this &lt;span style="font-weight:bold;"&gt;$cookie_domain = 'yourdomainname.com';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Note: if you are on local computer add localhost &lt;span style="font-weight:bold;"&gt;$cookie_domain = 'localhost';&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Now everything is configured and it's time to put the CKditor module to drupal/sites/all/modules&lt;br /&gt;&lt;br /&gt;(Note: There is no default directory named modules, you have to create a new folder called modules)&lt;br /&gt;&lt;br /&gt;Let's open our Drupal site and go to /admin/build/modules and enable the CKEditor module.&lt;br /&gt;&lt;br /&gt;Next go to /admin/user/permissions and set CKEditor access permission to authenticated user and CKFinder file upload permission.&lt;br /&gt;&lt;br /&gt;Now go to /admin/settings/ckeditor and edit the advanced profile and set the file browser as type as CKFinder and save the configurations.&lt;br /&gt;&lt;br /&gt;Now lets go and create a page or story and you can see instead of default plain text editor we have CKEditor and click on image button and you an see thast now you can browse for images and uploaded images and files to server from the site. Great!!!&lt;br /&gt;&lt;br /&gt;I hope I could help all those who had problem for setting up CKEditor and CKFinder on Drupal.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-1603420726629727276?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/1603420726629727276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=1603420726629727276' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/1603420726629727276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/1603420726629727276'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2010/09/how-to-install-ckeditor-and-ckfinder.html' title='How to install CKEditor and CKFinder !'/><author><name>PHP Blog</name><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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_QqY2agbaXcI/TJGSW0sL81I/AAAAAAAAAAM/NhZ-TfBKAAk/s72-c/ckeditor.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1032797411830546131.post-7338978727416270278</id><published>2010-04-26T00:26:00.000-07:00</published><updated>2010-04-26T00:28:52.495-07:00</updated><title type='text'>Ngày tốt cho cưới và làm nhà.</title><content type='html'>Ngày xưa các nhà thiên văn tưởng tượng vùng trời trong vũ trụ có một vòng tròn lớn gọi là vòng Hoàng đạo. Họ đem chia vòng này thành 360 độ, hai bên gọi là miền Hoàng đạo, dùng bốn quẻ chánh của Bát quái: Càn, Khảm, Ly, Khôn phân thành bốn phương (bốn mùa). Dùng Thập nhị Địa chi bố trí bốn phương để chỉ bốn mùa cho 12 tháng. Sau đó họ phân nạp 7 tinh tú vào mỗi phương. Mười hai Địa chi sắp xếp theo chiều kim đồng hồ, còn Nhị thập Bát tú thì ngược chiều kim đồng hồ. Do đó sao Phòng đóng ở cung Mão là Xuân phân, sao Tinh đóng tại Ngọ là Hạ chí, sao Mão đóng ở cung Dậu là Thu phân, sao Hư đóng tại cung Tí là Đông chí.&lt;br /&gt;Sự chuyển động của Mặt trời tạo nên sự thay đổi khí hậu bốn mùa, nó cũng làm cho sự vận hành khí huyết trong cơ thể con người thay đổi theo. Thời tiết ấm áp của mùa Xuân thì khí huyết trong người dễ lưu thông, sông suối mạch nước dễ luân lưu. Ngược lại khí trời lạnh rét của mùa Đông thì khí huyết của con người bị ngưng trệ, mạch nước cũng bị đông đặc. Sự chuyển động của Mặt trăng gây ảnh hưởng đến thủy triều và sinh lý của con người, nhất là những người đang mang những chứng bệnh nan y như phong cùi, ung thư, tê thấp... Ngoài ra nó cũng ảnh hưởng đến việc ăn uống của thú vật, đặc biệt loại thú rừng sinh sống về đêm.&lt;br /&gt;Con người sinh sống trong sự vận chuyển của các hành tinh (vật đổi sao dời), nên cuộc đời mỗi con người mỗi khác vì ảnh hưởng của các lành dữ của các hành tinh đó... Theo các chiêm tinh gia, ngày Hoàng đạo là ngày có nhiều cát tinh hội tụ nên tốt lành. Vì thế các nhà Thuật số chọn ngày này để khai trương, xuất hành, cúng kiến, an táng...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1. Chọn ngày tốt cho cưới&lt;/span&gt;&lt;br /&gt;Ngày xưa, trước khi dựng vợ gả chồng cho con cháu, các cụ thường nhờ người thầy xem tuổi của đôi trẻ để lương duyên của chúng khỏi bị "nửa đường gẫy gánh" hay tránh cho chúng khỏi bị cảnh phu thê "ly biệt" khi phạm "cô phòng quả tú". Ngày nay, quan niệm về hôn nhân đã thay đổi. Nam nữ "phải lòng" thương yêu nhau thì việc cưới gả tiếp theo là lẽ thường tình. Cho dù ông bà cha mẹ biết trước sự đổ vỡ cũng không thể nào ngăn cản được! Thôi thì cứ xem như đôi trẻ có duyên 'tiền định' cho lòng mình thanh thản. Còn chúng có "nợ" lâu dài với nhau hay không là còn tùy "duyên phận".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ngày tốt mà các nhà Thuật số luôn chọn các ngày để cưới gả:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * &lt;span style="font-weight:bold;"&gt;Ngày có sao Bất tương&lt;/span&gt; (Bất là không, tương là tương hợp. Nghĩa ở đây là không bị Âm tương, không bị Dương tương, không bị Cụ tương và bất tương là ngày đại kiết để dựng vợ gả chồng):&lt;br /&gt;&lt;br /&gt;       1. - Âm tương: Can Âm (-) phối Chi Âm (-), kỵ cho nữ.&lt;br /&gt;       2. - Dương tương: Can Dương (+) phối Chi Dương (+), kỵ cho nam.&lt;br /&gt;       3. - Âm Dương cụ tương: Can Âm (-) phối hợp Chi Dương (+), nam nữ đều bị kỵ.&lt;br /&gt;       4. - Âm Dương bất tương: Can Dương (+) hòa hợp với Chi Âm (-) thì tốt cho cả nam lẫn nữ.&lt;br /&gt;&lt;br /&gt;    * Ngày có nhiều cát tinh như: Thiên Hỷ, Thiên Đức + Nguyệt Đức, Tam Hiệp, Ngũ hiệp, Lục hiệp.&lt;br /&gt;    * Ngày trực Bình, trực Định, trực Thành, trực Thâu.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ngày kiêng kỵ nên tránh các ngày dưới đây:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    * Ngày Tam nương, Sát chủ dương và Nguyệt kỵ.&lt;br /&gt;    * Ngày có hung tinh như: Trùng phục, Thiên hình, Thiên tặc, Địa tặc, Nguyệt phá, Nguyệt sát, Nguyệt hỏa, Nguyệt yểm, Vãng vong, Sát thê.&lt;br /&gt;    * Ngày kỵ tuổi (Thiên khắc, Địa xung).&lt;br /&gt;    * Ngày trực Kiến, trực Phá, trực Nguy.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2. Chọn ngày làm nhà&lt;/span&gt;&lt;br /&gt;Việc chọn ngày làm nhà có ảnh hưởng khá lớn đến cuộc sống tâm linh của Gia chủ. Hầu hết khi tiến hành làm nhà người ta thường chọn ngày có các sao: Sát cống, Thanh long, Hoàng đạo và quan trọng là phải hợp với tuổi của Gia chủ. Phải tránh các ngày Hắc đạo, Ly sào, tránh thời gian xung với tuổi của Gia chủ. Bên cạnh đó cũng cần tránh các ngày xấu như Sát chủ, Thụ tử, Tam nương, Nguyệt kị, Kim thần thất sát.&lt;br /&gt;&lt;br /&gt;a. &lt;span style="font-weight:bold;"&gt;Chọn ngày động thổ&lt;/span&gt; Theo truyền thuyết thì lễ động thổ do Hán Vũ Đế lập ra. Không mang hình thức phức tạp như trước kia mà lễ động thổ ngày nay được tiến hàng trước khi xây cất 1 công trình. Người ta quan niệm rằng: Trên có Ngọc Hoàng, dưới sông có Hà Bá, đất đai thì có Thổ thần, do đó muốn xây dựng bất cứ công trình nào trên đất cũng cần xin phép và được sự đồng ý của Thổ thần.&lt;br /&gt;Ngày động thổ nên chọn ngày có các sao: Sinh khí, Thiên ân, Thiên đức, Nguyệt đức, Hoàng đạo, Thiên hỷ, Tam hợp, Địa tài.&lt;br /&gt;Nên tránh các ngày có sao: Thổ cấm, Thổ kị, Ly sào, Nguyệt kiến, Nguyệt phá, Sát chủ, Hoang ốc, Trực phá, Trực trừ&lt;br /&gt;&lt;br /&gt;b. &lt;span style="font-weight:bold;"&gt;Chọn ngày cất nóc&lt;/span&gt;, đổ mái nhà Bên cạnh việc chọn ngày đẹp, giờ đẹp để tiến hành làm nhà, xây cất nhà, cũng cần quan tâm đến việc chọn ngày giờ đổ mái. Chọn ngày có các sao tốt tương tự như ngày động thổ nhưng kị các sao: Thiên hỏa, Hỏa tai, Nguyệt phá, Trực phá.&lt;br /&gt;&lt;br /&gt;c. &lt;span style="font-weight:bold;"&gt;Chọn ngày nhập trạch&lt;/span&gt; Ngày nhập trạch là ngày dọn đến 1 ngôi nhà mới, có thể là nhà mới xây hoặc mới mua.&lt;br /&gt;Ngày nhập trạch nên là ngày có các sao: Thiên âm, Thiên hỷ, Thiên giải, Nguyệt tài, Thiên phú. Các sao tốt được chọn giống như với ngày Động thổ tránh các ngày có sao Chu tước, hay ngày Hắc đạo&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-7338978727416270278?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7338978727416270278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7338978727416270278' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7338978727416270278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7338978727416270278'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2010/04/ngay-tot-cho-cuoi-va-lam-nha.html' title='Ngày tốt cho cưới và làm nhà.'/><author><name>PHP Blog</name><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-1032797411830546131.post-152785933430447031</id><published>2009-12-11T22:53:00.000-08:00</published><updated>2009-12-11T22:59:05.113-08:00</updated><title type='text'>PHP Example AJAX and MySQL</title><content type='html'>Example explained - The JavaScript code&lt;br /&gt;&lt;br /&gt;This is the JavaScript code stored in the file "selectuser.js":&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;?&lt;br /&gt;var xmlhttp;&lt;br /&gt;&lt;br /&gt;function showUser(str)&lt;br /&gt;{&lt;br /&gt;xmlhttp=GetXmlHttpObject();&lt;br /&gt;if (xmlhttp==null)&lt;br /&gt;  {&lt;br /&gt;  alert ("Browser does not support HTTP Request");&lt;br /&gt;  return;&lt;br /&gt;  }&lt;br /&gt;var url="getuser.php";&lt;br /&gt;url=url+"?q="+str;&lt;br /&gt;url=url+"&amp;sid="+Math.random();&lt;br /&gt;xmlhttp.onreadystatechange=stateChanged;&lt;br /&gt;xmlhttp.open("GET",url,true);&lt;br /&gt;xmlhttp.send(null);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function stateChanged()&lt;br /&gt;{&lt;br /&gt;if (xmlhttp.readyState==4)&lt;br /&gt;{&lt;br /&gt;document.getElementById("txtHint").innerHTML=xmlhttp.responseText;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function GetXmlHttpObject()&lt;br /&gt;{&lt;br /&gt;if (window.XMLHttpRequest)&lt;br /&gt;  {&lt;br /&gt;  // code for IE7+, Firefox, Chrome, Opera, Safari&lt;br /&gt;  return new XMLHttpRequest();&lt;br /&gt;  }&lt;br /&gt;if (window.ActiveXObject)&lt;br /&gt;  {&lt;br /&gt;  // code for IE6, IE5&lt;br /&gt;  return new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;  }&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The stateChanged() and GetXmlHttpObject functions are the same as in the PHP AJAX Suggest chapter, you can go to there for an explanation of those.&lt;br /&gt;&lt;br /&gt;The showUser() Function&lt;br /&gt;&lt;br /&gt;When a person in the drop-down box is selected, the showUser() function executes the following:&lt;br /&gt;&lt;br /&gt;   1. Calls the GetXmlHttpObject() function to create an XMLHTTP object&lt;br /&gt;   2. Defines an URL (filename) to send to the server&lt;br /&gt;   3. Adds a parameter (q) to the URL with the content of the drop-down box&lt;br /&gt;   4. Adds a random number to prevent the server from using a cached file&lt;br /&gt;   5. Each time the readyState property changes, the stateChanged() function will be executed&lt;br /&gt;   6. Opens the XMLHTTP object with the given URL&lt;br /&gt;   7. Sends an HTTP request to the server&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example explained - The PHP Page&lt;br /&gt;&lt;br /&gt;The PHP page called by the JavaScript, is called "getuser.php".&lt;br /&gt;&lt;br /&gt;The PHP script runs an SQL query against a MySQL database, and returns the result as HTML:&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;$q=$_GET["q"];&lt;br /&gt;&lt;br /&gt;$con = mysql_connect('localhost', 'peter', 'abc123');&lt;br /&gt;if (!$con)&lt;br /&gt;  {&lt;br /&gt;  die('Could not connect: ' . mysql_error());&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;mysql_select_db("ajax_demo", $con);&lt;br /&gt;&lt;br /&gt;$sql="SELECT * FROM user WHERE id = '".$q."'";&lt;br /&gt;&lt;br /&gt;$result = mysql_query($sql);&lt;br /&gt;&lt;br /&gt;echo "&lt; table border='1' &gt;";&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;&lt; th&gt;Firstname&lt; /th&gt;&lt;br /&gt;&lt; th&gt;Lastname&lt; /th&gt;&lt;br /&gt;&lt; th&gt;Age&lt; /th&gt;&lt;br /&gt;&lt; th&gt;Hometown&lt; /th&gt;&lt;br /&gt;&lt; th&gt;Job&lt; /th&gt;&lt;br /&gt;&lt; /tr&gt;";&lt;br /&gt;&lt;br /&gt;while($row = mysql_fetch_array($result))&lt;br /&gt;  {&lt;br /&gt;  echo "&lt; tr&gt;";&lt;br /&gt;  echo "&lt; td&gt;" . $row['FirstName'] . "&lt; /td&gt;";&lt;br /&gt;  echo "&lt; td&gt;" . $row['LastName'] . "&lt; /td&gt;";&lt;br /&gt;  echo "&lt; td&gt;" . $row['Age'] . "&lt; /td&gt;";&lt;br /&gt;  echo "&lt; td&gt;" . $row['Hometown'] . "&lt; /td&gt;";&lt;br /&gt;  echo "&lt; td&gt;" . $row['Job'] . "&lt; /td&gt;";&lt;br /&gt;  echo "&lt; /tr&gt;";&lt;br /&gt;  }&lt;br /&gt;echo "&lt; /table&gt;";&lt;br /&gt;&lt;br /&gt;mysql_close($con);&lt;br /&gt;?&gt; &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When the query is sent from the JavaScript to the PHP page, the following happens:&lt;br /&gt;&lt;br /&gt;   1. PHP opens a connection to a MySQL server&lt;br /&gt;   2. The correct person is found&lt;br /&gt;   3. An HTML table is created, and filled with data, and sent back to the "txtHint" placeholder&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-152785933430447031?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/152785933430447031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=152785933430447031' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/152785933430447031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/152785933430447031'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/12/php-example-ajax-and-mysql.html' title='PHP Example AJAX and MySQL'/><author><name>PHP Blog</name><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-1032797411830546131.post-4421206513966632541</id><published>2009-06-15T00:35:00.001-07:00</published><updated>2009-06-15T00:35:55.765-07:00</updated><title type='text'>MySQL Change root Password</title><content type='html'>How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?&lt;br /&gt;&lt;br /&gt;Setting up mysql password is one of the essential tasks. By default root user is MySQL admin account. Please note that the Linux / UNIX login root account for your operating system and MySQL root are different. They are separate and nothing to do with each other (indeed some admin removes root account and setup admin as mysql super user).&lt;br /&gt;mysqladmin command to change root password&lt;br /&gt;&lt;br /&gt;If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:&lt;br /&gt;&lt;br /&gt;$ mysqladmin -u root password NEWPASSWORD&lt;br /&gt;&lt;br /&gt;However, if you want to change (or update) a root password, then you need to use following command&lt;br /&gt;&lt;br /&gt;$ mysqladmin -u root -p'oldpassword' password newpass&lt;br /&gt;&lt;br /&gt;For example, If old password is abc, and set new password to 123456, enter:&lt;br /&gt;&lt;br /&gt;$ mysqladmin -u root -p'abc' password '123456'&lt;br /&gt;&lt;br /&gt;Change MySQL password for other user&lt;br /&gt;&lt;br /&gt;To change a normal user password you need to type (let us assume you would like to change password for vivek):&lt;br /&gt;&lt;br /&gt;$ mysqladmin -u vivek -p oldpassword password newpass&lt;br /&gt;&lt;br /&gt;Changing MySQL root user password using MySQL sql command&lt;br /&gt;&lt;br /&gt;This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:&lt;br /&gt;&lt;br /&gt;1) Login to mysql server, type following command at shell prompt:&lt;br /&gt;&lt;br /&gt;$ mysql -u root -p&lt;br /&gt;&lt;br /&gt;2) Use mysql database (type command at mysql&gt; prompt):&lt;br /&gt;&lt;br /&gt;mysql&gt; use mysql;&lt;br /&gt;&lt;br /&gt;3) Change password for user vivek:&lt;br /&gt;&lt;br /&gt;mysql&gt; update user set password=PASSWORD("NEWPASSWORD") where User='vivek';&lt;br /&gt;&lt;br /&gt;4) Reload privileges:&lt;br /&gt;&lt;br /&gt;mysql&gt; flush privileges;&lt;br /&gt;mysql&gt; quit&lt;br /&gt;&lt;br /&gt;This method you need to use while using PHP or Perl scripting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4421206513966632541?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4421206513966632541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4421206513966632541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4421206513966632541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4421206513966632541'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/06/mysql-change-root-password.html' title='MySQL Change root Password'/><author><name>PHP Blog</name><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-1032797411830546131.post-9198246273008949634</id><published>2009-05-21T02:28:00.000-07:00</published><updated>2009-05-21T02:30:13.623-07:00</updated><title type='text'>PHP function: Delete and create database and table in MySql</title><content type='html'>&lt;pre&gt;&lt;br /&gt;$sql = "DROP DATABASE 'db'";&lt;br /&gt;    mysql_query($sql);&lt;br /&gt;    $sql = "CREATE DATABASE `db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";&lt;br /&gt;    mysql_query($sql);&lt;br /&gt;&lt;br /&gt;    $sql = "CREATE TABLE `db`.`table` (&lt;br /&gt;     `id` DOUBLE NOT NULL AUTO_INCREMENT PRIMARY KEY ,&lt;br /&gt;     `v1` VARCHAR( 50 ) NOT NULL ,&lt;br /&gt;     `v2` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v3` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v4` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v5` MEDIUMTEXT NULL ,&lt;br /&gt;     `v6` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v7` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v8` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v9` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v10` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v11` VARCHAR( 100 ) NULL ,&lt;br /&gt;     `v12` VARCHAR( 100 ) NULL ,&lt;br /&gt;     `v13` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v14` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v15` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v16` MEDIUMTEXT NULL ,&lt;br /&gt;     `v17` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v18` VARCHAR( 50 ) NULL ,&lt;br /&gt;     `v19` VARCHAR( 255 ) NULL ,&lt;br /&gt;     `v20` VARCHAR( 255 ) NULL&lt;br /&gt;     ) ENGINE = MYISAM ";&lt;br /&gt;&lt;br /&gt;    mysql_query($sql);&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/1032797411830546131-9198246273008949634?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/9198246273008949634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=9198246273008949634' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9198246273008949634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9198246273008949634'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-function-delete-and-create-database.html' title='PHP function: Delete and create database and table in MySql'/><author><name>PHP Blog</name><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-1032797411830546131.post-2888201718309337201</id><published>2009-05-18T23:27:00.000-07:00</published><updated>2009-05-18T23:28:53.529-07:00</updated><title type='text'>PHP script: random text link advertising using predefined arrays</title><content type='html'>Random text link advertising using predefined arrays&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?&lt;br /&gt;$random_url = array("http://www.tdscripts.com/linkorg.html",&lt;br /&gt;                    "http://www.tdscripts.com/keno.html",&lt;br /&gt;                    "http://www.tdscripts.com/ezibill.shtml",&lt;br /&gt;                    "http://www.tdscripts.com/tdforum.shtml",&lt;br /&gt;                    "http://www.tdscripts.com/picofday.html",&lt;br /&gt;                    "http://www.tdscripts.com/gutsorglory.html");&lt;br /&gt;&lt;br /&gt;$url_title = array("Link Organizer",&lt;br /&gt;                   "TD Keno",&lt;br /&gt;                   "eziBill *Free Promotion!",&lt;br /&gt;                   "TD Forum",&lt;br /&gt;                   "TD Pic of Day PHP",&lt;br /&gt;                   "Guts or Glory Poker PHP");&lt;br /&gt;$url_desc = array("- A comprehensive link list organizer",&lt;br /&gt;"- Offer your site visitors an engaging Keno game without the monetary risk",&lt;br /&gt;"- Sell access to and protect your membership area using iBill and our eziBill script",&lt;br /&gt;"- An unthreaded messageboard script to exchange ideas with your site visitors",&lt;br /&gt;"- Run your own picture of the day script from any site anywhere with this handy script",&lt;br /&gt;"- A casino-style card game written entirely in PHP");&lt;br /&gt;srand(time());&lt;br /&gt;$sizeof = count($random_url);&lt;br /&gt;$random = (rand()%$sizeof);&lt;br /&gt;print("&lt;center&gt;&lt;a href=\"$random_url[$random]\"&gt;$url_title[$random]&lt;/a&gt; $url_desc[$random]&lt;/center&gt;");&lt;br /&gt;?&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/1032797411830546131-2888201718309337201?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/2888201718309337201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=2888201718309337201' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2888201718309337201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2888201718309337201'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-random-text-link-advertising.html' title='PHP script: random text link advertising using predefined arrays'/><author><name>PHP Blog</name><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-1032797411830546131.post-2063903321216499701</id><published>2009-05-12T17:46:00.000-07:00</published><updated>2009-05-12T19:57:50.230-07:00</updated><title type='text'>New software ActivePresenter: Capture, edit, publish</title><content type='html'>ActivePresenter is an advanced presentation tool, designed especially for computer software simulations, with blazing fast, smart screen capture technology; a powerful authoring environment and the ability to create high-quality Ajax-based interactive simulations.&lt;br /&gt;&lt;br /&gt;With its smart and fast screen capture ability, ActivePresenter reproduces your on-screen activity and records in video, sound, image or text formats within few minutes. Coupled with a powerful yet easy-to-use authoring environment, you can easily create advanced simulations, scenarios, quizzes or online documentation just by operating on target application and let ActivePresenter do the jobs for you. No programming or multimedia skills needed.&lt;br /&gt;&lt;br /&gt;You can create Screenshot projects (recording screen shots as you go), Image projects (using existing images you have created) or Blank projects (using blank slides on which you can manually insert the information you require).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Feature Highlights&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    *  Automatically capture screens whenever you type or click, so you can create training materials and simulations easily only by operating on the target application&lt;br /&gt;    * Blazing fast: You can’t even notice any differences in application performance while ActivePresenter is capturing&lt;br /&gt;    * Automatically create appropriate actions to simulate your real operations&lt;br /&gt;    * Automatically insert predefined balloon to annotate each operation&lt;br /&gt;    * Filter multiple keyboard strokes based on context&lt;br /&gt;    * Full-screen capture mode&lt;br /&gt;    * Define dimensions and position of capturing window&lt;br /&gt;&lt;br /&gt;Download here:&lt;br /&gt;&lt;br /&gt;&lt;a href ="http:// www.atomisystems.com/apdownloads/ActivePresenter_v1.1_TRIAL_setup.exe"&gt;http:// www.atomisystems.com/apdownloads/ActivePresenter_v1.1_TRIAL_setup.exe&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;View Detail:&lt;br /&gt;&lt;a href="http://www.atomisystems.com/"&gt;http://www.atomisystems.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-2063903321216499701?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/2063903321216499701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=2063903321216499701' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2063903321216499701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2063903321216499701'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/new-software-activepresenter-capture.html' title='New software ActivePresenter: Capture, edit, publish'/><author><name>PHP Blog</name><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-1032797411830546131.post-5075582190250665453</id><published>2009-05-11T20:15:00.000-07:00</published><updated>2009-05-11T20:25:29.024-07:00</updated><title type='text'>How to install a new language in Joomla (Download Vietnamese - translations for Joomla)</title><content type='html'>Type:&lt;br /&gt;&lt;br /&gt;com_installer&lt;br /&gt;Access&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;menu=&gt;Installers=&gt;Language&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;menu=&gt;Site=&gt;Language Manager - New&lt;/span&gt;&lt;br /&gt;User Level:&lt;br /&gt;&lt;br /&gt;Super Administrator &lt;br /&gt;Screenshot&lt;br /&gt;inst_new_lang_ss&lt;br /&gt;Install a New Language&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Description:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Language files help localize the appearance of a Joomla! web site by translating the default English_GB labels and core instructions to the specified language. A Language file typically contains HTML, PHP, and XML files&lt;br /&gt;&lt;br /&gt;note icon NOTE: There is no way in a standard installation of Joomla! to change the language of the Back-end.&lt;br /&gt;&lt;br /&gt;There are two ways to install a new Language in Joomla! Both methods are described here and both assume that the Language file to be installed, has already been downloaded and it is saved on a local hard drive.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;To Upload a Language:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the host web server has GZIP support enabled with PHP, it is possible to upload a zipped (.zip) package file that will be installed automatically.&lt;br /&gt;&lt;br /&gt;To trace the file click on the Browse button. This will open the File Upload dialogue window. Navigate to the location of the desired Language file on the local hard drive. Select the Language file and click the Open button. The dialogue window will disappear and the path to, and name of, the Language file will appear in the File Upload field. Click the Upload and Install button to complete the transfer and installation of a copy of the Language file from the local computer to the joomla_root/languages/ directory tree.&lt;br /&gt;&lt;br /&gt;note711_small NOTE: There is usually an upper limit to the size of files that can be uploaded within the web server itself. This limit is set in the PHP configuration file (php.ini) and may differ between web servers and web hosts. The limit cannot be altered from within Joomla!. Some hosting companies do not allow the limit to be altered at all!&lt;br /&gt;&lt;br /&gt;To allow larger files to be uploaded it will probably be necessary to increase the upload_max_filesize and the post_max_size settings.&lt;br /&gt;&lt;br /&gt;For very large files it may also be necessary to increase the max_execution_time and the memory_limit settings. Alternatively it may be necessary to use an external program to upload the files. If so follow the next set of instructions.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;To Install From a Directory:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the host web server does not have GZIP support enabled with PHP it will be necessary to transfer the Language file to the web server using FTP (File Transfer Protocol) or possibly a web host provided control panel, but these are varied and outside the scope of this Help Screen.&lt;br /&gt;&lt;br /&gt;Unpack the compressed .zip file onto the local hard drive before uploading it via FTP. Ideally the file should be transferred to the joomla_root/administrator/components/com_installer/language/yourlanguagename directory of Joomla!.&lt;br /&gt;&lt;br /&gt;Once the files are uploaded enter the exact location of this file (it must be the absolute location) in this example: joomla_root/administrator/components/com_installer/language/yourlanguagename then click the Install button. The new Language will be installed by Joomla! in the joomla_root/language/yourlanguagename directory of the web site.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The Success (or Failure Screen)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If all goes well a page will be displayed proclaiming Upload Language - Success. This confirms the name of the Language installed together with the Language authors description message.&lt;br /&gt;&lt;br /&gt;If things did not go to plan the message Upload Language - Failed, followed usually by the reason for the failure. Make a note of the reason before clicking continue. Rectify the error, if possible, before trying again.&lt;br /&gt;&lt;br /&gt;The newly installed Language will now be listed in the Language Manager and access to all the functions relating to the use of the new Language are found here. &lt;br /&gt;&lt;br /&gt;Download Vietnamese - translations for Joomla&lt;br /&gt;Download here&lt;br /&gt;&lt;a href="http://www.ziddu.com/download/2811192/vi-vnbackend.zip.html"&gt;vi-vnbackend&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ziddu.com/download/2811191/vi-vnfrontend.zip.html"&gt;vi-vnfrontend&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-5075582190250665453?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/5075582190250665453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=5075582190250665453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5075582190250665453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5075582190250665453'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/how-to-install-new-language-in-joomla.html' title='How to install a new language in Joomla (Download Vietnamese - translations for Joomla)'/><author><name>PHP Blog</name><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-1032797411830546131.post-3179426919900428711</id><published>2009-05-11T01:10:00.000-07:00</published><updated>2009-05-11T18:02:11.568-07:00</updated><title type='text'>Getting Started with AdSense Manager</title><content type='html'>AdSense Manager 3.x is the latest update to the popular WordPress ad management plugin. More than a normal gradual update, version 3.x represents an almost complete rewrite to support a number of changes in the Google AdSense service and the recent explosion in new blog-targeted ad networks. As of writing, AdSense Manager 3.x now also supports Adpinion, AdRoll, AdBrite, Commission Junction, HTML Code, ShoppingAds and WidgetBucks.&lt;br /&gt;&lt;br /&gt;The instructions below will guide you through the first steps of configuring Adsense Manager 3.x. If you are upgrading from a previous version of AdSense Manager, you can skip these instructions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Getting Ready&lt;br /&gt;&lt;br /&gt;Before you can do anything else, you will first need to set yourself up with an AdSense account and install the AdSense Manager plugin.&lt;br /&gt;&lt;br /&gt;   1.&lt;br /&gt;&lt;br /&gt;You can also use Adpinion, AdRoll, AdBrite, Commission Junction, HTML Code, ShoppingAds and WidgetBucks. Once you’ve created your account your provider will give you some “Ad Code” to paste into your site. Keep this window open for later: you’ll need to be able to paste this code into AdSense Manager once installed.&lt;br /&gt;&lt;br /&gt;   2. Download AdSense Manager v3.x&lt;br /&gt;&lt;br /&gt;Take the downloaded file, unzip and copy the /adsense-manager/ directory into your WordPress plugins directory at /wp-content/plugins/. After this is done you should have a folder at /wp-content/plugins/adsense-manager/ containing all the plugin’s files. To activate the plugin, simply go to your WordPress dashboard » Plugins and click ‘Activate’.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Upgrading for Previous Versions&lt;br /&gt;&lt;br /&gt;If you’re upgrading from a previous 1.x / 2.x version of AdSense Manager simply copy the /adsense-manager/ directory from the downloaded .zip file into /wp-content/plugins/. This will replace the previous version with the new files. AdSense Manager will handle the upgrade of settings/etc. automatically when you next access the WordPress dashboard and show a notice if it succeeds.&lt;br /&gt;Setting Up Adsense Manager&lt;br /&gt;&lt;br /&gt;Previously you had to input your Google AdSense ID manually when setting up AdSense Manager, but this is now updated automatically when you import code. If you go to Options » Adsense Manager, you will find the following instructions for importing your first Ad Unit:&lt;br /&gt;&lt;br /&gt;       1. Create a new ad unit using your network’s ad online management system.&lt;br /&gt;       2. Copy the ad code generated (Edit » Copy, from within your browser)&lt;br /&gt;       3. Go to Manage » Ad Units and paste the code into the box&lt;br /&gt;       4. Click Import to New Ad Unit» &lt;br /&gt;&lt;br /&gt;Below here are the settings for Be Nice! a method for supporting development by donating a % of your Ad space and Alternate Ads to raise funds for AdSense Manager. All ads are hand-selected and family friendly, and the income generated in this way allows me to dedicate time that would be otherwise spent on a bar job.&lt;br /&gt;&lt;br /&gt;Just enter a % value indicating the proportion of ads you wish to use to support us. If you enter 0 only your own ads will be shown (no hard feelings but please consider donating instead).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Creating Ads&lt;br /&gt;&lt;br /&gt;All creating and editing of Ad Units is done on the Manage » Ad Units page in your WordPress Dashboard.&lt;br /&gt;&lt;br /&gt;The simplest way to ad new Ad Units to AdSense Manager is by importing Ad Code from your network. To do this simply go to your ad network’s management page, choose your ad settings, and copy the code that is generated. This can be pasted directly into the box at the bottom-left of the Manage » Ad Unit page.&lt;br /&gt;&lt;br /&gt;Manage » Ads&lt;br /&gt;&lt;br /&gt;From here you have three options: Save as Code, Import to Defaults, Import to Ad Unit.&lt;br /&gt;Import to Ad Unit&lt;br /&gt;&lt;br /&gt;This will be the most commonly used method of importing ad code. By clicking on this option, AdSense Manager will attempt to determine which entwork your ad unit is from and import the settings to create a network-specific unit. This has a number of benefits, including access to network management links and the ability to change defaults for a given network as a group. For example, some networks may require specific HTML wrapped around them.&lt;br /&gt;&lt;br /&gt;After clicking import you will see the imported settings: check values and set a name before saving.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Manage » Ads&lt;br /&gt;Import to Defaults&lt;br /&gt;&lt;br /&gt;This imports the ad code and uses the settings to set the defaults for the network. For many networks this will simply be the network ID, but some networks will store default dimensions etc. If you ever want to change the account ID associated with a network (e.g. if you change your Google AdSense account) this is the option you will want to use to update all your ads automatically.&lt;br /&gt;Save as Code&lt;br /&gt;&lt;br /&gt;If for some reason importing is not working, or you want to store the ad code as-is, you can choose to import to a plain Ad Code unit. This will not attempt to import, modify or do anything else to the code: it will be output precisely as imported (although, of course, you can edit it later).&lt;br /&gt;AdSense Classic&lt;br /&gt;&lt;br /&gt;The simplest way to create Ads in AdSense Manager is by importing Ad Code generated from your ad network (e.g. Google, or Adroll) described above. However, the plugin still supports old-style AdSense Ads if you want to create them from scratch. Simply click on the buttons for ‘AdSense Classic’ in the bottom-right of Manage » Ad Units, and then follow the instructions from AdSense Manager v2.x.&lt;br /&gt;Network Defaults&lt;br /&gt;&lt;br /&gt;As mentioned, each network in AdSense Manager has it’s own set of defaults (including the Account ID) that are used as the basis for all adverts on that network. For example you can optionally choose to wrap all ads on a network in specific HTML markup, or you can change the display settings so all AdSense ads are shown on Posts only for example.&lt;br /&gt;&lt;br /&gt;Default Settings for a network can be changed by clicking the “Network Defaults” button in the Manage » Ad Units list. As with editing an Ad Unit, when you’re finished click Save changes »&lt;br /&gt;Ad Management&lt;br /&gt;&lt;br /&gt;Once you have a few blocks listed, you can manage each block using the buttons provided on the right hand side of the Ad list. Details of each of these are given below:&lt;br /&gt;&lt;br /&gt;Manage » Ads&lt;br /&gt;&lt;br /&gt;Clicking Copy generates a copy of the selected Ad, which can then be reconfigured with any necessary changes. This is a good way of setting up a series of similar Ads for example. Note: You can also use Network Settings to configure multiple ads.&lt;br /&gt;&lt;br /&gt;The DA (Default Ad) radio button sets which Ad unit will be used by default on your site. When adding AdSense Manager code to your site (or in your posts) you have the option to either specify an ad ID or to show the default. If you opt to show the default Ad on your site, you can then cycle through different Ad configurations by changing the selected Default Ad here.&lt;br /&gt;Positioning Ads&lt;br /&gt;Widgets&lt;br /&gt;&lt;br /&gt;If you have the Sidebar Widgets plugin installed, each Ad block will appear on the Widgets configuration page to be positioned as you like. Each Ad will appear with the name of the block in the title.&lt;br /&gt;&lt;br /&gt;Ad Widget&lt;br /&gt;&lt;br /&gt;Drag onto your sidebar and position as you want.&lt;br /&gt;Posts and Pages&lt;br /&gt;&lt;br /&gt;You can include Ads into your Posts and Pages using the code below where “name” is the name of the Ad block you have created. New to v3.x is the addition of the shorthand &lt;!--am#name--&gt; format.&lt;br /&gt;&lt;br /&gt;[ad#name]&lt;br /&gt;&lt;br /&gt;You can also display the default Ad in your posts and pages by omitting #name. Doing this allows you to switch these Ads simply by switching the Default Ad in Manager » Ads.&lt;br /&gt;&lt;br /&gt;[ad]&lt;br /&gt;&lt;br /&gt;Of course any Ads in posts update automatically when colours or layouts are modified.&lt;br /&gt;Code&lt;br /&gt;&lt;br /&gt;You can include Ads in your non-Widget blog adding the code below in your Wordpress templates. For example, a good place to add Ads might be sidebar.php.&lt;br /&gt;&lt;br /&gt;&lt;?php adsensem_ad('name'); ?&gt;&lt;br /&gt;&lt;br /&gt;Again you can display the Default ad by omitting the ‘name’ e.g.&lt;br /&gt;&lt;br /&gt;&lt;?php adsensem_ad(); ?&gt;&lt;br /&gt;&lt;br /&gt;If you want to avoid errors when you disable AdSense Manager you’ll want to add a function check to the above code. For example:&lt;br /&gt;&lt;br /&gt;&lt;?php if(function_exists('adsensem_ad')){ adsensem_ad("name"); } ?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-3179426919900428711?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/3179426919900428711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=3179426919900428711' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3179426919900428711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3179426919900428711'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/getting-started-with-adsense-manager.html' title='Getting Started with AdSense Manager'/><author><name>PHP Blog</name><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-1032797411830546131.post-7652602273428966519</id><published>2009-05-10T17:51:00.000-07:00</published><updated>2009-05-10T17:58:30.131-07:00</updated><title type='text'>PHP script: SearchFeed Search Engine Script</title><content type='html'>&lt;span style="font-weight:bold;"&gt;SearchFeed Search Engine Script&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Using this script you can be running your own pay per click site in just a few minutes. Best of all it's FREE! SearchFeed Search Engine is one of best ways to make use of SearchFeed pay per click search engine affiliate program. SearchFeed Search Engine only takes a minute to configure, upload your files and just enter your SearchFeed account ID, tracking ID, site title, and you are up and running.&lt;br /&gt;&lt;br /&gt;SearchFeed Search Engine uses SearchFeed's XML feed to display search results. When JavaScript is used, you are limited to just a few results, don't have full control of source HTML, and depend on SearchFeed's servers to process results. By using XML SearchFeed just sends results, and your site does everything else. Average search takes about 1-2 seconds and each page loads in less than a second.&lt;br /&gt;&lt;br /&gt;Current SearchFeed Search Engine Features:&lt;br /&gt;# 100% Template based. You control how header, footer, and links are displayed. Updated&lt;br /&gt;# Displayed how many links you want per page. Updated&lt;br /&gt;# Each Search is stored in a session, so you don't query SearchFeed for each page.&lt;br /&gt;# Uses SearchFeed's XML Feed for maximum results and fast load time.&lt;br /&gt;# Language file to control all non template text.&lt;br /&gt;# Two new template files.&lt;br /&gt;# Option to compress output to save your bandwidth.&lt;br /&gt;&lt;br /&gt;Source code: &lt;br /&gt;&lt;a href="   http://www.ziddu.com/download/4696049/searchfeed.zip.html"&gt;download&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-7652602273428966519?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7652602273428966519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7652602273428966519' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7652602273428966519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7652602273428966519'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-searchfeed-search-engine.html' title='PHP script: SearchFeed Search Engine Script'/><author><name>PHP Blog</name><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-1032797411830546131.post-7439950252069975952</id><published>2009-05-09T00:57:00.000-07:00</published><updated>2009-05-09T01:01:34.514-07:00</updated><title type='text'>PHP script: Transform XML source code use XSL</title><content type='html'>Export xml file pass to xsl file on web with php&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$doc = "./xml/youxml.xml";&lt;br /&gt;&lt;br /&gt; $xml = new DOMDocument;&lt;br /&gt; $xml-&gt;load($doc);&lt;br /&gt; $xsl = new DOMDocument;&lt;br /&gt; $xsl-&gt;load('./xsl/format.xsl');&lt;br /&gt; // Configure the transformer&lt;br /&gt; $proc = new XSLTProcessor;&lt;br /&gt; $proc-&gt;importStyleSheet($xsl); // attach the xsl rules&lt;br /&gt;  &lt;br /&gt; echo $proc-&gt;transformToXML($xml);&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/1032797411830546131-7439950252069975952?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7439950252069975952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7439950252069975952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7439950252069975952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7439950252069975952'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-transform-xml-source-code.html' title='PHP script: Transform XML source code use XSL'/><author><name>PHP Blog</name><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-1032797411830546131.post-7791009989039251890</id><published>2009-05-08T00:43:00.000-07:00</published><updated>2009-05-08T00:46:59.858-07:00</updated><title type='text'>PHP function: show string unicode in string</title><content type='html'>Find and mark a small string in big string with unicode string&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;function str_post($string, $word)&lt;br /&gt;{&lt;br /&gt;   $retval = "";&lt;br /&gt;&lt;br /&gt;   $string = addslashes($string);&lt;br /&gt;   while($i&lt;=strlen($string))&lt;br /&gt;   {&lt;br /&gt;       if (strtolower(substr($string, $i, strlen($word))) == strtolower($word))&lt;br /&gt;       {&lt;br /&gt;           $retval .= substr($string, $pos1, $i)."&lt; font color = red&gt;";&lt;br /&gt;     $retval .= substr($string, $i, strlen($word))."&lt; /font&gt;";&lt;br /&gt;     $string = substr($string, $i + strlen($word));&lt;br /&gt;     $i = 0;     &lt;br /&gt;       }else{&lt;br /&gt;     $i++;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   if (strlen($string) &gt; 0) $retval .= $string;&lt;br /&gt;   return $retval;&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/1032797411830546131-7791009989039251890?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7791009989039251890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7791009989039251890' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7791009989039251890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7791009989039251890'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-function-show-string-unicode-in.html' title='PHP function: show string unicode in string'/><author><name>PHP Blog</name><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-1032797411830546131.post-8840674703570787274</id><published>2009-05-07T02:28:00.000-07:00</published><updated>2009-05-07T02:34:38.542-07:00</updated><title type='text'>PHP script: Update and populate a mySQL database using a loop</title><content type='html'>The most useful reader-rated php-scripts.com diary entries updated daily&lt;br /&gt;&lt;br /&gt;Now that we have dozens of diary entries, I'd like to display the most useful diary entries so that people who don't want to visit chronologically can visit the diary entries other readers have found the most useful. We already have done most of the work before in prior entries by creating the average function which will total each diary page and come up with an average on a page by page basis (see the bottom of the page). Since it could be somewhat server intensive to dynamically open and close all these files (if you want to know more about how opening dozens of files dynamically can be a disadvantage (especially if the information inside these files isn't frequently changing), then read the diary entry on 010700 for a further discussion), I'm going to make this part of the search log function we created before so that when we build the list of search pages with meta tags, we can also recalculate the average, but it will be a standalone script that can function on its own. We will require it into the search log script described on 010700. Yes, we could do this dynamically but again, I usually try to program with the path of least server resources used, that way as your site grows and you get more traffic, your scripts will not need severe modification to continue functioning as in intended. As you can probably see, we are building sort of a "daily update" script that could be executed once a day or multiple times per day (even as often as hourly would be fine). It is useful to plan your website building like this. If you do things today with the idea that you will one day have thousands of pages, it will make your life a lot easier modifying those pages.&lt;br /&gt;&lt;br /&gt;The first step - get the next filename&lt;br /&gt;&lt;br /&gt;We need to review the routine for how to cycle through a bunch of files in a directory. We can use an object dir or use the opendir function. I'm going to use the object method this time, since we used the opendir in our former version. It is kind of like using print and echo in the sense that each will do the same thing. Working with objects of course is an entirely different concept and one that can be complex for those newer to object-oriented programming, so let's review the code to cycle through our directory and pull out the .dat files, and an admittedly brief review of object-oriented programming:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$datapath = "/home/usr/www/votedir/data";&lt;br /&gt;chdir("$datapath");&lt;br /&gt;$maindir = dir(".");&lt;br /&gt;$maindir -&gt;rewind();&lt;br /&gt;while($thefile=$maindir-&gt;read()) {&lt;br /&gt;   if(($thefile != ".") AND ($thefile != "..") AND ($thefile != "index.html")) {&lt;br /&gt;     $myvalue = average2("$datapath/$thefile");&lt;br /&gt;     $myvalue = sprintf("%.2f", $myvalue);&lt;br /&gt;     $file = explode(".", $thefile);&lt;br /&gt;     $phpfile = "http://www.yourdomain.com/votedir/" . $file[0] . ".php3";&lt;br /&gt;     $meta = get_meta_tags($phpfile);&lt;br /&gt;     $desc = $meta["description"];&lt;br /&gt;       // generate the mySQL query&lt;br /&gt;       $query = "INSERT into avg_tally VALUES (0, ";&lt;br /&gt;       $query .= "'$myvalue', '$file[0]', '$desc')";&lt;br /&gt;       mysql_query($query, $mysql_link);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;$maindir-&gt;close();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE avg_tally&lt;br /&gt;(&lt;br /&gt;AVG_ID INT NOT NULL AUTO_INCREMENT,&lt;br /&gt;average FLOAT,&lt;br /&gt;filename CHAR(6),&lt;br /&gt;meta_desc VARCHAR(150),&lt;br /&gt;PRIMARY KEY(AVG_ID)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;You may notice the field "float" this is the field to use for floating point numbers. Also the use of the meta description which we grab as a better explanation for what the diary entry is about. We've already converted the $average into only having two decimal places by using the sprintf function.&lt;br /&gt;&lt;br /&gt;The second step - modify the average function&lt;br /&gt;&lt;br /&gt;We need to get the average function I created 7 months ago and provide a slight modification to it. We are going to call this new code function average2. The original code explanation for this is located here: 122699, but here is the code again that we are going to modify:&lt;br /&gt;&lt;br /&gt;&lt;?&lt;br /&gt;function average2($filename)&lt;br /&gt;{&lt;br /&gt;  global $average;&lt;br /&gt;  $x= -1;&lt;br /&gt;    if($file = fopen("$path/$filename", "r"))&lt;br /&gt;   {&lt;br /&gt;      while(!feof($file))&lt;br /&gt;     {&lt;br /&gt;      $therate = fgetss($file, 255);&lt;br /&gt;      $x++;&lt;br /&gt;      $count = $count + $therate;&lt;br /&gt;     }&lt;br /&gt;    fclose($file);&lt;br /&gt;   }&lt;br /&gt;$average = ($count / $x);&lt;br /&gt;return ($average);&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;We are introducing a statement I believe we haven't discussed yet called global. When you create functions the variables themselves used inside these functions cannot be used outside the function unless you use the global statement for the variable(s). In the case above by reviewing the red text you will see I have made sure we could return the value of $average instead of printing it like we do in the previously created average function. This is a better example of a function anyway since we wouldn't want to confine ourselves like I did in the original average function. Now with the new average2 function we can print the average, save the average to file, do whatever we want to do with this result. In our case, we are going to insert the average into the $avgs array. In the next diary I'll go through how to sort and display the results to complete this script in an alternating color table.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-8840674703570787274?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8840674703570787274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8840674703570787274' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8840674703570787274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8840674703570787274'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-update-and-populate-mysql.html' title='PHP script: Update and populate a mySQL database using a loop'/><author><name>PHP Blog</name><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-1032797411830546131.post-4037093538827616781</id><published>2009-05-06T00:09:00.000-07:00</published><updated>2009-05-06T00:13:50.125-07:00</updated><title type='text'>PHP function: Browser all files of folder</title><content type='html'>View all files in the folder. Searching through a directory and picking out files using a regular expression&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?&lt;br /&gt;$diary_directory = opendir(".");&lt;br /&gt;  while($filename = readdir($diary_directory))&lt;br /&gt;{&lt;br /&gt;    $filesplit = explode(".", $filename);&lt;br /&gt;    $check_filename = $filesplit[0];&lt;br /&gt;       if(ereg("[0-9]{6}", $check_filename))&lt;br /&gt;      {&lt;br /&gt;         $check_filename .= ".$filesplit[1]";&lt;br /&gt;         $valid_filename[] = $check_filename;&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;closedir($diary_directory);&lt;br /&gt;for($index = 0; $index &lt; count($valid_filename); $index++)&lt;br /&gt;{&lt;br /&gt;  print("$valid_filename[$index]&lt;br&gt;");&lt;br /&gt;}&lt;br /&gt;?&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/1032797411830546131-4037093538827616781?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4037093538827616781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4037093538827616781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4037093538827616781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4037093538827616781'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-function-browser-all-files-of.html' title='PHP function: Browser all files of folder'/><author><name>PHP Blog</name><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-1032797411830546131.post-46589995100132555</id><published>2009-05-05T00:23:00.000-07:00</published><updated>2009-05-05T00:24:52.897-07:00</updated><title type='text'>PHP Tutorial: Get Argument or Variable emvirment</title><content type='html'>&lt;?&lt;br /&gt;  $_PS = $_SERVER['PHP_SELF']; &lt;br /&gt;  $_PSTBL = split ("/",$_PS);&lt;br /&gt;  $_DR = $_SERVER['DOCUMENT_ROOT']; &lt;br /&gt;  $WEBHOST = $_SERVER['SERVER_NAME'];&lt;br /&gt;  $WEBBASE = "/" . $_PSTBL[1]; &lt;br /&gt;  $WEBROOT = $_DR . $WEBBASE;&lt;br /&gt;  if (isset($_GET)) {&lt;br /&gt;    while (list ($key, $val) = each ($_GET)) ${$key} = urldecode(trim($val));&lt;br /&gt;    while (list ($key, $val) = each ($_POST)) {&lt;br /&gt;  if (is_string($val)) {&lt;br /&gt;    ${$key} = trim($val);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;    while (list ($key, $val) = each ($_COOKIE)) ${$key} = urldecode(trim($val));&lt;br /&gt;    while (list ($key, $val) = each ($_SERVER )) ${$key} = urldecode(trim($val));&lt;br /&gt;  }&lt;br /&gt;  else if (isset($HTTP_GET_VARS)) {&lt;br /&gt;    while (list ($key, $val) = each ($HTTP_GET_VARS)) ${$key} = urldecode(trim($val));&lt;br /&gt;    while (list ($key, $val) = each ($HTTP_POST_VARS)) ${$key} = urldecode(trim($val));&lt;br /&gt;    while (list ($key, $val) = each ($HTTP_COOKIE_VARS)) ${$key} = urldecode(trim($val));&lt;br /&gt;   while (list ($key, $val) = each ($HTTP_SERVER_VARS)) ${$key} = urldecode(trim($val));&lt;br /&gt;  }&lt;br /&gt;  if (!isset($op)) $op = "";&lt;br /&gt;  if (!isset($ret)) $ret = "";&lt;br /&gt;  $oneShot =(isset($D2Username) &amp;&amp; ($ret != "close") &amp;&amp; ($ret != "test")) ? false : true; &lt;br /&gt;  $normalScreen = (isset($ScreenWidth) &amp;&amp; $ScreenWidth &gt;= 640) ? true : false;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-46589995100132555?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/46589995100132555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=46589995100132555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/46589995100132555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/46589995100132555'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-tutorial-get-argument-or-variable.html' title='PHP Tutorial: Get Argument or Variable emvirment'/><author><name>PHP Blog</name><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-1032797411830546131.post-6547819152558458131</id><published>2009-05-05T00:02:00.000-07:00</published><updated>2009-05-05T00:03:50.183-07:00</updated><title type='text'>PHP Script: Page counters</title><content type='html'>Creating a visible page counter is something I'd like to explore next. I have a stats program which tells me how many visitors I have already for each page that is essentially invisible, but I have received a number of emails expressing interest in how to make a counter using PHP that is visible. The code below inserted into a page counts the visitors and display the results dynamically.&lt;br /&gt;&lt;br /&gt;&lt;?&lt;br /&gt;if(file_exists("count.dat"))&lt;br /&gt;{&lt;br /&gt;  $exist_file = fopen("count.dat", "r");&lt;br /&gt;  $new_count = fgets($exist_file, 255);&lt;br /&gt;  $new_count++;&lt;br /&gt;  fclose($exist_file);&lt;br /&gt;  // to be invisible counter comment out next line;&lt;br /&gt;  print("$new_count people have visited this page");&lt;br /&gt;  $exist_count = fopen("count.dat", "w");&lt;br /&gt;  fputs($exist_count, $new_count);&lt;br /&gt;  fclose($exist_count);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;$new_file = fopen("count.dat", "w");&lt;br /&gt;fputs($new_file, "1");&lt;br /&gt;fclose($new_file);&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;Example #24: 17910 people have visited this page&lt;br /&gt;&lt;br /&gt;To insert the code to a page where you want the counter displayed you would use the following code:&lt;br /&gt;&lt;br /&gt;&lt;? require("/path/to/count.dat"); ?&gt;&lt;br /&gt;&lt;br /&gt;The first time you load your page you may think it isn't working, but if you look at the code above you'll see that it checks for the existence of count.dat and if it isn't there it creates the file for you, using the file_exists function. If count.dat doesn't exist then it will create it with the counter set as one. I could easily add a line to it that prints "you are visitor number 1" or something perhaps more dramatic, but I chose to leave it be. Admittedly this is a very basic script for counting the hits to a single page. Now what if we only wanted to count say, bookmarkers or type-ins?&lt;br /&gt;&lt;br /&gt;Counting only bookmark and type-in traffic&lt;br /&gt;&lt;br /&gt;Using the $HTTP_REFERER variable we can determine in most cases where a page visitor has come from. The reason I don't say all the time is because there are anonomizer type programs which will spoof or block this environment variable from recording accurate information as a means of providing the surfer some better security. So don't make it a habit to put all your programming eggs in the $HTTP_REFERER variable. However, for my example here, I am going to do this. When a surfer bookmarks your page or types your page URL into the browser window the $HTTP_REFERER variable will usually be blank.  So if I only wanted to count bookmarkers to a page I would add the following lines of code before the counting routine to the code above:&lt;br /&gt;&lt;br /&gt;if($HTTP_REFERER != "")&lt;br /&gt;{&lt;br /&gt;// go ahead and add one to the count and update the count.dat file&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Try adding the code above and you'll see it will only increment the counter if you type the URL into your browser or come from a bookmark. You can also hit refresh after you have typed in or come from a bookmark to increment the counter.  However, if you come from any hyperlink your visitors page count will not be incremented. Remember that the != means not equal to -- and when you say != "" it means that as long as there is something there, they must have come from other means than bookmark or type-in. I sometimes notice the words "bookmark" you could also add the regular expression to ignore case and look for the work bookmark by adding a second loop inside the above one:&lt;br /&gt;&lt;br /&gt;if(eregi("bookmark", $HTTP_REFERER)&lt;br /&gt;{&lt;br /&gt;// I found the word "bookmark" so don't count this visitor&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-6547819152558458131?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/6547819152558458131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=6547819152558458131' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6547819152558458131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6547819152558458131'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-page-counters.html' title='PHP Script: Page counters'/><author><name>PHP Blog</name><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-1032797411830546131.post-6514491765064600555</id><published>2009-05-04T01:44:00.000-07:00</published><updated>2009-05-04T01:46:23.315-07:00</updated><title type='text'>PHP Script: PHP Source Browser</title><content type='html'>This is just a VERY simple script to browse through a directory and it's sub-directories and be able to show the source of any .php file.&lt;br /&gt;&lt;br /&gt;It has a tiny amount of security to prevent people from going to a directory that starts with / or that contains ..&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$dir = (isset($_GET["dir"]) ? $_GET["dir"] : ".");&lt;br /&gt;$file = (isset($_GET["file"]) ? $_GET["file"] : "");&lt;br /&gt;&lt;br /&gt;if ((isset($dir) &amp;&amp; ($dir[0] == "/")) || (str_replace("..","",$dir) != $dir)) {&lt;br /&gt;    echo "permission denied";&lt;br /&gt;    exit;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if ($file) {&lt;br /&gt;    show_source($dir."/".$file);&lt;br /&gt;} else {&lt;br /&gt;    $dh = opendir($dir);&lt;br /&gt;    echo "Listing of ".$dir."&lt; br&gt;";&lt;br /&gt;    echo "&lt; ul&gt;";&lt;br /&gt;    while (($file = readdir($dh)) !== false) {&lt;br /&gt;        if (($file != "..") &amp;&amp; ($file != ".")) {&lt;br /&gt;            // it's not the static dirs . or ..&lt;br /&gt;            if (is_dir($dir."/".$file)) {&lt;br /&gt;                // it's a directory, show a directory link&lt;br /&gt;                echo "&lt; li&gt;&lt; a href=\"".$_SERVER["PHP_SELF"]."?dir=".$dir."/".$file."\"&gt;&lt; b&gt;$file/&lt; /b&gt;&lt; /a&gt;";&lt;br /&gt;            } else {&lt;br /&gt;                // it's a file&lt;br /&gt;                if (strtolower(substr($file, -4)) == ".php") {&lt;br /&gt;                    // it's a .php file, show source&lt;br /&gt;                    echo "&lt; li&gt;&lt; a href=\"".$_SERVER["PHP_SELF"]."?dir=".$dir."&amp;file=".$file."\"&gt;$file&lt; /a&gt;";&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    echo "&lt; /ul&gt;";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&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/1032797411830546131-6514491765064600555?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/6514491765064600555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=6514491765064600555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6514491765064600555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6514491765064600555'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-php-source-browser.html' title='PHP Script: PHP Source Browser'/><author><name>PHP Blog</name><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-1032797411830546131.post-8997665154517780936</id><published>2009-05-04T01:42:00.000-07:00</published><updated>2009-05-04T01:44:06.962-07:00</updated><title type='text'>PHP Script: Get the Source of a Remote HTML</title><content type='html'>Get the Source of a Remote HTML Document is a PHP script that can be used to determine the source and destination of remote HTML documents. Useful for proper citing of materials, linking to materials, and so on&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?php &lt;br /&gt;define('SHOW_HEADERS',false); &lt;br /&gt;&lt;br /&gt;function get_source($url,$show_headers=0) &lt;br /&gt;{ &lt;br /&gt;    if(preg_match('!^http://!',$url)) &lt;br /&gt;        $url=substr($url,7,strlen($url)); &lt;br /&gt;&lt;br /&gt;    if($start=strpos($url,'/')) &lt;br /&gt;        $uri=substr($url,$start,strlen($url)); &lt;br /&gt;    else &lt;br /&gt;        $uri=''; &lt;br /&gt;&lt;br /&gt;    $fp=fsockopen($url,80,$errno,$errstr,4); &lt;br /&gt;    if(!$fp) &lt;br /&gt;    { &lt;br /&gt;        echo "&lt; b&gt;&lt; font color=\"red\"&gt;Unable to connect to: $url&lt; /font&gt;&lt; /b&gt;"; &lt;br /&gt;        return false; &lt;br /&gt;    } &lt;br /&gt;    else &lt;br /&gt;    { &lt;br /&gt;        $buffer=''; &lt;br /&gt;        $headers=''; &lt;br /&gt;&lt;br /&gt;        fputs($fp,"GET /$uri HTTP/1.0\r\n"); &lt;br /&gt;        fputs($fp,"Host: $url\r\n"); &lt;br /&gt;        //fputs($fp,"Referer: http://www.plebian.com\r\n"); &lt;br /&gt;        fputs($fp,"User-Agent: sourcegetter\r\n"); &lt;br /&gt;        //fputs($fp,"Cookie: x=y;a=b\r\n"); &lt;br /&gt;        fputs($fp,"Connection: close\r\n"); &lt;br /&gt;&lt;br /&gt;        fputs($fp,"\r\n"); &lt;br /&gt;        while(!feof($fp)) &lt;br /&gt;        { &lt;br /&gt;            if(!isset($end_of_headers)) &lt;br /&gt;            { &lt;br /&gt;                $header=fgets($fp,4096); &lt;br /&gt;                if($header=="\r\n") &lt;br /&gt;                    $end_of_headers=1; &lt;br /&gt;                $headers.=$header; &lt;br /&gt;            } &lt;br /&gt;            else &lt;br /&gt;            { &lt;br /&gt;                $buffer.=fgets($fp,4096); &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        fclose($fp); &lt;br /&gt;&lt;br /&gt;        if($show_headers) &lt;br /&gt;        { &lt;br /&gt;            $headers=htmlentities($headers); &lt;br /&gt;            $headers=nl2br($headers); &lt;br /&gt;&lt;br /&gt;            echo $headers; &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        $buffer=htmlentities($buffer); &lt;br /&gt;        $buffer=nl2br($buffer); &lt;br /&gt;&lt;br /&gt;        echo $buffer; &lt;br /&gt;&lt;br /&gt;        return true; &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;echo '&lt;tt&gt;'; &lt;br /&gt;get_source('www.yoursite.com',SHOW_HEADERS); &lt;br /&gt;echo '&lt;/tt&gt;'; &lt;br /&gt;?&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/1032797411830546131-8997665154517780936?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8997665154517780936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8997665154517780936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8997665154517780936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8997665154517780936'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-get-source-of-remote-html.html' title='PHP Script: Get the Source of a Remote HTML'/><author><name>PHP Blog</name><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-1032797411830546131.post-9129651373592905006</id><published>2009-05-02T18:19:00.000-07:00</published><updated>2009-05-02T18:22:20.466-07:00</updated><title type='text'>PHP Script: Export form MySql to Ms Excel</title><content type='html'>This php script will write data from php using text from an SQL table (MySQL, supply your own SQL query) to a microsoft excel (.xls) file. The Excel file is specified as such by a set of headers, defining content, using php's header() function.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;include('DB_connection.php');&lt;br /&gt;$result = mysql_query('select * from excel_test', $linkID);&lt;br /&gt;$count = mysql_num_fields($result);&lt;br /&gt;&lt;br /&gt;for ($i = 0; $i &lt; $count; $i++){&lt;br /&gt;    $header .= mysql_field_name($result, $i)."\t";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;while($row = mysql_fetch_row($result)){&lt;br /&gt;  $line = '';&lt;br /&gt;  foreach($row as $value){&lt;br /&gt;    if(!isset($value) || $value == ""){&lt;br /&gt;      $value = "\t";&lt;br /&gt;    }else{&lt;br /&gt;# important to escape any quotes to preserve them in the data.&lt;br /&gt;      $value = str_replace('"', '""', $value);&lt;br /&gt;# needed to encapsulate data in quotes because some data might be multi line.&lt;br /&gt;# the good news is that numbers remain numbers in Excel even though quoted.&lt;br /&gt;      $value = '"' . $value . '"' . "\t";&lt;br /&gt;    }&lt;br /&gt;    $line .= $value;&lt;br /&gt;  }&lt;br /&gt;  $data .= trim($line)."\n";&lt;br /&gt;}&lt;br /&gt;# this line is needed because returns embedded in the data have "\r"&lt;br /&gt;# and this looks like a "box character" in Excel&lt;br /&gt;  $data = str_replace("\r", "", $data);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Nice to let someone know that the search came up empty.&lt;br /&gt;# Otherwise only the column name headers will be output to Excel.&lt;br /&gt;if ($data == "") {&lt;br /&gt;  $data = "\n no matching records found\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# This line will stream the file to the user rather than spray it across the screen&lt;br /&gt;header("Content-type: application/octet-stream");&lt;br /&gt;&lt;br /&gt;# replace excelfile.xls with whatever you want the filename to default to&lt;br /&gt;header("Content-Disposition: attachment; filename=excelfile.xls");&lt;br /&gt;header("Pragma: no-cache");&lt;br /&gt;header("Expires: 0");&lt;br /&gt;&lt;br /&gt;echo $header."\n".$data;&lt;br /&gt;?&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/1032797411830546131-9129651373592905006?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/9129651373592905006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=9129651373592905006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9129651373592905006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9129651373592905006'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-script-export-form-mysql-to-ms.html' title='PHP Script: Export form MySql to Ms Excel'/><author><name>PHP Blog</name><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-1032797411830546131.post-8020201908777696207</id><published>2009-05-02T18:03:00.000-07:00</published><updated>2009-05-02T18:08:16.178-07:00</updated><title type='text'>PHP Toturial:  Upload from MS-Access database to a MySQL server</title><content type='html'>This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. The table must&lt;br /&gt;already exist on MySQL It will figure out which fields are defined in the MySQL table and then upload the coresponding&lt;br /&gt;field from the ODBC ressource. If you give it no arguments. It will show you a list of tables in the MySQL database. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;/*&lt;br /&gt;* This include file defines the functions html_header and html_footer&lt;br /&gt;*/&lt;br /&gt;require( "design.inc");&lt;br /&gt;$mysqldb = "concord";&lt;br /&gt;&lt;br /&gt;function nonfatal_error($message)&lt;br /&gt;{&lt;br /&gt;printf( "&lt; H1&gt;%s&lt; /H1&gt;\n",$message);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function upload_records($odbcfd,$myfd,$mysqldb,$table)&lt;br /&gt;{&lt;br /&gt;/*&lt;br /&gt;* Figure out which columns the mysql database has&lt;br /&gt;*/&lt;br /&gt;$fieldlist = mysql_list_fields($mysqldb,$table);&lt;br /&gt;$numof = mysql_num_fields($fieldlist);&lt;br /&gt;for($i = 0; $i &lt; $numof; $i++)&lt;br /&gt;{&lt;br /&gt;$fieldname = mysql_field_name($fieldlist,$i);&lt;br /&gt;if($i == 0)&lt;br /&gt;$columnlist = $fieldname;&lt;br /&gt;else&lt;br /&gt;$columnlist = $columnlist . "," . $fieldname;&lt;br /&gt;$fieldtype = mysql_field_type($fieldlist,$i);&lt;br /&gt;switch($fieldtype)&lt;br /&gt;{&lt;br /&gt;case "string":&lt;br /&gt;case "datetime":&lt;br /&gt;$fieldquotes[$fieldname] = "'";&lt;br /&gt;break;&lt;br /&gt;default:&lt;br /&gt;$fieldquotes[$fieldname] = "";&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/*&lt;br /&gt;* Query the ODBC database and loop through the result.&lt;br /&gt;*/&lt;br /&gt;$res = odbc_exec($odbcfd, "SELECT * FROM $table");&lt;br /&gt;if($res == 0)&lt;br /&gt;{&lt;br /&gt;nonfatal_error( "Couldn't exec SELECT statement on ODBC database");&lt;br /&gt;return(0);&lt;br /&gt;}&lt;br /&gt;/*&lt;br /&gt;* Now we know we can query the ODBC database we can delete the records from&lt;br /&gt;the Mysql&lt;br /&gt;* database&lt;br /&gt;*/&lt;br /&gt;mysql_db_query($mysqldb, "DELETE FROM $table",$myfd);&lt;br /&gt;$rowinx = 0;&lt;br /&gt;while(odbc_fetch_row($res))&lt;br /&gt;{&lt;br /&gt;/*&lt;br /&gt;* Generate the SQL INSERT STATEMENT&lt;br /&gt;*/&lt;br /&gt;for($i = 0; $i &lt; $numof; $i++)&lt;br /&gt;{&lt;br /&gt;$fieldname = mysql_field_name($fieldlist,$i);&lt;br /&gt;if($i == 0)&lt;br /&gt;$vallist = $fieldquotes[$fieldname] .&lt;br /&gt;addslashes(odbc_result($res,$fieldname)) .&lt;br /&gt;$fieldquotes[$fieldname] ;&lt;br /&gt;else&lt;br /&gt;$vallist = $vallist . "," . $fieldquotes[$fieldname] .&lt;br /&gt;addslashes(odbc_result($res,$fieldname)) .&lt;br /&gt;$fieldquotes[$fieldname] ;&lt;br /&gt;}&lt;br /&gt;$cmd = "INSERT INTO $table ($columnlist) VALUES ($vallist)";&lt;br /&gt;if($rowinx % 10 == 0)&lt;br /&gt;echo "&lt;br&gt;";&lt;br /&gt;printf( " %06s\n ",$rowinx);&lt;br /&gt;if(mysql_db_query($mysqldb,$cmd,$myfd) == 0)&lt;br /&gt;{&lt;br /&gt;nonfatal_error(mysql_error());&lt;br /&gt;}&lt;br /&gt;$rowinx++;&lt;br /&gt;}&lt;br /&gt;return(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*-----------------------------------------------------------------&lt;br /&gt;* Start of the program&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Connect to the MySQL server&lt;br /&gt;*/&lt;br /&gt;$myfd = mysql_connect( "atilia", "guest", "xxxx");&lt;br /&gt;if($myfd &lt;= 0)&lt;br /&gt;{&lt;br /&gt;nonfatal_error( "Couldn't open MySQL database");&lt;br /&gt;exit($myfd);&lt;br /&gt;}&lt;br /&gt;/*&lt;br /&gt;* Connect to the ODBC ressource.&lt;br /&gt;* The DSN must be defined in the executing computer's ODBC tables&lt;br /&gt;*/&lt;br /&gt;$odbcfd = odbc_connect( "ConcAccess", "x", "e");&lt;br /&gt;if($odbcfd &lt;= 0)&lt;br /&gt;{&lt;br /&gt;nonfatal_error( "Couldn't open ODBC database");&lt;br /&gt;exit($odbcfd);&lt;br /&gt;}&lt;br /&gt;function list_tables($mysqldb)&lt;br /&gt;{&lt;br /&gt;echo "&lt; UL&gt;\n";&lt;br /&gt;$tables= mysql_list_tables($mysqldb);&lt;br /&gt;for($i = 0; $i &lt; mysql_num_rows($tables);$i++)&lt;br /&gt;{&lt;br /&gt;printf( "&lt; LI&gt;Upload table &lt; A HREF=\"upload.php3?table=%s\" &gt;%s&lt; /A&gt;\n",&lt;br /&gt;mysql_tablename($tables,$i),&lt;br /&gt;mysql_tablename($tables,$i));&lt;br /&gt;}&lt;br /&gt;echo "&lt; /UL&gt;\n";&lt;br /&gt;}&lt;br /&gt;switch ($table)&lt;br /&gt;{&lt;br /&gt;case "":&lt;br /&gt;html_header( "Update Database on mysql");&lt;br /&gt;?&gt;&lt;br /&gt;&lt;P&gt;This page allows you to upload tables from the MS-Access database to the&lt;br /&gt;database&lt;br /&gt;on the webserver. There &lt;I&gt;might&lt;/I&gt; be some uploading errors. This is the&lt;br /&gt;reason&lt;br /&gt;you can only upload one table at a time. You should select a table and then&lt;br /&gt;look at the&lt;br /&gt;result for errors.&lt;/P&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;list_tables($mysqldb);&lt;br /&gt;break;&lt;br /&gt;default:&lt;br /&gt;html_header( "Uploading $table");&lt;br /&gt;echo ( "Row ## Row ## Row ## Row ## Row ## Row ## Row ## Row ## Row ##&lt;br /&gt;Row ##&lt;br&gt;\n");&lt;br /&gt;$tables= mysql_list_tables($mysqldb);&lt;br /&gt;$dotable=0;&lt;br /&gt;for($i = 0; $i &lt; mysql_num_rows($tables); $i++)&lt;br /&gt;if(mysql_tablename($tables,$i) == $table)&lt;br /&gt;{&lt;br /&gt;$dotable=1;&lt;br /&gt;}&lt;br /&gt;if($dotable == 1)&lt;br /&gt;upload_records($odbcfd,$myfd,$mysqldb,$table);&lt;br /&gt;else&lt;br /&gt;nonfatal_error( "There was no such table");&lt;br /&gt;&lt;br /&gt;list_tables($mysqldb);&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;odbc_close($odbcfd);&lt;br /&gt;mysql_close($myfd);&lt;br /&gt;html_footer();&lt;br /&gt;?&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/1032797411830546131-8020201908777696207?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8020201908777696207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8020201908777696207' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8020201908777696207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8020201908777696207'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-toturial-upload-from-ms-access.html' title='PHP Toturial:  Upload from MS-Access database to a MySQL server'/><author><name>PHP Blog</name><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-1032797411830546131.post-4171473532837730763</id><published>2009-05-01T07:25:00.000-07:00</published><updated>2009-05-01T07:29:12.023-07:00</updated><title type='text'>PHP Toturial: Keyword Density Analysis Functions</title><content type='html'>This set of php keyword density functions enables you to generate a keyword density report of a given url. It includes a stop words function and a punctuation cleaning function.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;function kda($url)&lt;br /&gt;{&lt;br /&gt;    &lt;br /&gt;    if(!stristr($url, 'http://'))&lt;br /&gt;    {&lt;br /&gt;        $url = 'http://'.$url;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if($html = @file_get_contents($url))&lt;br /&gt;    {&lt;br /&gt;    $html = html_entity_decode(file_get_contents($url));&lt;br /&gt;    //preg_match('/(?&lt;=&lt; title&gt;).*?(?=&lt;\\/ title&gt;)/is', $html, $matches);&lt;br /&gt;    //$title = array_shift($matches);&lt;br /&gt;    &lt;br /&gt;    $meta_tags = get_meta_tags($url);&lt;br /&gt;    $html = kda_strip_tag_script($html);&lt;br /&gt;    $no_html = strip_tags($html);&lt;br /&gt;    &lt;br /&gt;    $tag_info = $meta_tags['description']." ".$meta_tags['keywords'];&lt;br /&gt;    $text .= $tag_info." ".$no_html;    &lt;br /&gt;    $total = count(explode(' ', $text));&lt;br /&gt;    &lt;br /&gt;    $text = kda_clean(kda_stopWords($text));&lt;br /&gt;    $words = explode(' ', $text);    &lt;br /&gt;    $total = count($words);    &lt;br /&gt;    for($x=0; $x&lt;$total; $x++)&lt;br /&gt;    {&lt;br /&gt;        $words[$x] = trim($words[$x]);&lt;br /&gt;        if($words[$x]!='')&lt;br /&gt;        {        &lt;br /&gt;        $ws[$words[$x]]++;&lt;br /&gt;        if(trim($words[$x+1])!='')&lt;br /&gt;        {&lt;br /&gt;            $phrase2 = $words[$x]." ".trim($words[$x+1]);&lt;br /&gt;            $ws[$phrase2]++;&lt;br /&gt;            if(trim($words[$x+2])!='')&lt;br /&gt;            {&lt;br /&gt;                $phrase3 = $words[$x]." ".trim($words[$x+1])." ".trim($words[$x+2]);&lt;br /&gt;                $ws[$phrase3]++;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;    foreach($ws as $word=&gt;$count)&lt;br /&gt;    {&lt;br /&gt;        if( ($count&gt;1) and (strlen($word)&gt;2) )&lt;br /&gt;        {&lt;br /&gt;            $phrase_size = count(explode(' ', $word));&lt;br /&gt;            $occurances[$phrase_size] = $occurances[$phrase_size] + $count;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    foreach($ws as $word=&gt;$count)&lt;br /&gt;    {&lt;br /&gt;        if( ($count&gt;1) and (strlen($word)&gt;2) )&lt;br /&gt;        {&lt;br /&gt;            $phrase_size = count(explode(' ', $word));            &lt;br /&gt;            $density = round( ($count/$occurances[$phrase_size])*100, 2);            &lt;br /&gt;            $dens[$phrase_size][$word] = $density;                        &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    arsort($dens[1]);&lt;br /&gt;    if($dens[2])&lt;br /&gt;    {&lt;br /&gt;        arsort($dens[2]);&lt;br /&gt;    }&lt;br /&gt;    if($dens[3])&lt;br /&gt;    {        &lt;br /&gt;        arsort($dens[3]);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    $return = array('dens'=&gt;$dens, 'occurances'=&gt;$occurances);&lt;br /&gt;    /*&lt;br /&gt;    echo "&lt; pre&gt;";&lt;br /&gt;    print_r($occurances);&lt;br /&gt;    print_r($dens);&lt;br /&gt;    */&lt;br /&gt;    return $return ;&lt;br /&gt;}else {&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;function kda_strip_tag_script($html) {&lt;br /&gt;    $pos1 = false;&lt;br /&gt;    $pos2 = false;&lt;br /&gt;    do {&lt;br /&gt;        if ($pos1 !== false &amp;&amp; $pos2 !== false) {&lt;br /&gt;            $first = NULL;&lt;br /&gt;            $second = NULL;&lt;br /&gt;            if ($pos1 &gt; 0)&lt;br /&gt;                 $first = substr($html, 0, $pos1);&lt;br /&gt;            if ($pos2 &lt; strlen($html) - 1)&lt;br /&gt;                $second = substr($html, $pos2);&lt;br /&gt;            $html = $first . $second;&lt;br /&gt;        }&lt;br /&gt;        preg_match("/&lt;script[^&gt;]*&gt;/i", $html, $matches);&lt;br /&gt;        $str1 =&amp; $matches[0];&lt;br /&gt;        preg_match("/&lt;\/script&gt;/i", $html, $matches);&lt;br /&gt;        $str2 =&amp; $matches[0];&lt;br /&gt;       $pos1 = strpos($html, $str1);&lt;br /&gt;        $pos2 = strpos($html, $str2);&lt;br /&gt;       if ($pos2 !== false)&lt;br /&gt;            $pos2 += strlen($str2);&lt;br /&gt;    } while ($pos1 !== false &amp;&amp; $pos2 !== false);&lt;br /&gt;    return $html;&lt;br /&gt;}&lt;br /&gt;function kda_clean($text)&lt;br /&gt;{&lt;br /&gt;global $stopwords_file;&lt;br /&gt;    $text = str_replace('.', '', $text);&lt;br /&gt;    $text = str_replace(',', '', $text);&lt;br /&gt;    $text = str_replace('(', '', $text);&lt;br /&gt;    $text = str_replace(')', '', $text);    &lt;br /&gt;    $text = str_replace('_', '', $text);&lt;br /&gt;    $text = str_replace('*', '', $text);    &lt;br /&gt;    $text = str_replace('"', '', $text);    &lt;br /&gt;    $text = str_replace('-', '', $text);    &lt;br /&gt;    $text = str_replace("!", '', $text);    &lt;br /&gt;    $text = str_replace("?", '', $text);    &lt;br /&gt;    $text = str_replace("\n", '', $text);    &lt;br /&gt;    $text = str_replace('/', '', $text);    &lt;br /&gt;    $text = str_replace('&amp;#8217;', "'", $text);    &lt;br /&gt;    &lt;br /&gt;    return trim(strtolower($text));&lt;br /&gt;}&lt;br /&gt;function kda_stopWords($term)&lt;br /&gt;    {&lt;br /&gt;        global $sw_count;&lt;br /&gt;    //load list of common words&lt;br /&gt;    $common = file('kdawords.txt');&lt;br /&gt;    $total = count($common);    &lt;br /&gt;    for ($x=0; $x&lt;= $total; $x++)&lt;br /&gt;    {&lt;br /&gt;        $common[$x] = trim(strtolower($common[$x]));&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    //make array of search terms        &lt;br /&gt;    $_terms = explode(" ", $term);&lt;br /&gt;    &lt;br /&gt;        foreach ($_terms as $line)&lt;br /&gt;        {&lt;br /&gt;            if (in_array(strtolower(trim($line)), $common))&lt;br /&gt;            {                &lt;br /&gt;                $removeKey = array_search($line, $_terms);&lt;br /&gt;                $sw_count++;&lt;br /&gt;                unset($_terms[$removeKey]);                &lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                $clean_term .= " ".$line;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        return $clean_term;    &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;?&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/1032797411830546131-4171473532837730763?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4171473532837730763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4171473532837730763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4171473532837730763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4171473532837730763'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/05/php-toturial-keyword-density-analysis.html' title='PHP Toturial: Keyword Density Analysis Functions'/><author><name>PHP Blog</name><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-1032797411830546131.post-7898468671163799426</id><published>2009-04-30T07:02:00.001-07:00</published><updated>2009-04-30T07:05:47.804-07:00</updated><title type='text'>PHP Toturial: Function for encrypting, decrypting, and hashing data</title><content type='html'>Mcrypt is a wonderful set of library functions for encrypting, decrypting, and hashing data. For Debian users, getting Mcrypt is apparently.&lt;br /&gt;First, install libmcrypt.&lt;br /&gt;You should now have mcrypt.so in /usr/lib/php4&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;?&lt;br /&gt;/* run a self-test through every listed cipher and mode&lt;br /&gt;*/&lt;br /&gt;function mcrypt_check_sanity() {&lt;br /&gt;$modes = mcrypt_list_modes();&lt;br /&gt;$algorithms = mcrypt_list_algorithms();&lt;br /&gt;&lt;br /&gt;foreach ($algorithms as $cipher) {&lt;br /&gt;       if(mcrypt_module_self_test($cipher)) {&lt;br /&gt;               print $cipher." ok.&lt;br /&gt;\n";&lt;br /&gt;       } else {&lt;br /&gt;               print $cipher." not ok.&lt;br /&gt;\n";&lt;br /&gt;       }&lt;br /&gt;       foreach ($modes as $mode) {&lt;br /&gt;               if(mcrypt_test_module_mode($cipher,$mode)) {&lt;br /&gt;                       $result = "ok";&lt;br /&gt;               } else {&lt;br /&gt;                       $result = "not ok";&lt;br /&gt;               }&lt;br /&gt;               print $cipher." in mode ".$mode." ".$result."&lt;br /&gt;\n";&lt;br /&gt;               mcrypt_module_close($td);&lt;br /&gt;       }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// a variant on the example posted in mdecrypt_generic&lt;br /&gt;// that works on versions of libmcrypt&lt;br /&gt;// without mcrypt_generic_deinit() defined&lt;br /&gt;function mcrypt_test_module_mode($module,$mode) {&lt;br /&gt; /* Data */&lt;br /&gt; $key = 'this is a very long key, even too long for the cipher';&lt;br /&gt; $plain_text = 'very important data';&lt;br /&gt;&lt;br /&gt; /* Open module, and create IV */&lt;br /&gt; $td = mcrypt_module_open($module, '',$mode, '');&lt;br /&gt; $key = substr($key, 0, mcrypt_enc_get_key_size($td));&lt;br /&gt; $iv_size = mcrypt_enc_get_iv_size($td);&lt;br /&gt; $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);&lt;br /&gt;&lt;br /&gt; /* Initialize encryption handle */&lt;br /&gt;if (mcrypt_generic_init($td, $key, $iv) != -1) {&lt;br /&gt;&lt;br /&gt; /* Encrypt data */&lt;br /&gt; $c_t = mcrypt_generic($td, $plain_text);&lt;br /&gt; mcrypt_generic_end($td);&lt;br /&gt; mcrypt_module_close($td);&lt;br /&gt;&lt;br /&gt; /* Reinitialize buffers for decryption */&lt;br /&gt; /* Open module, and create IV */&lt;br /&gt; $td = mcrypt_module_open($module, '', $mode, '');&lt;br /&gt; $key = substr($key, 0, mcrypt_enc_get_key_size($td));&lt;br /&gt; $iv_size = mcrypt_enc_get_iv_size($td);&lt;br /&gt; $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);&lt;br /&gt;&lt;br /&gt; mcrypt_generic_init($td, $key, $iv);&lt;br /&gt; $p_t = mdecrypt_generic($td, $c_t);&lt;br /&gt;&lt;br /&gt; /* Clean up */&lt;br /&gt; mcrypt_generic_end($td);&lt;br /&gt; mcrypt_module_close($td);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;if (strncmp($p_t, $plain_text, strlen($plain_text)) == 0) {&lt;br /&gt;       return TRUE;&lt;br /&gt;} else {&lt;br /&gt;       return FALSE;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// remember to call:&lt;br /&gt;// mcrypt_check_sanity();&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Obviously, there is lots more to be learned at:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.php.net/manual/en/ref.mcrypt.php"&gt;http://www.php.net/manual/en/ref.mcrypt.php&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-7898468671163799426?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7898468671163799426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7898468671163799426' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7898468671163799426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7898468671163799426'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-toturial-function-for-encrypting.html' title='PHP Toturial: Function for encrypting, decrypting, and hashing data'/><author><name>PHP Blog</name><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-1032797411830546131.post-8713093175184498781</id><published>2009-04-29T08:00:00.000-07:00</published><updated>2009-04-29T08:05:09.941-07:00</updated><title type='text'>PHP Script: Convert TCVN to Unicode by PHP code</title><content type='html'>Use two array to convert tcvn to unicode by PHP code&lt;br /&gt;&lt;br /&gt;$tcvnpos = array(184,181,182,183,185,168,190,187,188,189,198,169,202,199,200,201,203,208,204,206,207,209,170,213,210,211,212,214,221,215,216,220,222,227,223,225,226,228,171,232,229,230,231,233,172,237,234,235,236,238,243,239,241,242,244,173,248,245,246,247,249,253,250,251,252,254,174,184,181,182,183,185,161,190,187,188,189,198,162,202,199,200,201,203,208,204,206,207,209,163,213,210,211,212,214,221,215,216,220,222,227,223,225,226,228,164,232,229,230,231,233,165,237,234,235,236,238,243,239,241,242,244,166,248,245,246,247,249,253,250,251,252,254,167);&lt;br /&gt;&lt;br /&gt;// $tcvnpos&lt;br /&gt;$unichars = array("Ã¡","Ã ","áº£","Ã£","áº¡","Äƒ","áº¯","áº±","áº³","áºµ","áº·","Ã¢","áº¥","áº§","áº©","áº«","áº­","Ã©","Ã¨","áº»","áº½","áº¹","Ãª","áº¿","á»�","á»ƒ","á»…","á»‡","Ã­","Ã¬","á»‰","Ä©","á»‹","Ã³","Ã²","á»�","Ãµ","á»�","Ã´","á»‘","á»“","á»•","á»—","á»™","Æ¡","á»›","á»�","á»Ÿ","á»¡","á»£","Ãº","Ã¹","á»§","Å©","á»¥","Æ°","á»©","á»«","á»­","á»¯","á»±","Ã½","á»³","á»·","á»¹","á»µ","Ä‘","Ã�","ï»¿Ã€","áº¢","Ãƒ","áº ","Ä‚","áº®","áº°","áº²","áº´","áº¶","Ã‚","áº¤","áº¦","áº¨","áºª","áº¬","Ã‰","Ãˆ","áºº","áº¼","áº¸","ÃŠ","áº¾","á»€","á»‚","á»„","á»†","Ã�","ÃŒ","á»ˆ","Ä¨","á»Š","Ã“","Ã’","á»Ž","Ã•","á»Œ","Ã”","á»�","á»’","á»”","á»–","á»˜","Æ ","á»š","á»œ","á»ž","á» ","á»¢","Ãš","Ã™","á»¦","Å¨","á»¤","Æ¯","á»¨","á»ª","á»¬","á»®","á»°","Ã�","á»²","á»¶","á»¸","á»´","Ä�");&lt;br /&gt;    //  2 array $tcvnpos to  $unichar&lt;br /&gt;    $mapping = array();&lt;br /&gt;    // $mapping function&lt;br /&gt;    function mapping(){&lt;br /&gt;        for($j=0;$j&lt;sizeof($unichars);$j++){&lt;br /&gt;            $this-&gt;mapping[$tcvnpos[$j]] = $unichars[$j];&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    // Convert TCVN3 to Unicode&lt;br /&gt;    function TCVN3ToUnicode($value = null) {&lt;br /&gt;        $str='';&lt;br /&gt;        for($i=0;$i&lt;strlen($value);$i++){&lt;br /&gt;            $ch = $value[$i];&lt;br /&gt;            //  ASCII&lt;br /&gt;            $stt = ord($ch);&lt;br /&gt;            if($stt&gt;127){&lt;br /&gt;                //abc...&lt;br /&gt;                if($mapping[$stt]){&lt;br /&gt;                    $unipos = $mapping[$stt];&lt;br /&gt;                    $str = $str.$unipos;&lt;br /&gt;                }else{&lt;br /&gt;                    $str = $str.$ch;&lt;br /&gt;                }&lt;br /&gt;            }else{&lt;br /&gt;                //  abc...&lt;br /&gt;                $str = $str.$ch;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        return $str;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-8713093175184498781?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8713093175184498781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8713093175184498781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8713093175184498781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8713093175184498781'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-convert-tcvn-to-unicode-by.html' title='PHP Script: Convert TCVN to Unicode by PHP code'/><author><name>PHP Blog</name><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-1032797411830546131.post-6262758161289608767</id><published>2009-04-28T02:51:00.000-07:00</published><updated>2009-04-28T02:58:39.722-07:00</updated><title type='text'>PHP Script: Read text file line by line</title><content type='html'>Read text file line by line&lt;br /&gt;&lt;?&lt;br /&gt;function readLine($file, $line_num, $delimiter="\n")&lt;br /&gt;{&lt;br /&gt;    /*** set the counter to one ***/&lt;br /&gt;    $i = 1;&lt;br /&gt;&lt;br /&gt;    /*** open the file for reading ***/&lt;br /&gt;    $fp = fopen( $file, 'r' );&lt;br /&gt;&lt;br /&gt;    /*** loop over the file pointer ***/&lt;br /&gt;    while ( !feof ( $fp) )&lt;br /&gt;    {&lt;br /&gt;        /*** read the line into a buffer ***/&lt;br /&gt;        $buffer = stream_get_line( $fp, 1024, $delimiter );&lt;br /&gt;        /*** if we are at the right line number ***/&lt;br /&gt;        if( $i == $line_num )&lt;br /&gt;        {&lt;br /&gt;            /*** return the line that is currently in the buffer ***/&lt;br /&gt;            return $buffer;&lt;br /&gt;        }&lt;br /&gt;        /*** increment the line counter ***/&lt;br /&gt;        $i++;&lt;br /&gt;        /*** clear the buffer ***/&lt;br /&gt;        $buffer = '';&lt;br /&gt;    }&lt;br /&gt;    return false;&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-6262758161289608767?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/6262758161289608767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=6262758161289608767' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6262758161289608767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6262758161289608767'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-read-text-file-line-by-line.html' title='PHP Script: Read text file line by line'/><author><name>PHP Blog</name><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-1032797411830546131.post-832186401971713613</id><published>2009-04-27T03:07:00.000-07:00</published><updated>2009-04-27T03:14:45.476-07:00</updated><title type='text'>PHP Script: Robots.txt Generator</title><content type='html'>Robots.txt Generator lets you browse through your server’s directory structure. The robots.txt file sets permissions for indexing activities. Additionally the script warns the user, if no index-files or htaccess files were found.&lt;br /&gt;This script lets you browse through your server’s directory structure. If a robots.txt is found, it is read and the appropriate allowed/disallowed folders are checked/unchecked. Just change the checkers and hit the “update” button to update the robots.txt. You may also delete the file or edit the comment. Changes are always made to “User-agent: *”. Additionally the script warns, if no index-files or htaccess files were found.&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt; html&gt;&lt;br /&gt;&lt; head&gt;&lt;br /&gt;&lt; style type="text/css"&gt;&lt;br /&gt;&lt; !--&lt;br /&gt;body { font-family: Verdana; }&lt;br /&gt;-- &gt;&lt;br /&gt;&lt; /style&gt;&lt;br /&gt;&lt; /head&gt;&lt;br /&gt;&lt; body&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;// Setzen der notwendigen Variablen&lt;br /&gt;$deletefile = ((isset($_GET['deletefile'])==true) ? $_GET['deletefile'] : 0);&lt;br /&gt;$update     = ((isset($_GET['update'])==true) ? $_GET['update'] : 0);&lt;br /&gt;$changedir  = ((isset($_GET['changedir'])==true) ? $_GET['changedir'] : 0);&lt;br /&gt;$comment    = ((isset($_GET['comment'])==true) ? $_GET['comment'] : "");&lt;br /&gt;$dir        = ((isset($_GET['dir'])==true) ? $_GET['dir'] : $_SERVER['DOCUMENT_ROOT']);&lt;br /&gt;$id         = ((isset($_GET['id'])==true) ? $_GET['id'] : null);&lt;br /&gt;&lt;br /&gt;// Minimieren des Anpassungsaufwands&lt;br /&gt;$_PHPSELF = ((isset($PHP_SELF)==true) ? $PHP_SELF : $_SERVER['PHP_SELF']);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if($deletefile==1)&lt;br /&gt;{&lt;br /&gt;  if(@unlink("robots.txt"))&lt;br /&gt;    print "&lt; font color=green&gt;robots.txt successfully deleted&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;  else&lt;br /&gt;    print "&lt; font color=red&gt;could not delete robots.txt&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (!isset($dir) || (!$dir))&lt;br /&gt;  $dir =".";&lt;br /&gt;if (is_dir($dir))&lt;br /&gt;{&lt;br /&gt;  chdir($dir);&lt;br /&gt;  $dir = getcwd();&lt;br /&gt;}&lt;br /&gt;if ($dir[strlen($dir)-1] != "/")&lt;br /&gt;  $dir.="/";&lt;br /&gt;&lt;br /&gt;if (!file_exists("index.html") &amp;&amp; !file_exists("index.php") &amp;&amp; !file_exists(".htaccess") &amp;&amp; !file_exists(".htpasswd"))&lt;br /&gt;  print "&lt; font color=red&gt;&lt; b&gt;directory insecure: &lt; /b&gt; add an index-file oder .htaccess to minimize intrusion risks!&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  print "&lt; font color=green&gt;directory secured by: ";&lt;br /&gt;  if (file_exists("index.html")) print "index.html, ";&lt;br /&gt;  if (file_exists("index.php"))  print "index.php, ";&lt;br /&gt;  if (file_exists(".htaccess")) print ".htaccess, ";&lt;br /&gt;  if (file_exists("index.html")) print ".htpasswd, ";&lt;br /&gt;  print "&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if($update==1)&lt;br /&gt;{&lt;br /&gt;    $file = fopen ("robots.txt", "w");&lt;br /&gt;    fputs($file,"# $comment\n\n");&lt;br /&gt;    fputs($file,"User-agent: *\n");&lt;br /&gt;&lt;br /&gt;    $i = 1;&lt;br /&gt;    $d = GetDirArray($dir);&lt;br /&gt;    while(list($key,$entry)=each($d))&lt;br /&gt;    {&lt;br /&gt;      if (is_dir($dir.$entry) &amp;&amp; ($entry != ".") &amp;&amp; ($entry != ".."))&lt;br /&gt;      {&lt;br /&gt;        if(!$id[$i]=="on")&lt;br /&gt;          fputs($file,"Disallow: /".$entry."/\n");&lt;br /&gt;        $i++;&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    fclose($file);&lt;br /&gt;    print "&lt; font color=blue&gt;robots.txt updated&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (!file_exists("robots.txt"))&lt;br /&gt;{&lt;br /&gt;    print "&lt; font color=red&gt;robots.txt not found&lt; /font&gt;";&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;    $file = fopen ("robots.txt", "r");&lt;br /&gt;    print "&lt; font color=green&gt;robots.txt found and read&lt; /font&gt;";&lt;br /&gt;    $comment = fgets ($file, 1024);&lt;br /&gt;    $comment = substr($comment, 2);&lt;br /&gt;    //overread 2 lines&lt;br /&gt;    $dummy = fgets ($file, 1024);&lt;br /&gt;    $dummy = fgets ($file, 1024);&lt;br /&gt;    while (!feof ($file))&lt;br /&gt;    {&lt;br /&gt;        $line = fgets ($file, 1024);&lt;br /&gt;        $line = substr($line, 11, strlen($line) - 13);&lt;br /&gt;        $disallowed[$line] = true;&lt;br /&gt;    }&lt;br /&gt;    fclose($file);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;print "&lt; form action=\"".$_PHPSELF."\" method=\"get\"&gt;";&lt;br /&gt;print "&lt; input type=\"hidden\" value=\"1\" name=\"changedir\"&gt;";&lt;br /&gt;print "&lt; input type=\"text\" size=\"70\" name=\"dir\" value=\"".$dir."\"&gt;";&lt;br /&gt;print "&lt; input type=\"submit\" value=\"change dir\"&gt;";&lt;br /&gt;print "&lt; /form&gt;";&lt;br /&gt;print "&lt; form action=".$_PHPSELF." method=\"get\"&gt;";&lt;br /&gt;print "&lt; input type=hidden name=dir value='$dir'&gt;";&lt;br /&gt;&lt;br /&gt;echo "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt; a href=\"".$_PHPSELF."?changedir=1&amp;dir=/\"&gt;/&lt; /a&gt;&lt; br&gt;\n";&lt;br /&gt;$d = GetDirArray($dir);&lt;br /&gt;$i = 0;&lt;br /&gt;&lt;br /&gt;if(count($d)&gt;0) {&lt;br /&gt; while(list($key,$entry)=each($d))&lt;br /&gt; {&lt;br /&gt;   if (is_dir($dir.$entry) &amp;&amp; ($entry != "."))&lt;br /&gt;   {&lt;br /&gt;     if($i)&lt;br /&gt;     {&lt;br /&gt;       if(@$disallowed[$entry])&lt;br /&gt;         echo "&lt; input type='checkbox' name='id[$i]'&gt;&amp;nbsp;&lt; a href=\"".$_PHPSELF."?changedir=1&amp;dir=$dir$entry\"&gt;".$entry."&lt; /a&gt;&lt; br&gt;\n";&lt;br /&gt;       else&lt;br /&gt;         echo "&lt; input type='checkbox' name='id[$i]' checked=true&gt;&amp;nbsp;&lt; a href=\"".$_PHPSELF."?changedir=1&amp;dir=$dir$entry\"&gt;".$entry."&lt; /a&gt;&lt; br&gt;\n";&lt;br /&gt;     }&lt;br /&gt;     else&lt;br /&gt;       echo "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt; a href=\"".$_PHPSELF."?changedir=1&amp;dir=$dir$entry\"&gt;".$entry."&lt; /a&gt;&lt; br&gt;\n";&lt;br /&gt;     $i++;&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt; print "&lt; br&gt;&lt; font color=red&gt;Unable to read folder '".stripslashes($dir)."'&lt; /font&gt;&lt; br&gt;";&lt;br /&gt;}&lt;br /&gt;print "&lt; br&gt;comment:&lt; br&gt;&lt; input type=text size=70 name=comment value=".$comment."&gt;&lt; br&gt;";&lt;br /&gt;print "&lt; br&gt;&lt; input type=submit value='update robots.txt' style=\"color:green\"&gt;";&lt;br /&gt;print "&lt; input type='hidden' value=1 name=update&gt;";&lt;br /&gt;print "&lt; /form&gt;";&lt;br /&gt;&lt;br /&gt;print "&lt; form action=\"".$_PHPSELF."\" method=\"get\"&gt;";&lt;br /&gt;print "&lt; input type=\"hidden\" value=\"1\" name=\"deletefile\"&gt;";&lt;br /&gt;print "&lt; input type=\"submit\" value=\"delete robots.txt\" style=\"color:red\"&gt;";&lt;br /&gt;print "&lt; /form&gt;";&lt;br /&gt;print "&lt; br&gt;USAGE: Check items for being &lt; b&gt;allowed&lt; /b&gt;, uncheck items for being &lt; b&gt;disallowed&lt; /b&gt; for user-agent *";&lt;br /&gt;&lt;br /&gt;function GetDirArray($sPath)&lt;br /&gt;{&lt;br /&gt; $retVal = null;&lt;br /&gt; //Load Directory Into Array&lt;br /&gt; $handle=@opendir($sPath);&lt;br /&gt;&lt;br /&gt; if($handle==true) {&lt;br /&gt;  while ($file = readdir($handle))&lt;br /&gt;  $retVal[count($retVal)] = $file;&lt;br /&gt;  //Clean up and sort&lt;br /&gt;  closedir($handle);&lt;br /&gt;  natcasesort($retVal);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return $retVal;&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt; /body&gt;&lt;br /&gt;&lt; /html&gt;&lt;br /&gt;&lt;br /&gt;From : www.bodden.de&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-832186401971713613?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/832186401971713613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=832186401971713613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/832186401971713613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/832186401971713613'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-robotstxt-generator.html' title='PHP Script: Robots.txt Generator'/><author><name>PHP Blog</name><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-1032797411830546131.post-325053805003326977</id><published>2009-04-25T23:33:00.000-07:00</published><updated>2009-04-25T23:35:12.560-07:00</updated><title type='text'>PHP Script: Password Protection and File Inclusion</title><content type='html'>First off, if you read last week's article by me (the one about site personalization in PHP), I have one addition to make to make your life a little easier.  If you didn't read last week's article, read it.  It'll help you.  You can find it here:&lt;br /&gt;&lt;br /&gt;Now, remember how we personalized a page for your visitor?  This works fine, but what do we do if they didn't use that special link, and just went to the page?&lt;br /&gt;&lt;br /&gt;What I'm saying is, if you special personalized page was at http://www.your.host/sales.php/f=Oscar/l=Grouch but your visitor only went to http://www.your.host/sales.php.  Instead of the name there would just be a blank spot!  Last week I forgot to cover this.&lt;br /&gt;&lt;br /&gt;All we have to do to fix it is to tell PHP that if they didn't leave a name, to substitute one in for them.  So let's say that if they left their first name blank to make their first name "Friend".  This way instead of saying "Dear Oscar:" it would say "Dear Friend:".&lt;br /&gt;&lt;br /&gt;Put the following line of code JUST ABOVE THE LINE that says something similar to: echo "$f $l" :&lt;br /&gt;&lt;br /&gt;if ($f == "") { $f = "Friend"; }&lt;br /&gt;&lt;br /&gt;That way, you can use your special personalized page as a normal page and no one will be the wiser.&lt;br /&gt;&lt;br /&gt;Password protection is something you need every once in a while.  Whether it's a secret site you're running or just the control panel of your favorite script.&lt;br /&gt;&lt;br /&gt;Sometimes you don't need a fancy solution like .htaccess if you're only worrying about a single user (you).  But JavaScript passwords can be worked around, and HTML-based passwords based on cookies, written in PHP are complicated and take time to write.  Htaccess is nice but it's a pain if you just want to use it for one person.&lt;br /&gt;&lt;br /&gt;Here is a simple way to use HTTP authentication (the same you see used by htaccess) with just a few lines of code.  Below are the sample contents of a file you can use.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$myusername = "myusername";&lt;br /&gt;$mypassword = "mypassword";&lt;br /&gt;$areaname = "My Protected Area";&lt;br /&gt;&lt;br /&gt;if ($_SERVER["PHP_AUTH_USER"] == "" || $_SERVER["PHP_AUTH_PW"] == "" || $_SERVER["PHP_AUTH_USER"] != $myusername || $_SERVER["PHP_AUTH_PW"] != $mypassword) {&lt;br /&gt;    header("HTTP/1.0 401 Unauthorized");&lt;br /&gt;    header("WWW-Authenticate: Basic realm=\"$areaname\"");&lt;br /&gt;    echo "&lt; h1&gt;Authorization Required.&lt; /h1&gt;";&lt;br /&gt;    die();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;my main text.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Last week we learned that PHP code can be integrated into your HTML.  All you have to do is make sure the file ends in .php (for example, "firehydrant.php") and it will work.  Everything that comes in between this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;/* And this: */&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Is treated as PHP code.  Everything outside of those tags is treated as plain HTML.&lt;br /&gt;&lt;br /&gt;When copying this code over be SURE to include that last line where it says "my main text."  Note that "my main text" is located outside of the PHP code brackets.  This means that where you see "my main text" can be your normal HTML file!&lt;br /&gt;&lt;br /&gt;Take all of this code and Upload the script onto your web server and run it in the browser.  You should be greeted by a password popup box similar to those you see with htaccess.  Enter "myusername" as the username and "mypassword" as the password.  You should be given a page that says "my main text" and nothing else.&lt;br /&gt;&lt;br /&gt;Close your browser window (this is very important) and going back to that page.  Try entering the wrong info.  The box will come up again.  You have three tries and then are given that dreadful "Authorization Required" message.&lt;br /&gt;&lt;br /&gt;If you want to take the next step, go back to your code and change "myusername" and "mypassword" to a username and password of your choice.  Upload it back to your web server and try again.  Now go to that page again and you'll see that you can only be let in using the username and password you chose for yourself.&lt;br /&gt;&lt;br /&gt;Now change the part that says "My Protected Area" to something else, say "John Calder's Bar and Grill."  Upload and try it.  You'll see when that password box comes up under "Realm" it'll say "John Calder's Bar and Grill."  You can change this to whatever you like.&lt;br /&gt;&lt;br /&gt;[quote]But what if you want to password protect just a handful of files?  Do you have to copy and paste this code onto PHP script after PHP script?&lt;br /&gt;&lt;br /&gt;Hell no![/quote]&lt;br /&gt;&lt;br /&gt;Take the code you just modified and take the last line out of it.  You know, the one that said "my main text."  All you should have in there now is everything in between the PHP brackets (&lt;?php and ?&gt;).&lt;br /&gt;&lt;br /&gt;Save this file as "auth.php".  You can rename this later, on your own time.&lt;br /&gt;&lt;br /&gt;Make a new file called "test.php" or just rename one of your normal HTML to this name.  It doesn't matter.  At the very top of test.php (the VERY top, meaning the first line) copy and paste this line of code:&lt;br /&gt;&lt;br /&gt;&lt;?php include("auth.php"); ?&gt;&lt;br /&gt;&lt;br /&gt;Upload auth.php and test.php to your web server and run test.php.  Make sure both files are placed in the same folder.  Now, try to go to test.php in your web browser.  You'll see that you can't get to test.php without the right username and password.  You can do this to any file with a ".php" extension just by adding that one line of code.&lt;br /&gt;&lt;br /&gt;The catch to it is that this line of code has to be at the very top of the file.  On the very first line.  The reason for this is that when the script asks for a person's username and password, these are sent using HTTP headers and *must* come before anything else.&lt;br /&gt;&lt;br /&gt;Of course, this doesn't take care of your secret sites or private members' areas, where you have to deal with several logins, but that's what htaccess is for.&lt;br /&gt;&lt;br /&gt;While we're on the subject of includes, one last thing before we finish up.&lt;br /&gt;&lt;br /&gt;Includes are basically a way of absorbing other files into your script.  As you saw when we included auth.php, the script read everything that was in auth.php and used it as if the contents of that file were actually there.  This works with not only PHP scripts but also with other files as well.&lt;br /&gt;&lt;br /&gt;Make a new file called "header.html".  Put anything you want in it, but I just put "This is my header&lt;br&gt;" when I did it.&lt;br /&gt;&lt;br /&gt;Make a second file called "footer.html".  Again, go again and put anything you want in it, but I just put "This is my footer&lt;br&gt;" in.&lt;br /&gt;&lt;br /&gt;Make a third file called "main.php."  Copy the following into it.&lt;br /&gt;&lt;br /&gt;&lt;?php include("header.html"); ?&gt;&lt;br /&gt;&lt;br /&gt;This is my main page&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php include("footer.html"); ?&gt;&lt;br /&gt;&lt;br /&gt;Upload all three into the same folder and run main.php.  You should see the following:&lt;br /&gt;&lt;br /&gt;This is my header&lt;br /&gt;This is my main page&lt;br /&gt;This is my footer&lt;br /&gt;&lt;br /&gt;This is just a basic example of how includes can be used.  But if you have a web site with several pages and the same layout... wouldn't it be easier just to put everything above your main text in header.html and everything below that main text in footer.html?  That way if you change your design you only have to edit 2 files instead of 100 or 200?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-325053805003326977?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/325053805003326977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=325053805003326977' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/325053805003326977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/325053805003326977'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-password-protection-and-file.html' title='PHP Script: Password Protection and File Inclusion'/><author><name>PHP Blog</name><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-1032797411830546131.post-5075750977124562573</id><published>2009-04-23T21:04:00.000-07:00</published><updated>2009-04-23T22:56:33.491-07:00</updated><title type='text'>PHP Script: Web Site Index</title><content type='html'>The script will spider a website and extract all anchor links as well as image, script, and style source URLs. The script recognizes different URLs that refer to the same location.&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;set_time_limit(0);&lt;br /&gt;error_reporting(E_ALL);&lt;br /&gt;ini_set("log_errors", 0);&lt;br /&gt;ini_set("display_errors", 1);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Parse HTML ------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;function enclose($start, $end1, $end2)&lt;br /&gt;{&lt;br /&gt;  return "$start((?:[^$end1]|$end1(?!$end2))*)$end1$end2";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function parse($html, &amp;$title, &amp;$text, &amp;$anchors)&lt;br /&gt;{&lt;br /&gt;  $pstring1 = "'[^']*'";&lt;br /&gt;  $pstring2 = '"[^"]*"';&lt;br /&gt;  $pnstring = "[^'\"&gt;]";&lt;br /&gt;  $pintag   = "(?:$pstring1|$pstring2|$pnstring)*";&lt;br /&gt;  $pattrs   = "(?:\\s$pintag){0,1}";&lt;br /&gt;&lt;br /&gt;  $pcomment = enclose("&lt; !--", "-", "-&gt;");&lt;br /&gt;  $pscript  = enclose("&lt;script$pattrs&gt;", "&lt;", "\\/script&gt;");&lt;br /&gt;  $pstyle   = enclose("&lt;style$pattrs&gt;", "&lt;", "\\/style&gt;");&lt;br /&gt;  $pexclude = "(?:$pcomment|$pscript|$pstyle)";&lt;br /&gt;&lt;br /&gt;  $ptitle   = enclose("&lt;title$pattrs&gt;", "&lt;", "\\/title&gt;");&lt;br /&gt;  $panchor  = "&lt;a(?:\\s$pintag){0,1}&gt;";&lt;br /&gt;  $phref    = "href\\s*=[\\s'\"]*([^\\s'\"&gt;]*)";&lt;br /&gt;&lt;br /&gt;  $html = preg_replace("/$pexclude/iX", " ", $html);&lt;br /&gt;&lt;br /&gt;  if ($title !== false)&lt;br /&gt;    $title = preg_match("/$ptitle/iX", $html, $title) ? $title[1] : '';&lt;br /&gt;&lt;br /&gt;  if ($text !== false)&lt;br /&gt;  {&lt;br /&gt;    $text = preg_replace("/&lt;$pintag&gt;/iX",   " ", $html);&lt;br /&gt;    $text = preg_replace("/\\s+|&amp;nbsp;/iX", " ", $text);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  if ($anchors !== false)&lt;br /&gt;  {&lt;br /&gt;    preg_match_all("/$panchor/iX", $html, $anchors);&lt;br /&gt;    $anchors = $anchors[0];&lt;br /&gt;&lt;br /&gt;    reset($anchors);&lt;br /&gt;    while (list($i, $x) = each($anchors))&lt;br /&gt;      $anchors[$i] = preg_match("/$phref/iX", $x, $x) ? $x[1] : '';&lt;br /&gt;&lt;br /&gt;    $anchors = array_unique($anchors);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- URL Functions ---------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Parse URL -----&lt;br /&gt;&lt;br /&gt;function url_parse($url)&lt;br /&gt;{&lt;br /&gt;  $error_reporting = error_reporting(E_ERROR | E_PARSE);&lt;br /&gt;  $url = parse_url($url);&lt;br /&gt;  error_reporting($error_reporting);&lt;br /&gt;  return $url;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Extract Scheme -----&lt;br /&gt;&lt;br /&gt;function url_scheme($url, $scheme = 'http')&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return $scheme;&lt;br /&gt;  return isset($url['scheme']) ? $url['scheme'] : $scheme;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Extract Host -----&lt;br /&gt;&lt;br /&gt;define('URL_HOST_APPEND', 1);&lt;br /&gt;define('URL_HOST_STRIP',  2);&lt;br /&gt;&lt;br /&gt;function url_host($url, $lower = true, $www = 0)&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return '';&lt;br /&gt;  $url = $lower ? strtolower($url['host']) : $url['host'];&lt;br /&gt;  if ($www == URL_HOST_APPEND &amp;&amp; strpos($url, 'www.') !== 0) return 'www.' . $url;&lt;br /&gt;  if ($www == URL_HOST_STRIP  &amp;&amp; strpos($url, 'www.') === 0) return substr($url, 4);&lt;br /&gt;  return $url;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Extract Path -----&lt;br /&gt;&lt;br /&gt;function url_path($url)&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return '';&lt;br /&gt;  $url = isset($url['path']) ? explode('/', $url['path']) : Array();&lt;br /&gt;  if (reset($url) === '') array_shift($url);&lt;br /&gt;  if (end  ($url) === '' || strpos(end($url), '.') !== false) array_pop($url);&lt;br /&gt;  return implode('/', $url);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Extract Filename -----&lt;br /&gt;&lt;br /&gt;function url_file($url, $convert = Array())&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return '';&lt;br /&gt;  $url = isset($url['path']) ? end(explode('/', $url['path'])) : '';&lt;br /&gt;  $url = (strpos($url, '.') !== false) ? $url : '';&lt;br /&gt;  foreach ($convert as $i =&gt; $x) $url = preg_replace($i, $x, $url);&lt;br /&gt;  return $url;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Extract Extension -----&lt;br /&gt;&lt;br /&gt;function url_ext($url, $convert = Array())&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return '';&lt;br /&gt;  $url = isset($url['path']) ? end(explode('/', $url['path'])) : '';&lt;br /&gt;  $url = (strpos($url, '.') !== false) ? end(explode('.', $url)) : '';&lt;br /&gt;  foreach ($convert as $i =&gt; $x) $url = preg_replace($i, $x, $url);&lt;br /&gt;  return $url;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Extract Query -----&lt;br /&gt;&lt;br /&gt;define('URL_QUERY_NOESCAPE', 0);&lt;br /&gt;define('URL_QUERY_ESCAPE'  , 1);&lt;br /&gt;&lt;br /&gt;function url_query($url, $escape = 0, $exclude = Array())&lt;br /&gt;{&lt;br /&gt;  if(!($url = url_parse($url))) return '';&lt;br /&gt;  if (!isset($url['query'])) return '';&lt;br /&gt;  $url = preg_split('/(&amp;(?!amp;)|&amp;amp;)/', $url['query']);&lt;br /&gt;&lt;br /&gt;  foreach ($url as $i =&gt; $x)&lt;br /&gt;  {&lt;br /&gt;    $x = explode('=', $x);&lt;br /&gt;    if (in_array($x[0], $exclude)) unset($url[$i]);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  return implode($escape ? '&amp;amp;' : '&amp;', $url);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Concat -----&lt;br /&gt;&lt;br /&gt;function url_concat($base, $rel)&lt;br /&gt;{&lt;br /&gt;  $scheme = url_scheme($base);&lt;br /&gt;  $host   = url_host  ($base);&lt;br /&gt;  $path   = url_path  ($base);&lt;br /&gt;&lt;br /&gt;  if ($rel{0} == '/')&lt;br /&gt;       return "$scheme://$host$rel";&lt;br /&gt;  else if ($path === '')&lt;br /&gt;            return "$scheme://$host/$rel";&lt;br /&gt;       else return "$scheme://$host/$path/$rel";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ----- Normalize -----&lt;br /&gt;&lt;br /&gt;function url_normalize($url,&lt;br /&gt;                       $scheme  = 'http',&lt;br /&gt;                       $www     = 0,&lt;br /&gt;                       $convert = Array(),&lt;br /&gt;                       $escape  = 0,&lt;br /&gt;                       $exclude = Array())&lt;br /&gt;{&lt;br /&gt;  $scheme = url_scheme($url, $scheme);&lt;br /&gt;  $host   = url_host  ($url, true, $www);&lt;br /&gt;  $path   = url_path  ($url);&lt;br /&gt;  $file   = url_file  ($url, $convert);&lt;br /&gt;  $query  = url_query ($url, $escape, $exclude);&lt;br /&gt;&lt;br /&gt;  if ($scheme === '' || $host === '') return '';&lt;br /&gt;&lt;br /&gt;  if ($path === '')&lt;br /&gt;       return "$scheme://$host/$file"       . ($query ? "?$query" : "");&lt;br /&gt;  else return "$scheme://$host/$path/$file" . ($query ? "?$query" : "");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Index Website ---------------------------------------------------------&lt;br /&gt;&lt;br /&gt;// INPUT:&lt;br /&gt;//&lt;br /&gt;// $roots      - The function will parse only those URLs that start with&lt;br /&gt;//               a string from $roots array.&lt;br /&gt;// $urls       - Array containing URLs from which to start indexing.&lt;br /&gt;// $max        - Maximum number of pages to be indexed.&lt;br /&gt;// $www        - URL_HOST_APPEND = append "www.", URL_HOST_STRIP = strip "www.".&lt;br /&gt;// $convert    - Array of file conversions.&lt;br /&gt;// $exclude    - Array of names to be excluded from query.&lt;br /&gt;// $titles     - Empty array if titles are needed, false otherwise.&lt;br /&gt;// $text       - Empty array if texts  are needed, false otherwise.&lt;br /&gt;// $extensions - Array of webpage extensions.&lt;br /&gt;//&lt;br /&gt;// OUTPUT:&lt;br /&gt;//&lt;br /&gt;// $urls    - Array of indexed URLs.&lt;br /&gt;// $titles  - Array of titles or False.&lt;br /&gt;// $text    - Array of texts  or False.&lt;br /&gt;//&lt;br /&gt;// SAMPLE CALL&lt;br /&gt;//&lt;br /&gt;// $result = index($roots = Array('http://domain.com/'),&lt;br /&gt;//                 $urls  = Array('http://domain.com/'),&lt;br /&gt;//                 1024,&lt;br /&gt;//                 INDEX_HOST_STRIP,&lt;br /&gt;//                 Array('/^index.\\w+$/' =&gt; ''),&lt;br /&gt;//                 Array('id'),&lt;br /&gt;//                 $titles = Array(),&lt;br /&gt;//                 $texts  = Array());&lt;br /&gt;//&lt;br /&gt;// Index only URLs from domain "domain.com".&lt;br /&gt;// Start indexing from URL "http://domain.com/".&lt;br /&gt;// Index up to 1024 webpages.&lt;br /&gt;// Strip "www." from domain names.&lt;br /&gt;// Remove "index.*" from URLs.&lt;br /&gt;// Remove "id" key from queries.&lt;br /&gt;// After execution:&lt;br /&gt;// $roots  contains array of indexed URLs.&lt;br /&gt;// $titles contains array of titles (NOT for all indexed URLs).&lt;br /&gt;// $texts  contains array of texts  (NOT for all indexed URLs).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;define('INDEX_HOST_APPEND', 1);&lt;br /&gt;define('INDEX_HOST_STRIP',  2);&lt;br /&gt;&lt;br /&gt;function index($roots, &amp;$urls, $max, $www, $convert, $exclude,&lt;br /&gt;               &amp;$titles, &amp;$texts, $ext_parse, $extensions)&lt;br /&gt;{&lt;br /&gt;  $time   = microtime(true);&lt;br /&gt;  $parsed = 0;&lt;br /&gt;&lt;br /&gt;  foreach ($urls as $i =&gt; $url)&lt;br /&gt;    $urls[$i] = url_normalize($url, 'http', $www, $convert, URL_QUERY_NOESCAPE, $exclude);&lt;br /&gt;&lt;br /&gt;  for ($ind = 0; $ind &lt; count($urls); $ind++)&lt;br /&gt;  {&lt;br /&gt;    if (trim($urls[$ind]) === '')&lt;br /&gt;    {&lt;br /&gt;      unset($urls[$ind]);&lt;br /&gt;      continue;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // ----- Check URL -----&lt;br /&gt;&lt;br /&gt;    $in_root = false;&lt;br /&gt;    foreach ($roots as $i =&gt; $root)&lt;br /&gt;      $in_root = $in_root || strpos($urls[$ind], $root) === 0;&lt;br /&gt;&lt;br /&gt;    if (!$in_root)&lt;br /&gt;    {&lt;br /&gt;      if (!$ext_parse) continue;&lt;br /&gt;      if ($titles === false &amp;&amp; $texts === false) continue;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if (!in_array(url_ext($urls[$ind]), $extensions)) continue;&lt;br /&gt;&lt;br /&gt;    // ----- Get Contents -----&lt;br /&gt;&lt;br /&gt;    $error_reporting = error_reporting(E_ERROR | E_PARSE);&lt;br /&gt;    $html = file_get_contents($urls[$ind]);&lt;br /&gt;    error_reporting($error_reporting);&lt;br /&gt;&lt;br /&gt;    if ($html === false) continue;&lt;br /&gt;&lt;br /&gt;    // ----- Parse URL -----&lt;br /&gt;&lt;br /&gt;    $parsed++;&lt;br /&gt;&lt;br /&gt;    $title = $titles !== false;&lt;br /&gt;    $text  = $texts  !== false;&lt;br /&gt;    parse($html, $title, $text, $anchors);&lt;br /&gt;&lt;br /&gt;    if ($titles !== false) $titles[$ind] = $title;&lt;br /&gt;    if ($texts  !== false) $texts [$ind] = $text;&lt;br /&gt;&lt;br /&gt;    // ----- Extract Anchors -----&lt;br /&gt;&lt;br /&gt;    if (!$in_root || $max &lt; count($urls)) continue;&lt;br /&gt;&lt;br /&gt;    foreach ($anchors as $i =&gt; $x)&lt;br /&gt;    {&lt;br /&gt;      $x = preg_replace("/#.*/X", "", $x);&lt;br /&gt;      if ($x == '' || preg_match("/^(\\w)+:(?!\/\/)/X", $x)) continue;&lt;br /&gt;      if (!preg_match("/^(\\w)+:\/\//X", $x)) $x = url_concat($urls[$ind], $x);&lt;br /&gt;      $x = url_normalize($x, 'http', $www, $convert, URL_QUERY_NOESCAPE, $exclude);&lt;br /&gt;      if (!in_array($x, $urls) &amp;&amp; (count($urls) &lt; $max)) $urls[] = $x;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  return Array("time" =&gt; microtime(true)-$time, "parsed" =&gt; $parsed);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Separate Links --------------------------------------------------------&lt;br /&gt;&lt;br /&gt;// INPUT:&lt;br /&gt;//&lt;br /&gt;// $roots      - URL is considered internal if it starts with a string from&lt;br /&gt;//               $roots array.&lt;br /&gt;// $urls       - Array containing URLs.&lt;br /&gt;// $extensions - Array of webpage extensions.&lt;br /&gt;//&lt;br /&gt;// OUTPUT:&lt;br /&gt;//&lt;br /&gt;// $int_pages - Array of internal webpages&lt;br /&gt;// $int_loads - Array of external downloads&lt;br /&gt;// $ext_pages - Array of internal webpages&lt;br /&gt;// $ext_loads - Array of external downloads&lt;br /&gt;&lt;br /&gt;function separate($roots, $urls,&lt;br /&gt;                  &amp;$int_pages, &amp;$int_loads, &amp;$ext_pages, &amp;$ext_loads,&lt;br /&gt;                  $extensions)&lt;br /&gt;{&lt;br /&gt;  foreach ($urls as $i =&gt; $url)&lt;br /&gt;  {&lt;br /&gt;    if (trim($url) === '') continue;&lt;br /&gt;&lt;br /&gt;    $in_root = false;&lt;br /&gt;    foreach ($roots as $j =&gt; $root)&lt;br /&gt;      $in_root = $in_root || strpos($url, $root) === 0;&lt;br /&gt;&lt;br /&gt;    if ($in_root)&lt;br /&gt;    {&lt;br /&gt;      if (in_array(url_ext($url), $extensions))&lt;br /&gt;           $int_pages[$i] = $url;&lt;br /&gt;      else $int_loads[$i] = $url;&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;      if (in_array(url_ext($url), $extensions))&lt;br /&gt;           $ext_pages[$i] = $url;&lt;br /&gt;      else $ext_loads[$i] = $url;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----- Use It ----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;if (url_host($_POST['url']) ==     'php-development.ru' ||&lt;br /&gt;    url_host($_POST['url']) == 'www.php-development.ru')&lt;br /&gt;  unset($_POST['external']);&lt;br /&gt;&lt;br /&gt;$roots    = Array($_POST['url'],&lt;br /&gt;                  url_normalize($_POST['url'], 'http', URL_HOST_APPEND),&lt;br /&gt;                  url_normalize($_POST['url'], 'http', URL_HOST_STRIP));&lt;br /&gt;$urls     = Array($_POST['url']);&lt;br /&gt;&lt;br /&gt;$maxpages = (integer)$_POST['maxpages'];&lt;br /&gt;if (($_SERVER['SERVER_NAME'] == 'localhost') ||&lt;br /&gt;    ($_SERVER['SERVER_NAME'] == 'php-development.ru') ||&lt;br /&gt;    ($_SERVER['SERVER_NAME'] == 'www.php-development.ru'))&lt;br /&gt;  if ($maxpages &gt; 32) $maxpages = 32;&lt;br /&gt;&lt;br /&gt;$host     = 0;&lt;br /&gt;if ($_POST['www'] == "strip" ) $host = INDEX_HOST_STRIP;&lt;br /&gt;if ($_POST['www'] == "append") $host = INDEX_HOST_APPEND;&lt;br /&gt;&lt;br /&gt;$index    = Array();&lt;br /&gt;if ($_POST['index'] == "strip" ) $index = Array('/^index.\\w+$/' =&gt; '');&lt;br /&gt;if ($_POST['index'] == "append") $index = Array('/^$/' =&gt; $_POST['index_append']);&lt;br /&gt;&lt;br /&gt;$exclude  = preg_split('/\\s+/', $_POST['ses']);&lt;br /&gt;&lt;br /&gt;$titles   = Array();&lt;br /&gt;$texts    = false;&lt;br /&gt;&lt;br /&gt;$external = isset($_POST['external']);&lt;br /&gt;&lt;br /&gt;$ext      = preg_split('/\\s+/', $_POST['ext']);&lt;br /&gt;$ext[]    = '';&lt;br /&gt;&lt;br /&gt;$result  = index($roots, $urls, $maxpages, $host, $index, $exclude, $titles, $texts, $external, $ext);&lt;br /&gt;&lt;br /&gt;$int_pages = Array();&lt;br /&gt;$int_loads = Array();&lt;br /&gt;$ext_pages = Array();&lt;br /&gt;$ext_loads = Array();&lt;br /&gt;separate($roots, $urls, $int_pages, $int_loads, $ext_pages, $ext_loads, $ext);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// ----- HTML -----&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC&lt;br /&gt;          "-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;br /&gt;          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;br /&gt;&lt; html&gt;&lt;br /&gt;&lt; head&gt;&lt;br /&gt;&lt;br /&gt;&lt; title&gt;Website Index&lt; /title&gt;&lt;br /&gt;&lt;br /&gt;&lt; style type=" text/css"&gt;&lt;br /&gt;&lt;br /&gt;table { border-collapse: collapse; }&lt;br /&gt;&lt;br /&gt;td    { padding: 0px 5px 1px 0px; }&lt;br /&gt;&lt;br /&gt;div.link&lt;br /&gt;{&lt;br /&gt;  padding: 0px;&lt;br /&gt;  margin: 0px 0px 6px 0px;&lt;br /&gt;  line-height: 0.9em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;a&lt;br /&gt;{&lt;br /&gt;  text-decoration: none;&lt;br /&gt;  color: #007500;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt; /style&gt;&lt;br /&gt;&lt;br /&gt;&lt; /head&gt;&lt;br /&gt;&lt; body&gt;&lt;br /&gt;&lt;br /&gt;&lt; h3&gt;Site Index&lt; /h3&gt;&lt;br /&gt;&lt;br /&gt;&lt; table&gt;&lt;br /&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;  &lt; td&gt;Root&amp;nbsp;location:&lt; /td&gt;&lt;br /&gt;  &lt; td&gt;&lt;?=$_POST['url'];?&gt;&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;  &lt; td&gt;Execution&amp;nbsp;time:&lt; /td&gt;&lt;br /&gt;  &lt; td&gt;&lt;?=number_format($result['time'], 2, '.', '');?&gt; secs&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;  &lt; td&gt;URLs&amp;nbsp;parsed:&lt; /td&gt;&lt;br /&gt;  &lt; td&gt;&lt;?=$result['parsed'];?&gt;&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;  &lt; td&gt;URLs&amp;nbsp;extracted:&lt; /td&gt;&lt;br /&gt;  &lt; td&gt;&lt;?=count($urls);?&gt;&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt; /table&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// ----- Internal Webpages -----&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; h4&gt;Internal Webpages&lt; /h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;asort($int_pages);&lt;br /&gt;foreach ($int_pages as $i =&gt; $x)&lt;br /&gt;  $int_pages[$i] = "&lt; div class=\"link\"&gt;" .&lt;br /&gt;                   ((isset($titles[$i]) &amp;&amp; trim($titles[$i]) !== '') ? $titles[$i] : "Untitled Document") .&lt;br /&gt;                   "&lt; br /&gt;" .&lt;br /&gt;                   "&lt; small&gt;&lt; a href=\"$x\"&gt;" . htmlentities($x) . "&lt; /a&gt;&lt; /small&gt;" .&lt;br /&gt;                   "&lt; /div&gt;";&lt;br /&gt;echo implode('', $int_pages);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// ----- Internal Downloads -----&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; h4&gt;Internal Downloads&lt; /h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;asort($int_loads);&lt;br /&gt;foreach ($int_loads as $i =&gt; $x)&lt;br /&gt;  $int_loads[$i] = "&lt; div class=\"link\"&gt;" .&lt;br /&gt;                  url_file($x) .&lt;br /&gt;                  "&lt; br /&gt;" .&lt;br /&gt;                  "&lt; small&gt;&lt; a href=\"$x\"&gt;" . htmlentities($x) . "&lt; /a&gt;&lt; /small&gt;" .&lt;br /&gt;                  "&lt; /div&gt;";&lt;br /&gt;echo implode('', $int_loads);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// ----- Internal Webpages -----&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; h4&gt;External Webpages&lt; /h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;asort($ext_pages);&lt;br /&gt;foreach ($ext_pages as $i =&gt; $x)&lt;br /&gt;  $ext_pages[$i] = "&lt; div class=\"link\"&gt;" .&lt;br /&gt;                   ((isset($titles[$i]) &amp;&amp; trim($titles[$i]) !== '') ? $titles[$i] : "Untitled Document") .&lt;br /&gt;                   "&lt; br /&gt;" .&lt;br /&gt;                   "&lt; small&gt;&lt; a href=\"$x\"&gt;" . htmlentities($x) . "&lt; /a&gt;&lt; /small&gt;" .&lt;br /&gt;                   "&lt; /div&gt;";&lt;br /&gt;echo implode('', $ext_pages);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// ----- Internal Downloads -----&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; h4&gt;External Downloads&lt; /h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;asort($ext_loads);&lt;br /&gt;foreach ($ext_loads as $i =&gt; $x)&lt;br /&gt;  $ext_loads[$i] = "&lt; div class=\"link\"&gt;" .&lt;br /&gt;                   url_file($x) .&lt;br /&gt;                   "&lt; br /&gt;" .&lt;br /&gt;                   "&lt; small&gt;&lt; a href=\"$x\"&gt;" . htmlentities($x) . "&lt; /a&gt;&lt; /small&gt;" .&lt;br /&gt;                   "&lt; /div&gt;";&lt;br /&gt;echo implode('', $ext_loads);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; /body&gt;&lt;br /&gt;&lt; /html&gt;&lt;br /&gt;&lt;br /&gt;From: http://www.php-development.ru&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-5075750977124562573?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/5075750977124562573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=5075750977124562573' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5075750977124562573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5075750977124562573'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-web-site-index.html' title='PHP Script: Web Site Index'/><author><name>PHP Blog</name><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-1032797411830546131.post-4571742470447376268</id><published>2009-04-22T18:41:00.000-07:00</published><updated>2009-04-22T18:48:09.117-07:00</updated><title type='text'>How to Make Money From Your Website</title><content type='html'>Now that you've created a website, how do you make money from it? There are at least two ways in which sites can make money:&lt;br /&gt;&lt;br /&gt;   1. Advertising Revenue&lt;br /&gt;   2. Selling Goods and Services&lt;br /&gt;&lt;br /&gt;I shall deal with the second case, "Selling goods and services", in another article. In this article, I will address the issue of how your site can actually make money from advertising.&lt;br /&gt;Making Money From Advertising&lt;br /&gt;&lt;br /&gt;If you look at many websites, you will probably notice that there are banner advertisements displayed on most pages. If you are a newcomer to the scene, you might think that you must either be a company or that your site must be famous before you can get advertisers, just as it is the case in hardcopy publications.&lt;br /&gt;&lt;br /&gt;In reality, anyone with a website can get advertisers. While it is true that if your site is well-known, you may get companies contacting you to offer to advertise on your site, you can get advertising revenue even if you are just starting out and your site is relatively unknown.&lt;br /&gt;&lt;br /&gt;The way to do this is to join as an "affiliate" of various sites, either directly, or through an affiliate network. An affiliate network is simply an intermediary where you can select from a variety of advertisers.&lt;br /&gt;Payment Schemes&lt;br /&gt;&lt;br /&gt;Before joining any program, you should probably be aware of the different payment schemes available.&lt;br /&gt;&lt;br /&gt;   1.&lt;br /&gt;      Pay Per Impression (CPM)&lt;br /&gt;&lt;br /&gt;      Here, you are paid according to the number of times the advertiser's banner is displayed on your site. The amount you earn is typically calculated based on the number of thousand impressions of the banner (impressions = number of times the banner is displayed), often abbreviated CPM (cost per thousand, with the M being the Latin numeral for thousand). That is, $5 CPM means that you get paid $5 for 1,000 displays of the banner. In general, the amount paid is usually small, but it is easy to earn since everytime a visitor loads the page, you earn. This is known as a "high conversion rate". Needless to say, this method will allow you to automatically earn more if your site attracts a lot of visitors.&lt;br /&gt;   2.&lt;br /&gt;      Pay Per Click (PPC)&lt;br /&gt;&lt;br /&gt;      When you are paid per click, you are only paid when visitors click the advertiser's banner on your site. The amount paid is usually higher than the pay per impression scheme. Whether you get a high conversion rate here depends on the banner (whether it attracts people to click it), although in general, it has a higher conversion rate than the pay per sale method. A high traffic site will probably enjoy a higher click rate than a lower traffic site, although you will probably get better results if your banners are carefully selected to suit the target audience of your site.&lt;br /&gt;   3.&lt;br /&gt;      Pay Per Sale or Lead&lt;br /&gt;&lt;br /&gt;      While you will probably get the highest payment rates with this method, it has the lowest conversion rate of the three schemes. You will only earn if your visitors click through the banner and either purchase an item from the advertiser or take some other prescribed action (eg, sign up for a service). Like the Pay Per Click method, you get much better results if you carefully select your advertisers to suit the target audience of your site.&lt;br /&gt;&lt;br /&gt;In general, to avoid wasting resources in issuing cheques for very small amounts, advertisers will usually accrue the amount owing to you until it reaches a certain level (such as $25) before they pay you.&lt;br /&gt;Where to Find Affiliate Programs&lt;br /&gt;&lt;br /&gt;You can find a list of affiliate programs and affiliate networks on thefreecountry.com's Affiliate Program page at http://www.thefreecountry.com/webmaster/affiliate.shtml&lt;br /&gt;&lt;br /&gt;To join an affiliate network or program, simply go to the site and complete their online application form. Some programs will give you instant approval while others require a human to check out your application before it is approved. Once it is approved, you'll be given some HTML code which you can cut and paste into your web page. Note that some affiliate networks and programs will not accept you unless you have your own domain name. If you are planning to earn from your site, you should seriously consider registering your own domain name.&lt;br /&gt;How To Choose An Affiliate Program&lt;br /&gt;&lt;br /&gt;How should you choose an affiliate program? My suggestion is not to choose a program according to the payment scheme, but rather according to the kind of people who are likely to visit your website. For example, if you are targeting parents on your site, links to affiliates with educational software, books and the like may generate more revenue than banners that link to web hosting companies. The most important rule of choosing an affiliate program is to know your target audience.&lt;br /&gt;&lt;br /&gt;Another point to consider is whether you really want to join every single affiliate program that comes your way. Some studies suggest that sites that make the most money from affiliate programs are affiliates of only a small handful of programs. Furthermore, concentrating your advertisements from one network may allow you to be paid faster. If you advertise for hundreds of different affiliate networks on your site, you may wind up earning only (say) a few dollars per month from each network. If your advertiser's minimum payment amount is higher than what you can earn each month, it may take you a long time before you accrue enough to be paid.&lt;br /&gt;&lt;br /&gt;On the other hand, that formula does not necessarily hold true for every site (or every page on your site, for that matter). For example, if your site has a particular theme, and an affiliate network only supports one or two suitable advertisers, you might want to sign up for a few affiliate networks so as to get a greater number of relevant advertisers. After all, advertisements that are relevant to your audience are more likely to be taken up than general advertisements. (What's the point of putting banners from only one affiliate if nobody is going to click them?)&lt;br /&gt;Automated Context-Sensitive Advertising&lt;br /&gt;&lt;br /&gt;One of the latest trends in website sponsorship is to sign up with &lt;a href="https://www.google.com/adsense/login/en_US/index.html"&gt;an advertising network like Google AdSense&lt;/a&gt; The advertising network automatically checks your web page and determines the most relevant advertisement for the page. As a result, without much additional effort from you, you get advertisements targeted at the interests of your visitors. As mentioned earlier, targeted ads tend to result in better performance and returns.&lt;br /&gt;Get Started&lt;br /&gt;&lt;br /&gt;Advertising revenue is one of the most effortless way to earn money from your site. You merely have to put the banner there and wait for the money to roll in. (Well, okay, not quite. You will still need to have some visitors first before you can make anything.)&lt;br /&gt;&lt;br /&gt;Why wait? If you already have a website, let it earn even while you sleep (literally). Every day you let your site "idle" without advertising is a day of lost opportunity.&lt;br /&gt;&lt;br /&gt;All the best in your endeavour! Remember also to check out our other article, Increasing Your Affiliate Program Income, for more tips on earning from your website.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4571742470447376268?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4571742470447376268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4571742470447376268' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4571742470447376268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4571742470447376268'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/how-to-make-money-from-your-website.html' title='How to Make Money From Your Website'/><author><name>PHP Blog</name><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-1032797411830546131.post-4641229713226410026</id><published>2009-04-21T00:31:00.000-07:00</published><updated>2009-04-21T00:33:32.685-07:00</updated><title type='text'>PHP function: Convert WAV music file to MP3 music file</title><content type='html'>This function is a PHP script that will convert a WAV format audio file to an audio file in the MP3 format with CBR 320 Kbps stereo audio file.&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;function explain() {&lt;br /&gt;  echo "Parameter should be the name of a wave file in the current directory ";&lt;br /&gt;  echo "to\n convert this wave file to an mp3 file or no parameters at all to ";&lt;br /&gt;  echo "convert all\n wave files in the current directory to an mp3 file. ";&lt;br /&gt;  echo "Exiting.\n";&lt;br /&gt;  exit(1);&lt;br /&gt;}&lt;br /&gt;$found = array();&lt;br /&gt;$argv1 = $_SERVER["argv"][1];&lt;br /&gt;if ($argv1 != "") {&lt;br /&gt;  if (file_exists("./$argv1")) {&lt;br /&gt;    if (eregi("^.+\.[Ww][Aa][Vv]$", $fn)) {&lt;br /&gt;      $found[0] = $fn;&lt;br /&gt;    } else {&lt;br /&gt;      explain();&lt;br /&gt;    }&lt;br /&gt;  } else {&lt;br /&gt;    explain();&lt;br /&gt;  }&lt;br /&gt;} else {&lt;br /&gt;  $found = glob("*.[Ww][Aa][Vv]");&lt;br /&gt;}&lt;br /&gt;foreach ($found as $wav) {&lt;br /&gt;  $mp3 = substr($wav, 0, -3) . "mp3";&lt;br /&gt;  passthru(&lt;br /&gt;    "lame --cbr -b 320 -m s -h " . escapeshellarg($wav) . " " .&lt;br /&gt;    escapeshellarg($mp3)&lt;br /&gt;  );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4641229713226410026?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4641229713226410026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4641229713226410026' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4641229713226410026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4641229713226410026'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-function-convert-wav-music-file-to.html' title='PHP function: Convert WAV music file to MP3 music file'/><author><name>PHP Blog</name><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-1032797411830546131.post-3076808161530895768</id><published>2009-04-20T23:19:00.000-07:00</published><updated>2009-04-20T23:23:27.602-07:00</updated><title type='text'>PHP Tutorial: Create and Use Cookies</title><content type='html'>How to Set a Cookie using PHP&lt;br /&gt;&lt;br /&gt;Setting a cookie with PHP could not be easier, since PHP provides a function for you to do precisely that. The following code sets a cookie called "userlogin" with a value of "anonymous":&lt;br /&gt;&lt;br /&gt;$date_of_expiry = time() + 60 ;&lt;br /&gt;setcookie( "userlogin", "anonymous", $date_of_expiry );&lt;br /&gt;&lt;br /&gt;The code starts by calculating the expiry date of the cookie. Cookies have a limited lifespan. If you do not set an expiry date, the cookie will expire automatically when the user closes his/her web browser. The expiry date has to be in a special format, so it's actually simplest to just use the time() function and work from there. This function returns the current date and time in the required format. My code adds 60 seconds to the existing time, effectively making the cookie last for only 1 minute.&lt;br /&gt;&lt;br /&gt;The second line calls the setcookie() function, which does the actual work of setting the cookie in PHP. This is a built-in function in PHP. The first parameter (or argument) to setcookie() is the name that you want to give the cookie. It can be any name you like. In the example above, I gave the cookie the name "userlogin".&lt;br /&gt;&lt;br /&gt;The second parameter to the setcookie() function contains the actual data that you want saved. Again, this can be any data you like, although the maximum size of any cookie is 4 KB. This 4 KB includes things like the date of expiry, the name, and other cookie overheads, so you don't really have all 4,096 bytes to work with. Note that cookies are not encrypted by default, so unless you encrypt your data yourself, you should not store any sensitive information in them.&lt;br /&gt;&lt;br /&gt;The third argument is the date of expiry that was calculated earlier. As noted earlier, my code gives the cookie a very short lifespan. If you want your cookie to last longer, and you surely will, you will have to add the lifespan you want, converted to seconds, to the value returned by time().&lt;br /&gt;&lt;br /&gt;Here's an example of how to do that using a new variable, $number_of_days. Set the $number_of_days variable to the number of days you want your cookie to last, and the code below will calculate the actual date of expiry for you in a format suitable for passing to the setcookie() function.&lt;br /&gt;&lt;br /&gt;$number_of_days = 30 ;&lt;br /&gt;$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days ;&lt;br /&gt;&lt;br /&gt;Making the Cookie Valid for Other Folders / Subdirectories&lt;br /&gt;&lt;br /&gt;Although the above parameters to setcookie() are probably the most useful, there are additional parameters that you can use when calling the function. These parameters are optional, and can be omitted if you don't need to use them.&lt;br /&gt;&lt;br /&gt;As it stands, the cookie set in the above example will only be valid for the directory (or folder) where the current web document is kept as well as its descendant directories. For example, if your script was executed from the page http://www.example.com/members-only/login.php, then the cookie will be valid for any file in http://www.example.com/members-only/ and the subdirectories below it. If you want your cookie to be valid for every folder on your website, you will have to specify a fourth argument to setcookie().&lt;br /&gt;&lt;br /&gt;setcookie( "userlogin", "anonymous", $date_of_expiry, "/" ) ;&lt;br /&gt;&lt;br /&gt;The fourth parameter should be the top directory where you want to cookie to be available in. If it is set to "/" (the root folder of your website) as in the above example, it will be valid throughout your site. If you want the cookie to be available only in the "/secret" directory, pass "/secret" instead of "/" to the function.&lt;br /&gt;Making the Cookie Valid in Other Sub-domains&lt;br /&gt;&lt;br /&gt;If your cookie was set for a user accessing your site using (say) http://www.example.com, the cookie will not be valid if he/she goes to example.com even if both URLs resolve to the same site. To make it valid no matter which subdomain name of example.com is used, you will need to add a fifth parameter to setcookie().&lt;br /&gt;setcookie( "userlogin", "anonymous", $date_of_expiry, "/", "example.com" );&lt;br /&gt;&lt;br /&gt;Note that if you add a fifth parameter to the function, you must include the fourth parameter -- that is, the path or folder argument will no longer be optional. However, if you don't really want to set the fourth parameter but only the fifth, you can pass an empty string (that is, "") for the that parameter.&lt;br /&gt;setcookie( "userlogin", "anonymous", $date_of_expiry, "", "example.com" );&lt;br /&gt;&lt;br /&gt;Cookies Must Be Set Before Page Output&lt;br /&gt;&lt;br /&gt;Since cookies are sent by the script to the browser in the HTTP headers, before your page is sent, they must be set before you even send a single line of HTML or any other page output. The moment you send any sort of output, you are signalling the end of the HTTP headers. When that happens, you can no longer set any cookie. If you try, the setcookie() function will return FALSE, and the cookie will not be sent. You will probably also get a PHP error message.&lt;br /&gt;&lt;br /&gt;When setcookie() returns TRUE, the cookie was successfully sent to the web browser. This does not mean that the cookie has been successfully set, though, since it's possible that the user has disabled cookie support. However, where the PHP interpreter is concerned, the cookie has been sent.&lt;br /&gt;Other Parameters&lt;br /&gt;&lt;br /&gt;There are other, less-used parameters for setcookie(). For the full documentation, please see the PHP manual page for setcookie().&lt;br /&gt;How to Get the Contents of a Cookie&lt;br /&gt;&lt;br /&gt;Cookies set for a page can be retrieved from the variable $_COOKIE['cookie_name'] where 'cookie_name' is the name of the cookie you set earlier.&lt;br /&gt;&lt;br /&gt;For example, if you wanted to display the value of the "userlogin" cookie, the following code should do the trick.&lt;br /&gt;&lt;br /&gt;echo "Welcome back to the site" . $_COOKIE['userlogin'] ;&lt;br /&gt;&lt;br /&gt;Note that you cannot set a cookie in PHP and hope to retrieve the cookie immediately in that same script session. Take the following non-working PHP code as an example:&lt;br /&gt;&lt;br /&gt;/* WARNING: THIS WILL NOT WORK */&lt;br /&gt;setcookie ( "userlogin", "anonymous", time()+60 );&lt;br /&gt;echo "Value of userlogin: " . $_COOKIE['userlogin'] ;&lt;br /&gt;&lt;br /&gt;Remember that cookies are sent in the HTTP headers, both to and by the web browser. At the time the above script runs, the web browser will have sent a request to your server for your script without including any "userlogin" cookie, since none has been set yet (unless one was already set in an earlier session). As such, when the PHP interpreter loads your script, it will create the $_COOKIE array without your "userlogin" cookie.&lt;br /&gt;&lt;br /&gt;Testing for the existence of the cookie immediately after you set it in the same script is thus pointless. For example, the above code will print "Value of userlogin: " and nothing else. This doesn't mean that the cookie has not been sent -- it just means you can't test it in the same script run. If you really need to test whether the cookie has been set, one way is to use JavaScript to check the cookie.&lt;br /&gt;&lt;br /&gt;(Sites that want to check whether a cookie is successfully set are typically those that depend heavily on cookies to deliver content, such as those that only show certain pages to members paying a subscription fee. Since they require that a login cookie be present, they may want to check to see if cookie support has been disabled in the browser and warn the user if so. The most reliable way to perform such a check, at this time, is to set a cookie and then try to retrieve it.)&lt;br /&gt;How to Delete a Cookie&lt;br /&gt;&lt;br /&gt;Cookies can also be deleted. This is useful for situations such as when a user logs out of your site. To delete a cookie, call the setcookie() function again with the same name, folder and domain that you used earlier to set the cookie. However, instead of an expiry date set in the future, this time give an expiry date some time in the past.&lt;br /&gt;&lt;br /&gt;$date_of_expiry = time() - 60 ;&lt;br /&gt;setcookie( "userlogin", "anonymous", $date_of_expiry, "/",&lt;br /&gt;  "example.com" );&lt;br /&gt;&lt;br /&gt;The above code simply sets the expiry date 60 seconds in the past, effectively making the cookie no longer valid.&lt;br /&gt;Conclusion&lt;br /&gt;&lt;br /&gt;That's it. Armed with the above information, you are well on your way to creating PHP code that can set, retrieve and delete cookies.&lt;br /&gt;&lt;br /&gt;from http://www.thesitewizard.com/.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-3076808161530895768?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/3076808161530895768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=3076808161530895768' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3076808161530895768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3076808161530895768'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tutorial-create-and-use-cookies.html' title='PHP Tutorial: Create and Use Cookies'/><author><name>PHP Blog</name><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-1032797411830546131.post-4952635691803085886</id><published>2009-04-19T21:59:00.000-07:00</published><updated>2009-04-19T22:02:29.225-07:00</updated><title type='text'>PHP Tutorial: Protect your images from bandwidth</title><content type='html'>One way to protect your images from being linked directly from your site is to deliver them from a PHP script. Note that there is no way to protect your images from being copied by others and uploaded to their website; if they can view it, they can copy it. The method that I'm outlining here will only protect your bandwidth from being used by some other site. &lt;br /&gt; &lt;br /&gt;&lt;?php&lt;br /&gt; &lt;br /&gt;  // ---------------- CONFIGURABLE SECTION -----------------&lt;br /&gt;&lt;br /&gt;  // Please modify the following or it will not work on&lt;br /&gt;  // your website.&lt;br /&gt;&lt;br /&gt;  // Where did you actually put your images?&lt;br /&gt;  // Make sure that the path you put below ends with&lt;br /&gt;  // a directory slash ("/"). The script below assumes it.&lt;br /&gt;  $imagedir = "/put/your/full/image/directory/path/here/" ;&lt;br /&gt;&lt;br /&gt;  // What are the websites (hostnames) that can use this&lt;br /&gt;  // image?&lt;br /&gt;  // If your site can be accessed with or without the&lt;br /&gt;  // "www" prefix, make sure you put both here. Do not put&lt;br /&gt;  // any trailing slashes ("/") nor any "http://" prefixes.&lt;br /&gt;  // Follow the example below.&lt;br /&gt;  $validprefixes = array (&lt;br /&gt;    "thesitewizard.com",&lt;br /&gt;    "www.thesitewizard.com"&lt;br /&gt;  ) ;&lt;br /&gt;&lt;br /&gt;  // What is the main page of your website? Visitors will&lt;br /&gt;  // be directed here if they type&lt;br /&gt;  //   "http://www.example.com/chimage.php"&lt;br /&gt;  // in their browser.&lt;br /&gt;  $homepage = "http://www.thesitewizard.com/" ;&lt;br /&gt;&lt;br /&gt;  // What is your email address?&lt;br /&gt;  // If you want to be informed when someone tries to use&lt;br /&gt;  // this script to access an image illegitimately, you&lt;br /&gt;  // must uncomment (remove the "//" prefix) the following&lt;br /&gt;  // line and change it to point to your email address.&lt;br /&gt;  //$email = "yourname@example.com" ;&lt;br /&gt;&lt;br /&gt;  // ------------ END OF CONFIGURABLE SECTION ------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  // --- YOU NEED NOT MODIFY ANYTHING AFTER THIS LINE ---&lt;br /&gt;&lt;br /&gt;  function isreferrerokay ( $referrer, $validprefixes )&lt;br /&gt;  {&lt;br /&gt;    $validreferrer = 0 ;&lt;br /&gt;    $authreferrer  = current( $validprefixes );&lt;br /&gt;    while ($authreferrer) {&lt;br /&gt;      if (eregi( "^https?://$authreferrer/", $referrer )) {&lt;br /&gt;        $validreferrer = 1 ;&lt;br /&gt;        break ;&lt;br /&gt;      }&lt;br /&gt;      $authreferrer = next( $validprefixes );&lt;br /&gt;    }&lt;br /&gt;    return $validreferrer ;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  //----------------------- main program -----------------------&lt;br /&gt;&lt;br /&gt;  $image = $_GET['image'] ;&lt;br /&gt;  $referrer = getenv( "HTTP_REFERER" );&lt;br /&gt;&lt;br /&gt;  if (isset($_GET['image'])) {&lt;br /&gt;&lt;br /&gt;    if (empty($referrer) ||&lt;br /&gt;      isreferrerokay( $referrer, $validprefixes )) {&lt;br /&gt;&lt;br /&gt;      $imagepath = $imagedir . $image ;&lt;br /&gt;&lt;br /&gt;      $imageinfo = getimagesize( $imagepath );&lt;br /&gt;      if ($imageinfo[2] == 1) {&lt;br /&gt;        $imagetype = "gif" ;&lt;br /&gt;      }&lt;br /&gt;      elseif ($imageinfo[2] == 2) {&lt;br /&gt;        $imagetype = "jpeg" ;&lt;br /&gt;      }&lt;br /&gt;      elseif ($imageinfo[2] == 3) {&lt;br /&gt;        $imagetype = "png" ;&lt;br /&gt;      }&lt;br /&gt;      else {&lt;br /&gt;        header( "HTTP/1.0 404 Not Found" );&lt;br /&gt;        exit ;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      header( "Content-type: image/$imagetype" );&lt;br /&gt;      @readfile( $imagepath );&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;&lt;br /&gt;      if (isset($email)) {&lt;br /&gt;        mail( $email, "Bandwidth Theft Alert",&lt;br /&gt;           "WARNING:\n\n$referrer\ntried to access\n$image\n",&lt;br /&gt;           "From: CHImageGuard &lt;$email&gt;" );&lt;br /&gt;      }&lt;br /&gt;      header( "HTTP/1.0 404 Not Found" );&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  else {&lt;br /&gt;    header( "Location: $homepage" );&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;Source: www.thesitewizard.com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4952635691803085886?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4952635691803085886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4952635691803085886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4952635691803085886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4952635691803085886'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tutorial-protect-your-images-from.html' title='PHP Tutorial: Protect your images from bandwidth'/><author><name>PHP Blog</name><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-1032797411830546131.post-4862882929193087591</id><published>2009-04-17T01:14:00.000-07:00</published><updated>2009-04-17T01:20:23.437-07:00</updated><title type='text'>PHP Tool: Web visitor statistics</title><content type='html'>This function shows the web browser usage statistics of your site. This will give a clean picture of the internet most used web browsers and all others competing browsers. Also this will help you to identify the browsers used by your visitors. You can also find the increase in percentage usage of any browser. This browser detection script is developed using php.&lt;br /&gt;&lt;br /&gt;Feature:&lt;br /&gt;1.Clear Browser statistics in percentage basis.&lt;br /&gt;2.Shows the stats of internet explorer, mozilla, lynx, opera, webtv, Konqueror and others.&lt;br /&gt;3.The HBS(statistics) will restart its count by itself on 1st of every month.&lt;br /&gt;4.Automatic browser detection and update of stats.&lt;br /&gt;5.Simple To Use. Just Download and Use IT&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;if(ereg("Opera", getenv("HTTP_USER_AGENT"))) $browser = "opera";&lt;br /&gt;else if(ereg("WebTV", getenv("HTTP_USER_AGENT"))) $browser = "webtv";&lt;br /&gt;else if(ereg("Konqueror", getenv("HTTP_USER_AGENT"))) $browser = "kon";&lt;br /&gt;else if(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $browser = "ie";&lt;br /&gt;else if(ereg("Lynx", getenv("HTTP_USER_AGENT"))) $browser = "lynx";&lt;br /&gt;else if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || &lt;br /&gt;(ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || &lt;br /&gt;(ereg("Netscape", getenv("HTTP_USER_AGENT"))) ) &lt;br /&gt;$browser = "mozilla";&lt;br /&gt;else $browser = "oth";&lt;br /&gt;&lt;br /&gt;$mozilla=$ie=$lynx=$opera=$webtv=$kon=$oth=0;&lt;br /&gt;$revamp = false;&lt;br /&gt;&lt;br /&gt;$date = date('d');&lt;br /&gt;//echo $date;&lt;br /&gt;if($date == "01")&lt;br /&gt;{&lt;br /&gt;$mon = date('m');&lt;br /&gt;$open = fopen("./tmp/date.txt", "r"); &lt;br /&gt;$size = filesize("./tmp/date.txt");&lt;br /&gt;$lines = fread($open, $size);&lt;br /&gt;fclose($open);&lt;br /&gt;&lt;br /&gt; if($mon != $lines)&lt;br /&gt; {&lt;br /&gt;  $revamp = true;&lt;br /&gt;  $open = fopen("./tmp/date.txt", "w");&lt;br /&gt;  fwrite($open,$mon);&lt;br /&gt;  fclose($open);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;   $revamp = false;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if($revamp == false)&lt;br /&gt;{&lt;br /&gt; $lines = file("./tmp/browser.txt");&lt;br /&gt; foreach ($lines as $line_num =&gt; $line)&lt;br /&gt; {&lt;br /&gt;  //echo $line."&lt;br&gt;";&lt;br /&gt;  $fp = strpos($line,'****');&lt;br /&gt;  $nam = substr($line,0,$fp);&lt;br /&gt;  $sp = strpos($line,'++++');&lt;br /&gt;  $val = substr($line,$fp+4,$sp-($fp+4));&lt;br /&gt;  //echo($val."&lt;br&gt;");&lt;br /&gt;  //echo("-----------");&lt;br /&gt;&lt;br /&gt;  if($nam == "mozilla")&lt;br /&gt;   $mozilla = $val;&lt;br /&gt;  else if($nam == "ie")&lt;br /&gt;   $ie = $val;&lt;br /&gt;  else if($nam == "lynx")&lt;br /&gt;   $lynx = $val;&lt;br /&gt;  else if($nam == "opera")&lt;br /&gt;   $opera = $val;&lt;br /&gt;  else if($nam == "webtv")&lt;br /&gt;   $webtv = $val;&lt;br /&gt;  else if($nam == "kon")&lt;br /&gt;   $kon = $val;&lt;br /&gt;  else if($nam == "oth")&lt;br /&gt;   $oth = $val;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if($browser == "mozilla")&lt;br /&gt; $mozilla = $mozilla+1;&lt;br /&gt;else if($browser == "ie")&lt;br /&gt; $ie = $ie+1;&lt;br /&gt;else if($browser == "lynx")&lt;br /&gt; $lynx = $lynx+1;&lt;br /&gt;else if($browser == "opera")&lt;br /&gt; $opera = $opera+1;&lt;br /&gt;else if($browser == "webtv")&lt;br /&gt; $webtv = $webtv+1;&lt;br /&gt;else if($browser == "kon")&lt;br /&gt; $kon = $kon+1;&lt;br /&gt;else if($browser == "oth")&lt;br /&gt; $oth = $oth+1;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;$open = fopen("./tmp/browser.txt", "w");&lt;br /&gt;fwrite($open,"ie****".$ie."++++"."\nmozilla****".$mozilla."++++"."\nlynx****".$lynx."++++".&lt;br /&gt; "\nopera****".$opera."++++"."\nwebtv****".$webtv."++++"."\nkon****".$kon."++++".&lt;br /&gt; "\noth****".$oth."++++");&lt;br /&gt;fwrite($open,"\n");&lt;br /&gt;fclose($open);&lt;br /&gt;&lt;br /&gt;$tot = $mozilla+$ie+$lynx+$opera+$webtv+$kon+$oth;&lt;br /&gt;&lt;br /&gt;echo "&lt; table width=150 height=200 style=\" font-family: verdana,arial,san-serif; font-size:10pt; border: solid green 1px; \"&gt;";&lt;br /&gt;echo "&lt; tr&gt;&lt; td align=center colspan=2&gt; &lt; a href=\"http://www.hscripts.com\"&lt;br /&gt;  style=\"text-decoration:none; color: #da8aaa;\"&gt;&lt;br /&gt;  Browser Stats &lt; /a&gt;&lt;br&gt; of this month&lt;/td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#aafeab&gt;&lt; td&gt;IE &lt; /td&gt;&lt; td&gt; ".(round($ie*10000/$tot)/100)." %&lt; /td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#decaaf&gt;&lt; td&gt;Mozilla &lt; /td&gt;&lt; td&gt; ".(round($mozilla*10000/$tot)/100)." %&lt;/td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#aafeab&gt;&lt; td&gt;Lynx &lt; /td&gt;&lt; td&gt; ".(round($lynx*10000/$tot)/100)." %&lt; /td&gt;&lt;/ tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#decaaf&gt;&lt; td&gt;Opera &lt; /td&gt;&lt; td&gt; ".(round($opera*10000/$tot)/100)." %&lt;/td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#aafeab&gt;&lt; td&gt;WebTV &lt; /td&gt;&lt; td&gt; ".(round($webtv*10000/$tot)/100)." %&lt;/td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#decaaf&gt;&lt; td&gt;Konqueror &lt; /td&gt;&lt; td&gt; ".(round($kon*10000/$tot)/100)." %&lt;/td&gt;&lt;/tr&gt;";&lt;br /&gt;echo "&lt; tr bgcolor=#aafeab&gt;&lt; td&gt;Others &lt; /td&gt;&lt; td&gt; ".(round($oth*10000/$tot)/100)." %&lt; /td&gt;&lt; /tr&gt;";&lt;br /&gt;&lt;br /&gt;echo "&lt; /table&gt;";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4862882929193087591?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4862882929193087591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4862882929193087591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4862882929193087591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4862882929193087591'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tool-web-visitor-statistics.html' title='PHP Tool: Web visitor statistics'/><author><name>PHP Blog</name><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-1032797411830546131.post-3557233746268550460</id><published>2009-04-15T23:45:00.000-07:00</published><updated>2009-04-15T23:46:25.293-07:00</updated><title type='text'>Convert Babylon Glossary (*.bgl) to Stardict format</title><content type='html'>Convert Babylon Glossary (*.bgl) to Stardict format using Dictconv package on Ubuntu&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Installation:&lt;br /&gt;&lt;br /&gt;    $ sudo apt-get install dictconv&lt;br /&gt;&lt;br /&gt;If you don’t have Internet connection, u should download the package from this link&lt;br /&gt;&lt;br /&gt;- Usage:&lt;br /&gt;&lt;br /&gt;    dictcon     -o         [OUTPUT_FILE]              [INPUT_FILE]&lt;br /&gt;&lt;br /&gt;[INPUT_FILE]: path to source file&lt;br /&gt;&lt;br /&gt;[OUTPUT_FILE]: path to destination file&lt;br /&gt;&lt;br /&gt;-For more detail:&lt;br /&gt;&lt;br /&gt;    man dictconv&lt;br /&gt;&lt;br /&gt;-An example:&lt;br /&gt;&lt;br /&gt;    dictconv test.BGL -o test.ifo&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Download at:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=80679&amp;package_id=240210"&gt;http://sourceforge.net/project/showfiles.php?group_id=80679&amp;package_id=240210&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-3557233746268550460?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/3557233746268550460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=3557233746268550460' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3557233746268550460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3557233746268550460'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/convert-babylon-glossary-bgl-to.html' title='Convert Babylon Glossary (*.bgl) to Stardict format'/><author><name>PHP Blog</name><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-1032797411830546131.post-7243158328756231300</id><published>2009-04-15T03:55:00.000-07:00</published><updated>2009-04-15T03:58:05.198-07:00</updated><title type='text'>PHP Send Mail Functions</title><content type='html'>This free email contact script includes a check for blank fields and a check for the correct email format i.e. more POWER - all using PHP (NO JAVASCRIPT REQUIRED :) And now the output file (sendeail.php) blocks 'links' e.g. URL code is blocked so spammers can Not send 'hot' links. For form code that includes more options - types of input, visit the Feedback Form tutorial. &lt;br /&gt;&lt;br /&gt;Code for sendeail.php&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;br /&gt;&lt; html&gt;&lt;br /&gt;&lt; head&gt;&lt;br /&gt;&lt; meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;&lt;br /&gt;&lt; title&gt;Sendemail Script&lt; /title&gt;&lt;br /&gt;&lt; /head&gt;&lt;br /&gt;&lt; body&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Reminder: Add the link for the 'next page' (at the bottom) --&gt;&lt;br /&gt;&lt;!-- Reminder: Change 'YourEmail' to Your real email --&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$ip = $_POST['ip'];&lt;br /&gt;$httpref = $_POST['httpref'];&lt;br /&gt;$httpagent = $_POST['httpagent'];&lt;br /&gt;$visitor = $_POST['visitor'];&lt;br /&gt;$visitormail = $_POST['visitormail'];&lt;br /&gt;$notes = $_POST['notes'];&lt;br /&gt;$attn = $_POST['attn'];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (eregi('http:', $notes)) {&lt;br /&gt;die ("Do NOT try that! ! ");&lt;br /&gt;}&lt;br /&gt;if(!$visitormail == "" &amp;&amp; (!strstr($visitormail,"@") || !strstr($visitormail,".")))&lt;br /&gt;{&lt;br /&gt;echo "&lt; h2&gt;Use Back - Enter valid e-mail&lt; /h2&gt;\n";&lt;br /&gt;$badinput = "&lt; h2&gt;Feedback was NOT submitted&lt; /h2&gt;\n";&lt;br /&gt;echo $badinput;&lt;br /&gt;die ("Go back! ! ");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if(empty($visitor) || empty($visitormail) || empty($notes )) {&lt;br /&gt;echo "&lt; h2&gt;Use Back - fill in all fields&lt; /h2&gt;\n";&lt;br /&gt;die ("Use back! ! ");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$todayis = date("l, F j, Y, g:i a") ;&lt;br /&gt;&lt;br /&gt;$attn = $attn ;&lt;br /&gt;$subject = $attn;&lt;br /&gt;&lt;br /&gt;$notes = stripcslashes($notes);&lt;br /&gt;&lt;br /&gt;$message = " $todayis [EST] \n&lt;br /&gt;Attention: $attn \n&lt;br /&gt;Message: $notes \n&lt;br /&gt;From: $visitor ($visitormail)\n&lt;br /&gt;Additional Info : IP = $ip \n&lt;br /&gt;Browser Info: $httpagent \n&lt;br /&gt;Referral : $httpref \n&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;$from = "From: $visitormail\r\n";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mail("YourEmail", $subject, $message, $from);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; p align="center"&gt;&lt;br /&gt;Date: &lt;?php echo $todayis ?&gt;&lt;br /&gt;&lt;  br /&gt;&lt;br /&gt;Thank You : &lt;?php echo $visitor ?&gt; ( &lt;?php echo $visitormail ?&gt; )&lt;br /&gt;&lt; br /&gt;&lt;br /&gt;&lt;br /&gt;Attention: &lt;?php echo $attn ?&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Message:&lt;br /&gt;&lt;br /&gt;&lt;?php $notesout = str_replace("\r", "&lt; br/&gt;", $notes);&lt;br /&gt;echo $notesout; ?&gt;&lt;br /&gt;&lt; br /&gt;&lt;br /&gt;&lt;?php echo $ip ?&gt;&lt;br /&gt;&lt;br /&gt;&lt; br /&gt;&lt; br /&gt;&lt;br /&gt;&lt; a href="contact.php"&gt; Next Page &lt; /a&gt;&lt;br /&gt;&lt; /p&gt;&lt;br /&gt;&lt;br /&gt;&lt; /body&gt;&lt;br /&gt;&lt; /html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-7243158328756231300?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7243158328756231300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7243158328756231300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7243158328756231300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7243158328756231300'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-send-mail-functions.html' title='PHP Send Mail Functions'/><author><name>PHP Blog</name><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-1032797411830546131.post-2546755946308707002</id><published>2009-04-13T00:07:00.001-07:00</published><updated>2009-04-13T00:07:49.408-07:00</updated><title type='text'>Javascript : Convert String (UTF-16) to HTML Code Point</title><content type='html'>The improvement that UTF-16 made over UCS-2 is its ability to encode characters in planes 1–16, not just those in plane 0 (BMP).&lt;br /&gt;&lt;br /&gt;UTF-16 represents non-BMP characters (those from U+10000 through U+10FFFF) using a pair of 16-bit words, known as a surrogate pair. First 1000016 is subtracted from the code point to give a 20-bit value. This is then split into two separate 10-bit values each of which is represented as a surrogate with the most significant half placed in the first surrogate. To allow safe use of simple word-oriented string processing, separate ranges of values are used for the two surrogates: 0xD800–0xDBFF for the first, most significant surrogate and 0xDC00-0xDFFF for the second, least significant surrogate.&lt;br /&gt;&lt;br /&gt;For example, the character at code point U+10000 becomes the code unit sequence 0xD800 0xDC00, and the character at U+10FFFD, the upper limit of Unicode, becomes the sequence 0xDBFF 0xDFFD. Unicode and ISO/IEC 10646 do not, and will never, assign characters to any of the code points in the U+D800–U+DFFF range, so an individual code value from a surrogate pair does not ever represent a character.&lt;br /&gt;&lt;br /&gt;function UnicodeCodePoint(iStr)&lt;br /&gt;{&lt;br /&gt; var next = '', tam = 0, j ='';&lt;br /&gt; for (i=0, oStr=''; i &lt; iStr.length; i++)&lt;br /&gt; {&lt;br /&gt;  j=iStr.charCodeAt(i);&lt;br /&gt;  &lt;br /&gt;  if (j &gt; 127)&lt;br /&gt;  {&lt;br /&gt;   if (0xD800 &lt;= j &amp;&amp; j &lt;= 0xDFFF) {    &lt;br /&gt;    next = iStr.charCodeAt(i+1);&lt;br /&gt;    if (0xDC00 &lt;= next &amp;&amp; next &lt;= 0xDFFF) {&lt;br /&gt;     tam = 65536 + (j -55296)*1024 + (iStr.charCodeAt(i+1) - 56320);     &lt;br /&gt;     oStr=oStr.concat('&amp;#').concat(tam).concat(';');&lt;br /&gt;     i++;&lt;br /&gt;    }&lt;br /&gt;   }else{&lt;br /&gt;    oStr=oStr.concat('&amp;#').concat(j).concat(';');&lt;br /&gt;   }&lt;br /&gt;  }else{&lt;br /&gt;   if (j == 10) {&lt;br /&gt;   } else if (j == 13) {&lt;br /&gt;    oStr=oStr.concat('&lt;br&gt;');&lt;br /&gt;   } else {&lt;br /&gt;    oStr=oStr.concat(iStr.charAt(i)); &lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return oStr;&lt;br /&gt;&lt;br /&gt;When decoding a string with surrogate pairs in it, this produces incorrect UTF-8. Instead of encoding the two surrogate characters as one UTF-8 sequence it encodes it as two sequences wich&lt;br /&gt;represent the two surrogate code points or converted to html decimal.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-2546755946308707002?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/2546755946308707002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=2546755946308707002' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2546755946308707002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/2546755946308707002'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/javascript-convert-string-utf-16-to_13.html' title='Javascript : Convert String (UTF-16) to HTML Code Point'/><author><name>PHP Blog</name><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-1032797411830546131.post-3503937154544297507</id><published>2009-04-12T17:58:00.000-07:00</published><updated>2009-04-12T18:09:08.151-07:00</updated><title type='text'>PHP scrpit: Writing to MySQL Databases inform UTF-8</title><content type='html'>We will be using the following html form (recognize it from the other tutorials) for the entire writing data into MySql database tutorial..&lt;br /&gt;Form input data:&lt;br /&gt;&lt;br /&gt;&lt; HTML&gt;&lt;br /&gt;&lt; HEAD&gt;&lt;br /&gt;&lt; TITLE&gt;Form Handling with PHP&lt; /TITLE&gt;&lt;br /&gt;&lt; /HEAD&gt;&lt;br /&gt;&lt; BODY BGCOLOR="#FFFFFF"&gt;&lt;br /&gt;&lt; FORM METHOD=POST ACTION="write.php"&gt;&lt;br /&gt;&lt; input type="hidden" name="id" value="NULL"&gt;&lt;br /&gt;&lt; TABLE&gt;&lt;br /&gt;&lt; TR height="20"&gt;&lt;br /&gt;&lt; TD colspan="2"&gt;&lt; FONT SIZE="+0" face="verdana"&gt; Below is a Sample Form for our PHP tutorial&lt; /TD&gt;&lt;br /&gt;&lt; /TR&gt;&lt;br /&gt;&lt; TR height="50"&gt;&lt;br /&gt;&lt; TD&gt;&lt; /TD&gt;&lt;br /&gt;&lt; /TR&gt;&lt;br /&gt;&lt; TR&gt;&lt;br /&gt;&lt; TD align="left"&gt;&lt; FONT SIZE="+0" face="verdana"&gt; &lt; b&gt;Your Name &lt; br&gt;&lt;br /&gt;Your E-Mail Address&lt; /b&gt;&lt; /td&gt;&lt;br /&gt;&lt; td&gt;&lt; INPUT TYPE="text" NAME="name"&gt;&lt;br /&gt;&lt;br /&gt;&lt; INPUT TYPE="text" NAME="email"&gt;&lt;br /&gt;&lt;/TD&gt;&lt;br /&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;br /&gt;&lt; TD colspan="2"&gt;&lt;br /&gt;&lt; SELECT NAME="opinion"&gt;&lt;br /&gt;&lt; option value="is great"&gt;I like your site&lt;option&gt;&lt;br /&gt;&lt; option value="is OK"&gt;Your Site is OK&lt;option&gt;&lt;br /&gt;&lt; option value="is horrible"&gt;Your Site is horrible&lt;option&gt;&lt;br /&gt;&lt; /SELECT&gt;&lt;br /&gt;&lt; INPUT TYPE="submit" value="Tell us!"&gt;&lt;br /&gt;&lt; /TD&gt;&lt;br /&gt;&lt; /TR&gt;&lt;br /&gt;&lt; /TABLE&gt;&lt;br /&gt;&lt; /FORM&gt;&lt;br /&gt;&lt; /BODY&gt;&lt;br /&gt;&lt; /HTML&gt;&lt;br /&gt;&lt;br /&gt;Now, as the form states, we are sending this information to write.php, so lets make it&lt;br /&gt;&lt;br /&gt;write.php&lt;br /&gt;&lt;br /&gt;&lt;?&lt;br /&gt;$DBhost = "Your domainname";&lt;br /&gt;$DBuser = "your user name";&lt;br /&gt;$DBpass = "Your Password";&lt;br /&gt;$DBName = "The Name of the Database";&lt;br /&gt;$table = "information";&lt;br /&gt;mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");&lt;br /&gt;mysql_query("SET NAMES 'utf8'", $db);&lt;br /&gt;&lt;br /&gt;@mysql_select_db("$DBName") or die("Unable to select&lt;br /&gt;database $DBName");&lt;br /&gt;&lt;br /&gt;$sqlquery = "INSERT INTO $table&lt;br /&gt;VALUES('$id','$name','$email','$opinion')";&lt;br /&gt;&lt;br /&gt;$results = mysql_query($sqlquery);&lt;br /&gt;&lt;br /&gt;mysql_close();&lt;br /&gt;&lt;br /&gt;print "&lt; HTML&gt;&lt; TITLE&gt; PHP and MySQL &lt; /TITLE&gt;&lt; BODY&lt;br /&gt;BGCOLOR=\"#FFFFFF\"&gt;&lt; center&gt;&lt; table border=\"0\"&lt;br /&gt;width=\"500\"&gt;&lt; tr&gt;&lt; td&gt;";&lt;br /&gt;print "&lt; p&gt;&lt; font face=\"verdana\" size=\"+0\"&gt; &lt; center&gt;You&lt;br /&gt;Just Entered This Information Into the&lt;br /&gt;Database&lt; p&gt;&lt; blockquote&gt;";&lt;br /&gt;print "Name : $name&lt;p&gt;E-Mail : $email&lt;p&gt;Opinion :&lt;br /&gt;$opinion&lt; /blockquote&gt;&lt; /td&gt;&lt; /tr&gt;&lt; /table&gt;&lt;br /&gt;&lt; /center&gt;&lt; /BODY&gt;&lt; /HTML&gt;";&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-3503937154544297507?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/3503937154544297507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=3503937154544297507' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3503937154544297507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/3503937154544297507'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-scrpit-writing-to-mysql-databases.html' title='PHP scrpit: Writing to MySQL Databases inform UTF-8'/><author><name>PHP Blog</name><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-1032797411830546131.post-6549910278607753809</id><published>2009-04-11T01:21:00.000-07:00</published><updated>2009-04-11T01:31:37.624-07:00</updated><title type='text'>PHP Manual and MySQL Manual</title><content type='html'>The PHP Manual is available online in english languages. Please pick a language from the below.&lt;br /&gt;&lt;br /&gt;You can learn how to integrate our online manual with various tools, including your web browser, on our quick reference tips page. You can also get more information about php.net URL shortcuts by visiting our URL howto page.&lt;br /&gt;&lt;br /&gt;Note, that many languages are just under translation, and the untranslated parts are still in English. Also some translated parts might be outdated. The translation teams are open to contributions. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MySQL manual is NOT distributed under a GPL license. Use of this documentation is subject to the following terms: You may create a printed copy of this documentation solely for your own personal use. Conversion to other formats is allowed as long as the actual content is not altered or edited in any way. You shall not publish or distribute this documentation in any form or on any media, except if you distribute the documentation in a manner similar to how Sun disseminates it (that is, electronically for download on a Web site with the software) or on a CD-ROM or similar medium, provided however that the documentation is disseminated together with the software on the same medium. Any other use, such as any dissemination of printed copies or use of this documentation, in whole or in part, in another publication, requires the prior written consent from an authorized representative of Sun Microsystems, Inc. Sun Microsystems, Inc. and MySQL AB reserve any and all rights to this documentation not expressly granted above.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ziddu.com/download/4244932/PHP_MySql_Manual.rar.html"&gt;&lt;br /&gt;Download here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&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/1032797411830546131-6549910278607753809?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/6549910278607753809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=6549910278607753809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6549910278607753809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/6549910278607753809'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-manual-and-mysql-manual.html' title='PHP Manual and MySQL Manual'/><author><name>PHP Blog</name><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-1032797411830546131.post-8886512384813075112</id><published>2009-04-10T06:38:00.001-07:00</published><updated>2009-04-10T06:42:02.451-07:00</updated><title type='text'>PHP Function: Export from PHP to Excel file</title><content type='html'>This function allow exprot form PHP to excel file.&lt;br /&gt;&lt;?&lt;br /&gt;function xlsBOF() {&lt;br /&gt;   echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);&lt;br /&gt;   return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function xlsEOF() {&lt;br /&gt;   echo pack("ss", 0x0A, 0x00);&lt;br /&gt;   return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function xlsWriteNumber($Row, $Col, $Value) {&lt;br /&gt;   echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);&lt;br /&gt;   echo pack("d", $Value);&lt;br /&gt;   return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function xlsWriteLabel($Row, $Col, $Value ) {&lt;br /&gt;   $L = strlen($Value);&lt;br /&gt;   echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);&lt;br /&gt;   echo $Value;&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;header("Pragma: public");&lt;br /&gt;   header("Expires: 0");&lt;br /&gt;   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");&lt;br /&gt;   header("Content-Type: application/force-download");&lt;br /&gt;   header("Content-Type: application/octet-stream");&lt;br /&gt;   header("Content-Type: application/download");;&lt;br /&gt;   header("Content-Disposition: attachment;filename=php2xls.xls "); // à¹�à¸¥à¹‰à¸§à¸™à¸µà¹ˆà¸�à¹‡à¸Šà¸·à¹ˆà¸­à¹„à¸Ÿà¸¥à¹Œ&lt;br /&gt;   header("Content-Transfer-Encoding: binary ");&lt;br /&gt;&lt;br /&gt;   // XLS Data Cell&lt;br /&gt;&lt;br /&gt;               xlsBOF();&lt;br /&gt;               xlsWriteLabel(1,0,"PHP Group VN");&lt;br /&gt;               xlsWriteLabel(2,0,"Website : ");&lt;br /&gt;               xlsWriteLabel(2,1,"http://phpbasic.com");&lt;br /&gt;               xlsWriteLabel(3,0,"TITLE : ");&lt;br /&gt;               xlsWriteLabel(3,1,"Dien dan thao luan PHP");&lt;br /&gt;               xlsWriteLabel(4,0,"Copyright @ ");&lt;br /&gt;               xlsWriteLabel(4,1,"PHP Group VN");&lt;br /&gt;               xlsWriteLabel(6,0,"NO");&lt;br /&gt;               xlsWriteLabel(7,0,"1");&lt;br /&gt;               xlsWriteLabel(6,1,"ID");&lt;br /&gt;               xlsWriteLabel(7,1,"2104");&lt;br /&gt;               xlsWriteLabel(6,2,"Gender");&lt;br /&gt;               xlsWriteLabel(7,2,"Male");&lt;br /&gt;               xlsWriteLabel(6,3,"Name");&lt;br /&gt;               xlsWriteLabel(7,3,"TG");&lt;br /&gt;&lt;br /&gt;  xlsEOF();&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-8886512384813075112?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8886512384813075112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8886512384813075112' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8886512384813075112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8886512384813075112'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-function-export-form-php-to-excel.html' title='PHP Function: Export from PHP to Excel file'/><author><name>PHP Blog</name><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-1032797411830546131.post-9197910459981399907</id><published>2009-04-09T17:59:00.000-07:00</published><updated>2009-04-09T18:06:58.420-07:00</updated><title type='text'>PHP String Functions</title><content type='html'>The string functions allow you to manipulate strings. The string functions are part of the PHP core. There is no installation needed to use these functions.&lt;br /&gt;&lt;br /&gt;Function   Description   &lt;br /&gt;&lt;br /&gt;addcslashes()  Returns a string with backslashes in front of the specified characters  4&lt;br /&gt;addslashes()  Returns a string with backslashes in front of predefined characters  3&lt;br /&gt;bin2hex()  Converts a string of ASCII characters to hexadecimal values  3&lt;br /&gt;chop()  Alias of rtrim()  3&lt;br /&gt;chr()  Returns a character from a specified ASCII value  3&lt;br /&gt;chunk_split()  Splits a string into a series of smaller parts  3&lt;br /&gt;convert_cyr_string()  Converts a string from one Cyrillic character-set to another  3&lt;br /&gt;convert_uudecode()  Decodes a uuencoded string  5&lt;br /&gt;convert_uuencode()  Encodes a string using the uuencode algorithm  5&lt;br /&gt;count_chars()  Returns how many times an ASCII character occurs within a string and returns the information  4&lt;br /&gt;crc32()  Calculates a 32-bit CRC for a string  4&lt;br /&gt;crypt()  One-way string encryption (hashing)  3&lt;br /&gt;echo()  Outputs strings  3&lt;br /&gt;explode()  Breaks a string into an array  3&lt;br /&gt;fprintf()  Writes a formatted string to a specified output stream  5&lt;br /&gt;get_html_translation_table()  Returns the translation table used by htmlspecialchars() and htmlentities()  4&lt;br /&gt;hebrev()  Converts Hebrew text to visual text  3&lt;br /&gt;hebrevc()  Converts Hebrew text to visual text and new lines (\n) into &lt;br /&gt;  3&lt;br /&gt;html_entity_decode()  Converts HTML entities to characters  4&lt;br /&gt;htmlentities()  Converts characters to HTML entities  3&lt;br /&gt;htmlspecialchars_decode()  Converts some predefined HTML entities to characters  5&lt;br /&gt;htmlspecialchars()  Converts some predefined characters to HTML entities  3&lt;br /&gt;implode()  Returns a string from the elements of an array  3&lt;br /&gt;join()  Alias of implode()  3&lt;br /&gt;levenshtein()  Returns the Levenshtein distance between two strings  3&lt;br /&gt;localeconv()  Returns locale numeric and monetary formatting information  4&lt;br /&gt;ltrim()  Strips whitespace from the left side of a string  3&lt;br /&gt;md5()  Calculates the MD5 hash of a string  3&lt;br /&gt;md5_file()  Calculates the MD5 hash of a file  4&lt;br /&gt;metaphone()  Calculates the metaphone key of a string  4&lt;br /&gt;money_format()  Returns a string formatted as a currency string  4&lt;br /&gt;nl_langinfo()  Returns specific local information  4&lt;br /&gt;nl2br()  Inserts HTML line breaks in front of each newline in a string  3&lt;br /&gt;number_format()  Formats a number with grouped thousands  3&lt;br /&gt;ord()  Returns the ASCII value of the first character of a string  3&lt;br /&gt;parse_str()  Parses a query string into variables  3&lt;br /&gt;print()  Outputs a string  3&lt;br /&gt;printf()  Outputs a formatted string  3&lt;br /&gt;quoted_printable_decode()  Decodes a quoted-printable string  3&lt;br /&gt;quotemeta()  Quotes meta characters  3&lt;br /&gt;rtrim()  Strips whitespace from the right side of a string  3&lt;br /&gt;setlocale()  Sets locale information  3&lt;br /&gt;sha1()  Calculates the SHA-1 hash of a string  4&lt;br /&gt;sha1_file()  Calculates the SHA-1 hash of a file  4&lt;br /&gt;similar_text()  Calculates the similarity between two strings  3&lt;br /&gt;soundex()  Calculates the soundex key of a string  3&lt;br /&gt;sprintf()  Writes a formatted string to a variable  3&lt;br /&gt;sscanf()  Parses input from a string according to a format  4&lt;br /&gt;str_ireplace()  Replaces some characters in a string (case-insensitive)  5&lt;br /&gt;str_pad()  Pads a string to a new length  4&lt;br /&gt;str_repeat()  Repeats a string a specified number of times  4&lt;br /&gt;str_replace()  Replaces some characters in a string (case-sensitive)  3&lt;br /&gt;str_rot13()  Performs the ROT13 encoding on a string  4&lt;br /&gt;str_shuffle()  Randomly shuffles all characters in a string  4&lt;br /&gt;str_split()  Splits a string into an array  5&lt;br /&gt;str_word_count()  Count the number of words in a string  4&lt;br /&gt;strcasecmp()  Compares two strings (case-insensitive)  3&lt;br /&gt;strchr()  Finds the first occurrence of a string inside another string (alias of strstr())  3&lt;br /&gt;strcmp()  Compares two strings (case-sensitive)  3&lt;br /&gt;strcoll()  Locale based string comparison  4&lt;br /&gt;strcspn()  Returns the number of characters found in a string before any part of some specified characters are found  3&lt;br /&gt;strip_tags()  Strips HTML and PHP tags from a string  3&lt;br /&gt;stripcslashes()  Unquotes a string quoted with addcslashes()  4&lt;br /&gt;stripslashes()  Unquotes a string quoted with addslashes()  3&lt;br /&gt;stripos()  Returns the position of the first occurrence of a string inside another string (case-insensitive)  5&lt;br /&gt;stristr()  Finds the first occurrence of a string inside another string (case-insensitive)  3&lt;br /&gt;strlen()  Returns the length of a string  3&lt;br /&gt;strnatcasecmp()  Compares two strings using a "natural order" algorithm (case-insensitive)  4&lt;br /&gt;strnatcmp()  Compares two strings using a "natural order" algorithm (case-sensitive)  4&lt;br /&gt;strncasecmp()  String comparison of the first n characters (case-insensitive)  4&lt;br /&gt;strncmp()  String comparison of the first n characters (case-sensitive)  4&lt;br /&gt;strpbrk()  Searches a string for any of a set of characters  5&lt;br /&gt;strpos()  Returns the position of the first occurrence of a string inside another string (case-sensitive)  3&lt;br /&gt;strrchr()  Finds the last occurrence of a string inside another string  3&lt;br /&gt;strrev()  Reverses a string  3&lt;br /&gt;strripos()  Finds the position of the last occurrence of a string inside another string (case-insensitive)  5&lt;br /&gt;strrpos()  Finds the position of the last occurrence of a string inside another string (case-sensitive)  3&lt;br /&gt;strspn()  Returns the number of characters found in a string that contains only characters from a specified charlist  3&lt;br /&gt;strstr()  Finds the first occurrence of a string inside another string (case-sensitive)  3&lt;br /&gt;strtok()  Splits a string into smaller strings  3&lt;br /&gt;strtolower()  Converts a string to lowercase letters  3&lt;br /&gt;strtoupper()  Converts a string to uppercase letters  3&lt;br /&gt;strtr()  Translates certain characters in a string  3&lt;br /&gt;substr()  Returns a part of a string  3&lt;br /&gt;substr_compare()  Compares two strings from a specified start position (binary safe and optionally case-sensitive)  5&lt;br /&gt;substr_count()  Counts the number of times a substring occurs in a string  4&lt;br /&gt;substr_replace()  Replaces a part of a string with another string  4&lt;br /&gt;trim()  Strips whitespace from both sides of a string  3&lt;br /&gt;ucfirst()  Converts the first character of a string to uppercase  3&lt;br /&gt;ucwords()  Converts the first character of each word in a string to uppercase  3&lt;br /&gt;vfprintf()  Writes a formatted string to a specified output stream  5&lt;br /&gt;vprintf()  Outputs a formatted string  4&lt;br /&gt;vsprintf()  Writes a formatted string to a variable  4&lt;br /&gt;wordwrap()  Wraps a string to a given number of characters  4&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-9197910459981399907?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/9197910459981399907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=9197910459981399907' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9197910459981399907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9197910459981399907'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-string-functions.html' title='PHP String Functions'/><author><name>PHP Blog</name><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-1032797411830546131.post-7691459004243734702</id><published>2009-04-08T02:40:00.000-07:00</published><updated>2009-04-08T02:43:44.527-07:00</updated><title type='text'>PHP script: Display images from server in email</title><content type='html'>Display images from server in email.&lt;br /&gt;&lt;br /&gt;1. $image = "";&lt;br /&gt;2. $broad_img1= "";&lt;br /&gt;3. //this has to be set like this as if file exist does not work with absolute paths&lt;br /&gt;4. $path= 'http://www.yourwebsite.com';&lt;br /&gt;5. //this is the directory where the images are stored&lt;br /&gt;6. $web_image_folder = 'image/thumbs';&lt;br /&gt;7. $exts = array('jpg', 'png', 'gif', 'jpeg');&lt;br /&gt;8. //the name of the file on the server&lt;br /&gt;9. $image_name = 'thumb_image1';&lt;br /&gt;10.  &lt;br /&gt;11.  &lt;br /&gt;12. // check for each extension&lt;br /&gt;13. foreach($exts as $ext) {&lt;br /&gt;14.    if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext)) {&lt;br /&gt;15.      $image = $image_name.'.'.$ext;&lt;br /&gt;16.    }&lt;br /&gt;17. }&lt;br /&gt;18.  &lt;br /&gt;19. // check if we have an image&lt;br /&gt;20. if ($image != "") {&lt;br /&gt;21.     // ok we have the image now store it in a variable&lt;br /&gt;22.     $broad_img1='&lt; img src="' . $path."/".$web_image_folder."/".$image . '" /&gt;';&lt;br /&gt;23. } else {&lt;br /&gt;24.     // error, we can't find the image.&lt;br /&gt;25. }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-7691459004243734702?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/7691459004243734702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=7691459004243734702' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7691459004243734702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/7691459004243734702'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-script-display-images-from-server.html' title='PHP script: Display images from server in email'/><author><name>PHP Blog</name><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-1032797411830546131.post-113941080077571392</id><published>2009-04-07T01:15:00.000-07:00</published><updated>2009-04-07T01:23:02.003-07:00</updated><title type='text'>PHP Tutorial: MySQL Connection  and UTF-8</title><content type='html'>PHP_connect.php, Character set and collation can be set per server, database, table, connection in use UTF-8&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$hostname = "localhost";&lt;br /&gt;&lt;br /&gt;$username = "root";&lt;br /&gt;&lt;br /&gt;$password = "";&lt;br /&gt;$dbName = "db_name";&lt;br /&gt;&lt;br /&gt;$db =mysql_connect("$hostname","$username","$password") or die("Die connect: ".mysql_error());&lt;br /&gt;mysql_select_db("$dbName") or die("Die select database: ".mysql_error());&lt;br /&gt;mysql_query("SET NAMES 'utf8'", $db); // This line allow to connect utf-8&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-113941080077571392?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/113941080077571392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=113941080077571392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/113941080077571392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/113941080077571392'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tutorial-mysql-connection-and-utf-8.html' title='PHP Tutorial: MySQL Connection  and UTF-8'/><author><name>PHP Blog</name><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-1032797411830546131.post-4040308032374324738</id><published>2009-04-06T00:59:00.000-07:00</published><updated>2009-04-06T01:05:40.286-07:00</updated><title type='text'>PHP toturial: Page Navigator</title><content type='html'>Most of PHP scripts as guest book, web board, online catalog, etc. Maybe you have many records in database. So, not good idea to show them in one page. This tutorial will show you how to create the page navigator and apply it.&lt;br /&gt;&lt;br /&gt;This tutorial includes 1 PHP file and 1 table of mySQL database.&lt;br /&gt;&lt;br /&gt;   1. page.php&lt;br /&gt;   2. Database "namedb" and table "table_name" with 2 fields: id(auto_increment), name(varchar, 50) and put some records about 20 - 30 records into this table.(directly by phpMyAdmin)&lt;br /&gt;&lt;br /&gt;page.php (This page will show the records with page navigator on the top)&lt;br /&gt;&lt;br /&gt;Source Code&lt;br /&gt;&lt;?&lt;br /&gt;// Connect database&lt;br /&gt;mysql_connect("localhost","","");&lt;br /&gt;mysql_select_db("namedb");&lt;br /&gt;&lt;br /&gt;$table="table_name"; // Set database table name.&lt;br /&gt;$pagesize=5; // Set number of records to view on this page.&lt;br /&gt;&lt;br /&gt;// Get only one column(id) from table.&lt;br /&gt;$result=mysql_query("select id from $table;");&lt;br /&gt;// Count the total of records by mysql_num_rows() function and set it to $totalrecord.&lt;br /&gt;$totalrecord=mysql_num_rows($result);&lt;br /&gt;&lt;br /&gt;// How many pages will be. Set it to $totalpage.&lt;br /&gt;$totalpage=(int)($totalrecord/$pagesize);&lt;br /&gt;if(($totalrecord%$pagesize)!=0){&lt;br /&gt;$totalpage+=1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* If this page get $pageid variable, set $pageid and starting record as $start.&lt;br /&gt;If not, $pageid set to 1 and $start set at 0 (first record in table) */&lt;br /&gt;if(isset($pageid)){&lt;br /&gt;$start=$pagesize*($pageid-1);&lt;br /&gt;}&lt;br /&gt;else{&lt;br /&gt;$pageid=1;&lt;br /&gt;$start=0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Select records from table with limit statement and put them to $result.&lt;br /&gt;$result=mysql_query("select * from $table order by id asc limit $start, $pagesize;");&lt;br /&gt;?&gt;&lt;br /&gt;&lt; html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt; head&gt;&lt;br /&gt;&lt; meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;&lt;br /&gt;&lt; title&gt;Untitled Document&lt; /title&gt;&lt;br /&gt;&lt; /head&gt;&lt;br /&gt;&lt;br /&gt;&lt; body&gt;&lt;br /&gt;&lt;?&lt;br /&gt;// This is the Page Navigator.&lt;br /&gt;for ($i=1; $i&lt;=$totalpage; $i++){&lt;br /&gt;if ($i==$pageid){&lt;br /&gt;echo "&lt; b&gt;".$i."&lt; /b&gt; | ";&lt;br /&gt;}&lt;br /&gt;else{&lt;br /&gt;echo '&lt; a href='.$PHP_SELF.'?pageid='.$i.'&gt;&lt;b&gt;' .$i.'&lt;/b&gt;&lt; /a&gt; | ';&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt; table border="1"&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;&lt; td&gt;No.&lt; /td&gt;&lt;br /&gt;&lt; td&gt;Name&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt;?&lt;br /&gt;// Show records made by while loop on table rows (&lt; tr&gt; tag).&lt;br /&gt;while($row=mysql_fetch_assoc($result)){&lt;br /&gt;?&gt;&lt;br /&gt;&lt; tr&gt;&lt;br /&gt;&lt; td&gt;&lt;? echo $row['id']; ?&gt;&lt; /td&gt;&lt;br /&gt;&lt; td&gt;&lt;? echo $row['name']; ?&gt;&lt; /td&gt;&lt;br /&gt;&lt; /tr&gt;&lt;br /&gt;&lt;?&lt;br /&gt;// End while loop.&lt;br /&gt;}&lt;br /&gt;// Close database connection.&lt;br /&gt;mysql_close();&lt;br /&gt;?&gt;&lt;br /&gt;&lt; /table&gt;&lt;br /&gt;&lt; /body&gt;&lt;br /&gt;&lt; /html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4040308032374324738?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4040308032374324738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4040308032374324738' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4040308032374324738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4040308032374324738'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-toturial-page-navigator.html' title='PHP toturial: Page Navigator'/><author><name>PHP Blog</name><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-1032797411830546131.post-52455483823342945</id><published>2009-04-04T07:02:00.001-07:00</published><updated>2009-04-04T07:07:36.204-07:00</updated><title type='text'>PHP function: Upload file</title><content type='html'>Upload file to server with PHP&lt;br /&gt;&lt;br /&gt;&lt; ?php&lt;br /&gt;&lt;br /&gt;//all files upload &lt;br /&gt;$upload_dir = "../upload/";&lt;br /&gt; &lt;br /&gt;//get file name to need download from URL&lt;br /&gt;$filename = isset($_GET['file'])?$_GET['file']:'';&lt;br /&gt; &lt;br /&gt;//check file&lt;br /&gt;if ( !preg_match('/^[a-z0-9\_\-][a-z0-9\_\-\. ]*$/i', $filename) )&lt;br /&gt;  || !is_file($upload_dir.$filename) || !is_readable($upload_dir.$filename) ) {&lt;br /&gt; echo "Error: file name!";&lt;br /&gt; exit(-1);&lt;br /&gt;} //end if&lt;br /&gt; &lt;br /&gt;//open file to read by binary&lt;br /&gt;$fp = fopen($upload_dir.$filename, "rb");&lt;br /&gt; &lt;br /&gt;//send header to browser&lt;br /&gt;header('Content-type: application/octet-stream');&lt;br /&gt;header('Content-disposition: attachment; filename="'.$filename.'"');&lt;br /&gt;header('Content-length: ' . filesize($upload_dir.$filename));&lt;br /&gt; &lt;br /&gt;//read file and return value to browser&lt;br /&gt;fpassthru($fp);&lt;br /&gt;fclose($fp);&lt;br /&gt;&lt;br /&gt;&lt; ?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-52455483823342945?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/52455483823342945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=52455483823342945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/52455483823342945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/52455483823342945'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-function-upload-file.html' title='PHP function: Upload file'/><author><name>PHP Blog</name><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-1032797411830546131.post-5298024473964624403</id><published>2009-04-03T02:10:00.000-07:00</published><updated>2009-04-03T02:17:45.079-07:00</updated><title type='text'>PHP Tool: Encrypt and Decrypt base on Decode - Base64_decode</title><content type='html'>There are two function to encrypt and decrypt a string with PHP code&lt;br /&gt;&lt;br /&gt;function encrypt($string, $key) {&lt;br /&gt;    $result = '';&lt;br /&gt;    for($i=0; $i&lt;strlen($string); $i++) {&lt;br /&gt;      $char = substr($string, $i, 1);&lt;br /&gt;      $keychar = substr($key, ($i % strlen($key))-1, 1);&lt;br /&gt;      $char = chr(ord($char)+ord($keychar));&lt;br /&gt;      $result.=$char;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    return base64_encode($result);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;function decrypt($string, $key) {&lt;br /&gt;    $result = '';&lt;br /&gt;    $string = base64_decode($string);&lt;br /&gt;&lt;br /&gt;    for($i=0; $i&lt;strlen($string); $i++) {&lt;br /&gt;      $char = substr($string, $i, 1);&lt;br /&gt;      $keychar = substr($key, ($i % strlen($key))-1, 1);&lt;br /&gt;      $char = chr(ord($char)-ord($keychar));&lt;br /&gt;      $result.=$char;&lt;br /&gt;    }&lt;br /&gt;    return $result;&lt;br /&gt;  }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-5298024473964624403?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/5298024473964624403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=5298024473964624403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5298024473964624403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5298024473964624403'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tool-encrypt-and-decrypt-base-on.html' title='PHP Tool: Encrypt and Decrypt base on Decode - Base64_decode'/><author><name>PHP Blog</name><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-1032797411830546131.post-5076708584121037260</id><published>2009-04-02T00:09:00.000-07:00</published><updated>2009-04-02T00:17:52.063-07:00</updated><title type='text'>PHP Tool &amp; Code to Decode - Base64_decode</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 10"&gt;&lt;meta name="Originator" content="Microsoft Word 10"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C09%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0cm; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 90.0pt 72.0pt 90.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman";} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;PHP Tool &amp;amp; Free Code to Decode - Base64_decode. Copy the below code and save it as decoded.php and execute it. Paste your encoded code in the text area and press the Decode button in the web page.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt; html &gt;&lt;br /&gt;&lt; head &gt;&lt;br /&gt;&lt; title &gt;PHP Tool &amp;amp; Code to Decode - Base64_decode&lt; /title &gt;&lt;br /&gt;&lt; /head&gt;&lt;br /&gt;&lt; body &gt;&lt; h1 &gt;eval gzinflate base64_decode Decoder PHP Code&lt; /h1 &gt;&lt;br /&gt;&lt;/p&gt;&lt;form id="form1" name="form1" method="post" action="decoded.php"&gt;&lt;br /&gt;  &lt; textarea name="coded" cols="60" rows="8" id="coded"&gt;&lt; /textarea &gt;&lt;br /&gt;  &lt; input type="submit" name="Submit" value="Decode"&gt;&lt;br /&gt;&lt; /form&gt;&lt;br /&gt;&lt;br /&gt;&lt; ?php&lt;br /&gt;&lt;br /&gt;$contents=stripslashes($_POST["coded"]);&lt;br /&gt;if(trim($contents)!="")&lt;br /&gt;{&lt;br /&gt;   while (preg_match("/eval\(gzinflate/",$contents))&lt;br /&gt;   {&lt;br /&gt;      $contents=preg_replace("/&lt;\?|\?&gt;/", "", $contents);&lt;br /&gt;      eval(preg_replace("/eval/", "\$contents=", $contents));&lt;br /&gt;   &lt;br /&gt;   }&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt; br &gt;&lt;br /&gt;  &lt; textarea name="decoded" cols="60" rows="8" id="decoded"&gt;&lt; /textarea &gt;&lt;br /&gt;&lt;br /&gt;&lt; /body &gt;&lt;br /&gt;&lt; /html &gt;&lt;p&gt;&lt;/p&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-5076708584121037260?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/5076708584121037260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=5076708584121037260' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5076708584121037260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/5076708584121037260'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tool-code-to-decode-base64decode.html' title='PHP Tool &amp; Code to Decode - Base64_decode'/><author><name>PHP Blog</name><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-1032797411830546131.post-9024915518550311083</id><published>2009-04-01T01:07:00.000-07:00</published><updated>2009-04-01T19:27:52.486-07:00</updated><title type='text'>PHP Tutorial: Convert UTF-8 to HTML Function</title><content type='html'>This PHP function converts utf-8 characters to htlm characters in "&amp;amp;#" code ponit ";", see it follow:&lt;br /&gt;&lt;br /&gt;function utf8_to_html ($data)&lt;br /&gt;  {&lt;br /&gt;  return preg_replace("/([\\xC0-\\xF7]{1,1}[\\x80-\\xBF]+)/e", '_utf8_to_html("\\1")', $data);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;function _utf8_to_html ($data)&lt;br /&gt;  {&lt;br /&gt;  $ret = 0;&lt;br /&gt;  foreach((str_split(strrev(chr((ord($data{0}) % 252 % 248 % 240 % 224 % 192) + 128) . substr($data, 1)))) as $k =&gt; $v)&lt;br /&gt;      $ret += (ord($v) % 128) * pow(64, $k);&lt;br /&gt;      if ($ret &gt; 131071){&lt;br /&gt;          return "&amp;amp;#$ret;";&lt;br /&gt;      }else{&lt;br /&gt;          return html_entity_decode('&amp;amp;#'.$ret.';',ENT_NOQUOTES,'UTF-8');&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;Use: utf8_to_html ($string)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-9024915518550311083?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/9024915518550311083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=9024915518550311083' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9024915518550311083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/9024915518550311083'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/04/php-tutorial-convert-utf-8-to-html.html' title='PHP Tutorial: Convert UTF-8 to HTML Function'/><author><name>PHP Blog</name><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-1032797411830546131.post-8528354787541057843</id><published>2009-03-31T00:03:00.000-07:00</published><updated>2009-04-01T19:28:46.013-07:00</updated><title type='text'>Javascript : Convert string to HTML Code</title><content type='html'>This is javascript function, it converts string characters to html code point.&lt;br /&gt;&lt;br /&gt;function UnicodeCodePoint(iStr)&lt;br /&gt;{&lt;br /&gt;   for (i=0, oStr=''; i &lt; j="iStr.charCodeAt(i);"&gt; 127)&lt;br /&gt;       {&lt;br /&gt;           oStr=oStr.concat('&amp;amp;#').concat(j).concat(';');&lt;br /&gt;       }&lt;br /&gt;       else&lt;br /&gt;       {&lt;br /&gt;           if (j == 10) {&lt;br /&gt;           } else if (j == 13) {&lt;br /&gt;               oStr=oStr.concat('&lt;br /&gt;');&lt;br /&gt;           } else {&lt;br /&gt;               oStr=oStr.concat(iStr.charAt(i));&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   return oStr;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-8528354787541057843?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/8528354787541057843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=8528354787541057843' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8528354787541057843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/8528354787541057843'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/03/javascript-convert-string-to-html-code.html' title='Javascript : Convert string to HTML Code'/><author><name>PHP Blog</name><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-1032797411830546131.post-4439623565400575316</id><published>2009-03-30T00:20:00.000-07:00</published><updated>2009-03-30T00:34:17.461-07:00</updated><title type='text'>PHP function: Div pages on the php web code</title><content type='html'>This is php function to div pages on the web php&lt;br /&gt;&lt;br /&gt;function divPage($total,$currentPage,$div,$rows){&lt;br /&gt;   if(!$total || !$rows || !$div || $total&lt;=$rows) return false;     $nPage = floor($total/$rows) + (($total%$rows)?1:0);     $nDiv  = floor($nPage/$div) + (($nPage%$div)?1:0);     $currentDiv = floor($currentPage/$div) ;     $sPage = '';     if($currentDiv) {         $sPage .= '&lt; href="javascript:GotoPage(0)"&gt;&lt;img src="http://www.blogger.com/nomna/images/dlredarrow.gif" /&gt;&lt; /a&gt; ';&lt;br /&gt;       $sPage .= '&lt; href="javascript:GotoPage('.($currentDiv*$div - 1).')"&gt; &lt; src="./nomna/images/lredarrow.gif"&gt;  &lt; /a&gt; ';&lt;br /&gt;   }&lt;br /&gt;   $count =($nPage&lt;=($currentDiv+1)*$div)?($nPage-$currentDiv*$div):$div;     for($i=0;$i&lt;$count;$i++){         $page = ($currentDiv*$div + $i);          $sPage .= '&lt; href="javascript:GotoPage('.($currentDiv*$div + $i ).')" page="=" style=""&gt;'.($page+1).'&lt; /a&gt; ';&lt;br /&gt;   }&lt;br /&gt;   if($currentDiv &lt; $nDiv - 1){                    $sPage .= '&lt; href="javascript:GotoPage('.(($currentDiv+1)*$div).')"&gt;  &lt;img src="http://www.blogger.com/nomna/images/rredarrow.gif" /&gt; &lt; /a&gt; ';&lt;br /&gt;       $sPage .= '&lt; href="javascript:GotoPage('.(($nDiv-1)*$div).')"&gt;&lt; src="./nomna/images/drredarrow.gif"&gt;&lt; /a&gt;';&lt;br /&gt;   }&lt;br /&gt;   return $sPage;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1032797411830546131-4439623565400575316?l=phpscriptvn.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpscriptvn.blogspot.com/feeds/4439623565400575316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1032797411830546131&amp;postID=4439623565400575316' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4439623565400575316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1032797411830546131/posts/default/4439623565400575316'/><link rel='alternate' type='text/html' href='http://phpscriptvn.blogspot.com/2009/03/php-function-div-page-on-php-web-code.html' title='PHP function: Div pages on the php web code'/><author><name>PHP Blog</name><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>
