⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 add_message.php

📁 shooting flash game with script
💻 PHP
字号:
<?php
$username = $_POST["username"];

$newdir = $username;
if (!file_exists($newdir))
	mkdir($newdir);

if ($_FILES['userfile']['name'] != null) {
	$uploadfile = $_FILES['userfile']['name'];
	$uploadfile = $newdir.'/'.$uploadfile;
	if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
	print "<script>alert('File upload failed');</script>";
		exit;
	}
}
//if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
	require_once('xmlHandler.php');
	$fn_xml = "chatroom.xml";

	// the login name is stored in session cookie and content is coming from the POST data
	$message = $_POST["message"];
	if (trim($message)=="") $message="__EMPTY__";
	
	// create the chatroom xml file handler
	$xmlh = new xmlHandler($fn_xml);

	// check if the chatroom XML file exists
	if (!$xmlh->fileExist()) {
		print "<script>alert('File upload failed');</script>";
		exit;
	}

	// create the following DOM tree structure for a message
	// and add it to the chatroom XML file
	//
	//	<message name="...">...</message>
	//

	$xmlh->openFile();

	// get the 'messages' element as the current element
	$messages_n = $xmlh->getElement("messages");
	
	// create a 'message' element for each message
	$message_n = $xmlh->addElement($messages_n, "message");
	
	// add the name
	$xmlh->setAttribute($message_n, "name", $username);
	
	// add the file information
	$xmlh->setAttribute($message_n, "file", $uploadfile);

/*	
	// add the whiteboard information
	if ($_POST["wb"] != "") {
		$xmlh->setAttribute($message_n, "file", $_POST["wb"]);
	}
*/	
	$xmlh->setAttribute($message_n, "color", "0x".$_POST["red"].$_POST["green"].$_POST["blue"]);
	$xmlh->setAttribute($message_n, "font", $_POST["font"]);
	$xmlh->setAttribute($message_n, "fontsize", $_POST["fontsize"]);

	setCookie("red", $_POST["red"]);
	setCookie("green", $_POST["green"]);
	setCookie("blue", $_POST["blue"]);
	setCookie("font", $_POST["font"]);
	setCookie("fontsize", $_POST["fontsize"]);


	// add the content of the message
	$xmlh->addText($message_n, $message);

	$xmlh->saveFile();
	header("Location: client.php");

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -