Location: PHPKode > projects > Admbook > admin/config-up.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 (!isset($error))
		$error = "";
	if (!isset($style))
		$style = "";
	if (!isset($maxLengthMessage))
		$maxLengthMessage = "";
	if (!isset($messagesToPage))
		$messagesToPage = "";
	if (!isset($pageInLine))
		$pageInLine = "";
	if (!isset($maxWordLength))
		$maxWordLength = "";
	if (!isset($repeatSendTime))
		$repeatSendTime = "";
	if (!isset($adminMail))
		$adminMail = "";
	if (!isset($adminName))
		$adminName = "";
	if (!isset($newAdminPass))
		$newAdminPass = "";
	session_register("error");
	session_register("style");
	session_register("maxLengthMessage");
	session_register("messagesToPage");
	session_register("pageInLine");
	session_register("maxWordLength");
	session_register("repeatSendTime");
	session_register("adminMail");
	session_register("adminName");
	session_register("oldAdminPass");
	session_register("newAdminPass");
	session_register("confirmAdminPass");
	session_register("errColor");
	session_register("bgColor");
	session_register("textColor");
	session_register("linkColor");
	session_register("borderColor");
	session_register("lineColor");
	session_register("adminLineColor");
	session_register("headerBgColor");
	session_register("headerTextColor");
	session_register("headerLinkColor");
	session_register("messageBgColor");
	session_register("messageTextColor");
	session_register("messageLinkColor");
	session_register("adminMessageBgColor");
	session_register("adminMessageTextColor");
	session_register("adminMessageLinkColor");
	session_register("textCharset");
	session_register("i");
	session_register("bold");
	session_register("a");
	session_register("smile");

	if(!isInteger($maxLengthMessage))
	{
		$error .= "'Max messages length' must have only number<br>";
		$style .= "\n.maxmessageslength {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if(!isInteger($messagesToPage))
	{
		$error .= "'Messages to page' must have only number<br>";
		$style .= "\n.messagestopage {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if(!isInteger($pageInLine))
	{
		$error .= "'Page in line' must have only number<br>";
		$style .= "\n.pageinline {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if(!isInteger($maxWordLength))
	{
		$error .= "'Max word length' must have only number<br>";
		$style .= "\n.maxwordlength {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if(!isFloat($repeatSendTime))
	{
		$error .= "'Time for repeating send message' must have only number<br>";
		$style .= "\n.repeatsendtime {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if ($adminMail != "" && !validEmail($adminMail))
	{
		if (!validEmail($adminMail))
		{
			$error .= "Wrong e-mail<br>";
			$style .= "\n.adminmail {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
	}
	if ($adminName == "")
	{
		$error .= "Admin name is empty<br>";
		$style .= "\n.adminname {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	else if (strlen($adminName) > 30)
	{
		$error .= "Name is long<br>";
		$style .= "\n.adminname {\n\tcolor : ".$constant['error-color']."\n}\n";
	}
	if ($newAdminPass != "")
	{
		$newPassLen = strlen($newAdminPass);
		if ($newPassLen < 4)
		{
			$error .= "'New password' is short<br>";
			$style .= "\n.adminpassword {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
		if ($newAdminPass != $confirmAdminPass)
		{
			$error .= "'New password' and 'Confirm password' different<br>";
			$style .= "\n.adminpassword {\n\tcolor : ".$constant['error-color']."\n}\n";
		}
		if ($newPassLen > 3 && $newAdminPass == $confirmAdminPass)
		{
			session_register("password");
			$password = md5($newAdminPass);
		}
	}
	if ($error != "")
	{
		Header("Location: config.php?page=".$page);exit;
	}
	if ($password == "")
		$password = $constant['admin-password'];
	if (isset($i))
		$i = "true";
	else
		$i = "false";
	if (isset($bold))
		$bold = "true";
	else
		$bold = "false";
	if (isset($a))
		$a = "true";
	else
		$a = "false";
	if (isset($smile))
		$smile = "true";
	else
		$smile = "false";
	if($locale == "")
		$locale = $constant['locale'];
	if($bgColor == "")
		$bgColor = $constant['background-color'];
	if($textColor == "")
		$textColor = $constant['text-color'];
	if($linkColor == "")
		$linkColor = $constant['link-color'];
	if($borderColor == "")
		$borderColor = $constant['border-color'];
	if($lineColor == "")
		$lineColor = $constant['line-color'];
	if($adminLineColor == "")
		$adminLineColor = $constant['admin-line-color'];
	if($errColor == "")
		$errColor = $constant['error-color'];
	if($headerBgColor == "")
		$headerBgColor = $constant['header-background-color'];
	if($headerTextColor == "")
		$headerTextColor = $constant['header-text-color'];
	if($headerLinkColor == "")
		$headerLinkColor = $constant['header-link-color'];
	if($messageBgColor == "")
		$messageBgColor = $constant['message-background-color'];
	if($messageTextColor == "")
		$messageTextColor = $constant['message-text-color'];
	if($messageLinkColor == "")
		$messageLinkColor = $constant['message-link-color'];
	if ($adminMessageBgColor == "")
		$adminMessageBgColor = $constant['admin-message-background-color'];
	if ($adminMessageTextColor == "")
		$adminMessageTextColor = $constant['admin-message-text-color'];
	if ($adminMessageLinkColor == "")
		$adminMessageLinkColor = $constant['admin-message-link-color'];
	$updateConstant = "<?php\n";
	$updateConstant .= "\t\$constant['max-length-message'] = \"".translateHtml($maxLengthMessage,false)."\";\n";
	$updateConstant .= "\t\$constant['max-word-length'] = \"".translateHtml($maxWordLength,false)."\";\n";
	$updateConstant .= "\t\$constant['messages-to-page'] = \"".translateHtml($messagesToPage,false)."\";\n";
	$updateConstant .= "\t\$constant['page-in-line'] = \"".translateHtml($pageInLine,false)."\";\n";
	$updateConstant .= "\t\$constant['repeat-send-time'] = \"".translateHtml($repeatSendTime,false)."\";\n";
	$updateConstant .= "\t\$constant['bold-in-message'] = ".translateHtml($bold,false).";\n";
	$updateConstant .= "\t\$constant['italic-in-message'] = ".translateHtml($i,false).";\n";
	$updateConstant .= "\t\$constant['link-in-message'] = ".translateHtml($a,false).";\n";
	$updateConstant .= "\t\$constant['smile-in-message'] = ".translateHtml($smile,false).";\n";
	$updateConstant .= "\t\$constant['background-color'] = \"".translateHtml($bgColor,false)."\";\n";
	$updateConstant .= "\t\$constant['text-color'] = \"".translateHtml($textColor,false)."\";\n";
	$updateConstant .= "\t\$constant['link-color'] = \"".translateHtml($linkColor,false)."\";\n";
	$updateConstant .= "\t\$constant['header-background-color'] = \"".translateHtml($headerBgColor,false)."\";\n";
	$updateConstant .= "\t\$constant['header-text-color'] = \"".translateHtml($headerTextColor,false)."\";\n";
	$updateConstant .= "\t\$constant['header-link-color'] = \"".translateHtml($headerLinkColor,false)."\";\n";
	$updateConstant .= "\t\$constant['message-background-color'] = \"".translateHtml($messageBgColor,false)."\";\n";
	$updateConstant .= "\t\$constant['message-text-color'] = \"".translateHtml($messageTextColor,false)."\";\n";
	$updateConstant .= "\t\$constant['message-link-color'] = \"".translateHtml($messageLinkColor,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-message-background-color'] = \"".translateHtml($adminMessageBgColor,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-message-text-color'] = \"".translateHtml($adminMessageTextColor,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-message-link-color'] = \"".translateHtml($adminMessageLinkColor,false)."\";\n";
	$updateConstant .= "\t\$constant['border-color'] = \"".translateHtml($borderColor,false)."\";\n";
	$updateConstant .= "\t\$constant['line-color'] = \"".translateHtml($lineColor,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-line-color'] = \"".translateHtml($adminLineColor,false)."\";\n";
	$updateConstant .= "\t\$constant['error-color'] = \"".translateHtml($errColor,false)."\";\n";
	$updateConstant .= "\t\$constant['charset'] = \"".translateHtml($textCharset,false)."\";\n";
	$updateConstant .= "\t\$constant['locale'] = \"".translateHtml($locale,false)."\";\n";
	$updateConstant .= "\t\$constant['version'] = \"".$constant['version']."\";\n";
	$updateConstant .= "\t\$constant['help-page-en'] = \"".$constant['help-page-en']."\";\n";
	$updateConstant .= "\t\$constant['help-page-ru'] = \"".$constant['help-page-ru']."\";\n";
	$updateConstant .= "\t\$constant['admin-mail'] = \"".translateHtml($adminMail,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-name'] = \"".translateHtml($adminName,false)."\";\n";
	$updateConstant .= "\t\$constant['admin-password'] = \"".$password."\";\n";
	$updateConstant .= "?>";
	reWriteDataInFile ($updateConstant,"../settings-data.php");
	session_unregister("error");
	session_unregister("style");
	session_unregister("maxLengthMessage");
	session_unregister("messagesToPage");
	session_unregister("pageInLine");
	session_unregister("maxWordLength");
	session_unregister("repeatSendTime");
	session_unregister("adminMail");
	session_unregister("adminName");
	session_unregister("oldAdminPass");
	session_unregister("newAdminPass");
	session_unregister("confirmAdminPass");
	session_unregister("errColor");
	session_unregister("bgColor");
	session_unregister("borderColor");
	session_unregister("lineColor");
	session_unregister("adminLineColor");
	session_unregister("textColor");
	session_unregister("linkColor");
	session_unregister("headerBgColor");
	session_unregister("headerTextColor");
	session_unregister("headerLinkColor");
	session_unregister("messageBgColor");
	session_unregister("messageTextColor");
	session_unregister("messageLinkColor");
	session_unregister("adminMessageBgColor");
	session_unregister("adminMessageTextColor");
	session_unregister("adminMessageLinkColor");
	session_unregister("textCharset");
	session_unregister("i");
	session_unregister("bold");
	session_unregister("a");
	session_unregister("smile");
	$timer->stop();
	Header("Location: config.php?page=".$page."&".$timer->elapsed());exit;
?>
Return current item: Admbook