function get($name = null, $auction_id = null, $cache = true) { $db = Database::getInstance(); if ($cache == true) { $setting = tools::readCache($name . '_setting'); if (!empty($setting)) { return $setting; } else { $setting = $db->getRow("SELECT value FROM " . DB_PREFIX . "settings WHERE name = '{$name}'"); if (!empty($setting)) { return $setting['value']; } else { return false; } } } $increments = $db->getRow("SELECT * FROM " . DB_PREFIX . "increments WHERE auction_id = {$auction_id}"); return $increments[$name]; }
$bid_histories_result[] = $bid_history; } $result['Histories'] = $bid_histories_result; } } $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;
function get_online_users() { $dir = _DIR_ . '/data/'; $files = scandir($dir); $count = 0; foreach ($files as $filename) { if (is_dir($dir . $filename)) { continue; } if (substr($filename, 0, 11) == 'user_count_') { $isOnline = tools::readCache($filename); if (!empty($isOnline)) { $count++; } else { tools::deleteCache($filename); } } } return $count; }
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']; } }
$data['user_id'] = $row['user_id']; $data['autobid'] = $row['id']; $data['bid_debit'] = get('bid_debit', $data['auction_id'], 0); $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);