function cs_utf2ascii($s)
{
static $tbl = array("\xc3\xa1"=>"a","\xc3\xa4"=>"a","\xc4\x8d"=>"c","\xc4\x8f"=>"d","\xc3\xa9"=>"e","\xc4\x9b"=>"e","\xc3\xad"=>"i","\xc4\xbe"=>"l","\xc4\xba"=>"l","\xc5\x88"=>"n","\xc3\xb3"=>"o","\xc3\xb6"=>"o","\xc5\x91"=>"o","\xc3\xb4"=>"o","\xc5\x99"=>"r","\xc5\x95"=>"r","\xc5\xa1"=>"s","\xc5\xa5"=>"t","\xc3\xba"=>"u","\xc5\xaf"=>"u","\xc3\xbc"=>"u","\xc5\xb1"=>"u","\xc3\xbd"=>"y","\xc5\xbe"=>"z","\xc3\x81"=>"A","\xc3\x84"=>"A","\xc4\x8c"=>"C","\xc4\x8e"=>"D","\xc3\x89"=>"E","\xc4\x9a"=>"E","\xc3\x8d"=>"I","\xc4\xbd"=>"L","\xc4\xb9"=>"L","\xc5\x87"=>"N","\xc3\x93"=>"O","\xc3\x96"=>"O","\xc5\x90"=>"O","\xc3\x94"=>"O","\xc5\x98"=>"R","\xc5\x94"=>"R","\xc5\xa0"=>"S","\xc5\xa4"=>"T","\xc3\x9a"=>"U","\xc5\xae"=>"U","\xc3\x9c"=>"U","\xc5\xb0"=>"U","\xc3\x9d"=>"Y","\xc5\xbd"=>"Z");
return strtr($s, $tbl);
}
if (!function_exists("memory_get_usage"))
{
function memory_get_usage()
{}
}
//namapovani slozek, globalni pristup:
$dir=dirname(__FILE__).'/../';
$dir=substr(dirname(__FILE__),0,strrpos(dirname(__FILE__),'/')).'/';
$DIR->BASE=$dir;
$DIR->ENGINE=$dir.'engine/';
$DIR->PRESETS=$dir.'presets/';
include($DIR->ENGINE."module-base.php");
include($DIR->BASE."presets.php");//promene s fixnim zakladnim nastavenim, hlave DB
$DIR->DBSETS=$dir.'engine/db/';
$DIR->MODULES=$dir.'engine/modules/';//pouziva se toto nekde? :)
$DIR->INC=$dir.'inc/';
$DIR->TPL=$dir.'tpl/';
$DIR->TMP='/tmp/';
$DIR->LOG=$dir.'log/';
$DIR->SCRIPTS=$dir.'scripts/';
$DIR->IMPORT=$dir.'import/';
$DIR->IMG=$dir.'img/';
$DIR->IMGWEB=URLBASE.'img/';
$DIR->FILES=$dir.'files/';
$DIR->FILESWEB='/files/';
$DIR->AUTOIMG=$dir.'img/auto/';
$DIR->AUTOIMGWEB=URLBASE.'img/auto/';
$DIR->UPLOADMETER=URLBASE.'uploadmeter/';
$DIR->FCKEDIT=$dir.'fckeditor/';
$DIR->FCKEDITWEB=URLBASE.'fckeditor/';
$DIR->XML=$dir.'xml/';
$DIR->MAILSPOOL=$dir.'spool/';
include($DIR->ENGINE."bTemplate.php");//sablonovaci system
include($DIR->ENGINE."atoms/_.php");//sada utilitek a podpurnych objektu a fci
include($DIR->ENGINE."module-group.php");
include($DIR->ENGINE.'modules.php');
include($DIR->ENGINE.'denied.php');
include($DIR->DBSETS."_.php");
global $kernel;//vychozi globalni objekt
/** OBSOLETE !!! pouziva se $presets->actlang a na ziskani GetLang()
global $actlang;
$actlang='cz';
*/
$godshoudknow='';
/*************************CLASS KERNEL*******************************/
Class Kernel{
var $client;
var $anchor,$activekey;
var $logger;//logovaci trida
var $presets;//zakladni nastaveni
var $modules;//moduly systemu
var $rgroups;//skupiny s pravy
var $user;//objektovy zaznam z DB, nastavuje clienter
var $btemp;//pripravena instance pro sablonu
var $config; // konfiguracni objekt
var $mstack; // message_stack objekt
private $lang; // aktualni jazyk
private $explicitLang = false;
private static $cInstance = false; // insance singletonu
public static function getInstance()
{
if( self::$cInstance === false )
{
// construct
self::$cInstance = new Kernel();
}
return self::$cInstance;
}
// singleton design - private constructor
// but for backward compatibility
public function __construct()
{
if ( isset(self::$cInstance) && is_a(self::$cInstance, 'Kernel'))
{
die('Singleton warning!');
}
else
{
self::$cInstance = $this;
}
$this->init();
}
public function __destruct() {
$this->Deinit();
}
public function init()
{
$this->SetLimits(60,"50M");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//ze vseho nejdrive nastavime jazykovou mutaci (muze byt zmenena v modulu rewriter)
//$this->SetLang();
//hlavni inicializace
global $DIR,$presets;
//$kernel=&$this;//zpristupnim se navenek
$this->presets=$presets;//zkopnu si nastaveni
// ob_start();//umozneni presmerovani v prubehu vykonu, asi nebude potreba po aplikaci sablon
$this->logger=new Logger($DIR->LOG.'main.log');
$this->logger->Log();
$this->logger->StopwatchStart('kernel-totaltime');
$this->logger->Log('kernel-init',"datetime: ".strftime("%d.%m.%Y %H:%M:%S"));
$this->logger->Log('kernel-init',"user IP ".getenv("REMOTE_ADDR"));
$this->logger->Log('kernel-init',"request \"".$_SERVER["QUERY_STRING"].'"');
$this->logger->Log('kernel-init',"memory start ".(memory_get_usage()/1024)."KB");
//priprava pomocnych casovacu:
$this->logger->StopwatchStartPaused('spend-products-load');
$this->logger->StopwatchStartPaused('spend-rewrite-GetRURL');
$this->logger->StopwatchStartPaused('templating');
$this->logger->StopwatchStartPaused('dbkernel');
if(@$_POST) stripslashesAll($_POST);
//pripojim k DB
$this->ConnectMainDB();
//INIT DB -> vytvoreni tabulky users a usertypes, jinak neni mozne se dostat do admina
//proto se tyto 2 vytvori pokud neexistuji kdyz je zadan GET firstinit=1
if (getget('firstinit')==1){
$db=new DBusertypes();
$db->CreateTable();
$db=new DBusers();
$db->CreateTable();
}
// inicializace konfiguracniho objektu
$this->config = Configuration::getInstance();
$this->config->loadConfig();
//pripravim spravu odkazu
$this->anchor=new QueryMan(URLBASE.'?');
// explicitni nastaveni jazyka pro spravu odkazu
if ($this->GetExplicitLang() !== false)
{
$this->anchor->SetLang($this->GetExplicitLang());
}
//nastavim implicitni prava,oddelavat pres unset
$this->rgroups->all='1';
//pripravim sablonu
$this->btemp=new bTemplate($DIR->TPL.GetLang().'/',TRUE,USETPLCACHE,$this->presets->charset);
// inicializace mstacku
$this->mstack = new messageStack('kernel');
//napojeni modulu
$this->modules=new ModulesRoot($this,$this,'');
//logy zavisle na initech modulu:
$this->logger->Log('kernel-init',"referer \"".$_SESSION['http_referer'].'"');
//if ($this->rgroups->webmaster)//ted uz vime skupiny, vyvojari nechteji cache
// $this->btemp->use_cache=false;
//error_reporting($this->rgroups->god?E_ALL:0);
if (@$this->rgroups->admin || @$this->rgroups->god)
{
mquery("SET wait_timeout=600");
if (@$this->rgroups->admin)
{
//$this->SetLimits(600,"100M");
}
if (@$this->rgroups->god)
{
//$this->SetLimits(3600,"150M");
}
}
else
{
mquery("SET wait_timeout=120");
}
$this->logger->LogTime('kernel-init','Init over');
}
function ConnectMainDB(){
global $conn1;
$conn1 = DBConnect($this->presets->dbset['host'],
$this->presets->dbset['user'],
$this->presets->dbset['password'],
$this->presets->dbset['db'],
$this->presets->dbset['charset'],
$this->presets->dbset['collation']
);
}
function PageHeader(){
header("Content-Type: text/html; charset=".$this->presets->charset);
$this->modules->GetPageInfo($title,$keywords,$description);
$out=$this->btemp;
if(@$this->modules->admin->active)
$out->set('user',$this->user);
/*if(strlen($title) > 60) {
$titlest = explode("-", $title);
$titlest = $titlest[0];
} else {
$titlest = $title;
}*/
$out->set('title',($title=="")?mygettext('page_title'):$title);
$out->set('description',($description=="")?mygettext('page_description'):$description);
$out->set('keywords',($keywords=="")?mygettext('page_keywords'):$keywords);
$out->set('charset',GetCharset());
$out->set('ispda',(strpos($_SERVER["HTTP_USER_AGENT"],"Windows CE")),TRUE);
$out->set('isadmin',@$this->rgroups->admin);
global $HEADERTPL;
return $out->fetch($HEADERTPL,TRUE);
}
function PageFooter(){
$out=$this->btemp;
return $out->fetch('footer.tpl');
}
function PageMain(){
$this->logger->LogTime('kernel-pagemain','start');
$out=$this->modules->PageMain();
$this->logger->LogTime('kernel-pagemain','stop');
return $out;
}
function PageTreeMenu(&$module,$class='tree',$startid=0,$showroot=TRUE,$firstonly=FALSE,$tplnum=0){
$this->logger->LogTime('kernel-tree-menu',"start (tplnum: $tplnum)");
if (!isset($module)) return FALSE;
$tree=new TreeMenu($class);
$module->TreeAdd($tree,$tree->menu,$startid,$showroot,$firstonly);
$ap = $tplnum ? $tplnum : '';
$out=$tree->Output($this->btemp,"admin/treemenu$ap.tpl");
$this->logger->LogTime('kernel-tree-menu',"stop");
return $out;
}
/*DEPRECATED*/
function PageMenu($menuname){
$db=new DBset_menu();
$list=$db->GetItems($menuname);
$menu=new Menu($menuname);
foreach($list as $item){
if ($item->type==0)
$menu->AddItem($item->name,$this->modules->articles->anchor->Anchor('aid',$item->aid),false,'');
}
return $menu->Output();
}
function GetFormArgs($a,$method="post",$withmeter=FALSE,$asbgprocess=FALSE){
global $DIR;
$s="action=\"$a\" method=\"$method\"";//zaklad
if ($asbgprocess) $s.=" target=\"bgprocess\"";
if ($withmeter && UPLOADMETERALLOW===true){
$id=rand() . '.' . time();//vygeneruju ID
$s.=" onSubmit=\"window.open('".$DIR->UPLOADMETER."index.php?id=$id','uploadmeter','".UPLOADMETERPARAMS."', true); ";
if ($asbgprocess) $s.=" BGPStart($asbgprocess); ";
$s.="return true;\" ";
$s.=">btemp;
if ($this->user){
$tpl->set('user',$this->user);
return $tpl->fetch('clienter/logoutbox.tpl');
}else{
$tpl->set('areg',$this->modules->shop->registration->anchor->Anchor());
return $tpl->fetch('clienter/loginbox.tpl');
}
}
//vraci html pro editor vracejici promenou $postvar a s prednastavenym textem $text
function GetEditor($postvar,$text){
global $DIR;
require_once $DIR->FCKEDIT."fckeditor.php";
$e=new FCKeditor($postvar);
$e->BasePath=$DIR->FCKEDITWEB;
$e->Value=$text.' ';
$e->Height=400;
return $e->CreateHtml();
}
function Deinit(){
global $conn1, $conn2;
$this->logger->Log('kernel-footer',"memory stop ".(memory_get_usage()/1024)."KB");
$this->logger->StopwatchStop('spend-products-load');
$this->logger->StopwatchStop('spend-rewrite-GetRURL');
$this->logger->Log('count-rewrite-GetRURL',@$this->modules->rewriter->c_getrurl);
$this->logger->Log('count-rewrite-FingRURL',@$this->modules->rewriter->c_findrurl);
$this->logger->StopwatchStop('templating');
$this->logger->StopwatchStop('dbkernel');
$this->logger->StopwatchStop('kernel-totaltime');
$this->logger->Flush();
if($conn1) {
@mysql_close($conn1);
}
if($conn2) {
@mysql_close($conn2);
}
}
function SetLimits($time,$mem="8M"){
if (ini_get("safe_mode")) return;
ini_set("memory_limit",$mem);
set_time_limit($time);
}
/**
* nastavi se jazykovamutace, ktera se ma pouzit
*/
function SetLang($customlang='')
{
global $presets;
global $DIR;
global $texts;
//nejdrive si spravne nastavime deflang, podle domeny
$domain=strtolower($_SERVER['SERVER_NAME']);
if (
isset($presets->domain2lang[$domain]) &&
array_search($presets->domain2lang[$domain],$presets->languages)!==FALSE
)
$presets->deflang=$presets->domain2lang[$domain];
// nastav explicitni zadani jazyka - pro odkazy
$this->SetExplicitLang(false);
//nastavim aktualni jazyk
if ($customlang && array_search($customlang,$presets->languages)!==FALSE)
{
$presets->actlang=$customlang;
}
else if (defined('LANGUAGEMODE') && LANGUAGEMODE=='DOMAIN')
{
$presets->actlang=$presets->deflang;
}
else if (isset($_GET['lang']) && array_search($_GET['lang'],$presets->languages)!==FALSE)
{
$presets->actlang = $_GET['lang'];
// nastav explicitni zadani jazyka - pro odkazy
$this->SetExplicitLang($presets->actlang);
}
else
{
$presets->actlang=$presets->deflang;
}
//vlozim
include $DIR->PRESETS.GetLang()."/config.php";
include $DIR->PRESETS.GetLang()."/texts.php";
//jestlize byl inicializovan btemp,tak ho musime inicializovat znovu
if (is_object($this->btemp))
$this->btemp->bTemplate($DIR->TPL.GetLang().'/',TRUE,USETPLCACHE,$this->presets->charset);
}
function Panic($msg,$sendsms=false,$backlog=5){
/* ob_start();
$NL="
";
echo "Time: ".strftime("%A %d-%b-%y %T %Z").$NL;
echo "MSG: ".$msg.$NL;
echo "USER LOGIN:".$this->user->login.$NL;
echo "XFOR IP:".@$_SERVER['HTTP_X_FORWARDED_FOR'].$NL;
echo "IP:".@$_SERVER['REMOTE_ADDR'].$NL;
foreach(array('SERVER'=>$_SERVER,
'COOKIES'=>$_COOKIE,
'SESSIONS'=>$_SESSION,
'GET'=>$_GET,
'POST'=>$_POST,
'FILES'=>$_FILES) as $name=>$a){
echo $NL.$NL.$name.$NL;
foreach($a as $k=>$v){
echo "$k: ";
print_r($v);
echo $NL;
}
}
$back=1024*$backlog;
global $DIR;
foreach(array($DIR->LOG.'main.log',$DIR->LOG.'nonkernel.log') as $a){
echo $NL.$NL."Last +- $backlog KB of $a:".$NL;
$f=fopen($a,'r');
$s=filesize($a)-$back;
if ($s>0) fseek($f, $s);
while ($data=fgets($f))
echo $data.$NL;
fclose($f);
}
$data=ob_get_contents();
ob_end_clean();
sendmail("SYSTEM","SYSTEM","dimov@4e1.cz; konecny@4e1.cz","PANIC from ".$_SERVER['HTTP_HOST'].($sendsms?"":" no sms"),br2nl($data),$data,"utf8");
//echo $data;*/
}
public function GetExplicitLang()
{
return $this->explicitLang;
}
public function SetExplicitLang( $lang )
{
$this->explicitLang = $lang;
}
public function getLang()
{
return $this->presets->actlang;
}
/**
* Deep cloning objects
* @param $obj
* @return
*/
public static function deepclone($obj)
{
return unserialize(serialize($obj));
}
/**
* Testovani prav na dane mnozine
*
* @param TRUE ak mam alespon jedno opravneni z dane mnoziny
*/
public function testRightSet($set)
{
// test rights
$curRights = explode(',',$set);
$tmpPassed = false;
foreach($curRights as $tmpRight)
{
if (isset($this->rgroups->$tmpRight))
{
$tmpPassed=true;
break;
}
}
return $tmpPassed;
}
}
File included successfully!
Fatal error: Call to a member function set() on null in /var/www/clients/client107/web215/web/index.php on line 46