Location: PHPKode > projects > Siteman personal website CMS > siteman-personal-website-cms/index.php
<?php
	if (isset($_GET["page"])) {
		if (substr($_GET["page"],0,1) != ".") {
			$page = $_GET["page"];
		}
		else {
			$page = "index";
		}
	}
	else {
		$page = "index";
	}
	if (!isset($class_included)) {
		include("data/class.php");
	}
	if (!isset($Siteman)) {
		$Siteman = new Website("1.1.11");
	}
	if ($do == "login") {
		if (isset($_POST["username"]) && isset($_POST["password"])) {
			$Siteman->loginresult = $Siteman->login($_POST["username"],$_POST["password"]);
		}
		if (isset($_POST["returnto"])) {
			$Siteman->refresh(0,$_POST["returnto"]);
		}
	}
	else if ($do == "logout") {
		$Siteman->logout();
		if (isset($_GET["return"])) {
			$Siteman->refresh(0,$_GET["return"]);
		}
	}
	$visits = file("data/count.txt");
	$hits = count(file("data/stats.txt"));
	if ($page == "index") {
		$hits++;
	}
	$resetdate = date($short_dateformat,$visits[0]);
	if ($do == "default") {
		$info = $Siteman->db_get(0,$page,"data/pages");
		$content = "pages/" . $page . ".php";
		$includewrappers = 0;
		$title_bar = $info[4];
		$page_title = $info[5];
		$info[3]++;

		if (file_exists($content)) {
			$pages = $Siteman->safe_file("data/pages.txt");
			$c = 0;
			while ($c < 5) {
				$Siteman->wait_for_unlock("data/pages.txt",200);
				if (!$Siteman->is_locked("data/pages.txt")) {
					if ($pages) {
						$Siteman->write_lock("data/pages.txt");
						$fp = fopen("data/pages.txt","w");
						$first = 1;
						foreach ($pages as $gti) {
							$inte = explode("|",$gti);
							if ($inte[0]) {
								if ($first) {
									$first = 0;
								}
								else {
									fwrite($fp,"\n");
								}
								if ($inte[0] == $page) {
									fwrite($fp,trim(implode("|",$info)));
								}
								else {
									fwrite($fp,trim($gti));
								}
							}
						}
						fclose($fp);
						$Siteman->write_unlock("data/pages.txt");
						$c = 400;
					}
				}
				$c++;
			}
		}
	}
	$adress = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
	
	include("data/page_header.php");
	switch ($do) {
	
		case "prevphp":
			if ($Siteman->mlevel >= 4) {
				echo preg_replace("'<\?php.*?\?>'si","",stripslashes($_POST["content"]));
			}
			break 1;
		
		case "default":
			if ($info[2] == 1 || $Siteman->mlevel >= $info[2]) {
				include_once($content);
				if ($Siteman->mlevel < 5) {
					if ($page == "index") {
						if (substr_count($_SERVER["HTTP_REFERER"],$adress) == 0) {
							echo "<script language=\"Javascript\" type=\"text/javascript\">
							var res = screen.width.toString() + 'x' + screen.height.toString();
							var referer = '" . urlencode($_SERVER["HTTP_REFERER"]) . "';
							document.write('<img width=\"1\" height=\"1\" src=\"stats.php?new=1&amp;res=' + res + '&amp;referer=' + referer + '\" id=\"stat\" name=\"stat\" />');
							</script>";
						}
					}
				}
			}
			break 1;
	}
	include("data/page_footer.php");

?>
Return current item: Siteman personal website CMS