예제 #1
0
function inituser($fromid, $toid)
{
    $otu = new TTUser($fromid);
    $tu = new TTUser($toid);
    $all = $otu->getAll(false);
    $allr = array();
    $now = time();
    foreach ($all as $k => $v) {
        $arr = explode(':', $k);
        $arr[0] = $toid;
        $nk = implode(':', $arr);
        $nv = $v;
        $isobj = TTExtend::checkObj($v);
        if ($isobj) {
            $v['id'] = $nk;
            if (isset($v['stime'])) {
                $v['stime'] = $now - 50;
            }
            if (isset($v['pos']['y'])) {
                $arr = explode(':', $v['pos']['y']);
                if (count($arr) > 1 && ($arr[0] = $toid)) {
                    $arr[0] = $toid;
                    $v['pos']['y'] = implode(':', $arr);
                }
            }
            $allr[$nk] = json_encode($v);
        } else {
            $allr[$nk] = $nv;
        }
    }
    $tt = TT::get_tt('main', $toid);
    $tt->put($allr);
    //print_r($tu->getAll());
}
예제 #2
0
파일: TTLog.php 프로젝트: uning/mall-back
 /**
  * @param $data
  * @return unknown_type
  */
 public static function record($data)
 {
     $t =& self::$_t;
     if ($t == null) {
         $t = TT::get_tt('log');
     }
     $t->putCat(null, $data);
 }
예제 #3
0
파일: test.php 프로젝트: uning/mall-back
 static function test_TTExtend()
 {
     $t = TT::get_tt('web');
     $oid = 'keyid1:o';
     $data['id'] = $oid;
     $data['name'] = 'name';
     $data['add'] = array('dff' => 'add', 2 => 3445);
     $str = '$id=$t->puto($data)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->getbyid($id)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $data = array();
     $data['id'] = $oid;
     $data['name'] = 'new name';
     $data['col'] = 'add new name';
     $str = '$id=$t->puto($data,true)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->getbyid($id)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$id=$t->puto($data,false)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->getbyid($id)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->numch("add",1)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->numch("add",1)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $ids = array('add', ':d:df:new', $oid);
     $str = '$t->getbyids($ids)';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $t->put(':d:df:new', 'ddffffff');
     $str = '$t->get("new")';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     $str = '$t->get("new")';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
 }
예제 #4
0
파일: TTGenid.php 프로젝트: uning/mall-back
 public static function update($data, $id = null)
 {
     if ($id == null) {
         $id = $data['id'];
     }
     if ($id < 1) {
         return null;
     }
     $t =& self::$_t;
     if ($t == null) {
         $t = TT::get_tt('genid');
     }
     $odata = $t->get($id);
     if (!$odata) {
         return null;
     }
     $newdata = array_merge($odata, $data);
     $t->put($id, $newdata);
     return $newdata;
 }
예제 #5
0
파일: TTUDB.php 프로젝트: uning/mallb
 function TTUDB($uid, $only_read = false, $name = 'main')
 {
     $this->_u = $uid;
     $this->type = $only_read ? 'slave' : 'master';
     $this->_t = TT::get_tt($this->name, $this->_u, $this->type);
 }
예제 #6
0
파일: TTGenid.php 프로젝트: uning/mallb
 public static function getbypid($pid)
 {
     $t =& self::$_t;
     if ($t == null) {
         $t = TT::get_tt('genid', 'slave');
     }
     $q = $t->getQuery();
     $q->addCond('pid', TokyoTyrant::RDBQC_STREQ, $pid);
     $res = $q->search();
     if ($res) {
         foreach ($res as $k => $v) {
             $v['id'] = $k;
             return $v;
         }
     }
 }
예제 #7
0
파일: config.php 프로젝트: uning/mall-back
<?php

ini_set('memory_limit', '1G');
$myloc = dirname(__FILE__);
require_once $myloc . '/../../web/public/base.php';
require_once LIB_ROOT . 'DBModel.php';
$mail_body = "<pre>\n";
$gtt = TT::get_tt('genid', 0, 'slave');
$gttw = TT::get_tt('genid');
$now = time();
//$now -= 86400;
$datestr = date('Y-m-d', $now);
$weekday = date('N', $now);
$day_starttime = strtotime($datestr);
$day_endtime = $day_starttime + 86400;
echo "date:{$datestr} \nweekday:{$weekday}\n";
$mail_body .= "date:{$datestr} \nweekday:{$weekday}\n";
require_once '../../web/renren/renren.php';
$ren = new Renren();
$ren->api_key = 'a32cb73bea154d2c9d40703b66dc9142';
$ren->secret = '023a6201a9b04955b1af79b1e9037c16';
$ren->init();
$dbconfig = array('host' => '127.0.0.1', 'username' => 'admin', 'password' => '123456', 'port' => '3307', 'charset' => 'utf8', 'dbname' => 'mall_stat');
$cmd = "mysql -u{$dbconfig['username']} -P{$dbconfig['port']}  -h{$dbconfig['host']} ";
if ($dbconfig['password']) {
    $cmd .= " -p'{$dbconfig['password']}'";
}
$db = ServerConfig::connect_mysql($dbconfig);
function getModel($name)
{
    global $db;
예제 #8
0
파일: pay_log.php 프로젝트: uning/mallb
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

 <?php 
require_once 'config.php';
$pid = $_REQUEST['pid'];
if ($pid) {
    $sess = TTGenid::getbypid($pid);
    $u = $sess['id'];
}
$ot = TT::get_tt('order');
$q = $ot->getQuery();
if ($u) {
    $q->addCond('uid', TokyoTyrant::RDBQC_NUMEQ, $u);
} else {
    $q->addCond('handledTime', TokyoTyrant::RDBQC_NUMGT, strtotime(date("Y-m-d")));
}
$q->addCond('status', TokyoTyrant::RDBQC_NUMEQ, 1);
//	$q->setLimit(100);
echo "<pre>";
$rets = $q->search();
$amount = 0;
$cs = array();
foreach ($rets as $k => $ret) {
    $amount += $ret['amount'];
    if ($cs[$ret['amount']] === null) {
예제 #9
0
<?php

$myloc = dirname(__FILE__);
require_once $myloc . '/config.php';
$logt = TT::get_tt('log');
$num = $logt->num();
$tq = $logt->getQuery();
$tq->setLimit(1);
$r = $tq->search();
foreach ($r as $k => $v) {
    $start = $k;
    break;
}
if (!$start) {
    die("no log start get ");
}
echo "start={$start} lognum = {$num}\n";
$mail_body .= "start={$start} lognum = {$num}\n";
$table = 'log_history';
$uhfname = $myloc . "/data/{$table}/{$weekday}.csv";
system("mkdir -p {$myloc}/data/{$table}/");
$uhf = fopen($uhfname, 'w') or die("open {$uhfname} failed");
$cont_no = 0;
$end = $start + $num;
$end = $logt->put(null, array('ad' => 1, 'add' => 2));
for ($i = $start; $i <= $end; ++$i) {
    try {
        $data = $logt->get($i);
    } catch (Exception $ee) {
        print_r($ee);
    }
예제 #10
0
파일: JsonServer.php 프로젝트: uning/mallb
 protected function _handle(&$req)
 {
     //just add method map here
     $tm = $_SERVER['REQUEST_TIME'];
     $method = $req['m'];
     $mypre = $method;
     $log_nok = false;
     if (array_key_exists($method, self::$log_NOK_methods)) {
         $log_nok = true;
     }
     $req['p']['_cid'] = $req['cid'];
     $u = $req['p']['u'];
     if (!$log_nok) {
         if (check_dup($u, $req['cid'], $ret)) {
             TTLog::record(array('s' => 'dup', 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
             return $ret;
         }
     }
     if ($this->_debug) {
         CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param');
     }
     if (isset(self::$exist_methods[$method])) {
         $caller =& self::$exist_methods[$method];
         $c =& $caller[0];
         $m = $caller[1];
     } else {
         $caller = explode('.', $method);
         $cn = $caller[0];
         $m = $caller[1];
         $file = CONTROLLER_ROOT . "{$cn}.php";
         if (!file_exists($file)) {
             throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)");
         }
         @(require_once $file);
         $c = new $cn();
         if (!method_exists($c, $m)) {
             throw new JsonServerExecption("{$cn} don't has callable method {$m}");
         }
     }
     try {
         $ret = $c->{$m}($req['p']);
         //for debug
         if (isset(self::$record_users[$u])) {
             $dt = TT::get_tt('debug');
             $dt->needSV = true;
             $dt->put(array('m' => $method, 'tm' => $_SERVER['REQUEST_TIME'], 'in' => $req['p'], 'out' => $ret));
         }
         if (!$u) {
             $u = 'nouser';
         }
     } catch (Exception $e) {
         $r['s'] = 'exc';
         $r['msg'] = $e->getMessage();
         $r['exce'] = $e->getTrace();
         error_log($method . ':' . $r['msg']);
     }
     if ($this->_debug) {
         CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp');
     }
     if (!$ret) {
         $ret['s'] = "KO";
         $ret['msg'] = "{$cn}::{$m} return null";
     }
     if ($log_nok) {
         if ($ret['s'] != 'OK') {
             TTLog::record(array('s' => 'OK', 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
         }
     } else {
         if (!array_key_exists($m, self::$nolog_methods)) {
             TTLog::record(array('s' => $ret['s'], 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
         }
     }
     return $ret;
 }
예제 #11
0
파일: test.php 프로젝트: uning/mall-back
 public function test_tt()
 {
     $tu = new TTUser(1);
     $tt = TT::get_tt('main', 1);
     $id = $tu->getdid(TT::SHOP_NUM);
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = 10;
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = -10;
     $str = '$tu->numch(TT::SHOP_NUM,$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $tu->putf('strint', '0000');
     $str = '$tu->getf("strint")';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = -10;
     $str = '$tu->numch("strint",$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $shop_num = 10;
     $str = '$tu->numch("strint",$shop_num)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $tt->put("strint", 'a');
     $str = '$tt->get("strint")';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $str = '$tt->numch("strint",100)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
     $str = '$tt->numch("strint",100)';
     echo "{$str}=";
     record_time($st);
     eval('print_r(  ' . $str . ');');
     record_time($st, $str);
     echo "\n";
 }
예제 #12
0
파일: list_user.php 프로젝트: uning/mallb
require_once '../base.php';
echo "<pre>\n";
$u = $argv[1];
if (!$u) {
    $u = $_REQUEST['start'];
}
if (!$u) {
    $pid = $argv[2];
}
if (!$u) {
    $pid = 1;
}
$page_num = 30;
$e = $u + $page_num;
$s = $u - $page_num;
$tc = TT::get_tt('genid', 'slave');
$num = $tc->num();
echo "total users: {$num}\n";
if ($s >= 0) {
    echo "<a href='?start={$s}'>prev</a> | ";
}
if ($num > $u) {
    echo "<a href='?start={$e}'>next</a> | ";
}
$last = $num - $page_num + 10;
echo "<a href='?start={$last}'>last</a>  ";
echo "<hr/>\n";
$pid = $_REQUEST['pid'];
if ($pid) {
    $sess = TTGenid::getbypid($pid);
    $u = $sess['id'];
예제 #13
0
파일: view_debug.php 프로젝트: uning/mallb
<?php

$myloc = dirname(__FILE__);
require_once '../base.php';
echo "<pre>\n";
$now = time();
$datestr = date('Y-m-d', $now);
$weekday = date('N', $now);
$day_starttime = strtotime($datestr);
$day_endtime = $day_starttime + 86400;
$logt = TT::get_tt('debug');
$logt->needSV = false;
$id = $logt->genUid();
echo "max : {$id}:\n";
#exit;
$num = $logt->num();
$cont_no = 0;
$end = $id;
$vnum = $_REQUEST['num'];
$u = $_REQUEST['u'];
if (!$vnum) {
    $vnum = 50;
}
$start = $end - $vnum;
if ($start < 1) {
    $start = 1;
}
for ($i = $id; $i > $start; --$i) {
    $data = $logt->get($i);
    if (!$data) {
        continue;
예제 #14
0
<?php

require_once '../base.php';
$otu = new TTUser(2);
$all = $otu->getAll(false);
$now = time();
$tc = TT::get_tt('genid');
$num = $tc->num();
echo "init start from {$num}\n";
for ($i = $num + 1; $i < 300000; $i++) {
    $id = $tc->put(null, array('pid' => 'test' . $i, 'at' => $now));
    $tt = TT::get_tt('main', $toid);
    $allr = array();
    $tu = new TTUser($i);
    $toid = $i;
    foreach ($all as $k => $v) {
        $arr = explode(':', $k);
        $arr[0] = $toid;
        $nk = implode(':', $arr);
        $nv = $v;
        $isobj = TTExtend::checkObj($v);
        if ($isobj) {
            $v['id'] = $nk;
            if (isset($v['stime'])) {
                $v['stime'] = $now - 50;
            }
            if (isset($v['pos']['y'])) {
                $arr = explode(':', $v['pos']['y']);
                if (count($arr) > 1 && ($arr[0] = $toid)) {
                    $arr[0] = $toid;
                    $v['pos']['y'] = implode(':', $arr);
예제 #15
0
 public function getbyids($ids, $uid = null, &$t = null)
 {
     $id = $ids[0];
     if (!$t && !$uid) {
         $idata = explode(':', $id, 4);
         if ($idata[0] > 0) {
             $uid = $idata[0];
         }
     }
     if (!$uid) {
         throw new Exception("no uid set");
     }
     if ($t == null) {
         $t = TT::get_tt($this->name, $uid, $this->type);
     }
     $ret = $t->get($ids);
     $res = array();
     foreach ($ret as $k => $v) {
         $res[$k] = json_decode($v, true);
     }
     return $res;
 }