Error connecting to the MySQL server!
$mysql_error
Please check the 'passwords.php' for correct settings!"; die; } mysql_select_db($database_name); if($mysql_error = mysql_error() ){ echo "Error connecting to the MySQL database!
$mysql_error
Please check the 'passwords.php' for correct settings!
"; die; } } if(is_array($_POST)) foreach ($_POST as $key => $value) unset($$key); if(is_array($_GET)) foreach ($_GET as $key => $value) unset($$key); if(is_array($_REQUEST)) foreach ($_REQUEST as $key => $value) unset($$key); if(is_array($_SESSION)) foreach ($_SESSION as $key => $value) unset($$key); if(is_array($_COOKIE)) foreach ($_COOKIE as $key => $value) unset($$key); $site_url = $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); if(substr($site_url,-1,1)=="/") $site_url=substr($site_url,0,-1); $_SITEURL = $site_url; //=== SQL functions ========================================== function sqlq($x){ $q= mysql_query( $x ); if ( mysql_error() ) print( mysql_error()."
".$x."
" ); return $q; } //."\n $x" function sqlr($x,$strip=0){ $q=mysql_query($x); if ( mysql_error() ) print(mysql_error()."
".$x."
"); if(mysql_num_rows($q)>0){ $a = mysql_result($q,0); if ($strip==1) $a=stripslashes($a); } else $a=""; return $a; } function sqlo($x,$strip=0){ $a = mysql_fetch_object(mysql_query($x)); if ( mysql_error() ) print(mysql_error()."
".$x."
"); if ($strip==1) return strip($a); else return $a; } function sqla($x,$strip=0){ $a = mysql_fetch_array(mysql_query($x)); if ( mysql_error() ) print(mysql_error()."
".$x."
"); if ($strip==1) foreach ($a as $k => $v) $a[$k]=stripslashes($v); return $a; } //=== MISCELLANEOUS string functions =========================== function strip($var,$html=false) { if (is_array($var)) { if ($html==true) foreach ($var as $k => $v) $var[$k] = strip($v,1); else foreach ($var as $k => $v) $var[$k] = strip($v); } else if (is_object($var)) { $class_vars = get_class_vars(get_class($var)); if ($html==true) foreach ($class_vars as $name => $value) eval('$var->'.$name.' = strip($value,1);'); else foreach ($class_vars as $name => $value) eval('$var->'.$name.' = strip($value);'); } else { if ($html==true) $var = htmlspecialchars($var); $var = stripslashes($var); } return $var; } function addsl($var) { if (is_array($var)) { if ($html==1) foreach ($var as $k => $v) $var[$k] = addsl($v,1); else foreach ($var as $k => $v) $var[$k] = addsl($v); } else if (is_object($var)) { $class_vars = get_class_vars(get_class($var)); if ($html==1) foreach ($class_vars as $name => $value) eval('$var->'.$name.' = addsl($value,1);'); else foreach ($class_vars as $name => $value) eval('$var->'.$name.' = addsl($value);'); } else { $var = addslashes($var); } return $var; } function geto($vn){return stripslashes(sqlr("select varvalue from options where varname='".addsl($vn)."'"));} function seto($vn,$vv){sqlq("update options set varvalue='".addsl($vv)."' where varname='".addsl($vn)."'");} //=== kTPL functions ============================================= function tpl_load($f,$p=true,$e=false){ $f="templates/".$f; if (!file_exists($f)) { print "Template processing error: template file \"".$f."\" dosn't exist!"; die; } $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; } function tpl_strip_subs($c){ global $tpl_SUBS; 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); } // foreach($tpl_SUBS as $k=>$v) tpl_strip_subs($v); return $c; } 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); } ob_start(); //FUNCTIONS 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(); //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); } //LANG while(preg_match("/% *LANG *{ *([^\} ]+) *} *%/",$c,$m)) $c=str_replace($m[0],$_LANG[$m[1]],$c); //INCLUDES while(preg_match("/% *INCLUDE *{ *([^\} ]+) *} *%/",$c,$m)){ $c1=join('',file(trim($m[1]))); $c=preg_replace("/".str_replace('/','\/',preg_quote($m[0]))."/",tpl_process($c1),$c,1); } //MODULES while(preg_match("/%MODULE *{ *([^\} ]+) *} *((GET|POST) *{ *([^\} ]+) *})?%/",$c,$m)){ $old=ob_get_contents(); ob_end_clean(); ob_start(); $m[2]=trim($m[2]); if($m[2]!=""){ $flds=explode("&",trim($m[4])); foreach($flds as $v){ $t=explode("=",$v); if($m[3]=="GET") $_GET[$t[0]]=$t[1]; if($m[3]=="POST") $_POST[$t[0]]=$t[1]; } } include($m[1]); if($m[2]!=""){ $flds=explode("&",trim($m[4])); foreach($flds as $v){ $t=explode("=",$v); if($m[3]=="GET") unset($_GET[$t[0]]); if($m[3]=="POST") unset($_POST[$t[0]]); } } $c1=ob_get_contents(); ob_end_clean(); $c=preg_replace("/".str_replace('/','\/',preg_quote($m[0]))."/",tpl_process($c1),$c,1); ob_start(); echo($old); } return $c; } ?>