Exemple #1
0
 /**
  * 移动临时文件
  *
  * @param {array} $file
  * @param {string} $target
  * @return {string}
  */
 public static function move($file, $target)
 {
     $timestamp = microtime(true);
     $source = is_array($file) ? $file['tmp_name'] : $file;
     move_uploaded_file($source, $target);
     DEBUG::put('Move ' . $source . ' to ' . $target . ' spent: ' . round((microtime(true) - $timestamp) * 1000, 3) . 'ms', 'Upload');
     return $target;
 }
Exemple #2
0
 function query($sql, $type = '')
 {
     $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
     if (!$this->curlink) {
         $this->connect();
     }
     if (!($query = $func($sql, $this->curlink))) {
         if ($type != 'SILENT') {
             $this->halt('MySQL Query ERROR', $sql);
         }
     }
     DEBUG::query_counter();
     return $this->last_query = $query;
 }
 public static function run()
 {
     $o = self::getInstance();
     $SID = $_COOKIE["SID"];
     if (!$SID) {
         return null;
     }
     try {
         if ($SID && !preg_match("/^[a-z0-9]+\$/", $SID)) {
             throw new Exception("SID contains incorrect characters");
         }
         $SID = preg_replace("/[^a-z0-9]/", "", $SID);
         if (!$SID) {
             throw new Exception("SID is empty");
         }
         if ($rw = DB::f1("select * from users_sessions where sid=:SID", array("SID" => $SID))) {
             $rw_session = $rw;
         } else {
             throw new Exception("Auth session not found");
         }
         $Q = new UsersExec();
         $Q->where("id", $rw_session["user_id"]);
         if ($rw = $Q->f1()) {
             $user = $rw;
             $user["rw_session"] = $rw;
             if ($user["settings"]["rememberme"]) {
                 setcookie("SID", $SID, time() + $o->CONFIG["rememberme_time"], "/", $o->CONFIG["cookie_domain"]);
             } else {
                 setcookie("SID", $SID, 0, "/", $o->CONFIG["cookie_domain"]);
             }
             if ($o->CONFIG["enable_online"]) {
                 $online_file = $o->CONFIG["online_cache_dir"] . "/" . (int) (time() / $o->CONFIG["online_interval"]) % 2 . "/" . $user->id;
                 touch($online_file);
             }
             $o->user = $user;
             return true;
         } else {
             throw new Exception("User id=" . $rw_session["user_id"] . " not found");
         }
     } catch (Exception $e) {
         DEBUG::log("Auth Exception: " . $e->getMessage(), __CLASS__);
         if ($SID) {
             DB::q("delete from users_sessions where sid=:SID", array("SID" => $SID));
         }
         $_COOKIE["SID"] = "";
         setcookie("SID", "", time() - 86400, "/", $o->CONFIG["cookie_domain"]);
     }
 }
Exemple #4
0
function __autoload($className)
{
    if ($className == 'Memcache') {
        //如果是系统的Memcache则不包含
        return;
    } else {
        if ($className == 'Smarty') {
            //如果类名是Smarty,则直接包含
            include 'Smarty.class.php';
        } else {
            include strtolower($className) . '.class.php';
        }
    }
    DEBUG::addmsg('<b>' . $className . '</b>类', 1);
    //在Debug消息中显示自动包含的类
}
 /**
  * Test to make sure a user cannot go manipulate the form flow
  *
  * @before reset
  * @before login
  * @before validateWizard
  *
  * @param AcceptanceTester $I
  */
 public function validateFormSequence(AcceptanceTester $I)
 {
     $I->wantToTest('The user cannot manipulate the form sequence manually');
     /**
      * Step 1: Start
      */
     DEBUG::debug('Trying to go forward 1 step without clicking continue ...');
     $I->amOnPage(admin_url('/?page=wpem&step=settings'));
     // Redirected back to the most current step
     $I->seeInCurrentUrl('/wp-admin/?page=wpem&step=start');
     $I->click(self::PRIMARY_BUTTON);
     $I->waitForElementNotVisible('.wpem-step-1 form', 15);
     /**
      * Step 2: Settings
      */
     $I->seeInCurrentUrl('/wp-admin/?page=wpem&step=settings');
     DEBUG::debug('Trying to go back to the previous step ...');
     $I->moveBack();
     // Redirected back to the most current step
     $I->seeInCurrentUrl('/wp-admin/?page=wpem&step=settings');
     DEBUG::debug("Typing in the previous step's URL directly ...");
     $I->amOnPage(admin_url('/?page=wpem&step=start'));
     // Redirected back to the most current step
     $I->seeInCurrentUrl('/wp-admin/?page=wpem&step=settings');
 }
Exemple #6
0
ob_start();
//Start a buffer, mainly in case there is a mysql error
// Include our dependencies
require ASSETS . '/class_debug.php';
//Require the debug class
require ASSETS . "/class_misc.php";
require ASSETS . "/class_mysql.php";
require ASSETS . "/class_cache.php";
require ASSETS . "/class_encrypt.php";
require ASSETS . "/class_useragent.php";
require ASSETS . "/class_time.php";
$DB = new DB_MYSQL();
$Cache = new CACHE();
$Enc = new CRYPT();
$UA = new USER_AGENT();
$Debug = new DEBUG();
$Debug->handle_errors();
$Debug->set_flag('Debug constructed');
// throw_error(code/message) - any sort of error will go here
// Technically we shouldn't print all the data from these objects.
// The DB object has all the database credentials
function throw_error($c, $Sneaky = false)
{
    echo $c;
    if ($Sneaky) {
        global $DB, $Cache;
        print_r($DB);
        print_r($Cache);
    }
}
// API Keys; ptpimg+api@nervex.net
Exemple #7
0
 /**
  * 关闭SQL连接
  */
 public static function close()
 {
     DEBUG::put('Close connection.', 'MySQL');
     return @mysqli_close(SQL::$connection);
 }
Exemple #8
0
<?php

require_once "fn.php";
$CONFIG = (require "config.php");
try {
    DEBUG::start();
    mb_internal_encoding("UTF-8");
    setlocale(LC_ALL, "ru_RU.UTF-8");
    $app = app::getInstance();
    $app->setConfig($CONFIG);
    $app->setAjax($_REQUEST["ajax"]);
    $app->run();
    $app->display();
    DEBUG::finish();
    if (($_REQUEST["debug"] || $CONFIG["debug"]) && !$_REQUEST["ajax"]) {
        echo DEBUG::out($CONFIG["debug_format"]);
    }
} catch (Exception $e) {
    $str = "Unspecified fatal exception: " . $e->getMessage() . "\nException occurs in file " . $e->getFile() . " on line " . $e->getLine() . "\n\n";
    if ($_REQUEST["ajax"]) {
        echo "var error=\"" . my_js_conv($str) . "\"; ";
    } else {
        echo str_replace("\n", "<br />", $str);
    }
    file_put_contents($CONFIG["tmp_dir"] . "/error.log", date("Y-m-d h:i:s") . " - " . $str, FILE_APPEND);
}
 public static function f1($query, $opts = null, $connection_id = null)
 {
     if (class_exists("DEBUG")) {
         DEBUG::log_start("PDO FETCH");
     }
     $o = self::getInstance();
     if (!preg_match("/limit\\s*\\d+\\s*,\\s*\\d+/", $query)) {
         $query .= " limit 0,1";
     }
     $res = $o->query($query, $opts, $connection_id);
     if (isset($res) && $res instanceof PDOStatement) {
         $rw = $res->fetch();
         if (class_exists("DEBUG")) {
             DEBUG::log_end($query . (isset($opts) ? " with opts: " . join(",", $opts) : " without opts"), "PDO+FETCH ONE", "PDO FETCH");
         }
         return $rw;
     }
     return null;
 }
Exemple #10
0
<?php

require_once dirname(__FILE__) . "/../fn.php";
require_once "req.php";
$CONFIG = (require dirname(__FILE__) . "/../config.php");
DB::setConfig($CONFIG["db"]);
DEBUG::start();
ob_implicit_flush(1);
mb_internal_encoding("UTF-8");
setlocale(LC_ALL, "ru_RU.UTF-8");
$out = "\n\nvar countries = new Array();\nvar cities = new Array();\n\ncountries[0] = '<!--[not_choosena]-->';\ncities[0] = new Array();\ncities[0][0] = '<!--[not_choosen]-->';\n\n";
$geo_countries = set_by_id(DB::f("select * from geo_countries"));
$geo_cities = set_by_id(DB::f("select * from geo_cities"));
foreach ($geo_countries as $rw) {
    $rw = my_js_conv($rw);
    $out .= "countries[" . $rw[id] . "] = '" . $rw[name] . "';\ncities[" . $rw[id] . "] = new Array();\ncities[" . $rw[id] . "][0] = '<!--[not_choosen]-->';\n";
}
$out .= "\n\n";
foreach ($geo_cities as $rw) {
    $rw = my_js_conv($rw);
    $out .= "cities[" . $rw[country_id] . "][" . $rw[id] . "] = '" . $rw[name] . "';\n";
}
$out = preg_replace_callback("/<!--\\[([^\\[\\]]+)\\]-->/", "use_dictionary_callback", $out);
echo $out;
Exemple #11
0
    define('IN_API', false);
}
error_reporting(E_ALL ^ E_NOTICE);
ob_start();
header('Content-type: text/html; charset=utf-8');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
@date_default_timezone_set('Asia/Shanghai');
require_once SYSTEM_ROOT . './config.cfg.php';
require_once SYSTEM_ROOT . './class/error.php';
require_once SYSTEM_ROOT . './class/db.php';
require_once SYSTEM_ROOT . './class/debug.php';
require_once SYSTEM_ROOT . './function/core.php';
require_once SYSTEM_ROOT . './function/updater.php';
DEBUG::INIT();
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($ua, 'wap') || strpos($ua, 'mobi') || strpos($ua, 'opera') || $_GET['mobile']) {
    define('IN_MOBILE', true);
} else {
    define('IN_MOBILE', false);
}
if (strpos($ua, 'bot') || strpos($ua, 'spider')) {
    define('IN_ROBOT', true);
}
check_update();
if (SYS_KEY) {
    define('ENCRYPT_KEY', SYS_KEY);
} elseif (!getSetting('SYS_KEY')) {
    $key = random(32);
    saveSetting('SYS_KEY', $key);
Exemple #12
0
ob_start();
//Start a buffer, mainly in case there is a mysql error
// Include our dependencies
require SERVER_ROOT . '/classes/class_debug.php';
//Require the debug class
require SERVER_ROOT . '/classes/class_misc.php';
require SERVER_ROOT . '/classes/class_mysql.php';
require SERVER_ROOT . '/classes/class_cache.php';
require SERVER_ROOT . '/classes/class_encrypt.php';
require SERVER_ROOT . '/classes/class_useragent.php';
require SERVER_ROOT . '/classes/class_time.php';
$DB = new DB_MYSQL();
$Cache = new CACHE();
$Enc = new CRYPT();
$UA = new USER_AGENT();
$Debug = new DEBUG();
$Debug->handle_errors();
$Debug->set_flag('Debug constructed');
// throw_error(code/message) - any sort of error will go here
// Technically we shouldn't print all the data from these objects.
// The DB object has all the database credentials
function throw_error($c, $Sneaky = false)
{
    echo $c;
    if ($Sneaky) {
        global $DB, $Cache;
        print_r($DB->Queries);
        print_r($Cache);
    }
}
// API Keys; ptpimg+api@nervex.net
 function page_footer()
 {
     return DEBUG::output();
 }
Exemple #14
0
    echo '<p>当前分支:稳定版 (<a id="switch_to_dev" href="javascript:;">切换到开发版</a>)</p>';
}
?>
<p>开发版拥有更快的更新速度,但同时也拥有一定的不稳定性.</p>
<br>
<p class="result">正在检查更新...</p>
<div class="filelist hidden">
<ul></ul>
<p><button class="btn red">开始更新</button></p>
</div>
</div>
</div>
</div>
</div>
<p class="copyright"><?php 
echo DEBUG::output();
?>
</p>
</div>
<script src="<?php 
echo jquery_path();
?>
"></script>
<script type="text/javascript">var formhash = '<?php 
echo $formhash;
?>
';var version = '<?php 
echo VERSION;
?>
';</script>
<script src="system/js/kk_dropdown.js?version=<?php 
Exemple #15
0
 function kk_sign($n = array())
 {
     global $_config;
     require_once SYSTEM_ROOT . './config.cfg.php';
     foreach ($this->m as $m) {
         require_once SYSTEM_ROOT . "./class/{$m}.php";
     }
     DEBUG::INIT();
     require_once SYSTEM_ROOT . './function/core.php';
     CACHE::load(array('plugins', 'setting'));
     $this->a();
     $this->b();
     $n = $n ? $n : $this->n;
     foreach ($n as $m) {
         $mm = "_load_module_{$m}";
         if (method_exists($this, $mm)) {
             $this->{$mm}();
         } else {
             $this->_load_module($m);
         }
     }
     $this->f();
 }
Exemple #16
0
 /**
  * 清空DEBUG流,并返回之前的信息
  *
  * @return string
  */
 public static function clear()
 {
     $ret = DEBUG::$stack;
     DEBUG::$stack = '';
     return $ret;
 }
 public function setSuccess($msg, $autoredirect = 0, $autoredirect_url = null)
 {
     $this->CID = "success";
     $this->CHDATA[$this->CID]["autoredirect"] = $autoredirect;
     $this->CHDATA[$this->CID]["autoredirect_url"] = $autoredirect_url;
     $this->CHDATA[$this->CID]["msg"] = $msg;
     DEBUG::log("msg=" . $msg, __METHOD__);
 }
Exemple #18
0
 private function createRange($rangeStart, $rangeEnd, $step)
 {
     if ($step == 0) {
         DEBUG::error(".. {$rangeEnd} {$rangeEnd} {$step} (Warning): range operator was passed ZERO as `step' value");
         return $rangeStart;
     }
     $output = "[";
     for ($i = $rangeStart; $step >= 0 ? $i <= $rangeEnd : $i >= $rangeEnd; $i += $step) {
         $output .= "" . $i . ", ";
     }
     if ($output == "[") {
         $output = "";
     } else {
         $output = substr($output, 0, strlen($output) - 2) . "]";
     }
     return $output;
 }
Exemple #19
0
/********************************************************/

$ScriptStartTime=microtime(true); //To track how long a page takes to create

//Lets prevent people from clearing feeds
if (isset($_GET['clearcache'])) {
	unset($_GET['clearcache']);
}

require 'classes/config.php'; //The config contains all site wide configuration information as well as memcached rules

require(SERVER_ROOT.'/classes/class_cache.php'); //Require the caching class
require(SERVER_ROOT.'/classes/class_debug.php'); //Require the debug class
$Cache = NEW CACHE; //Load the caching class

$Debug = new DEBUG;
$Debug->handle_errors();

// Send a message to an IRC bot listening on SOCKET_LISTEN_PORT
function send_irc($Raw) {
	$IRCSocket = fsockopen(SOCKET_LISTEN_ADDRESS, SOCKET_LISTEN_PORT);
	fwrite($IRCSocket, $Raw);
	fclose($IRCSocket);
}

function check_perms() {
	return false;
}

function error($Code) {
	echo '<error>',$Code,'</error></payload>';
Exemple #20
0
 /**
  * 返回JSON格式数据
  *
  * @param mixed $data
  */
 public static function sendJSON($data = null)
 {
     @header('content-type: application/json');
     if (is_array($data) && APP::$is_debug) {
         $data['debug'] = DEBUG::get();
     }
     echo json_encode($data);
     APP::end();
 }
Exemple #21
0
 /**
  * 注册中间件
  *
  * @param string $path        路径
  * @param callback $function  要执行的函数
  * @param bool $is_preg       路径是否为正则表达式,默认为false
  */
 public static function register($path, $function, $is_preg = false)
 {
     ROUTER::$_list[] = array($path, $function, $is_preg);
     DEBUG::put("Use: {$path} => {$function}", 'Router');
 }
Exemple #22
0
//Start a buffer, mainly in case there is a mysql error
require SERVER_ROOT . '/classes/debug.class.php';
//Require the debug class
require SERVER_ROOT . '/classes/mysql.class.php';
//Require the database wrapper
require SERVER_ROOT . '/classes/cache.class.php';
//Require the caching class
require SERVER_ROOT . '/classes/encrypt.class.php';
//Require the encryption class
require SERVER_ROOT . '/classes/time.class.php';
//Require the time class
require SERVER_ROOT . '/classes/paranoia.class.php';
//Require the paranoia check_paranoia function
require SERVER_ROOT . '/classes/regex.php';
require SERVER_ROOT . '/classes/util.php';
$Debug = new DEBUG();
$Debug->handle_errors();
$Debug->set_flag('Debug constructed');
$DB = new DB_MYSQL();
$Cache = new CACHE($MemcachedServers);
$Enc = new CRYPT();
// Autoload classes.
require SERVER_ROOT . '/classes/classloader.php';
// Note: G::initialize is called twice.
// This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache.
// TODO: remove one of the calls once we're moving everything into that class
G::initialize();
//Begin browser identification
$Browser = UserAgent::browser($_SERVER['HTTP_USER_AGENT']);
$OperatingSystem = UserAgent::operating_system($_SERVER['HTTP_USER_AGENT']);
//$Mobile = UserAgent::mobile($_SERVER['HTTP_USER_AGENT']);
 public function __construct($app)
 {
     $this->app = $app;
     $this->CONFIG = $this->app->getCONFIG("channels", $this->app->CID);
     DEBUG::log("CID=" . $this->app->CID . ", page=" . $this->app->page . ", action=" . $this->app->action, __METHOD__);
 }