Location: PHPKode > projects > Admbook > admin/update.php
<?php
	session_start();
	include("../settings-data.php");
	include("../lib.php");
	checkPermissions($login, $password);
	if (file_exists("../content-data.php"))
		include("../content-data.php");
	$error = "";
	$style = "";
	if (!isset($id))
		$id = "";
	if (!isset($content[$id-1]))
	{
		session_destroy();
		Header("Location: login.php");exit;
	}
	session_register("error");
	session_register("style");
	session_register("name");
	session_register("url");
	session_register("email");
	session_register("icq");
	session_register("message");
	session_register("admName");
	session_register("admMessage");
	if ($name == "")
	{
		$error .= "Name is empty<br>";
		$style .= "\n.name {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	else if (strlen($name) > 30)
	{
		$error .= "Name is long<br>";
		$style .= "\n.name {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if ($url != "" && $url != "http://")
	{
		$url_status = @check_url($url);
		if (!$url_status)
		{
			$error .= "Wrong or inaccessible url<br>";
			$style .= "\n.url {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
		else if ($url_status == "DNS")
		{
			$error .= "Inaccessible url<br>";
			$style .= "\n.url {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
	}
	if ($email != "" && !validEmail($email))
	{
		if (!validEmail($email))
		{
			$error .= "Wrong e-mail<br>";
			$style .= "\n.email {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
	}
	if ($message == "")
	{
		$error .= "Message is empty<br>";
		$style .= "\n.message {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	else if (strlen($message) > ($constant['max-length-message']-1))
	{
		$error .= "Message is long<br>Maximum length ".$constant['max-length-message']." bytes<br>";
		$style .= "\n.message {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if ($icq != "")
	{
		if(!isInteger($icq))
		{
			$error .= "ICQ number must have only number<br>";
			$style .= "\n.icq {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
	}
	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: edit.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'] = \"".translateHtml($name, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['url'] = \"".translateHtml($url, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['mail'] = \"".translateHtml($email, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['icq'] = \"".translateHtml($icq, false)."\";\n";
			$updateContent .= "\t\$content[".$i."]['message'] = \"".translateHtml($message)."\";\n";
			$updateContent .= "\t\$content[".$i."]['time'] = \"".$currentContent['time']."\";\n";
			if (isset($admName))
				$updateContent .= "\t\$content[".$i."]['admin-name'] = \"".translateHtml($admName, false)."\";\n";
			else
				$updateContent .= "\t\$content[".$i."]['admin-name'] = \"\";\n";
			if (isset($admMail))
				$updateContent .= "\t\$content[".$i."]['admin-mail'] = \"".translateHtml($admMail, false)."\";\n";
			else
				$updateContent .= "\t\$content[".$i."]['admin-mail'] = \"\";\n";
			if (isset($admMessage))
				$updateContent .= "\t\$content[".$i."]['admin-message'] = \"".translateHtml($admMessage)."\";\n";
			else
				$updateContent .= "\t\$content[".$i."]['admin-message'] = \"\";\n";
			if (isset($admName) && isset($admMessage))
				$updateContent .= "\t\$content[".$i."]['admin-time'] = \"".time()."\";\n";
			else
				$updateContent .= "\t\$content[".$i."]['admin-time'] = \"".$currentContent['admin-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("name");
	session_unregister("url");
	session_unregister("email");
	session_unregister("icq");
	session_unregister("message");
	session_unregister("admName");
	session_unregister("admMessage");
	Header("Location: index.php?page=".$page);exit;
?>
Return current item: Admbook