public function setOrder($order_by, $order) { $this->plist = NULL; if ($order_by == 'ac') { if ($order != 'asc') { $order = 'desc'; } $key = 'user_list_' . $order_by . '_' . $order . '_' . $this->getCurrentPage(); $cache = MDL_Cache::getInstance(); if (!isset($cache->{$key})) { $sql = 'select `user_id` from ' . DB_TABLE_USER; $db = BFL_Database::getInstance(); $stmt = $db->factory($sql); $stmt->execute(); $user_records = array(); while ($user = $stmt->fetch()) { $user_records[] = new MDL_User_Record(new MDL_User($user['user_id'])); } $this->tmp_order = $order; usort($user_records, array($this, 'cmpByAccepted')); unset($this->tmp_order); $users = array(); foreach ($user_records as $user_record) { $users[] = $user_record->getUser(); } $cache->{$key} = $users; } $users = $cache->{$key}; $this->plist = $this->separatePage($users); } }
public function getRecords() { if ($this->records === NULL) { $user_id = $this->getUser()->getID(); $cache_key = 'user_records_' . $user_id; $cache = MDL_Cache::getInstance(); if (!isset($cache->{$cache_key})) { $db = BFL_Database::getInstance(); $stmt = $db->factory('select `record_id` from ' . DB_TABLE_RECORD . ' where `record_user_id`=:user_id'); $stmt->bindValue(':user_id', $user_id); $stmt->execute(); $records = array(); while ($rs = $stmt->fetch()) { $records[] = new MDL_Record($rs['record_id'], MDL_Record::GET_ALL); } $cache->{$cache_key} = $records; } $records = $cache->{$cache_key}; $this->records = $records; } return $this->records; }
<?php $this->title = '首页'; $this->display('header.php'); ?> <div style="padding:10px; margin:10px;"> <?php $cache = MDL_Cache::getInstance(); if (isset($cache->index_page)) { $contents = $cache->index_page; } else { $contents = BFL_HTTP::fetch("http://code.google.com/p/vakuum-oj/"); preg_match('/<div id="wikicontent" style="padding:0 3em 1.2em 0">(.+?)<\\/div>/ies', $contents, $match); $contents = str_replace('¶', '', $match[0]); $cache->set('index_page', $contents, 3600); } echo $contents; ?> </div> <?php $this->display('footer.php');