1   <?php
  2  
  3   if( file_exists('debug.php') ) include_once('debug.php');
  4   if( !defined('DEBUG_MODE') ) 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()) header("Content-length: ".strlen($html));
  92   header("Connection-Type: Keep-Alive");
  93   echo $html;
  94  
  95   LogEntry("Output End\n");
  96  
  97   if( isset($template) && $template->ErrorNo != 0 )
  98   {
  99     print "\n(".$objTemplate->ErrorNo.") ".$objTemplate->ErrorStr."\n";
  100   }
  101  
  102   LogEntry("Output Complete\n");
  103   $objLanguageCache->SaveTemplateCache();
  104   LogEntry("Templates Cached\n");
  105  
  106   //if($objSession->SessionEnabled())
  107   //  $objSession->SaveSessionData();  
  108   //echo "Cookie: <PRE>"; print_r($_COOKIE); echo "</PRE><br>\n";
  109   //ob_end_flush();
  110   $timeend = getmicrotime();
  111   $diff = $timeend - $timestart;
  112  
  113   LogEntry("\nTotal Queries Executed: $sqlcount in $totalsql seconds\n");
  114   LogEntry("\nPage Execution Time: $diff seconds\n", true);
  115   if($LogFile)
  116     fclose($LogFile);
  117  
  118  
  119   ?>