_SetPageId();
$this->_SetData();
$this->_setPage();
}
function HandlePage()
{
// Determine which function to load
switch($this->_action)
{
case "otherpage":{
$this->ShowOtherPage();
break;}
default:
{
$this->ShowPage();
break;
}
}
}
function _setPage(){
$uri = $_SERVER["REQUEST_URI"];
if(is_numeric(strpos($uri, "/pages/html")))
{
$this->_action = "otherpage";
}
}
function _SetPageId()
{
$uri = $_SERVER["REQUEST_URI"];
$iPos = strpos($uri, "/pages/");
$iPos += strlen("/pages/");
$pageName = substr($uri, $iPos, 100);
$pageName = eregi_replace("/$", "", $pageName);
$pageName = AL_HELPER::_MakeURLNormal($pageName);
$tmp = explode("?",$pageName);
$pageName = $tmp[0];
$query = sprintf("select PageID from %spages where lower(title)='%s'", $GLOBALS["AL_CFG"]["tablePrefix"], mysql_escape_string($pageName));
$result = mysql_query($query);
if($row = mysql_fetch_array($result)){
$this->_pageId = $row["PageID"];
}else
{
// Bad page
$this->_pageId = 0;
}
}
function grabPredefinedPages($content){
if(!isset($GLOBALS["sitemapText"])){
$GLOBALS["sitemapText"] = AL_TEMPLATE::_GetPanelContent("GeneralSiteMapPanel");
$GLOBALS["sitemapText"] .= '
';
$GLOBALS["sitemapText"] .= AL_TEMPLATE::_GetPanelContent("CategoryArticleMapPanel");
$GLOBALS["sitemapText"] .= '
';
$GLOBALS["sitemapText"] .= AL_TEMPLATE::_GetPanelContent("BlogMapPanel");
$GLOBALS["sitemapText"] .= '
';
$GLOBALS["sitemapText"] .= AL_TEMPLATE::_GetPanelContent("AuthorMapPanel");
}
$content = str_ireplace("%%SiteMap%%",$GLOBALS["sitemapText"] ,$content);
if(!isset($GLOBALS["syndicateText"])){
$GLOBALS["syndicateText"] = AL_TEMPLATE::_GetPanelContent("SyndicatePanel");
}
$content = str_ireplace("%%Syndicate%%",$GLOBALS["syndicateText"],$content);
return $content;
}
function _SetData()
{
// Set the title of the page
$query = sprintf("select * from %spages where PageID='%d'", $GLOBALS["AL_CFG"]["tablePrefix"], $this->_pageId);
$result = mysql_query($query);
if($row = mysql_fetch_array($result))
{
$this->_title = $row["Title"];
$this->_data = $row;
$row["Content"] = $this->grabPredefinedPages($row["Content"]);
$this->_content = $row["Content"];
$pagedata = new AL_TEMPLATE();
if(strlen($this->_content) == 0)
{
$this->_content = " ";
}
$this->_content = str_replace("\\'", "'", $pagedata->ParseTemplate(true,$this->_content));
$metaKeys = trim($row["MetaKeywords"]);
if(!empty($metaKeys)){
$GLOBALS["AL_CFG"]["siteKeywords"] = $row["MetaKeywords"];
}
$metaDesc = trim($row["MetaDesc"]);
if(!empty($metaDesc)){
$GLOBALS["AL_CFG"]["siteDesc"] = $row["MetaDesc"];
}
}
}
function GetTitle()
{
return $this->_title;
}
function GetContent()
{
return $this->_content;
}
function IncrementViewCount()
{
$query = sprintf("update %spages set Views=Views+1 where PageID='%d'", $GLOBALS["AL_CFG"]["tablePrefix"], $this->_pageId);
@mysql_query($query);
}
function CheckExternal(){
$query = sprintf("select * from %spages where PageID='%d'", $GLOBALS["AL_CFG"]["tablePrefix"], $this->_pageId);
$checkRow = mysql_fetch_array(mysql_query($query));
if($checkRow["Type"] == "1"){
if(!eregi("http",$checkRow["ExternalLink"])){
$checkRow["ExternalLink"] = $GLOBALS["AL_CFG"]["siteURL"] . $checkRow["ExternalLink"];
}
header("Location: ".$checkRow["ExternalLink"]);
die();
}elseif (eregi("%%HomePageContent%%",$checkRow["Content"])){
header("Location: ".$GLOBALS["AL_CFG"]["siteURL"]);
die();
}
else
{
return true;
}
}
function ShowOtherPage()
{
$uri = $_SERVER["REQUEST_URI"];
$iPos = strpos($uri, "/pages/html");
$iPos += strlen("/pages/html");
$pageName = substr($uri, $iPos, 100);
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
if(eregi('\?',$pageName)){
$pageRay = explode('?',$pageName);
$pageName = $pageRay[0];
$_SERVER['QUERY_STRING'] = $pageRay[1];
$pageRay2 = explode("&",$pageRay[1]);
foreach ($pageRay2 as $key=>$value)
{
$pageRay3 = array();
$pageRay3 = explode("=",$value);
$_GET[$pageRay3[0]] = urldecode($pageRay3[1]);
$_REQUEST[$pageRay3[0]] = urldecode($pageRay3[1]);
}
}
//chdir("html");
if(strstr($pageName,".css") or strstr($pageName,".jpg") OR strstr($pageName,".jpeg") OR strstr($pageName,".gif") or strstr($pageName,".png")){
if(strstr($pageName,".css")){
header("Content-Type: text/css");
}
ob_start();
echo file_get_contents($_SERVER["DOCUMENT_ROOT"] . $GLOBALS["AL_CFG"]["appPath"] ."/html/".$pageName);
$includeData = ob_get_contents();
ob_end_clean();
echo $includeData;
die();
}
$tmp = explode("/",$pageName);
$count = count($tmp)-1;
for ($i=0;$i<$count;$i++){
$adddir .= $tmp[$i].'/';
$backdir .= "../";
}
chdir("html".$adddir);
/*
$dirh = opendir("../");
if ($dirh) {
while ($dir_element = readdir($dirh)) {
echo $dir_element."
";
}
unset($dir_element);
closedir($dirh);
}*/
$HTTP_GET_VARS = $_GET;
$_SERVER['PHP_SELF'] = '/pages/html'.$pageName;
$_SERVER['SCRIPT_NAME'] = '/pages/html'.$pageName;
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . '/pages/html'.$pageName;
ob_start();
include($_SERVER["DOCUMENT_ROOT"] . $GLOBALS["AL_CFG"]["appPath"] ."/html/".$pageName);
$includeData = ob_get_contents();
ob_end_clean();
chdir($backdir);
$GLOBALS["Content"] = $includeData;
// Load the view page page
$GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($GLOBALS["AL_CFG"]["SiteName"]);
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("Other");
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
}
function ShowPage()
{
// Increment the number of views for this page
$this->IncrementViewCount();
$this->CheckExternal();
// Load the view page page
$GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($this->GetTitle());
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("Pages");
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
}
}
?>