예제 #1
0
 public function query($sql)
 {
     $cache_time = $this->cache_time;
     if ($cache_time > 0) {
         if (cache_exists($sql, $cache_time, CACHE_SELECT_PATH)) {
             $this->opt_reset();
             //查询参数初始化
             return cache_get($sql, CACHE_SELECT_PATH);
         }
     }
     if (!$this->exe($sql)) {
         return false;
     }
     $list = array();
     if (!$this->lastquery) {
         return false;
     }
     while (($res = $this->fetch()) != false) {
         $list[] = $res;
     }
     if ($cache_time > 0) {
         cache_set($sql, $list, $cache_time, CACHE_SELECT_PATH);
     }
     return $list ? $list : false;
 }
예제 #2
0
function unyaml($file)
{
    static $yaml = false;
    if ($_SERVER['HTTP_HOST'] != 'localhost:8000') {
        if (cache_exists($file)) {
            return read_cache($file);
        }
    }
    if (!$yaml) {
        $yaml = new sfYamlParser();
    }
    $data = $yaml->parse(file_get_contents($file));
    $data = fix_comments($data);
    write_cache($file, $data);
    return $data;
}
예제 #3
0
 function menuList()
 {
     if (cache_exists('menu')) {
         return cache_get('menu');
     }
     $menu = array();
     $menu = $this->oneLevelMenu();
     $menu_nums = count($menu);
     for ($i = 0; $i < $menu_nums; $i++) {
         $menu[$i]['two_level'] = $this->twoLevelMenu($menu[$i]['id']);
         $two_menu_nums = count($menu[$i]['two_level']);
         for ($j = 0; $j < $two_menu_nums; $j++) {
             if ($menu[$i]['two_level'][$j]['id']) {
                 $menu[$i]['two_level'][$j]['three_level'] = $this->twoLevelMenu($menu[$i]['two_level'][$j]['id'], 3);
             }
         }
     }
     cache_set('menu', $menu);
     return $menu;
 }
예제 #4
0
 public function query($sql)
 {
     $cache_time = $this->cache_time;
     if ($cache_time > 0) {
         if (cache_exists($sql, $cache_time, CACHE_SELECT_PATH)) {
             $this->opt_reset();
             //查询参数初始化
             return cache_get($sql, CACHE_SELECT_PATH);
         }
     }
     if (!$this->exe($sql)) {
         return false;
     }
     if (!$this->lastquery) {
         return false;
     }
     $list = array();
     $list = $this->lastquery->fetch(PDO::FETCH_ASSOC);
     $this->result_free();
     if ($cache_time > 0) {
         cache_set($sql, $list, $cache_time, CACHE_SELECT_PATH);
     }
     return $list ? $list : false;
 }
예제 #5
0
function regenerate_cache($Page)
{
    // Regenerate the cache of a page if it's expired
    if ($Page != "" && (isset($GLOBALS[b('Q2hlY2tWZXJzaW9u')]) && $GLOBALS[b('Q2hlY2tWZXJzaW9u')] == true)) {
        $cache_time = ISC_CACHE_TIME;
        $cache_folder = ISC_CACHE_FOLDER;
        $cache_order = ISC_CACHE_ORDER;
        $cache_user = ISC_CACHE_USER;
        $cache_data = $cache_time . $cache_folder . $cache_order . $cache_user;
        // Can we regenerate the cache?
        if (!cache_exists($cache_data)) {
            $cache_built = true;
        }
    }
}
예제 #6
0
/**
 * Overview Items Status, Furasta.Org
 *
 * This file is accessed by AJAX and it
 * changes the status of an overview item,
 * ie open or closed.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 * @package    admin_overview
 */
$id = @$_GET['id'];
$status = @$_GET['status'];
if ($id == '' || $status == '') {
    die('1');
}
$array = array($id => $status);
$cache_file = 'FURASTA_OVERVIEW_ITEMS_STATUS_' . $_SESSION['user']['id'];
if (cache_exists($cache_file, 'DB_USERS')) {
    $items = json_decode(cache_get($cache_file, 'DB_USERS'), true);
    if (array_key_exists($id, $items)) {
        $items[$id] = $status;
        $array = $items;
    } else {
        $array = array_merge($array, $items);
    }
}
cache($cache_file, json_encode($array), 'DB_USERS');
die('0');
예제 #7
0
<?php

/**
 * JS Load, Furasta.Org
 *
 * This file loads multiple Javascript files, caches them,
 * compresses them, gzips them (if possible) and
 * advises the browser as to how long to keep a
 * client side cache.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 */
require '../../.settings.php';
require '../function/cache.php';
$cache_file = $_SERVER['QUERY_STRING'];
if ($cache_file == '' || strpos($cache_file, '..') !== false) {
    die('hash cannot be blank, or contain ".." for security reasons.');
}
header('Content-type: text/javascript; charset: UTF-8');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + '35000000') . ' GMT');
header('Cache-Control: public, max-age=35000000');
if (cache_exists($cache_file, 'JS')) {
    echo cache_get($cache_file, 'JS');
}
ob_end_flush();
예제 #8
0
 /**
  * order 
  * 
  * Re-orders the $items array according to
  * a cached order file.
  *
  * @access public
  * @return bool
  */
 function order()
 {
     $items = $this->items;
     $cache_file = 'FURASTA_OVERVIEW_ITEMS_STATUS_' . $_SESSION['user']['id'];
     if (cache_exists($cache_file, 'USERS')) {
         $items_status = json_decode(cache_get($cache_file, 'USERS'));
         foreach ($items as $item => $value) {
             foreach ($items_status as $key => $status) {
                 if ($value['id'] == $key) {
                     $items[$item]['status'] = $status;
                     break;
                 }
             }
         }
     }
     $cache_file = 'FURASTA_OVERVIEW_ITEMS_' . $_SESSION['user']['id'];
     if (cache_exists($cache_file, 'USERS')) {
         $order = json_decode(cache_get($cache_file, 'USERS'), true);
     } else {
         $order = array('1' => array('website-overview', 'recently-trashed'), '2' => array('recently-edited', 'furasta-devblog'));
         cache($cache_file, json_encode($order), 'USERS');
     }
     $ordered = array();
     $num = 0;
     foreach ($order as $key => $value) {
         foreach ($value as $id) {
             $num++;
             foreach ($items as $item => $vals) {
                 if ($vals['id'] == $id) {
                     $ordered[$key][$num] = $vals;
                     unset($items[$item]);
                     break;
                 }
             }
         }
     }
     if (count($items) != 0) {
         for ($i = 0; $i <= count($items) - 1; $i++) {
             $num++;
             if ($i % 2) {
                 $ordered['2'][$num] = $items[$i];
             } else {
                 $ordered['1'][$num] = $items[$i];
             }
         }
     }
     return $this->items = $ordered;
 }
예제 #9
0
 /**
  * 获取联动数据
  * @param type $condition 
  */
 function getCateLinkage($condition = array(), $field = 'laid,title,pid,sort')
 {
     $cache_name = 'LinkageCateData_' . $condition['lcgid'];
     if (!cache_exists($cache_name, NULL, $this->cache_dir . 'linkage')) {
         $data = $this->linkage_model->field($field)->where($condition)->order('lcgid,sort')->findall();
         cache_set($cache_name, $data, NULL, $this->cache_dir . 'linkage');
         return $data;
     } else {
         return cache_get($cache_name, $this->cache_dir . 'linkage');
     }
 }
예제 #10
0
/**
 * cache_exists_image
 *
 * checks if an image cache exists
 *
 * @param string $name
 * @param string $path
 * @return bool
 */
function cache_exists_image($name, $path)
{
    return cache_exists(md5($name), 'IMAGES' . '/' . md5($path));
}
예제 #11
0
        $date = date('Ymd');
        if ($mdate === $date) {
            return true;
        } else {
            return false;
        }
    }
}
function delete_cache($cache_path)
{
    if (file_exists($cache_path)) {
        unlink($cache_path);
    }
}
function create_cache($cache_path, $rss_url)
{
    $rss_data = file_get_contents($rss_url);
    $xml = simplexml_load_string($rss_data);
    $json = json_encode($xml);
    $object = json_decode($json);
    $image_tag = $object->entry[0]->content;
    preg_match('/src="([^"]+)"/', $image_tag, $m);
    $image_url = $m[1];
    file_put_contents($cache_path, file_get_contents($image_url));
}
if (!cache_exists($cache_path)) {
    delete_cache($cache_path);
    create_cache($cache_path, $rss_url);
}
header('Content-Type: image/gif');
echo file_get_contents($cache_path);
예제 #12
0
<?php

/**
 * CSS Load, Furasta.Org
 *
 * This file loads multiple CSS files, caches them,
 * compresses them, gzips them (if possible) and
 * advises the browser as to how long to keep a
 * client side cache.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 */
require '../../.settings.php';
require '../function/cache.php';
$cache_file = $_SERVER['QUERY_STRING'];
if ($cache_file == '' || strpos($cache_file, '..') !== false) {
    die('hash cannot be blank, or contain ".." for security reasons.');
}
header('Content-type: text/css; charset: UTF-8');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + '35000000') . ' GMT');
header('Cache-Control: public, max-age=35000000');
if (cache_exists($cache_file, 'CSS')) {
    echo cache_get($cache_file, 'CSS');
}
ob_end_flush();