Location: PHPKode > projects > Admbook > admin/reply-add.php
<?php
	class Timer {
		var $startTime;
		var $endTime;
		function start() {
			$this->startTime = gettimeofday();
		}
		function stop() {
			$this->endTime = gettimeofday();
		}
		function elapsed() {
			return (($this->endTime["sec"] - $this->startTime["sec"]) * 1000000 + ($this->endTime["usec"] - $this->startTime["usec"])) / 1000000;
		}
	}
	$timer = new Timer();
	$timer->start();
	session_start();
	include("../settings-data.php");
	include("../lib.php");
	checkPermissions($login, $password);
	if (file_exists("../content-data.php"))
		include("../content-data.php");
	if (!isset($error))
		$error = "";
	if (!isset($style))
		$style = "";
	if (!isset($id))
		$id = "";
	if (!isset($content[$id-1]))
	{
		session_destroy();
		Header("Location: login.php");exit;
	}
	setUserCookie(stripslashes($admName), "cookie[admin-name]");
	setUserCookie(stripslashes($admMail), "cookie[admin-mail]");
	session_register("error");
	session_register("style");
	session_register("admName");
	session_register("admMail");
	session_register("admMessage");
	if (isset($admName) && isset($admMessage))
	{
		if ($admName == "")
		{
			$error .= "Admin name is empty<br>";
			$style .= "\n.adminname {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
		if ($admMessage == "")
		{
			$error .= "Admin message is empty<br>";
			$style .= "\n.adminmessage {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
	}
	if ($admMail != "" && !validEmail($admMail))
	{
		$error .= "Wrong admin e-mail<br/>";
		$style .= "\n.adminmail {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if ($error != "")
	{
		Header("Location: reply.php?id=".$id."&page=".$page);exit;
	}
	$currentContent = $content[$id-1];
	$contentCnt = sizeof($content);
	$updateContent = "<?php\n";
	for($i = 0; $i < $contentCnt; $i++)
	{
		if ($i == $id-1)
		{
			$updateContent .= "\t\$content[".$i."]['ip'] = \"".$currentContent['ip']."\";\n";
			$updateContent .= "\t\$content[".$i."]['host'] = \"".$currentContent['host']."\";\n";
			$updateContent .= "\t\$content[".$i."]['proxy'] = \"".$currentContent['proxy']."\";\n";
			$updateContent .= "\t\$content[".$i."]['name'] = \"".$currentContent['name']."\";\n";
			$updateContent .= "\t\$content[".$i."]['url'] = \"".$currentContent['url']."\";\n";
			$updateContent .= "\t\$content[".$i."]['mail'] = \"".$currentContent['mail']."\";\n";
			$updateContent .= "\t\$content[".$i."]['icq'] = \"".$currentContent['icq']."\";\n";
			$updateContent .= "\t\$content[".$i."]['message'] = \"".$currentContent['message']."\";\n";
			$updateContent .= "\t\$content[".$i."]['time'] = \"".$currentContent['time']."\";\n";
			$updateContent .= "\t\$content[".$i."]['admin-name'] = \"".translateHtml($admName, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['admin-mail'] = \"".translateHtml($admMail, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['admin-message'] = \"".translateHtml($admMessage)."\";\n";
			$updateContent .= "\t\$content[".$i."]['admin-time'] = \"".time()."\";\n";
		}
		else
		{
			while(list($key, $value) = each($content[$i]))
			{
				$updateContent .= "\t\$content[".$i."]['".$key."'] = \"".$value."\";\n";
			}
		}
		if ($i != $contentCnt-1)
			$updateContent .= "\n";
	}
	$updateContent .= "?>";
	reWriteDataInFile ($updateContent,"../content-data.php");
	session_unregister("error");
	session_unregister("style");
	session_unregister("admName");
	session_unregister("admMail");
	session_unregister("admMessage");
	$timer->stop();
	Header("Location: index.php?page=".$page."&".$timer->elapsed());exit;
?>
Return current item: Admbook