当前位置: 首页>>代码示例>>PHP>>正文


PHP cache::o方法代码示例

本文整理汇总了PHP中cache::o方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::o方法的具体用法?PHP cache::o怎么用?PHP cache::o使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache的用法示例。


在下文中一共展示了cache::o方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: count_content

 /**
  * Подсчёт кол-ва контента в данном месяце и в данном году
  * @param int $month данный месяц
  * @param int $year данный год
  * @return string JS массив кол-ва торрентов по дням
  */
 public function count_content($month = null, $year = null)
 {
     $month = !$month ? date("n") : $month;
     $year = !$year ? date("Y") : $year;
     if (!($r = cache::o()->read('calendar/c' . $month . '-' . $year))) {
         $year_after = $month == 12 ? $year + 1 : $year;
         $month_after = $month < 12 ? $month + 1 : 1;
         $from = mktime(null, null, null, $month, 1, $year);
         $to = mktime(null, null, null, $month_after, 1, $year_after);
         $datas = db::o()->p($from, $to)->query('SELECT posted_time FROM content 
             WHERE posted_time BETWEEN ? AND ?');
         //$count = count($datas);
         $content = array();
         while ($data = db::o()->fetch_assoc($datas)) {
             $day = date("j", $data["posted_time"]);
             $content[$day]++;
         }
         $ncontent = "";
         for ($i = 0; $i <= 31; $i++) {
             $ncontent .= ($ncontent !== "" ? ", " : "") . longval($content[$i]);
         }
         $r = array("new Array(" . $ncontent . ")");
         cache::o()->write($r);
     }
     return $r[0];
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:32,代码来源:calendar.php

示例2: __construct

 /**
  * Конструктор категорий
  * @return null
  */
 public function __construct()
 {
     if (!self::$c && (self::$c = cache::o()->read('categories')) === false) {
         self::cats2array();
         cache::o()->write(self::$c);
     }
     tpl::o()->register_modifier("print_cats", array($this, 'print_selected'));
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:12,代码来源:class.categories.php

示例3: init

 /**
  * Инициализация AJAX-части модуля
  * @return null
  */
 public function init()
 {
     lang::o()->get('admin/pages/main');
     if (!users::o()->perm('system')) {
         return;
     }
     $act = $_GET["act"];
     users::o()->admin_mode();
     /* @var $etc etc */
     $etc = n("etc");
     $all = false;
     switch ($act) {
         case "attachments":
             $all = true;
         case "unattachments":
             /* @var $attach attachments */
             $attach = n("attachments");
             $attach->clear(0, $all);
             break;
         case "sitemap":
             $this->sitemap();
             ok();
             break;
         case "cleanup":
             /* @var $cleanup cleanup */
             $cleanup = n("cleanup");
             $cleanup->execute(true);
             break;
         case "cache":
             cache::o()->clear();
             break;
         case "cache_tpl":
             cache::o()->clear_tpl();
             break;
         case "stats":
             $st = stats::o()->read();
             foreach ($st as $s => $v) {
                 stats::o()->write($s, 0);
             }
             break;
         case "logs":
             /* @var $logs logs_man_ajax */
             $logs = plugins::o()->get_module('logs', 1, true);
             $logs->clear();
             break;
         case "peers":
             db::o()->truncate_table('content_peers');
             db::o()->update(array('leechers' => 0, 'seeders' => 0), 'content_torrents');
             break;
         case "downloaded":
             db::o()->truncate_table('content_downloaded');
             db::o()->update(array('downloaded' => 0), 'content_torrents');
             break;
         case "chat":
             /* @var $chat chat */
             $chat = plugins::o()->get_module('chat');
             $chat->truncate();
             break;
         case "pm":
             /* @var $pm messages_ajax */
             $pm = plugins::o()->get_module('messages', false, true);
             $pm->clear();
             break;
         case "ratings":
             $r = db::o()->query('SELECT toid, type FROM ratings GROUP BY toid, type');
             /* @var $rating rating */
             $rating = n("rating");
             while ($row = db::o()->fetch_assoc($r)) {
                 $rating->change_type($row['type'])->clear($row['toid']);
             }
             break;
             // Далее: Важная часть сайта, да
         // Далее: Важная часть сайта, да
         case "content":
             $r = db::o()->query('SELECT id FROM content');
             while (list($id) = db::o()->fetch_row($r)) {
                 try {
                     $etc->delete_content($id);
                 } catch (EngineException $e) {
                 }
             }
             break;
         case "comments":
             /* @var $comments comments */
             $comments = n("comments");
             $comments->clear(null, true);
             break;
         case "polls":
             /* @var $polls polls */
             $polls = n("polls");
             $polls->clear();
             break;
         case "news":
             /* @var $news news_ajax */
             $news = plugins::o()->get_module('news', false, true);
             $news->clear();
//.........这里部分代码省略.........
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:101,代码来源:main.php

示例4: delete

 /**
  * Удаление контента
  * @param int $id ID контента
  * @return null
  * @throws EngineException 
  */
 public function delete($id)
 {
     check_formkey();
     $id = (int) $id;
     $lj = $cols = "";
     if ($this->tstate) {
         $cols = ", t.screenshots";
         $lj = ' LEFT JOIN content_torrents AS t ON t.cid=c.id';
     }
     $row = db::o()->p($id)->query('SELECT c.poster_id, c.title, c.posted_time, 
         p.id AS poll_id ' . $cols . ' FROM content AS c ' . $lj . '
             LEFT JOIN polls AS p ON p.type="content" AND p.toid=c.id
             WHERE c.id=? LIMIT 1');
     list($poster_id, $title, $posted_time, $pid, $screenshots) = db::o()->fetch_row($row);
     if ($row) {
         if (users::o()->v('id') == $poster_id) {
             users::o()->check_perms('del_content');
         } else {
             users::o()->check_perms('del_content', '2');
         }
     } else {
         throw new EngineException('content_not_exists');
     }
     db::o()->p($id)->delete('content', 'WHERE id=? LIMIT 1');
     if ($this->tstate) {
         db::o()->p($id)->delete('content_torrents', 'WHERE cid=? LIMIT 1');
         db::o()->p($id)->delete('content_downloaded', 'WHERE tid=? LIMIT 1');
         db::o()->p($id)->delete('content_peers', 'WHERE tid=? LIMIT 1');
         cache::o()->remove("details/l-id" . $id);
         $this->delete_files($posted_time, $poster_id, $screenshots);
     }
     try {
         plugins::o()->pass_data(array('id' => $id), true)->run_hook('content_delete');
     } catch (PReturn $e) {
         return $e->r();
     }
     db::o()->p($id)->delete('content_readed', 'WHERE content_id=? LIMIT 1');
     /* @var $etc etc */
     $etc = n("etc");
     $etc->add_res('content', -1, '', $poster_id);
     log_add("deleted_content", "user", array($title));
     users::o()->admin_mode();
     n("comments")->change_type('content')->clear($id);
     n("rating")->change_type('content')->clear($id);
     n("mailer")->change_type('content')->remove($id);
     if ($pid) {
         n("polls")->delete($pid);
     }
     users::o()->admin_mode(false);
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:56,代码来源:content.php

示例5: __construct

 /**
  * Конструктор? А где конструктор? А нет его.
  * @return null 
  */
 private function __construct()
 {
     if (!class_exists('cache')) {
         return;
     }
     $this->cached = cache::o()->read(self::cachefile);
     if ($this->cached === false) {
         cache::o()->pop_readed();
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:14,代码来源:class.file.php

示例6: write_session

 /**
  * Инициализация сессии пользователя
  * @return null
  */
 public function write_session()
 {
     if (!cache::o()->query_delay('usessions', config::o()->v('delay_userupdates'))) {
         return;
     }
     $ip = $this->get_ip();
     $url = $_SERVER['REQUEST_URI'];
     $ctime = time();
     $agent = $_SERVER["HTTP_USER_AGENT"];
     if (!$this->vars) {
         $uid = 0;
         $userdata = '';
     } else {
         $uid = $this->vars['id'];
         $userdata = array('username' => $this->vars['username'], 'group' => $this->vars['group'], 'hidden' => $this->vars['hidden'], 'useragent' => $agent, 'url' => $url);
         if ($this->vars['bot']) {
             $userdata['bot'] = true;
             $this->vars = array();
         }
         $userdata = serialize($userdata);
     }
     //$past = time() - 300;
     $sid = session_id();
     $updateset = array("sid" => $sid, "uid" => $uid, "userdata" => $userdata, "ip" => $ip, "time" => $ctime);
     $users_updateset = array("ip" => $ip, "last_visited" => time());
     try {
         plugins::o()->pass_data(array('update_sess' => &$updateset, 'update_user' => &$users_updateset), true)->run_hook('users_sessions');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($this->vars) {
         db::o()->p($uid)->update($users_updateset, "users", "WHERE id=? LIMIT 1");
     }
     db::o()->p($sid)->update($updateset, "sessions", "WHERE sid=? LIMIT 1");
     if (db::o()->affected_rows() < 1) {
         db::o()->insert($updateset, "sessions");
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:42,代码来源:class.users.php

示例7: die

if (!defined('INSITE')) {
    die("Remote access denied!");
}
$allowed = "acp_modules";
$allowed_admin_pages = "acp_pages";
if (!($admin_modules = cache::o()->read('admin_modules'))) {
    $admin_modules = array();
    $r = db::o()->query('SELECT ai.name AS ai_name, ac.name AS ac_name, am.name AS am_name, am.link 
    FROM admin_items AS ai 
    LEFT JOIN admin_cats AS ac ON ac.item=ai.id
    LEFT JOIN admin_modules AS am ON am.cat=ac.id
    ORDER BY am.id');
    while ($row = db::o()->fetch_assoc($r)) {
        $admin_modules[$row['ai_name']][$row['ac_name']][$row['am_name']] = $row['link'];
    }
    cache::o()->write($admin_modules);
}
users::o()->check_perms('acp');
$item_mainpage = false;
/**
 * Узнаём, в какой вкладке сейчас находимся
 */
if ($_GET['item'] && $admin_modules[$_GET['item']]) {
    $item = $_GET['item'];
    $item_mainpage = true;
} else {
    $item = "main";
    $item_mainpage = true;
}
/**
 * Узнаём, какой модуль затребован
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:31,代码来源:index.php

示例8: delete

 /**
  * Удаление новости
  * @param int $id ID новости
  * @return null
  * @throws EngineException 
  */
 public function delete($id)
 {
     $id = (int) $id;
     check_formkey();
     list($pid, $title) = db::o()->fetch_row(db::o()->p($id)->query('SELECT poster_id, title FROM news
             WHERE id=? LIMIT 1'));
     if ($pid) {
         if (users::o()->v('id') == $pid) {
             users::o()->check_perms('del_news');
         } else {
             users::o()->check_perms('del_news', '2');
         }
     } else {
         throw new EngineException('news_are_not_exists');
     }
     db::o()->p($id)->delete('news', 'WHERE id=? LIMIT 1');
     cache::o()->remove('news');
     log_add("deleted_news", "user", array($title));
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:25,代码来源:news.php

示例9: parse

 /**
  * Парсинг таблицы конвертации
  * @param int $toffset позиция таблицы для конвертации
  * @param int $loffset позиция значений
  * @return null
  */
 private function parse($toffset = 0, $loffset = 0)
 {
     $toffset = (int) $toffset;
     $loffset = (int) $loffset;
     if (!$toffset && !$loffset) {
         $this->truncate_tables();
     }
     @mb_internal_encoding('UTF-8');
     $a = array();
     $finish = "<script type='text/javascript'>continue_convert(0, 0, true);</script>";
     $cachefile = 'convert/cparse-off' . $toffset;
     if (!($a = cache::o()->read($cachefile))) {
         $content = $this->convert_tables();
         $tpos = utf8_preg_offset($content, $toffset, true);
         $c = preg_match_all('/(^)\\s*?(\\@?)table\\s+(\\w+)\\/([\\w\\s,]+?)(?:\\s*?\\:\\s*?(\\w+))?(?:\\s*?\\?(.*?))?\\s*?($)/miu', $content, $matches, PREG_OFFSET_CAPTURE, $tpos);
         $i = 0;
         if (!$matches) {
             die($finish);
         }
         $noerr = $matches[2][$i][0];
         $table = $matches[3][$i][0];
         $orderby = $matches[4][$i][0];
         $ftable = $matches[5][$i][0];
         if (!$ftable) {
             $ftable = $table;
         }
         $cond = trim($matches[6][$i][0]);
         $pos = utf8_preg_offset($content, $matches[7][$i][1]);
         $i++;
         if ($matches[1][$i]) {
             $ntoffset = utf8_preg_offset($content, $matches[1][$i][1]);
             $len = $ntoffset - $pos;
         }
         $data = trim($len ? mb_substr($content, $pos, $len) : mb_substr($content, $pos));
         $this->parse_columns($data);
         $a = array($table, $orderby, $ftable, $cond, $ntoffset, $this->columns, $this->insert, $noerr);
         cache::o()->write($a, $cachefile);
     } else {
         list($table, $orderby, $ftable, $cond, $ntoffset, $this->columns, $this->insert, $noerr) = $a;
     }
     $s = $this->select4insert($table, $orderby, $ftable, $cond, $loffset, $noerr);
     $c = db::o()->prepend_db($this->db)->no_parse()->no_prefix()->count_rows($this->prefix . $ftable, $cond);
     if ($c <= $loffset + $this->peronce || !$s) {
         if (!$ntoffset) {
             die($finish);
         } else {
             die("<script type='text/javascript'>continue_convert(" . $ntoffset . ", '0');</script>");
         }
     } else {
         die("<script type='text/javascript'>continue_convert(" . $toffset . ", " . ($loffset + $this->peronce) . ");</script>");
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:58,代码来源:convert.php

示例10: uncache

 /**
  * Очистка кеша
  * @param int $id ID опроса
  * @param bool $onvotes очистка при голосовании?
  * @return null 
  */
 protected function uncache($id, $onvotes = false)
 {
     if ($onvotes && !config::o()->v('clearonvote_pollcache')) {
         return;
     }
     cache::o()->remove('polls/v-id' . $id);
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:13,代码来源:class.polls.php

示例11: parse_pattern

 /**
  * Парсинг шаблона
  * @param int $id ID шаблона
  * @return array массив данного шаблона
  */
 protected function parse_pattern($id)
 {
     $id = (int) $id;
     if (!($row = cache::o()->read('patterns/pattern-id' . $id))) {
         $r = db::o()->p($id)->query('SELECT * FROM patterns WHERE id=? LIMIT 1');
         $row = db::o()->fetch_assoc($r);
         if (!$row) {
             return;
         }
         $row['pattern'] = unserialize($row['pattern']);
         foreach ($row['pattern'] as $k => $e) {
             if ($e['type'] == 'radio' || $e['type'] == 'select') {
                 $vals =& $e['values'];
                 $vals = explode(';', $vals);
                 $c = count($vals);
                 for ($i = 0; $i < $c; $i++) {
                     $vals[$i] = trim($vals[$i]);
                     $p = mb_strpos($vals[$i], ':');
                     if (!$p) {
                         continue;
                     }
                     $f = mb_substr($vals[$i], 0, $p);
                     $s = mb_substr($vals[$i], $p + 1);
                     $vals[$i] = array(trim($f), trim($s));
                 }
             }
             $fd =& $e['formdata'];
             $r = preg_split('/^\\{form\\.([a-z0-9\\_\\-]+)\\}/msiu', $fd, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
             $fd = array();
             $c = count($r);
             $key = null;
             for ($i = 0; $i < $c; $i++) {
                 if ($i % 2 == 0) {
                     $key = $r[$i];
                 } else {
                     $fd[$key] = preg_replace('/\\{this\\.\\$value\\}/siu', '{this.' . $e['rname'] . '}', $r[$i]);
                 }
             }
             $row['pattern'][$k] = $e;
         }
         cache::o()->write($row);
     }
     return $row;
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:49,代码来源:ajax_index.php

示例12: delete

 /**
  * Удаление шаблона
  * @param int $id ID шаблона
  * @return null
  */
 public function delete($id)
 {
     $id = (int) $id;
     db::o()->p($id)->delete('patterns', 'WHERE id=? LIMIT 1');
     cache::o()->remove('patterns/pattern-id' . $id);
     log_add('deleted_pattern', 'admin', $id);
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:12,代码来源:patterns.php

示例13: o

 /**
  * Получение объекта класса
  * @return cache $this
  */
 public static function o()
 {
     if (!self::$o) {
         self::$o = new self();
     }
     return self::$o;
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:11,代码来源:class.cache.php

示例14: init

 /**
  * Инициализация AJAX-части модуля
  * @return null
  */
 public function init()
 {
     $act = $_GET["act"];
     $id = (int) $_POST["id"];
     switch ($act) {
         case "edit":
             $this->edit($id);
             break;
         case "delete":
             $this->delete($id);
             break;
         case "switch":
             $this->switch_state((int) $_POST['id']);
             break;
         case "order":
             $this->save_order($_POST['smilieid']);
             break;
     }
     cache::o()->remove('smilies');
     ok();
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:25,代码来源:smilies.php

示例15: config

 /**
  * Настройка сайта
  * @param array $data массив данных
  * @param array $error массив ошибок
  * @return null
  */
 protected function config($data, &$error)
 {
     include_once ROOT . 'include/classes/class.cache.php';
     include_once ROOT . 'include/classes/class.users.php';
     include_once ROOT . 'include/classes/class.config.php';
     cache::o()->clear();
     $params = array('site_title', 'baseurl', 'contact_email', 'furl', 'cache_on');
     $upd = rex($data, $params);
     // предустановка параметров, если не заданы
     if (!$upd['baseurl']) {
         $upd['baseurl'] = preg_replace('/^(.*)(\\/|\\\\)(.*?)$/siu', '\\1', $_SERVER['PHP_SELF']);
     }
     if (!$upd['contact_email']) {
         $upd['contact_email'] = 'admin@' . $_SERVER['SERVER_NAME'];
     }
     if (!isset($data['furl'])) {
         $upd['furl'] = (bool) $_SERVER['HTTP_FURL_AVALIABLE'];
     } else {
         $upd['furl'] = (bool) $upd['furl'];
     }
     if (!isset($data['cache_on'])) {
         $upd['cache_on'] = true;
     } else {
         $upd['cache_on'] = (bool) $upd['cache_on'];
     }
     $upd['secret_key'] = users::o()->generate_salt();
     foreach ($upd as $k => $v) {
         config::o()->set($k, $v);
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:36,代码来源:main.php


注:本文中的cache::o方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。