Пример #1
0
</head>

<body>
<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('Asia/Shanghai');
$db = new SimpleDB();
$err = array(1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', 8 => 'E_NOTICE', 16 => 'E_CORE_ERROR', 32 => 'E_CORE_WARNING', 64 => 'E_COMPILE_ERROR', 128 => 'E_COMPILE_WARNING', 256 => 'E_USER_ERROR', 512 => 'E_USER_WARNING', 1024 => 'E_USER_NOTICE', 2048 => 'E_STRICT', 4096 => 'E_RECOVERABLE_ERROR', 8192 => 'E_DEPRECATED', 16384 => 'E_USER_DEPRECATED', 32767 => 'E_ALL');
?>
<h4>Auto-XHProf List</h4>
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#AAA">
<tr bgcolor="#CCC">
<td width="5%">ID</td><td width="25%">URL</td><td width="8%">Resp Time</td><td>Error Desc</td><td width="10%">Profile</td><td width="10%">Client Time</td></tr>
<?php 
$rows = $db->query("SELECT * FROM ax_log ORDER BY id DESC LIMIT 100");
if ($rows) {
    foreach ($rows as $row) {
        $error_id = $row['error_id'];
        $xhprof_id = $row['xhprof_id'];
        if (!empty($error_id)) {
            $error = $db->query("SELECT * FROM ax_error WHERE id='" . $error_id . "'");
            if ($error != null) {
                $error_id = "<font color='red'>" . $err[$error[0]['type']] . ":</font> " . $error[0]['message'] . " in " . $error[0]['file'] . " on line <b>" . $error[0]['line'] . "</b>";
            }
        }
        if (!empty($xhprof_id)) {
            $xhprof_id = "<a href='xhprof/index.php?run=" . $xhprof_id . "'>" . $xhprof_id . "</a>";
        }
        printf("<tr bgcolor='#FFF' valign='top'><td>%s</td><td>http://%s</td><td>%s s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $row['id'], $row['host'] . $row['uri'], $row['resp_time'], $error_id, $xhprof_id, $row['client_time']);
    }
Пример #2
0
    /* ===================================== step 2 update hits ========================================== */
    //memcached更新.写入全局点击量.每个应用的点击量.每个版块的点击量.
    /* ===================================== step 3 update heartbeat ========================================== */
    if (cookie('online_update') + $check_time < $cTime) {
        //刷新用户在线时间
        //设置10分钟过期
        cookie('online_update', $cTime, 7200);
        //$_SESSION['online_pageviews']	=	0;
        //判断是否存在记录.
        if ($uid > 0) {
            $where = "WHERE (uid='{$uid}')";
        } else {
            $where = "WHERE (uid=0 AND ip='{$ip}')";
        }
        $sql = "SELECT uid FROM " . $config['DB_PREFIX'] . "online " . $where;
        $result = $db->query("{$sql}");
        //如果没有记录.添加记录.
        if ($result) {
            $sql = "UPDATE " . $config['DB_PREFIX'] . "online SET activeTime={$cTime},ip='{$ip}' " . $where;
            $result = $db->execute("{$sql}");
        } else {
            $sql = "INSERT INTO " . $config['DB_PREFIX'] . "online (uid,uname,app,ip,agent,activeTime) VALUES ('{$uid}','{$uname}','{$app}','{$ip}','{$agent}',{$cTime});";
            $result = $db->execute("{$sql}");
        }
    }
    if ($result) {
        echo 'var onlineclick = "ok";';
    }
}
/* ===================================== 公共部分 ========================================== */
// 获取客户端IP地址
Пример #3
0
 protected function createTable()
 {
     $row = $this->db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='usage'");
     if ($row === false || count($row) === 0) {
         $sql[] = "CREATE TABLE usage(id PRIMARY KEY, user VARCHAR(20), day DATE, timestamp DATETIME)";
         $sql[] = "CREATE INDEX 'user_index' ON usage(user)";
         $sql[] = "CREATE INDEX 'day_index' ON usage(day)";
         foreach ($sql as $create) {
             $this->log->debug($create);
             $this->db->execute($create);
         }
     } else {
         $this->log->debug("Table usage exists");
     }
 }
 public function deleteStyle($id)
 {
     $this->sdb->query("DELETE FROM hb_mod_styles WHERE id=?", array($id));
     $this->addInfo("Selected style has been removed");
     return true;
 }
Пример #5
0
//初步验证合法性
$result = preg_match('/^[a-zA-Z0-9]+$/', $url, $match);
if (!$result) {
    die('error01,wrong parameters!');
}
$url_id = getDncodeNum($url);
if ($url_id <= 0) {
    die('error02,wrong parameters!');
}
//加载数据库查询类
require SITE_PATH . '/addons/libs/SimpleDB.class.php';
//引入数据库配置
$db_config = (require SITE_PATH . '/config.inc.php');
$db = new SimpleDB($db_config);
//查询短网址记录 - 有条件的,此处可用memcached做一层缓存
$result = $db->query("SELECT * FROM " . $db_config['DB_PREFIX'] . "url where id='" . $url_id . "' limit 1");
//状态为1的 跳转到正确地址
if ($result[0]['status'] == 1) {
    header('location:' . $result[0]['url']);
} else {
    die('error03,wrong parameters!');
}
//本地化 URL解码方法 将字母转换成数字ID
function getDncodeNum($num)
{
    //编码符号集一定要与加密的相同
    $index = "HwpGAejoUOPr6DbKBlvRILmsq4z7X3TCtky8NVd5iWE0ga2MchSZxfn1Y9JQuF";
    $out = 0;
    $len = strlen($num) - 1;
    for ($t = 0; $t <= $len; $t++) {
        $out = $out + strpos($index, substr($num, $t, 1)) * pow(62, $len - $t);
Пример #6
0
$list = $sdb->listDomains();
print_r($list);
Utils::printResult('CreateDomain', in_array('UnitTest', $list), $r);
$sdb->setDomain('UnitTest');
$a = array('name' => 'Bob', 'age' => 30);
$r = $sdb->putAttributesAssoc('bob', $a);
Utils::printResult('putAttributesAssoc', true, $r);
$r = $sdb->getAttributes('bob');
Utils::printResult('getAttributes', $r['name'] == 'Bob', $r);
$sdb->setSingleAttr('bob', 'foo', 'bar');
$r = $sdb->getAttributes('bob');
Utils::printResult('setSingleAttr', $r['foo'] == 'bar');
$a = array('alice' => array('name' => 'Alice', 'age' => 50), 'charlie' => array('name' => 'Charlie', 'age' => 20));
$r = $sdb->batchPutAttributesAssoc($a);
Utils::printResult('batchPutAttributesAssoc', true, $r);
$r = $sdb->query("SELECT * FROM UnitTest WHERE age>'25'");
Utils::printResult('query', count($r) == 2, $r);
$r = $sdb->singleAttrQuery('name', 'Alice');
Utils::printResult('singleAttrQuery - single val', count($r), $r);
$r = $sdb->singleAttrQuery('name', array('Alice', 'Bob'));
Utils::printResult('singleAttrQuery - multival', count($r) == 2, $r);
$r = $sdb->deleteDomain('UnitTest');
$list = $sdb->listDomains();
Utils::printResult('DeleteDomain', !in_array('UnitTest', $list), $r);
echo '<pre>' . print_r($sdb->getLog(), 1) . '</pre>';
/*
$bi = new BookInfo();
$r = $bi->getBookInfoFromWS('055321246x');
if ($debug) var_dump($r);
Utils::printResult('ItemLookup',!empty($r['title']));