1 / 10

網路程式設計期末專題 多人聊天室 網站

網路程式設計期末專題 多人聊天室 網站. 第3組 501435003 吳文義 501435011 劉炎 敦 指導教授:潘仁義. 聊天室 - 功能及目的. 利用 PHP製作 多 用戶端 同時 聊天室 網站 , 各使用者利用瀏覽器 , 可 同時進行文字訊息 傳遞及表情符號顯示, 描述其 組成及運作 方式, 並說明各 功能設定注意事項。. 聊天室 - 系統 環境. 作業系統: Windows 7 網頁伺服器 :Apache 2.2.8 網頁程式開發 語言 :PHP 6.0.0-dev 檔案說明 : Chatroom.html  聊天室主要介面

mattox
Download Presentation

網路程式設計期末專題 多人聊天室 網站

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製作多用戶端同時聊天室網站, 各使用者利用瀏覽器, 可同時進行文字訊息傳遞及表情符號顯示, 描述其組成及運作方式, 並說明各功能設定注意事項。

  3. 聊天室-系統環境 作業系統:Windows 7 網頁伺服器:Apache 2.2.8 網頁程式開發語言:PHP 6.0.0-dev 檔案說明: Chatroom.html 聊天室主要介面 Chatform.php  新增訊息表單及程式碼 Showchatmsgs.php 顯示聊天室訊息 Chatroom.txt  儲存聊天室文字內容

  4. 聊天室-架構 進入聊天室 Chatroom.html Showchatmsgs.php 取出訊息 Chatroom.txt Chatform.php 寫入訊息

  5. 執行畫面 http://114.33.210.41:9999/chat3/chatroom.html

  6. PHP-header-refresh應用 1、每隔5秒,網頁重新導向 (每5秒重整一次聊天內容頁面)<?php header("refresh:5 ; url=showchatmsgs.php")?>

  7. 主程式說明 chatform.php (一) <? session_start(); // 開啟Session $chatfile = ‘chatroom.txt’;//文字檔_存放聊天文字內容 $ip_addr = $_SERVER['REMOTE_ADDR']; //查詢來源IP $MMM = $_POST["COLOR"].$_POST["Message"]."</font>".$_POST["EM"] // ↑ 文字顏色    ↑ 訊息      ↑ 表情符號 ; if (isset($_POST[“Clear”])) unset($_SESSION["user"]); // 檢查user session變裡,若有則註 冊user 為 Sender欄位內容 if(isset($MMM) && isset($_POST[“Send”])) {if(isset($_POST[“Sender”])) { $_SESSION["user"]; $_SESSION["user"] = $_POST["Sender"]; }

  8. 主程式說明 chatform.php (二) //建立訊息字串 (使用者暱稱及IP) $msgs= "<b>".$_SESSION["user"]."</b>_ <font color=#228742 size=-1>from:".$ip_addr."</font>_Says : "; //↑ 顯示IP及標示顏色 $msgs .= stripslashes($MMM).“<br>\n”; //文字訊息內容 $fdatas = file($chatfile); $file = fopen($chatfile,'w'); fputs($file, $msgs); $i=1; //將訊息寫回檔案 while (list($linenum, $line) = each($fdatas)) { fputs($file, $line); $i += 1; if ($i >200) break; // 只寫入200行至chatroom.txt } fclose($file); } ?>

  9. 心得及過程 過程: 在製作過程中, 預到幾個困難, 1.平台及語言的選擇:Linux or Windows / ASP or PHP 2.執行上的問題:出現ERROR時,如何debug及找出解決方法 3.新增功能的挑戰:a.加上表情符號圖案b.來源IP標示顏色 c.文字交談顏色選擇 心得: 對於網路上資料的傳遞及應用有更佳了解, 解決bug後,所獲得的成就感,也是激發學習慾望益處之一, 雖然在程式方面不是專長, 但多多少少也了解到,問題發生後,如何去尋找解決方法。

  10. 報告完畢

More Related