assign("editorlist", $editorlist); $page = isset($_GET["page"]) ? $_GET["page"] : "index"; if($page == "articles"){ header("Location: articles.php?page=articles"); }elseif($page == "index"){ $articlesLimit = 2; include("articlesItems.php"); } $bad_chars=array("'",'"',".",",","<",">","?","/","`","~","\\","!"); $page = str_replace($bad_chars,"",$page); $smarty->assign("page", $page); //for incorrect password message if(isset($_REQUEST["error"]) && $_REQUEST["error"] != ""){ $smarty->assign("error", $_REQUEST["error"]); } $pagewpluses = str_replace(" ", "+", $page); //url page name with +'s ion place of spaces and no .txt on end $page = $page.".txt"; //filename $fileContentsString = ""; $selectedIndex= -1; if(file_exists("./content/sitemap.txt")){ $fileContents2 = unserialize(file_get_contents('./content/sitemap.txt')); //crumbtrail $crumbtrail_array = explode("\n", $fileContents2["content"]); $crumbtrail_image = ' :: '; $crumbtrail = ""; $i=0; $found = false; $current_level = ""; //loop through the array until you find the current page, then go backwards until you reach the top level to get your crumbtrail while($i -1){ if($found || strpos($crumbtrail_array[$i], "|index.php?page=".$pagewpluses)){ if(!$found){ //$selectedIndex = $i+1; $found = true; } $this_page = explode("|", $crumbtrail_array[$i]); //remove the link from the current page so the menu and sitemap don't link to the current page if(strpos($crumbtrail_array[$i], "|index.php?page=".$pagewpluses)){ $crumbtrail_array[$i] = $this_page[0] . "|" . $this_page[1] . "|"; } if($current_level == "" || strlen($current_level) > strlen($this_page[0])){ $current_level = $this_page[0]; if($crumbtrail == "" || count($this_page) < 3 | !isset($this_page[2]) || $this_page[2] == ""){ $crumbtrail = $crumbtrail_image . stripslashes($this_page[1]) . $crumbtrail; }else{ $crumbtrail = $crumbtrail_image . ' ' . stripslashes($this_page[1]) . '' . $crumbtrail; } //if you are on the top level if($current_level == "."){ break(1); } } //once you find the page in the array go backwards until you reach the top level (.) $i--; }else{ //iterate through the array until you find the page you're on $i++; $selectedIndex = $i+1; } } //echo $crumbtrail; if($crumbtrail == ""){ $crumbtrail = $crumbtrail_image . " " . ucwords(str_replace("+", " ", $pagewpluses)); } $smarty->assign("crumbtrail", $crumbtrail); //menu $mid = new LayersMenu(); //new LayersMenu(6, 7, 2, 1); // Gtk2-like //$mid->setMenuStructureFile('plugins/phplayersmenu/layersmenu-horizontal-1.txt'); $fileContentsString = stripslashes(implode("\n", $crumbtrail_array)); //$fileContentsString = $fileContents2["content"]; $mid->setMenuStructureString($fileContentsString); $mid->setIconsize(16, 16); $mid->parseStructureForMenu('hormenu1'); if($selectedIndex > 0){ //$mid->setSelectedItemByCount('hormenu1', $selectedIndex); } $mid->newHorizontalMenu('hormenu1'); $header = $mid->getHeader(); $smarty->assign("header",$header); $menu = $mid->getMenu('hormenu1'); $smarty->assign("menu",$menu); $menufooter = $mid->getFooter(); $smarty->assign("menufooter",$menufooter); } if(file_exists("./content/".$page)){ //$fileContents = unserialize(file_get_contents('./content/'.$page)); $smarty->assign("content", $fileContentsString); if($page == "sitemap.txt"){ /* $plainmid = new PlainMenu(); //$plainmid->setPlainMenuTpl('layersmenu-plain_menu.ihtml'); //$plainmid->setMenuStructureFile('/content/sitemap.txt'); $plainmid->setMenuStructureString($fileContents["content"]); $plainmid->setIconsize(16, 16); $plainmid->parseStructureForMenu('plainmenu'); $sitemap = $plainmid->newPlainMenu('plainmenu'); $smarty->assign("sitemap",$sitemap); */ require_once 'plugins/phplayersmenu/lib/treemenu.inc.php'; $treemid = new TreeMenu(); $treemid->setMenuStructureString($fileContentsString); $treemid->setIconsize(16, 16); $treemid->parseStructureForMenu('treemenu1'); if($selectedIndex > 0){ //$treemid->setSelectedItemByCount('treemenu1', $selectedIndex); } //$treemid->setSelectedItemByUrl('treemenu1', basename(__FILE__)); $smarty->assign("sitemap", $treemid->newTreeMenu('treemenu1')); } } //$menustring = ".|Linus B. Torvalds|http://www.cs.Helsinki.FI/u/torvalds/|The father of Linux||Linus\n" . "...|Bugzilla|http://qa.mandrakesoft.com/|||Linux\n" . "..|Slackware|http://www.freesoftware.org/|Slackware Linux||Linux\n"; //$plainmid->setMenuStructureString($menustring); //$smarty->assign("menu2", $plainmid->newPlainMenu('plainmenu')); // let's map PHP's stripslashes function to a Smarty modifier. $smarty->register_modifier('html_entity_decode', 'html_entity_decode'); //send email if(isset($GET["page"]) && $_GET["page"] == "contact us"){ if(isset($_REQUEST["sendEmail"])){ if(isset($_REQUEST["message"]) && $_REQUEST["message"] != "" && isset($_REQUEST["senderName"]) && $_REQUEST["senderName"] != "" && isset($_REQUEST["senderEmail"]) && $_REQUEST["senderEmail"] != "") { if(mail($adminEmail, $feedbackSubject . $_REQUEST["subject"], $_REQUEST["message"], "From: \"".$_POST["senderName"]."\" <".$_POST["senderEmail"].">")){ $smarty->assign("emailSuccess", "Your message has been sent."); }else{ $smarty->assign("emailError", "Your email could not be sent, please try again later."); $smarty->assign("subject", $_REQUEST["subject"]); $smarty->assign("message", $_REQUEST["message"]); } }else{ $smarty->assign("emailError", "You must enter your name, your email address and a message
before you press send."); $smarty->assign("subject", $_REQUEST["subject"]); $smarty->assign("subject", $_REQUEST["senderName"]); $smarty->assign("subject", $_REQUEST["senderEmail"]); } } } $editorauthorised = false; $editoradmin = false; if(isset($_SESSION["authorisededitor"])){ $loggedIn = true; $smarty->assign("loggedIn", true); $smarty->assign("editor", $_SESSION["authorisededitor"]); $editablepages = explode(",", $editorpages[$_SESSION["authorisededitor"]]); $thiseditor = $_SESSION["authorisededitor"]; if(in_array("*", $editablepages)){ $editoradmin = true; $thiseditor .= " (administrator)"; }elseif(in_array($pagewpluses, $editablepages)){ $editorauthorised = true; } $smarty->assign("editor", $thiseditor); } if ($editoradmin || (isset($_SESSION["authorised"]) && $_SESSION["authorised"] == true)){ $_SESSION["authorised"] = "true"; $smarty->assign("loggedIn", true); $admin = true; }else{ $admin = false; } $smarty->assign("admin", $admin); if ($admin || $editorauthorised){ $editMode = isset($_GET["edit"]) ? true : false; $area = isset($_GET["area"]) ? $_GET["area"] : ""; $smarty->assign("edit",$editMode); $smarty->assign("area",$area ); $smarty->assign("editable", true); } if (file_exists("content/top.txt")) { $topContent = file_get_contents("content/top.txt"); $smarty->assign("top",stripslashes($topContent)); } if($page == "search.txt" && isset($_REQUEST['search_term']) && $_REQUEST['search_term'] != ""){ $searchterm = $_REQUEST['search_term']; $content_dir = "content"; $search_results = ""; $dir = dir($content_dir); $search_results_array = array(); while ($file = $dir->read()) { if(is_file($content_dir."/".$file)){ $fileContents = file_get_contents($content_dir."/".$file); if(stristr($fileContents, $searchterm)){ //echo $file . "
"; $pageName = substr($file, 0, -4); //url page name with +'s ion place of spaces and no .txt on end $search_results_array[$pageName] = substr_count (strtolower($fileContents), strtolower($searchterm)); $fileContentsArray = unserialize($fileContents); if(stristr($fileContentsArray["title"], $searchterm)){ $search_results_array[$pageName] += 100; }elseif(stristr($fileContentsArray["metadata"], $searchterm)){ $search_results_array[$pageName] += 50; } } } } $content_dir2 = "content/"; $dir = dir($content_dir2); while ($file = $dir->read()) { if(is_file($content_dir2."/".$file)){ $fileContents = file_get_contents($content_dir2."/".$file); if(stristr($fileContents, $searchterm)){ $pageName = substr($file, 0, -4); //url page name with +'s ion place of spaces and no .txt on end $search_results_array[$pageName] = substr_count (strtolower($fileContents), strtolower($searchterm)); $fileContentsArray = unserialize($fileContents); if(stristr($fileContentsArray["title"], $searchterm)){ $search_results_array[$pageName] += 100; }elseif(stristr($fileContentsArray["summary"], $searchterm)){ $search_results_array[$pageName] += 50; } } } } $search_results = "Your search for " . $searchterm . " returned "; switch(count($search_results_array)){ case 0: $search_results .= "no"; $end = "."; break; default: $search_results .= count($search_results_array); $end = ":"; break; } $search_results .= ' results.
If you can not find the page you are looking for have a look at the sitemap.

'; arsort($search_results_array); foreach($search_results_array as $key => $value){ //if($fileTime < 1){ if(!is_numeric(substr($key, 0, 8))){ $fileContentsArray = unserialize(file_get_contents($content_dir."/".$key.".txt")); $search_results .= ' > '.stripslashes(ucwords($fileContentsArray["title"])).'
'; }else{ $fileTime = strtotime(substr($key, 0, 8)); $fileContentsArray = unserialize(file_get_contents($content_dir2."/".$key.".txt")); $search_results .= ' '.stripslashes(ucwords($fileContentsArray["title"])).'
'; } } }else{ $search_results = "Please enter a search term in the search box."; } $smarty->assign("search_results", $search_results); if (file_exists("content/".$page)) { $content = unserialize(file_get_contents("content/".$page)); //var_dump($content); foreach ($content as $key => $value) { $smarty->assign($key,stripslashes($value)); } $smarty->assign("updatedOn", "Page updated: " . date ("F j Y", filemtime("content/".$page))); } else { if(!$loggedIn){ $content = unserialize(file_get_contents("content/404.txt")); //var_dump($content); foreach ($content as $key => $value) { $smarty->assign($key,stripslashes($value)); } $smarty->assign("crumbtrail",""); }else{ $smarty->assign("newPage",true); $smarty->assign("edit", true); $smarty->assign("area", "content"); } } if (file_exists("content/right.txt")) { $rightContent = file_get_contents("content/right.txt"); $smarty->assign("right",$rightContent); } if (file_exists("content/footer.txt")) { $footerContent = file_get_contents("content/footer.txt"); $smarty->assign("footer",$footerContent); } //$smarty->assign("contentWidth", "790px"); $smarty->display('index.tpl'); ?>