"; $vr+=1; $col=""; $level-=1; } else $level+=1; } elseif($level==1) { $col.=$str[$i]; } else { $out.=$str[$i]; } } return $out.str_repeat("", $vr); } function phplib($nm) { require_once "/phplib/$nm"; } function jtostring($val) { $out = "{"; $keys = array_keys($val); for($i=0;$i= 0 && strpos($haystack, $needle, $temp) !== FALSE); } function checkTempNotify() { if(tempNotifyExists()) { $vl = readTempNotify(); js("setNotifyBar('#__temp_message', '".addslashes($vl)."', 3000);"); } } function notifyBar($id) { echo("
"); } function getifexists($ar, $vl) { if(isset($ar[$vl])) return $ar[$vl]; else return null; } function jserialise($ar) {return jsserialise($ar);} function jsserialise($ar) { $keys = array_keys($ar); $values = array_values($ar); $out = ""; for($i=0;$i0) { return substr($str, 0, $pos-1); } else return $str; } function junserialise($ar) {return jsunserialise($ar);} function jsunserialise($ar) { $ars= array(); foreach(explode("\r\n", $ar) as $line) { if($line!="") { $ur = explode("-", $line); $key = startsWith($ur[0], "array_")?junserialise(base64_decode(substr($ur[0], 6))):base64_decode($ur[0]); $value = startsWith($ur[1], "array_")?junserialise(base64_decode(substr($ur[1], 6))):base64_decode($ur[1]); $ars[$key] = $value; } } return $ars; } function formatDateTime($dt) { if($dt"); } function jslib($name) { jss("/jslib/$name"); } function isBanned($ip) { $sql = beginSQL("server"); $res = mysql_query_return_assoc("SELECT banned FROM sessionInfo WHERE `ip`='$ip'"); $ret = $res[0]["banned"]; @mysql_free_result_array($res); endSQL($sql); return $ret; } function redirect($page,$wtime=0) { echo ''; } function getAdminLevel($ip) { $sql = beginSQL("server"); $res = mysql_query_return_assoc("SELECT `level` FROM admins WHERE `ip`='$ip'"); $ret=false; if($res != array()) { $ret = $res[0]["level"]; } @mysql_free_result_array($res); endSQL($sql); return $ret; } function banUser($ip) { $sql = beginSQL("server"); mysql_query("UPDATE sessionInfo SET `banned`=1 WHERE `ip`='$ip'"); endSQL($sql); } function unbanUser($ip) { $sql = beginSQL("server"); mysql_query("UPDATE sessionInfo SET `banned`=0 WHERE `ip`='$ip'"); endSQL($sql); } function jquery() { jslib("jquery-1.8.2.js"); jslib("jquery.base64.js"); } function js($str) { echo(""); } function issetmultiple($ar, $vls) { $val = true; foreach($vls as $r) $val = $val && isset($ar[$r]); return $val; } function pageinit_n($sql=null) { pageinit($sql); jquery(); jslib("notify.js"); enableBanCheck(); doActiveCheck(); } function pathfix($str) { return str_replace("\\", "/", $str); } function sqldate($stamp=null) { return date("y.m.d H.i.s", $stamp==null?time():$stamp); } function enableBanCheck() { jslib("check.js"); js("banCheck();"); if(isBanned(getip())) doBan(); } function activeNotifyBar($id, $val) { echo("
$val
"); } function doActiveCheck() { if(!isActive()) { if(getAdminLevel(getip())!==false) { echo("
WEBSITE OFFLINE
"); } else die("website offline"); } } function doBan() { redirect("/banned.php"); die(); } function pageinit($vsql=null) { $sql = $vsql==null?beginSQL("server"):$vsql; if($vsql!=null) { mysql_select_db("server",$sql); } $res = mysql_query_return_assoc("SELECT * FROM `sessionInfo` WHERE `ip`='".getip()."'"); echo(mysql_error()); if($res==array()) { mysql_query("INSERT INTO sessionInfo ( ip, url, sessionid, last ) VALUES ( '".getip()."', '".geturl()."', ".(sessionid()==null||streq(sessionid(),"")?"NULL":"'".$_REQUEST["PHPSESSID"]."'").", '".date("y.m.d H:i:s")."' )"); echo(mysql_error()); } else { mysql_query("UPDATE sessionInfo SET url='".geturl()."', sessionid=".(sessionid()==null||streq(sessionid(),"")?"NULL":"'".$_REQUEST["PHPSESSID"]."'").", last='".date("y.m.d H:i:s")."', views=views+1 WHERE `ip`='".getip()."' "); echo(mysql_error()); } @mysql_free_result_array($res); doLogger(); if($vsql==null) endSQL($sql); } function doLoggerOnce() { $sql = beginSQL("server"); doLogger(); endSQL($sql); } function setLogAll($l) { file_put_contents("/logall", $l?"true":"false"); } function isLogAll() { return streq(file_get_contents("/logall"), "true")?true:false; } function js_onKeyPress($id, $func, $key) { js('$(document).ready(function() { $("'.$id.'").keypress(function (e){ if(e.keyCode=='.$key.') '.$func.'; }); });'); } function js_onEnterPress($id, $func) { js_onKeyPress($id, $func, 13); } function doLogger() { $r = mysql_query_return_assoc("SELECT * FROM logInfo WHERE `ip`='".getip()."'"); if(($r!=array())||isLogAll()) { mysql_query("INSERT INTO logs ( ip, url, session, time ) VALUES ( '".getip()."', '".geturl()."', ".(sessionid()==null||streq(sessionid(),"")?"NULL":"'".$_REQUEST["PHPSESSID"]."'").", '".sqldate()."' )"); } else @mysql_free_result_array($r); } function writeAllText($fn, $txt) { $p = fopen($fn, "w"); fwrite($p, $txt); fclose($p); } function sessionid() { return $_REQUEST["PHPSESSID"]; } function geturl() { $actual_link = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; return $actual_link; } function getmsg() { $txt = @readalltext("\message"); if(streq($txt,"")) return NULL; return $txt; } function button($value, $onclick=null,$other="") { echo(""); } function sessionActive() { return sessionid() !== ''; } function setTempNotify($msg) { $_SESSION["msg"]=$msg; } function tempNotifyExists() { return isset($_SESSION["msg"]); } function readTempNotify() { $msg=null; if(isset($_SESSION["msg"])) { $msg = $_SESSION["msg"]; unset($_SESSION["msg"]); } return $msg; } function index($ar, $i) { return $ar[$i]; } function mysql_query_return_assoc($q) { $res = (mysql_query($q)); $ret=array(); $i=0; if(!$res) echo(mysql_error()); else while($cur = mysql_fetch_assoc($res)) { $ret[$i++] = $cur; } //mysql_free_result($q); return $ret; } function readAllText($fn) { $fp = fopen($fn,"r"); $data = fread($fp, filesize($fn)); fclose($fp); return $data; } function beginSQL($db) { $con = mysql_connect(SQL_DEFAULT_HOST_NAME, SQL_DEFAULT_USER, SQL_DEFAULT_PASSWORD); mysql_select_db($db, $con); return $con; } function endSQL($con) { mysql_close($con); } function css($css) { echo ''; } function css_main($dir="/") { echo ''; } function title($title, $others="",$id=null) { echo "

$title

\n"; echo "$title"; } function mysql_free_result_array($res) { foreach($res as $re) mysql_free_result($re); } function lb() { echo("
"); } function para() { echo("

"); } function validip($ip) { return preg_match("~([0-9]{1,3}[.]){3,3}[0-9]{1,3}~",$ip); } function getip() { if (validip($_SERVER["HTTP_CLIENT_IP"])) { return $_SERVER["HTTP_CLIENT_IP"]; } foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) { if (validip(trim($ip))) { return $ip; } } if (validip($_SERVER["HTTP_X_FORWARDED"])) { return $_SERVER["HTTP_X_FORWARDED"]; } elseif (validip($_SERVER["HTTP_FORWARDED_FOR"])) { return $_SERVER["HTTP_FORWARDED_FOR"]; } elseif (validip($_SERVER["HTTP_FORWARDED"])) { return $_SERVER["HTTP_FORWARDED"]; } elseif (validip($_SERVER["HTTP_X_FORWARDED"])) { return $_SERVER["HTTP_X_FORWARDED"]; } else { return $_SERVER["REMOTE_ADDR"]; } } function link_tab($res, $txt, $other="") { link($res, $txt, "target='_black' ".$other); } function link($res, $txt, $other="") { echo("$txt"); } function streq($str,$str2) { return strcmp($str,$str2)==0; } function echoline($ln) { echo($ln); lb(); } function echopara($pa) { echo($pa); para(); } class Session { public static function unserialize($session_data) { $method = ini_get("session.serialize_handler"); switch ($method) { case "php": return self::unserialize_php($session_data); break; case "php_binary": return self::unserialize_phpbinary($session_data); break; default: throw new Exception("Unsupported session.serialize_handler: " . $method . ". Supported: php, php_binary"); } } private static function unserialize_php($session_data) { $return_data = array(); $offset = 0; while ($offset < strlen($session_data)) { if (!strstr(substr($session_data, $offset), "|")) { throw new Exception("invalid data, remaining: " . substr($session_data, $offset)); } $pos = strpos($session_data, "|", $offset); $num = $pos - $offset; $varname = substr($session_data, $offset, $num); $offset += $num + 1; $data = unserialize(substr($session_data, $offset)); $return_data[$varname] = $data; $offset += strlen(serialize($data)); } return $return_data; } private static function unserialize_phpbinary($session_data) { $return_data = array(); $offset = 0; while ($offset < strlen($session_data)) { $num = ord($session_data[$offset]); $offset += 1; $varname = substr($session_data, $offset, $num); $offset += $num; $data = unserialize(substr($session_data, $offset)); $return_data[$varname] = $data; $offset += strlen(serialize($data)); } return $return_data; } public static function serialize( $array, $safe = true ) { // the session is passed as refernece, even if you dont want it to if( $safe ) $array = unserialize(serialize( $array )) ; //var_dump($array); $raw = '' ; $line = 0 ; $keys = array_keys( $array ) ; foreach( $keys as $key ) { $value = $array[ $key ] ; $line ++ ; $raw .= $key .'|' ; if( is_array( $value ) && isset( $value['huge_recursion_blocker_we_hope'] )) { $raw .= 'R:'. $value['huge_recursion_blocker_we_hope'] . ';' ; } else { $raw .= serialize( $value ) ; } $array[$key] = Array( 'huge_recursion_blocker_we_hope' => $line ) ; } return $raw ; } } ?>