1   <?php
  2  
  3   if( file_exists('debug.php') ) include_once('debug.php');
  4   if( !(defined('DEBUG_MODE')&&DEBUG_MODE==1) ) error_reporting(0);
  5  
  6   list($usec, $sec) = explode(" ",microtime());
  7   $timestart = (float)$usec + (float)$sec;
  8  
  9   $pathtoroot = "./";
  10   $pathtoroot = realpath($pathtoroot)."/";
  11  
  12   if (!file_exists($pathtoroot."config.php")) {
  13           echo "In-Portal is probably not installed, or configuration file is missing.<br>";
  14           echo "Please use the installation script to fix the problem.<br><br>";
  15           echo "<a href='admin/install.php'>Go to installation script</a><br><br>";
  16           flush();
  17           die();
  18   }
  19  
  20   //ob_start();
  21   $FrontEnd=1;
  22  
  23   $indexURL="../../index.php"; //Set to relative URL from the theme directory
  24  
  25   /* initalize the in-portal system */
  26   include_once("kernel/startup.php");
  27  
  28   LogEntry("System Init Complete\n");
  29   /* load the current front-end language set */
  30  
  31   //$objLanguageCache->LoadLanguage($objSession->Get("Language"),0);
  32  
  33   $rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
  34  
  35   //$secureURL = "https://".ThisDomain().$objConfig->Get("Site_Path");
  36   $secureURL = $rootURL;
  37  
  38   $html="<HTML>No Template</HTML>";
  39  
  40   if( !$var_list['t'] ) $var_list['t'] = 'index';
  41  
  42   if( !isset($CurrentTheme) ) $CurrentTheme = null;
  43   if( !is_object($CurrentTheme) ) $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]);
  44  
  45   if(is_object($CurrentTheme))
  46   {
  47           if(!$CurrentTheme->Get("Enabled"))
  48           {
  49                   $CurrentTheme = $objThemes->GetItem($objThemes->GetPrimaryTheme());
  50           }
  51           if((int)$CurrentTheme->Get("ThemeId")>0)
  52           {
  53         $timeout = $CurrentTheme->Get("CacheTimeout");
  54         $objLanguageCache->LoadTemplateCache($var_list["t"],$timeout,$CurrentTheme->Get("ThemeId"));
  55         $objLanguageCache->LoadCachedVars($objSession->Get("Language"));
  56  
  57             LogEntry("Language Set Loaded\n");
  58  
  59             $TemplateRoot = $CurrentTheme->ThemeDirectory()."/";
  60  
  61             LogEntry("Parsing Templates in $TemplateRoot\n");
  62             $objTemplate = new clsTemplateList($TemplateRoot);
  63             $html = $objTemplate->ParseTemplate($var_list["t"]);  
  64       }
  65       else
  66       {
  67         echo "No Primary Theme Selected";
  68         die();
  69       }
  70   }
  71   else
  72   {
  73     echo "No Primary Theme Selected\n";
  74     die();
  75   }
  76  
  77  
  78  
  79   if(is_object($objSession))
  80   {
  81           
  82           $objSession->SetVariable("Template_Referer", $_local_t);
  83   }
  84   if($objTemplate->ErrorNo == -1)
  85   {
  86           $html = $objTemplate->ParseTemplate('error_template');
  87   }
  88   //$html = replacePngTags($html);
  89   LogEntry("Output Start\n");
  90   $html .= "<!-- Page Execution Time: ".( isset($ptime) ? $ptime : 0 )." -->";
  91   if( IsDebugMode() )
  92   {
  93           if($Action) $debugger->setHTMLByIndex(1,'Front Action: <b>'.$Action.'</b>','append');
  94           $html = '<a href="javascript:toggleDebugLayer();">Show Debugger</a><br>'.$html;
  95   }
  96   else
  97   {
  98           header("Content-length: ".strlen($html));
  99   }
  100   header("Connection-Type: Keep-Alive");
  101   echo $html;
  102  
  103   LogEntry("Output End\n");
  104  
  105   if( isset($template) && $template->ErrorNo != 0 )
  106   {
  107     print "\n(".$objTemplate->ErrorNo.") ".$objTemplate->ErrorStr."\n";
  108   }
  109  
  110   LogEntry("Output Complete\n");
  111   $objLanguageCache->SaveTemplateCache();
  112   LogEntry("Templates Cached\n");
  113  
  114   //if($objSession->SessionEnabled())
  115   //  $objSession->SaveSessionData();  
  116   //echo "Cookie: <PRE>"; print_r($_COOKIE); echo "</PRE><br>\n";
  117   //ob_end_flush();
  118   $timeend = getmicrotime();
  119   $diff = $timeend - $timestart;
  120  
  121   LogEntry("\nTotal Queries Executed: $sqlcount in $totalsql seconds\n");
  122   LogEntry("\nPage Execution Time: $diff seconds\n", true);
  123   if($LogFile)
  124     fclose($LogFile);
  125  
  126  
  127   ?>