예제 #1
0
function dotest($m, $p = null)
{
    $server = new JsonServer();
    if (!$p) {
        $p = JsonServer::getMethodLastCallParam($m);
    }
    echo "method {$m}\n";
    echo "The params are these as follow:\n";
    print_r($p);
    echo "The response are these as follow:\n";
    record_time($st);
    print_r($server->doRequest($m, $p));
    record_time($st, " {$m} ");
    echo "===============================================\n\n";
}
예제 #2
0
파일: check.php 프로젝트: uning/mall-back
function dotest($m, $p = null)
{
    $server = new JsonServer();
    if (!$p) {
        $p = JsonServer::getMethodLastCallParam($m);
    }
    if (!$p) {
        echo "WARN:{$m} :param is null\n";
        return;
    }
    record_time($st);
    $r = $server->doRequest($m, $p);
    if (!$r || !$r['s']) {
        echo "FAIL:{$m} :func error\n";
    }
    record_time($st, $m);
}
    $stmt->fetch();
    $hashedPassword = $row["hashed_password"];
    $admin = $row["admin"];
    $_SESSION["firstName"] = $row["firstname"];
    //Verify Fetched Password && Check if user is an admin
    if (password_verify($password, $hashedPassword) && $admin == 0) {
        $_SESSION["logged_in"] = 1;
        $_SESSION["email"] = $email;
        record_time($link, $email);
        header("Location: home.php");
    } else {
        if (password_verify($password, $hashedPassword)) {
            $_SESSION["logged_in"] = 1;
            $_SESSION["email"] = $email;
            $_SESSION['Admin'] = 1;
            record_time($link, $email);
            header("Location: adminhome.php");
        } else {
            $_SESSION['login_error'] = 1;
            header("Location: index.php");
            exit;
        }
    }
}
function record_time($link, $email)
{
    date_default_timezone_set('America/Chicago');
    $time = date('H:i:s');
    $time_query = "INSERT INTO login_timestamp VALUES(?,?)";
    $stmt = $link->prepare($time_query);
    $stmt->bind_param('ss', $email, $time);
예제 #4
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";
 }
예제 #5
0
    $us = $q->search();
    record_time($st, "search user");
    echo 'count($us)=' . count($us) . "\n";
    $ttotal = 0;
    for ($i = 0; $i < 10; $i++) {
        $q = $tt->getQuery();
        record_time($st, "getQuery");
        $q->addCond('v', TokyoTyrant::RDBQC_STREQ, $uid . ":{$i}");
        $uss = $q->search();
        record_time($st, "search user with v");
        $q = $tt->getQuery();
        record_time($st, "getQuery");
        $q->addCond('v', TokyoTyrant::RDBQC_STREQ, $uid . ":{$i}");
        $q->addCond('u', TokyoTyrant::RDBQC_STREQ, $uid);
        $uss1 = $q->search();
        record_time($st, "search user with id and v");
        echo 'count($uss)=' . count($uss) . ' ==' . count($uss1) . "\n";
        $ttotal += count($uss1);
    }
    echo 'count($us)=' . count($us) . "=={$ttotal}\n";
    echo "u:\n";
    print_r($u);
    echo "us:\n";
    print_r($us);
    echo "uss:\n";
    print_r($uss);
    echo "uss1:\n";
    print_r($uss1);
} catch (TokyoTyrantException $e) {
    if ($e->getCode() === TokyoTyrant::TTE_KEEP) {
        echo "Existing record! Not modified\n";
예제 #6
0
파일: session.php 프로젝트: uning/system
<?php

function record_time(&$start, $usage = "")
{
    $end = microtime(true);
    $cost = $end - $start;
    $cost = ceil(1000000 * $cost);
    if ($usage) {
        echo "{$usage} use time {$cost} us\n";
    }
    $start = $end;
}
echo session_save_path() . "=session_save_path()\n";
record_time($st);
echo "<pre>\n";
echo session_start() . "=session_start()\n";
echo "session_id = " . session_id() . "\n";
record_time($st, 'session_start');
$_SESSION['key'] += 1;
$_SESSION['name'] = "dfd";
echo "key in _SESSION = " . $_SESSION['key'];
echo "\n";
record_time($st, 'get key');
print_r($_SESSION);
예제 #7
0
        $ret = $t->get($key, null, false, 1000, 'add', '');
        print_r($ret);
        echo "get slice from='add' to='bdd'\n";
        $ret = $t->get($key, null, false, 1000, 'add', 'bdd');
        print_r($ret);
        echo "get clos from='add1,bdd1'\n";
        $ret = $t->getcols($key, array('add1', 'bdd1'));
        print_r($ret);
    }
}
record_time($start, "init");
try {
    // Test::testSuperUpdate();
    Test::testSuper();
    // Test::testCF();
    record_time($start, "testSuper");
} catch (Exception $e) {
    print_r($e);
    echo $e->getMessage() . "\n";
}
exit;
/**test uuid

exit;
//*/
/*
 $keyID = '1';
 echo 'print_r($t->get_list($keyID))'."\n";
 print_r($t->get_list($keyID));
 exit;
 //*/
예제 #8
0
파일: sync.php 프로젝트: uning/system
        $i = 0;
        $udatas = array();
        $sdatas = $st->get($keys);
        foreach ($mdatas as $mk => $mv) {
            if ($sdatas[$mk] != $mv) {
                $udatas[$mk] = $mv;
                $utotal += 1;
            }
        }
        $mdatas = array();
        $keys = array();
        if ($udatas) {
            $st->put($udatas);
        }
        echo record_time($stime, " process {$total} {$utotal}  items ");
    }
}
if ($i > 0) {
    $sdatas = $st->get($keys);
    foreach ($mdatas as $mk => $mv) {
        if ($sdatas[$mk] != $mv) {
            $udatas[$mk] = $mv;
            $utotal += 1;
        }
    }
    if ($udatas) {
        $st->put($udatas);
    }
    echo record_time($stime, " process {$total} {$utotal}  items ");
}
echo "mnum=" . $mt->num() . " snum=" . $st->num() . "\n";
예제 #9
0
record_time($st);
try {
    /* Connect to a table database */
    $tt = new TokyoTyrantTable("localhost", 10000);
    record_time($st, "connect");
    for ($j = 0; $j < 30; $j++) {
        $data['field' . $j] = uniqid();
    }
    $start = floor($tt->num() / 100);
    echo "start={$start} \n";
    for ($i = 1; $i < 100000; $i++) {
        $cur = $i + $start;
        $data['u'] = $cur;
        for ($j = 0; $j < 100; $j++) {
            $data['v'] = $cur . ':' . rand() % 10;
            $tt->put(null, $data);
        }
        if ($cur % 100 == 0) {
            record_time($st, "insert {$cur}*100");
        }
    }
} catch (TokyoTyrantException $e) {
    if ($e->getCode() === TokyoTyrant::TTE_KEEP) {
        echo "Existing record! Not modified\n";
    } else {
        echo "Error: ", $e->getMessage(), "\n";
    }
} catch (Exception $e) {
    var_dump($e);
    $e->print_trace();
}
예제 #10
0
파일: TestCC.php 프로젝트: uning/mall-back
    public function put($p)
    {
        $ret['s'] = 'OK';
        $t = new CassandraCF('mall', 'UserItem', true);
        // if(is_array($p)){
        $id = $p['u'];
        $ret['id'] = $t->put_super($p['d'], $id);
        return $ret;
    }
    public function get($p)
    {
        $ret['s'] = 'OK';
        $t = new CassandraCF('mall', 'UserItem', true);
        $id = $p['u'];
        $ret['d'] = $t->get($id);
        return $ret;
    }
}
//return;
$p = array('u' => '2', 'd' => array('id' => 'testid', 'first' => 'Zeng', 'last' => 'tingkun', 'addr' => array('city' => 'beijing', 'zip' => '123456')));
print_r($p);
$t = new Test();
record_time($start);
print_r($t->put($p));
record_time($start, '$t->put($p)');
$p['d']['id'] = '';
$p['d']['info'] = 'with no id';
print_r($t->put($p));
print_r($t->get($p));
record_time($start, '$t->get($p)');
예제 #11
0
파일: test_load.php 프로젝트: uning/system
<?php

require_once 'StatClient.php';
function record_time(&$start, $usage = "", $unit = 0)
{
    $end = microtime(true);
    $cost = $end - $start;
    $cost = ceil(1000000 * $cost);
    if ($unit > 0) {
        $cost = ceil($cost / $unit);
    }
    if ($usage) {
        echo "{$usage} use time {$cost} us\n";
    }
    $start = $end;
}
$data['m'] = 100;
$data['s'] = "dfdsl\n \r dfdf";
$data['dff'] = 'dfd';
record_time($st);
$num = 1;
for ($i = 0; $i < $num; $i += 1) {
    $data['tm'] = time();
    $data['indx'] = $i;
    StatClient::record($data);
}
record_time($st, 'put ' . $num);
예제 #12
0
파일: test.php 프로젝트: uning/mall-back
 static function testTTUDB()
 {
     $u = 1001;
     $tn = new TTUDB($u);
     $group = 'g1';
     $now = time();
     record_time($st);
     $data_with_noid = array('me' => 'im $data_with_noid', 'oth' => array('dffd', 'dfd'));
     $data_with_noid['tm'] = $now;
     $tn->puto($data_with_noid, 'group');
     print_r($data_with_noid);
     record_time($st, 'print_r($data_with_noid);');
     print_r($tn->get());
     record_time($st, '$tn->get()');
     print_r($tn->getbyid($data_with_noid['id']));
     record_time($st, '$tn->getbyid($data_with_noid["id"])');
     print_r($tn->getbyids(array($data_with_noid['id'])));
     record_time($st, '$tn->getbyids(array($data_with_noid["id"]))');
     $data_with_id['id'] = $data_with_noid['id'];
     $data_with_id['new'] = 'im new field';
     $data_with_id['me'] = 'im new field';
     print_r($data_with_id);
     $tn->puto($data_with_id, 'g');
     print_r($data_with_id);
     record_time($st, '$tn->puto($data_with_id,$u,\'g\',$t)');
     print_r($tn->getbyid($data_with_noid['id']));
     record_time($st, '$tn->getbyid($data_with_noid["id"],$u)');
     $data_with_id = array();
     $data_with_id['id'] = $data_with_noid['id'];
     $data_with_id['new'] = 'im new field nokeep';
     $data_with_id['me'] = 'im new field nokeep';
     $tn->puto($data_with_id, 'g', false);
     print_r($data_with_id);
     record_time($st, '$tn->puto($d:wata_with_id,$u,\'g\',$t,false)');
     //for field
     $tn->numch("money");
     $tn->numch("gem");
     record_time($st, '$tn->numch("money")');
     record_time($st, '$tn->getf("money")=' . print_r($tn->getf($u, "money"), true));
     record_time($st, '$tn->getf(array("money"))=' . print_r($tn->getf(array("money")), true));
     record_time($st, '$tn->getf()=' . print_r($tn->getf(), true));
     $pair['k1'] = 'v1';
     $pair['k2'] = 'v2';
     $pair['k3'] = 'v3';
     $tn->mputf($pair);
     $tn->putf('putf', 'i am insert by putf');
     record_time($st, ' put pair');
     record_time($st, '$tn->numch("money")');
     record_time($st, '$tn->getf("money")=' . print_r($tn->getf("money")));
     record_time($st, '$tn->getf(array("money"))=' . print_r($tn->getf(array("money"))));
     record_time($st, '$tn->getf(array("putf","money"))=' . print_r($tn->getf(array("money", 'putf'))));
     record_time($st, '$tn->getf($u)=' . print_r($tn->getf($u)));
     $data = array('me' => 'im in a array');
     $data['index'] = count($datas);
     $datas[] = $data;
     $data['index'] = count($datas);
     $datas[] = $data;
     $data['index'] = count($datas);
     $datas[] = $data;
     record_time($st, '$tn->mputo($datas,$u)=' . print_r($tn->mputo($datas, 'new_group')));
     record_time($st, '$tn->getf($u,new_group)=' . print_r($tn->get('new_group')));
     for ($i = 1; $i < 11; $i++) {
         $achieve = array();
         $achieve['tag'] = $i;
         $achieve['is_done'] = '0';
         $achieve['finish_num'] = '0';
         $tn->puto($achieve, TT::ACHIVE_GROUP);
         $ret['ac'][] = $achieve;
     }
     $str = '$tn->getAll()';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
     print_r($tn->get(TT::ACHIVE_GROUP));
     $str = '$tn->numch("newdd")';
     echo "{$str}=";
     eval('print_r(  ' . $str . ');');
     echo "\n";
 }