Esempio n. 1
0
 protected function setCache(Container $di, $cacheConfig, $basePath)
 {
     foreach ($cacheConfig as $key => $value) {
         \phpFastCache::setup($key, $value);
     }
     \phpFastCache::setup("path", $basePath . "/var/cache");
     $di->set("cache", $di->lazyNew('phpFastCache'));
 }
Esempio n. 2
0
 /**
  * is existing?
  */
 public static function is($keyword, $nousercache = 0)
 {
     if ($nousercache == 0) {
         return self::$cache->isExisting($keyword . SessionAccountHandler::getId());
     } else {
         return self::$cache->isExisting($keyword);
     }
 }
Esempio n. 3
0
 public function _initCache()
 {
     //$servers = array();
     $cacheCfg = $this->_config->memcached->config;
     $servers = $cacheCfg->toArray();
     if (!empty($servers)) {
         phpFastCache::$storage = "auto";
         $cache = __c($cacheCfg->type);
         $server = array(array($cacheCfg->host, $cacheCfg->port, $cacheCfg->timeout));
         $cache->option("server", $server);
         Registry::set("cache", $cache);
     }
 }
Esempio n. 4
0
 /**
  * Constructor
  */
 function __construct($prefix = 'index.php?')
 {
     global $base_dir, $_SERVER;
     phpFastCache::setup('storage', 'files');
     phpFastCache::setup('path', $base_dir);
     phpFastCache::setup('securityKey', 'cache');
     $this->cache = phpFastCache();
     $this->id = $_SERVER['QUERY_STRING'];
     if ($this->id == '') {
         $this->id = 'mod=home';
     }
     $this->id = $this->prefix . $this->id;
 }
Esempio n. 5
0
 public function SSLForwardJS()
 {
     $ip = $this->getRealIP();
     if (!class_exists("phpFastCache")) {
         die("Please required phpFastCache Class");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
         $data = file_get_contents($url);
         phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
Esempio n. 6
0
 public function testAction()
 {
     phpFastCache::$storage = "auto";
     $cache = __c("memcache");
     $server = array(array("192.168.10.122", 11211, 100));
     $cache->option("server", $server);
     $cache->keyword = array("something here++++++++++++++++_________", 600);
     //        var_dump($cache->get("31lh9kj9cs3627fauu90njuj26"));
     var_dump($cache->keyword);
     $excel = new CreateExcel();
     //        $excel->setHeader('高子航' . date('Y年m月d日 H:i:s', time()));
     //        $excel->setTitle(array( '高子航'));
     //        $excel->setData(array());
     //        $excel->echoExcel('show_' . date('Y_m_d_H_i_s', time()));
     die;
 }
 public function result()
 {
     if ($this->on_cache == true) {
         require $this->path . '/phpfastcache/phpfastcache.php';
         phpFastCache::setup("storage", "auto");
         phpFastCache::setup('path', $this->path . '/phpfastcache/cache/');
         $cache = phpFastCache();
         $this->data = $cache->get($this->key_cache);
         if ($this->data == null) {
             $this->data = $this->get_direct();
             $cache->set($this->key_cache, $this->data, 86400);
         }
     } else {
         $this->data = $this->get_direct();
     }
     return $this->data;
 }
Esempio n. 8
0
 function phpFastCache($storage = "auto", $config = array())
 {
     $storage = strtolower($storage);
     if (empty($config)) {
         $config = phpFastCache::$config;
     }
     if ($storage == "" || $storage == "auto") {
         $storage = phpFastCache::getAutoClass($config);
     }
     $instance = md5(json_encode($config) . $storage);
     if (!isset(phpFastCache_instances::$instances[$instance])) {
         $class = "phpfastcache_" . $storage;
         phpFastCache::required($storage);
         phpFastCache_instances::$instances[$instance] = new $class($config);
     }
     return phpFastCache_instances::$instances[$instance];
 }
Esempio n. 9
0
 public function SSLForwardJS()
 {
     $ip = $this->getRealIP();
     if (!class_exists("phpFastCache")) {
         die("<div style='border: 2px solid #09f; font-size: .8em; font-family: Arial;background: #FCF0F0;border: 2px solid #F07272;padding: 10px;'>Please enable plugin <b>Cache</b> to run plugin <b>Statistic</b>!</div>");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $ctx = stream_context_create(array('http' => array('timeout' => 0.5)));
         $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
         $json = file_get_html($url);
         phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
Esempio n. 10
0
 public function __construct()
 {
     $system = CoreLoader::$system;
     date_default_timezone_set($system['default_timezone']);
     $this->registerErrorHandle();
     $this->router = CoreInput::$router;
     $this->input = new CoreInput();
     $this->model = new CoreModelLoader();
     $this->lib = new CoreLibLoader();
     $this->rule = new CoreRule();
     $this->cache = phpFastCache::getInstance($system['cache_config']['storage'], $system['cache_config']);
     if ($system['autoload_db']) {
         $this->database();
     }
     if (!empty($system['language'])) {
         self::$locale = new CoreLocale($system['language']);
     }
     Fn::stripslashes_all();
 }
Esempio n. 11
0
 public function getLocation($ip = "")
 {
     if ($ip == "") {
         $ip = $this->getRealIP();
     }
     if (!class_exists("phpFastCache")) {
         die("Please required phpFastCache Class");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $url = "http://api.codehelper.io/ips/?php&ip=" . $ip;
         $json = file_get_contents($url);
         $data = json_decode($json, true);
         phpFastCache::set("codehelper_ip_" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
Esempio n. 12
0
<?php

include 'config.php';
require "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
phpFastCache::setup("path", dirname(__FILE__) . '/cache');
// Path For Files
//User Whitelist Check
if (!in_array($username, $user_whitelist)) {
    echo "Clever girl... But you're not on the list. <a href='http://goo.gl/forms/0wgJeVpIaI'>Request Access</a>";
    exit;
}
// Set Caching
$cache = phpFastCache();
// Try to get $content from Caching First
// product_page is "identity keyword";
$link = $cache->get($username);
if ($link == null) {
    $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
    $content = $connection->get(API_KIND, array("screen_name" => $username, "count" => intval(POSTS_COUNT)));
    if (empty($content->errors)) {
        //All is dandy
        foreach ($content as $tweet_object) {
            $urls = $tweet_object->entities->urls;
            //Get URLS
            foreach ($urls as $url) {
                //$debug = $url->expanded_url;
                if (strpos($url->display_url, 'periscope.tv') !== false) {
                    //Find periscope link
                    $link = $url->expanded_url;
                }
function updatecaching()
{
    global $ts;
    $conn = 1;
    $errorCode = 0;
    $memcacheAuth = 0;
    include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
    if ($_POST['MC_NAME'] == 'memcachier') {
        $memcacheAuth = 1;
        $conn = 0;
        $memcache = new MemcacheSASL();
        $memcache->addServer($_POST['MC_SERVER'], $_POST['MC_PORT']);
        if ($memcachierAuth = $memcache->setSaslAuthData($_POST['MC_USERNAME'], $_POST['MC_PASSWORD'])) {
            $memcache->set('auth', 'ok');
            if (!($conn = $memcache->get('auth'))) {
                $errorCode = 3;
            }
            $memcache->delete('auth');
        } else {
            $errorCode = 3;
        }
    } elseif ($_POST['MC_NAME'] != '') {
        $conn = 0;
        $memcacheAuth = 1;
        phpFastCache::setup("storage", $_POST['MC_NAME']);
        $memcache = new phpFastCache();
        $driverPresent = isset($memcache->driver->option['availability']) ? 0 : 1;
        if ($driverPresent) {
            if ($_POST['MC_NAME'] == 'memcache') {
                $server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
                $memcache->option('server', $server);
            }
            $memcache->set('auth', 'ok', 30);
            if (!($conn = $memcache->get('auth'))) {
                $errorCode = 1;
            }
            $memcache->delete('auth');
        }
    }
    if ($conn && !$errorCode) {
        $data = 'define(\'MEMCACHE\',\'' . $memcacheAuth . '\');' . "\r\n";
        $data .= 'define(\'MC_SERVER\',\'' . $_POST['MC_SERVER'] . '\');' . "\t// Set name of your memcache  server\r\n";
        $data .= 'define(\'MC_PORT\',\'' . $_POST['MC_PORT'] . '\');' . "\t\t\t// Set port of your memcache  server\r\n";
        $data .= 'define(\'MC_USERNAME\',\'' . $_POST['MC_USERNAME'] . '\');' . "\t\t\t\t\t\t\t// Set username of memcachier  server\r\n";
        $data .= 'define(\'MC_PASSWORD\',\'' . $_POST['MC_PASSWORD'] . '\');' . "\t\t\t// Set password your memcachier  server\r\n";
        $data .= 'define(\'MC_NAME\',\'' . $_POST['MC_NAME'] . '\');' . "\t\t\t// Set name of caching method if 0 : '', 1 : memcache, 2 : files, 3 : memcachier, 4 : apc, 5 : wincache, 6 : sqlite & 7 : memcached";
        configeditor('MEMCACHE', $data, 0);
        $_SESSION['cometchat']['error'] = 'Caching details updated successfully.';
    } else {
        if ($_POST['MC_NAME'] == 'memcachier') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memchachier server details';
        } elseif ($_POST['MC_NAME'] == 'files') {
            $_SESSION['cometchat']['error'] = 'Please check file permission of your cache directory. Please try 755/777/644';
        } elseif ($_POST['MC_NAME'] == 'apc') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your APC configuration.';
        } elseif ($_POST['MC_NAME'] == 'wincache') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Wincache configuration.';
        } elseif ($_POST['MC_NAME'] == 'sqlite') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your SQLite configuration.';
        } elseif ($_POST['MC_NAME'] == 'memcached') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcached configuration.';
        } else {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcache server configuration.';
        }
    }
    header("Location:?module=settings&action=caching&ts={$ts}");
}
Esempio n. 14
0
function cometchatMemcacheConnect()
{
    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
    global $memcache;
    if (MEMCACHE != 0 && MC_NAME == 'memcachier') {
        $memcache = new MemcacheSASL();
        $memcache->addServer(MC_SERVER, MC_PORT);
        $memcache->setSaslAuthData(MC_USERNAME, MC_PASSWORD);
    } elseif (MEMCACHE != 0) {
        phpFastCache::setup("path", dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache');
        phpFastCache::setup("storage", MC_NAME);
        $memcache = phpFastCache();
    }
}
Esempio n. 15
0
<?php

// phpFastCache Library
require_once dirname(__FILE__) . "/phpfastcache/2.4.2/base.php";
// OK, setup your cache
phpFastCache::$storage = "files";
//memcache
phpFastCache::$config = array("storage" => phpFastCache::$storage, "fallback" => "files", "securityKey" => "auto", "htaccess" => true, "path" => "", "memcached" => array(array("127.0.0.1", 11211, 1)), "memcache" => array(array("127.0.0.1", 11211, 1)), "server" => array(array("127.0.0.1", 11211, 1)), "redis" => array("host" => "127.0.0.1", "port" => "", "password" => "", "database" => "", "timeout" => ""), "extensions" => array());
phpFastCache::setup(phpFastCache::$config);
// temporary disabled phpFastCache
phpFastCache::$disabled = false;
// default chmod | only change if you know what you are doing
phpFastCache::$default_chmod = "";
// keep it blank, it will use 666 for module and 644 for cgi
Esempio n. 16
0
        $NameBD = $cmd->parametro->get("NameBD");
    }
    $bool = mysql_select_db($NameBD, $connect);
    $q = mysql_query('select * from bsw_bi.bi_server where dbName="' . $NameBD . '"');
    if (mysql_num_rows($q) == 1) {
        $_SESSION['id_server'] = mysql_result($q, 0);
    } else {
        die($LANG_ERROR_BI);
    }
} catch (Exception $e) {
    print $LANG_ERROR_CONNECT . " {$database}";
}
include_once "fast/phpfastcache/phpfastcache.php";
phpFastCache::setup("storage", "auto");
if (php_uname("s") == "Darwin") {
    phpFastCache::setup("path", '/private/var/tmp');
}
// Path For Files includes/work must be in 777
function readDashboardSections()
{
    $q = 'select distinct dashboard
	from bi_dashboard,bm_items_groups
	where bi_dashboard.id_item=bm_items_groups.id_item and
		  bm_items_groups.groupid=' . $_SESSION['groupid'] . '
	order by displayorder';
    $q1 = mysql_query($q);
    while ($r = mysql_fetch_array($q1, MYSQL_ASSOC)) {
        $data[] = array('dashboard' => $r['dashboard']);
    }
    return $data;
}
Esempio n. 17
0
        echo '<br><b>Error File:</b> ' . $errfile;
        echo '<br><b>Error Line:</b> ' . $errline;
    } else {
        throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
    }
});
// grab the settings
require ROOT . 'settings.php';
// grab status definitions
require SCRIPTROOT . 'statusdefs.php';
// set timezone
date_default_timezone_set('UTC');
// setup cache
require SCRIPTROOT . 'phpfastcache/phpfastcache.php';
phpFastCache::setup('storage', 'files');
phpFastCache::setup('path', ROOT . 'cache');
$cache = phpFastCache();
// setup routing
require SCRIPTROOT . 'AltoRouter/AltoRouter.php';
$routes = new AltoRouter();
// load the actual routes
require ROOT . 'routes.php';
// handle the route request
$route = $routes->match();
// error page handling
function ErrorPage($Error)
{
    ob_get_clean();
    http_response_code($Error);
    $error = $Error;
    require VIEWROOT . 'error.php';
Esempio n. 18
0
<?php

//if(!defined('IN_TRACKER'))
//    die('Hacking attempt!');
require_once "cache/phpfastcache.php";
phpFastCache::setup("bonho", "auto");
$Cache = phpFastCache();
function get_global_sp_state()
{
    global $Cache;
    static $global_promotion_state;
    if (!$global_promotion_state) {
        if (!($global_promotion_state = $Cache->get_value('global_promotion_state'))) {
            $res = mysql_query("SELECT * FROM torrents_state");
            $row = mysql_fetch_assoc($res);
            $global_promotion_state = $row["global_sp_state"];
            $Cache->cache_value('global_promotion_state', $global_promotion_state, 57226);
        }
    }
    return $global_promotion_state;
}
// IP Validation
function validip($ip)
{
    if (!ip2long($ip)) {
        //IPv6
        return true;
    }
    if (!empty($ip) && $ip == long2ip(ip2long($ip))) {
        // reserved IANA IPv4 addresses
        // http://www.iana.org/assignments/ipv4-address-space
Esempio n. 19
0
 protected function __setChmodAuto()
 {
     return phpFastCache::__setChmodAuto($this->config);
 }
Esempio n. 20
0
 public static function setup($name, $value = "")
 {
     if (is_array($name)) {
         self::$config = $name;
     } else {
         self::$config[$name] = $value;
     }
 }
Esempio n. 21
0
 public function cache($folder = 'design')
 {
     require_once ROOT . DS . 'includes' . DS . 'libraries' . DS . 'phpfastcache.php';
     phpFastCache::setup("storage", "files");
     phpFastCache::setup("path", ROOT . DS . 'cache');
     phpFastCache::setup("securityKey", $folder);
     $cache = phpFastCache();
     return $cache;
 }
 function __construct($storage = "", $option = array())
 {
     if (isset(self::$config['fallback'][$storage])) {
         $storage = self::$config['fallback'][$storage];
     }
     if ($storage == "") {
         $storage = self::$storage;
         self::option("storage", $storage);
     } else {
         self::$storage = $storage;
     }
     $this->tmp['storage'] = $storage;
     $this->option = array_merge($this->option, self::$config, $option);
     if ($storage != "auto" && $storage != "" && $this->isExistingDriver($storage)) {
         $driver = "phpfastcache_" . $storage;
     } else {
         $storage = $this->autoDriver();
         self::$storage = $storage;
         $driver = "phpfastcache_" . $storage;
     }
     $this->option("storage", $storage);
     if ($this->option['securityKey'] == "auto" || $this->option['securityKey'] == "") {
         $this->option['securityKey'] = "cache.storage." . $_SERVER['HTTP_HOST'];
     }
     $this->driver = new $driver($this->option);
     $this->driver->is_driver = true;
 }
Esempio n. 23
0
<?php

// phpFastCache Library
require_once dirname(__FILE__) . "/phpfastcache/3.0.0/phpfastcache.php";
// OK, setup your cache
phpFastCache::$config = array("storage" => "auto", "default_chmod" => 0777, "htaccess" => true, "path" => "", "securityKey" => "auto", "memcache" => array(array("127.0.0.1", 11211, 1)), "redis" => array("host" => "127.0.0.1", "port" => "", "password" => "", "database" => "", "timeout" => ""), "extensions" => array(), "fallback" => "files");
// temporary disabled phpFastCache
phpFastCache::$disabled = false;
Esempio n. 24
0
 /**
  * Prohibit creating an object from outside
  */
 public function __construct()
 {
     phpFastCache::setup("storage", "files");
     self::$cache = new phpFastCache();
 }
Esempio n. 25
0
function getColorVars()
{
    global $client;
    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
    global $settingscache;
    global $colors;
    phpFastCache::setup("path", dirname(__FILE__) . DIRECTORY_SEPARATOR . 'writable' . DIRECTORY_SEPARATOR . 'cache');
    phpFastCache::setup("storage", 'files');
    $settingscache = phpFastCache();
    if ($conf = getCachedSettings($client . "cometchat_color", 3600)) {
        $colors = unserialize($conf);
    } else {
        cometchatDBConnect();
        $colors = array();
        $sql = "select `color_key`,`color_value`,`color` from `cometchat_colors`";
        $query = mysqli_query($GLOBALS['dbh'], $sql);
        while ($color = mysqli_fetch_assoc($query)) {
            if (empty($colors[$color['color']])) {
                $colors[$color['color']] = array();
            }
            $colors[$color['color']][$color['color_key']] = $color['color_value'];
        }
        setCachedSettings($client . "cometchat_color", serialize($colors), 3600);
    }
}
Esempio n. 26
0
 public static function loadDataArray($keys)
 {
     if (!self::$enabled) {
         return null;
     }
     if (self::$cache === null) {
         phpFastCache::setup(phpFastCache::$config);
         self::$cache = phpFastCache();
     }
     ///Logger::Log('load: '.implode(':',$keys), LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
     return self::$cache->getMulti($keys);
 }
Esempio n. 27
0
 function __construct($storage = "", $option = array())
 {
     if (isset(self::$config['fallback'][$storage])) {
         $storage = self::$config['fallback'][$storage];
     }
     if ($storage == "") {
         $storage = self::$storage;
         self::option("storage", $storage);
     } else {
         self::$storage = $storage;
     }
     $this->tmp['storage'] = $storage;
     $this->option = array_merge($this->option, self::$config, $option);
     if ($storage != "auto" && $storage != "" && $this->isExistingDriver($storage)) {
         $driver = "phpfastcache_" . $storage;
     } else {
         $storage = $this->autoDriver();
         self::$storage = $storage;
         $driver = "phpfastcache_" . $storage;
     }
     require_once dirname(__FILE__) . "/drivers/" . $storage . ".php";
     $this->option("storage", $storage);
     if ($this->option['securityKey'] == "auto" || $this->option['securityKey'] == "") {
         $suffix = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : get_current_user();
         $this->option['securityKey'] = "cache.storage." . $suffix;
     }
     $this->driver = new $driver($this->option);
     $this->driver->is_driver = true;
 }
 public static function init()
 {
     $fastCacheConfig = array("storage" => "files", "path" => $_SERVER['DOCUMENT_ROOT'] . "/../db/cache", "securityKey" => "auto", "default_chmod" => 0777, "htaccess" => TRUE);
     \phpFastCache::setup($fastCacheConfig);
     self::$cache = new \phpFastCache();
 }
<?php

/*
 * This script bootstraps all loading
 *
 * It will handle all the includes, page construction and output
 */
session_start();
$script = $_SERVER['SCRIPT_NAME'];
$menuPath = str_replace("/pages/", "", $script);
$baseDir = $_SERVER['DOCUMENT_ROOT'] . '/';
$includesDir = $baseDir . "includes/";
//load up the cache engine
include $includesDir . 'phpfastcache.php';
phpFastCache::setup("storage", "files");
phpFastCache::setup("path", $baseDir . 'cache/');
// Path For Files
$cache = phpFastCache();
// detect if this is an ajax page call
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    $ajax = true;
} else {
    $ajax = false;
}
//detect if this is a post (which could also be an ajax call
if ($_POST) {
    $post = true;
} else {
    $post = false;
}
include 'mangoConfig.php';
Esempio n. 30
0
 function __construct($storage = "", $option = array())
 {
     if ($storage == "") {
         $storage = self::$storage;
         self::option("storage", $storage);
     } else {
         self::$storage = $storage;
     }
     $this->tmp['storage'] = $storage;
     $this->option = array_merge($this->option, self::$config, $option);
     if ($storage != "auto" && $storage != "" && $this->isExistingDriver($storage)) {
         $driver = "phpfastcache_" . $storage;
     } else {
         $storage = $this->autoDriver();
         self::$storage = $storage;
         $driver = "phpfastcache_" . $storage;
     }
     require_once dirname(__FILE__) . "/drivers/" . $storage . ".php";
     $this->option("storage", $storage);
     if ($this->option['securityKey'] == "auto" || $this->option['securityKey'] == "") {
         $suffix = isset($_SERVER['HTTP_HOST']) ? str_replace("www.", "", strtolower($_SERVER['HTTP_HOST'])) : get_current_user();
         $this->option['securityKey'] = "cache.storage." . $suffix;
     }
     $this->driver = new $driver($this->option);
     $this->fallback = !$this->driver->checkdriver();
     // do fallback
     if (method_exists($this->driver, "connectServer")) {
         $this->driver->connectServer();
     }
     if ($this->driver->fallback === true) {
         //	echo 'Fall Back';
         require_once dirname(__FILE__) . "/drivers/" . $this->option['fallback'] . ".php";
         $driver = "phpfastcache_" . $this->option['fallback'];
         $this->option("storage", $this->option['fallback']);
         $this->driver = new $driver($this->option);
         $this->driver->is_driver = true;
         $this->fallback = true;
     } else {
         $this->driver->is_driver = true;
         $this->fallback = false;
     }
 }