1 / 18

網路程式設計期末專題 多人聊天室 網站 背景知識簡介

網路程式設計期末專題 多人聊天室 網站 背景知識簡介. 第3組 501435003 吳文義 501435011 劉炎敦. 背景知識. 功能及目的: 利用PHP製作 多 用戶端 同時 聊天室網站。 技術背景: 1.Ap p S e rv 簡介 2 . HTML-框架 應用 3 . 表單變數 傳遞 get/ p ost 說明 4 . PHP -header- refresh應用 5 .PHP-fopen 功能 6.PHP-REMOTE_ADDR 說明 7.php.ini 注意事項. 1.AppServ 簡介. AppServ 2.6.0 由以下四者組成 :

marek
Télécharger la présentation

網路程式設計期末專題 多人聊天室 網站 背景知識簡介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 網路程式設計期末專題多人聊天室網站背景知識簡介網路程式設計期末專題多人聊天室網站背景知識簡介 第3組 501435003 吳文義 501435011 劉炎敦

  2. 背景知識 功能及目的: 利用PHP製作多用戶端同時聊天室網站。 技術背景: 1.AppServ簡介 • 2.HTML-框架應用 • 3.表單變數傳遞get/post說明 • 4.PHP-header-refresh應用 5.PHP-fopen功能 6.PHP-REMOTE_ADDR說明 7.php.ini注意事項

  3. 1.AppServ簡介 AppServ2.6.0 由以下四者組成: 網頁伺服器-Apache 2.2.8 網頁程式開發語言-PHP 6.0.0-dev 資料庫-MySQL 6.0.4-alpha 資料庫管理工具-phpMyAdmin-2.10.3

  4. Apache 於1996年, Apache起初由伊利諾大學香檳分校的國家超級電腦應用中心(NCSA)開發。此後,Apache Httpd被開放原始碼團體的成員不斷的發展和加強。 由於其跨平台和安全性。被廣泛使用,是最流行的Web伺服器端軟體之一。它快速、可靠並且可通過簡單的API擴充,並且將Perl/Python等直譯器編譯到伺服器中。

  5. PHP PHP最初是由勒多夫在1995年開始開發的。而現在PHP的標準由PHP Group和開放原始碼社群維護。 是一種開源的通用電腦指令碼語言,尤其適用於網路開發並可嵌入HTML中使用。PHP的語法借鑒吸收了C語言、Java和Perl等流行電腦語言的特點,易於一般程式設計師學習。

  6. MySQL 原開發者為瑞典的MySQL AB公司,該公司於2008年被昇陽微系統(Sun Microsystems)收購。2009年,甲骨文公司(Oracle)收購昇陽微系統公司,MySQL成為Oracle旗下產品。 MySQL在過去由於效能高、成本低、可靠性好,已經成為最流行的開源資料庫,因此被廣泛地應用在Internet上的中小型網站中

  7. phpMyAdmin 以PHP為基礎,以Web-Base方式架構在網站主機上的MySQL的資料庫管理工具,處理大量資料的匯入及匯出更為方便。 您可以在任何地方使用這些程式產生的 HTML頁面,也就是於遠端管理MySQL資料庫,方便的建立、修改、刪除資料庫及資料表。也可藉由phpMyAdmin建立常用的php語法,方便編寫網頁時所需要的sql語法正確性。

  8. 2.HTML-框架應用(一) Frameset+Frame <frameset rows="80%,*"> <frame src=“a.php" name="chat"> <frame src=“b.php" name="speak"> </frameset>說明:在現有網頁中,上半部佔螢幕80%高度,內容為a.php,下半部*號表示剩餘空間由b.php填滿. Rows表示行,由上到下來組成框架.如下圖示: rows/cols 單位可用像素及%來表示

  9. 2.HTML-框架應用(二) Frameset+Frame <frameset cols=“300,*"> <frame src=“a.php" name="chat"> <frame src=“b.php" name="speak"> </frameset>說明:在現有網頁中,左半部佔螢幕300像素,右半部*號表示剩餘空間由b.php填滿. cols表示列,由左至右來組成框架.如下圖示: rows/cols 單位可用像素及%來表示

  10. 3.表單變數傳遞get/post說明(一) HTML Form 表單有兩種資料傳遞方式,分別為 GET 與 PSOT 這兩種,當網有填好表單資料並按下送出表單的按鈕之後,必須透過這兩種方式將資料送出到伺服器(Web Server),以下為兩種方式的 HTML Code 寫法。一、GET 傳遞方式 <form action="接收資料的程式" method="get">二、POST 傳遞方式<form action="接收資料的程式" method="post">

  11. 3.表單變數傳遞get說明(二) • URL 改變,在URL 裡顯示 HTML Form 參數的 name/value 值。 • 只適合有少量參數的 HTML Form,因為 URL 長度有字元限制,不能無限長。 • 涉及安全性的資訊,比如使用者密碼,不能用 get,因為會在 URL 上顯示,不安全。 <form method="get" action=""> <input type="text" name="id" /> <input type="submit" /> </form> --------------------------------------------------------------------------------------------- GET /?id=010101 HTTP/1.1 Host: xxx.abc.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 ( .NET CLR 3.5.30729)

  12. 3.表單變數傳遞post說明(三) • URL 不改變,不在 URL 裡顯示 HTML Form 的資料。 • Form 提交的資訊沒有長度限制。 • 涉及安全性的資訊,如使用者密碼,應採用 post 方式。 <form method="post" action=""> <input type="text" name="id" /> <input type="submit" /> </form> ------------------------------------------------------------------------------------------------ POST / HTTP/1.1 Host: xxx.abc.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 ( .NET CLR 3.5.30729) Content-Type: application/x-www-form-urlencoded </code><code>Content-Length: 9 id=020202

  13. 5.PHP-header-refresh應用 1、header函數使用location網頁導向A、語法: header("檔頭資訊名稱:檔頭內容"); B、範例: <?php header("location: http://www.google.com.tw")?> <?php header("location: simple.php")?> <?php header("HTTP/1.0 404 Not Found");?> 2、header函數使用refresh網頁重讀及網頁導向 A、語法: 語法一:header("refresh:秒數")語法二:header("refresh:秒數";url=網址或目錄檔案) B、範例: <?php header("refresh:5")?> <?php header("refresh:5 ; url=http://google.com")?> <?php header("refresh:5 ; url=chat.php")?>

  14. 6.PHP-fopen功能(一) 本例採用w模式,寫入文字檔內容 <?php $filename = "test"; $str = ""; //判斷是否有該檔案 if(file_exists($filename)){ $file = fopen($filename, “w"); if($file != NULL){ while (!feof($file)) { $str .= fgets($file); } fclose($file); } } echo $str; ?>

  15. 6.PHP-fopen功能(二) 本例採用w模式,寫入文字檔內容 <?php $filename = "test"; $str = ""; //判斷是否有該檔案 if(file_exists($filename)){ $file = fopen($filename, “w"); if($file != NULL){ while (!feof($file)) { $str .= fgets($file); } fclose($file); } } echo $str; ?> feof(資源) 是否到達檔案底部  T/F fgets(資源)    每讀一行資料回傳,到底回傳false  fclose(資源)     return True/Flase

  16. 6.PHP-REMOTE_ADDR說明 獲取用戶端IP $ip_addr = $_SERVER['REMOTE_ADDR']; 藉由顯示來源端IP的, 加強確認使用者身份, 避免一人分飾多角, 以及冒名回答等情況發生. EX.在聊天室中,用戶暱稱後會加上IP. 小王(來自:114.33.22.11): 小陳,你好~ 小陳(來自:224.33.11.55):HELLO,小王~ 小李子(來自:232.11.22.33):大家好~!!!

  17. 7.PHP.ini注意事項 問題: Warning: Cannot modify header information – headers already sent by 解決方式: output_buffering=On 開啟緩衝區

  18. 參考文獻 AppServ http://www.appservnetwork.com/ Apache http://zh.wikipedia.org/wiki/Apache_HTTP_Server MySQL http://zh.wikipedia.org/wiki/MySQL PHP http://zh.wikipedia.org/wiki/PHP phpMyAdmin http://zh.wikipedia.org/wiki/PhpMyAdmin Frameset框架 http://enjoywebtech.blogspot.tw/2008/01/html15-framesetframe.html Method get/post http://blog.toright.com/archives/1203 PHP header http://tw.myblog.yahoo.com/jw!jc9MO8qQEQIIR9edc.sXeA--/article?mid=12&sc=1 PHP readfile http://chia-ronglearn.blogspot.tw/2013/08/php-readfile.html PHP 顯示IP方式 http://www.dotblogs.com.tw/jellycheng/archive/2010/12/16/20169.aspx

More Related