本文整理汇总了PHP中tools::writeCache方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::writeCache方法的具体用法?PHP tools::writeCache怎么用?PHP tools::writeCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::writeCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SUM
}
}
$result['Auction'] = $auction;
// writing data to the application cache
if (!empty($_GET['histories'])) {
$auction = tools::writeCache('auction_view_' . $value, $result);
} else {
$auction = tools::writeCache('auction_' . $value, $result);
}
}
$result['User_id'] = $user_id;
if (!empty($user_id)) {
$balance = tools::readCache('bids_balance_' . $user_id);
if (empty($balance)) {
$balance = database::getInstance()->getRow("SELECT SUM(credit) - SUM(debit) AS balance FROM " . DB_PREFIX . "bids WHERE user_id = {$user_id}");
tools::writeCache('bids_balance_' . $user_id, $balance);
}
$result['Balance'] = $balance['balance'];
}
$result['Auction']['price'] = $result['Auction']['price'];
$result['Auction']['serverTimestamp'] = time();
$result['Auction']['serverTimeString'] = date('d-m-Y, H:i:s');
$result['Auction']['time_left'] = strtotime($result['Auction']['end_time']) - time();
if ($result['Auction']['time_left'] <= 0 && $result['Auction']['closed'] == 0) {
$result['Auction']['time_left'] = 1;
}
if ($site_online == 'no') {
$result['Auction']['isPeakNow'] = 0;
$result['Auction']['peak_only'] = 1;
} else {
$result['Auction']['isPeakNow'] = $isPeakNow;
示例2: getUserInfos
private function getUserInfos()
{
if (isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) {
$isOnline = tools::readCache('user_count_' . $_SESSION['user_id']);
if (!empty($isOnline)) {
tools::deleteCache('user_count_' . $_SESSION['user_id']);
tools::writeCache('user_count_' . $_SESSION['user_id'], $_SESSION['user_id'], 300);
} else {
tools::writeCache('user_count_' . $_SESSION['user_id'], $_SESSION['user_id'], 300);
}
$balance = $this->db->select("fetch", "bids", "SUM(credit) - SUM(debit) AS total", array("user_id" => $_SESSION['user_id']));
$this->user['balance'] = $balance['total'];
}
}
示例3: login
function login()
{
if (isset($_SESSION['user_id'])) {
tools::redirect('/account');
}
if (!empty($_POST)) {
$data = tools::filter($_POST);
$user = $this->user->getByUsername($data['username']);
if (!$user) {
tools::setFlash($this->l('Username does not exist'), 'error');
tools::redirect('/user/login');
} else {
if ($user['active'] == 0) {
tools::setFlash($this->l('Account not active'), 'error');
tools::redirect('/user/login');
} else {
// php >= 5.6 -> if (hash_equals($user['ppasswd'], crypt($data['password'], $user['ppasswd']))) {
if (password_verify($data['password'], $user['ppasswd'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $data['username'];
if ($user['admin'] == 1) {
$_SESSION['admin'] = true;
}
// increment online users number
tools::writeCache('user_count_' . $user['id'], $user['id'], 300);
// log access
$this->user->logAccess();
// if account not completed redirect to form
if (empty($user['firstname'])) {
tools::setFlash($this->l('Please complete your profile'), 'error');
tools::redirect('/user/edit');
} else {
tools::setFlash($this->l('Logged in successfully'), 'success');
tools::redirect('/account');
}
} else {
tools::setFlash($this->l('Wrong password'), 'error');
//tools::redirect('/user/login');
}
}
}
}
$this->smarty->display('user/login.tpl');
}
示例4: get
$data['price_increment'] = get('price_increment', $data['auction_id'], 0);
$data['time_increment'] = get('time_increment', $data['auction_id'], 0);
$result = bid($data);
}
}
}
}
sleep(4);
}
tools::deleteCache('autobid.pid');
break;
case 'close':
if (tools::readCache('close.pid')) {
return false;
} else {
tools::writeCache('close.pid', microtime(), 50);
}
$db = database::getInstance();
$isPeakNow = tools::isPeakNow();
$expireTime = time() + 60;
while (time() < $expireTime) {
$sql = "SELECT id, peak_only, end_time FROM " . DB_PREFIX . "auctions WHERE end_time <= '" . date('Y-m-d H:i:s') . "' AND closed=0 AND active=1 AND status_id=3";
if ($res = $db->getRows($sql)) {
if (sizeof($res) > 0) {
foreach ($res as $auction) {
if (checkCanClose($auction['id'], $isPeakNow) == false) {
if ($auction['peak_only'] == 1 && !$isPeakNow) {
$peak = tools::isPeakNow(true);
if (strtotime($peak['peak_start']) < time()) {
$peak['peak_start'] = date('Y-m-d H:i:s', strtotime($peak['peak_start']) + 86400);
}