?? login.php
字號:
<?php
require_once('xmlHandler.php');
$fn_xml = "chatroom.xml";
// Check that if name (form input) is in the post data, set it in the session cookie
if (isset($_POST["name"])) {
setcookie("name", $_POST["name"]);
// create the chatroom xml file handler
$xmlh = new xmlHandler($fn_xml);
if (!$xmlh->fileExist()) {
header("Location: error.html");
exit;
}
// open the existing XML file
$xmlh->openFile();
// get all the child nodes of the the 'users' element
$users_array = $xmlh->getChildNodes("user");
// check if the ms agent is selected by other users
if ($users_array!=null) {
foreach ($users_array as $users) {
$aname = $xmlh->getAttribute($users, "agent");
$uname = $xmlh->getAttribute($users, "name");
if ($aname==$_POST["agentname"] || $uname==$_POST["name"]) {
header("Location: error.html");
exit;
}
}
}
// add the user information to the xml file
// get the 'users' element
$users_n = $xmlh->getElement("users");
// create a 'user' element
$user_n = $xmlh->addElement($users_n, "user");
// add the user name and agent name
$xmlh->setAttribute($user_n, "name", $_POST["name"]);
$xmlh->setAttribute($user_n, "agent", $_POST["agentname"]);
// save the XML file
$xmlh->saveFile();
}
else {
header("Location: error.html");
exit;
}
// Cookie done, redirect to client.php (to avoid reloading of page from the client)
header("Location: client.php");
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -