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