/** * @return array */ public function getFeed($params = []) { /** @var Page $page */ $page = $this->grav['page']; /** @var Twig $twig */ $twig = $this->grav['twig']; /** @var Data $config */ $config = $this->mergeConfig($page, TRUE); // Autoload composer components require __DIR__ . '/vendor/autoload.php'; // Set up cache settings $cache_config = array("storage" => "files", "default_chmod" => 0777, "fallback" => "files", "securityKey" => "auto", "htaccess" => true, "path" => __DIR__ . "/cache"); // Init the cache engine $this->cache = phpFastCache("files", $cache_config); // Generate API url $url = 'https://api.instagram.com/v1/users/' . $config->get('feed_parameters.user_id') . '/media/recent/?access_token=' . $config->get('feed_parameters.access_token'); // Get the cached results if available $results = $this->cache->get($url); // Get the results from the live API, cached version not found if ($results === null) { $results = Response::get($url); // Cache the results $this->cache->set($url, $results, InstagramPlugin::HOUR_IN_SECONDS * $config->get('feed_parameters.cache_time')); // Convert hours to seconds } $this->parseResponse($results); $this->template_vars = ['user_id' => $config->get('feed_parameters.user_id'), 'client_id' => $config->get('feed_parameters.client_id'), 'feed' => $this->feeds, 'count' => $config->get('feed_parameters.count')]; $output = $this->grav['twig']->twig()->render($this->template_html, $this->template_vars); return $output; }
function __construct($storage = "", $config = array()) { $config = array_merge(phpFastCache::$config, $config); $config['storage'] = $storage; $storage = strtolower($storage); if ($storage == "" || $storage == "auto") { $storage = self::getAutoClass($config); } $this->instance = phpFastCache($storage, $config); }
/** * onPluginsLoaded method */ public function onPluginsLoaded() { // phpFastCache not working in CLI mode... if (PHILE_CLI_MODE) { return; } unset($this->settings['active']); $config = $this->settings + \phpFastCache::$config; $storage = $this->settings['storage']; $cache = phpFastCache($storage, $config); ServiceLocator::registerService('Phile_Cache', new PhpFastCache($cache)); }
/** * 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; }
/** * Constructor * * @param array */ public function __construct() { $CI =& get_instance(); $CI->config->load('fastcache'); //unique failsafe token for each project if (!file_exists(APPPATH . 'cache/fastcache_token.php')) { $token = md5(uniqid(mt_rand(), true)); file_put_contents(APPPATH . 'cache/fastcache_token.php', '<?php ' . "ªn" . '$token=\'' . $token . '\';'); } else { include APPPATH . 'cache/fastcache_token.php'; } $this->token = $token; $c = $CI->config->item('fastcache'); $this->cache = phpFastCache($c['storage'], $CI->config->item('fastcache')); }
function getPhotosByHighglithFirst($category) { global $detect; $cache = phpFastCache(); if (isset($_GET['clear_cache'])) { $cache->delete('posts'); } $posts = $cache->get("posts"); if (!$posts || $posts == null) { $posts = getPhotos($category, false); $posts = getPhotos($category, $posts); // cache for an hour $cache->set("posts", $posts, 3000); } return $posts; }
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; }
/** * 获得详情页数据 */ function get_shahinfo($hash) { if (preg_match('/^[0-9A-Z]+$/u', $hash)) { $cache = phpFastCache("files", array("path" => "cache")); $conter = $cache->get($hash); if (is_null($conter)) { $url = 'http://www.torrentkitty.org/information/'; $content = get_data($url . $hash); $html = new simple_html_dom(); $html->load($content); @($ret = $html->find('h3')); if (isset($ret['0']->nodes['0']->_['4']) && $ret['0']->nodes['0']->_['4'] == 'Magnet Link does not eixst. You may try to upload it again.') { $info['error'] = TRUE; } else { foreach ($html->find('.magnet-link') as $article) { $item['magnet'] = $article->plaintext; $articles[] = $item; } foreach ($html->find('.detailSummary') as $article) { foreach ($article->find('tr') as $tr) { foreach ($article->find('td') as $td) { $item[] = $td->plaintext; } } } preg_match('%<table[^>]*id="torrentDetail"[^>]*>(.*?) </table>%si', $content, $match); preg_match('%<h2>(.*?)</h2>%si', $content, $ret); $title = mb_substr($ret['0'], 25); $info['title'] = strip_tags($title); $info['list'] = $match; $info['size'] = $item['3']; $info['quantity'] = $item['2']; $info['cdate'] = $item['4']; $info['magnetic'] = $articles['0']['magnet']; $cache->set($hash, $info, 864000); } } else { $info = $conter; } } else { $info['error'] = TRUE; } return $info; }
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(); } }
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null) { $cacheAge = 60 * 60; $offset = getOffset(); setTimezone(); $cache = phpFastCache(); //$cache->clean(); $dt = getDates($from); $from = $dt[0]; if ($to == null) { $to = $dt[1]; } $from = str_replace("-", "/", $from); $to = str_replace("-", "/", $to); $phour = getPeakHours(); $unit = getUnit($id_item); $plan = getPlan($id_plan); $item = getItem($id_item); $div = 1; if (strtolower($unit) == 'bps') { $div = 1024 * 1024; $unit = 'Mbps'; } $rtag = ""; foreach ($_SESSION['tag'] as $key => $value) { if ($key != "" && $key != "None") { $rtag = $rtag . ',"' . $key . '"'; } } if ($rtag == '') { $rtag = 'bm_tags.tag like "%"'; } else { $rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')'; } if ($id_plan == 0) { $id_plan = '> 0'; } else { $id_plan = '=' . $id_plan; } if ($id_host == null) { $id_host = ""; } else { $id_host = " and bm_host.id_host=" . $id_host; } $hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard where bm_host.id_plan=bm_plan.id_plan and bm_host.groupid = ' . $_SESSION['groupid'] . ' and bm_plan.id_plan ' . $id_plan . ' and bm_plan_groups.id_plan = bm_plan.id_plan and bm_host.borrado=0 and bm_host.id_plan=bm_plan.id_plan and bm_plan_groups.groupid=bm_host.groupid and bm_threshold.id_item=bi_dashboard.id_item and bm_host.id_host in (select id from bm_tags where ' . $rtag . ') and bi_dashboard.id_item=' . $id_item . $id_host . ' order by bm_host.id_plan'; //var_dump($hosts); // Find Percentile 5 and 95 if (true) { $hostsr = mysql_query($hosts); while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) { $id_host = $host['id_host']; $hostName = $host['host']; $nominal = $host['nominal']; $critical = $host['critical']; $warning = $host['warning']; $nacD = $host['nacD'] * 1024; $nacU = $host['nacU'] * 1024; if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } $hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU); $incache = true; unset($cachedData); $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; //if (isset($_SESSION['cache'][$key])) // $obj = $_SESSION['cache'][$key]; //else //echo $key . "<br>"; $obj = $cache->get($key); if ($obj == null) { $incache = false; $_SESSION['cacheFull'] = false; } else { $_SESSION['cachePartial'] = true; foreach ($obj as $key => $value) { if (isset($value['clock'])) { $cachedData[] = $value; } } } } if (!isset($cachedData)) { $incache = false; } if ($incache) { foreach ($cachedData as $key => $row) { $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } else { $table = 'xyz_' . str_pad($id_item, 10, "0", STR_PAD_LEFT); //var_dump($table); if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table . "'")) == 1) { if ($phour['peak'] > $phour['offpeak']) { $q = 'select clock,value,valid,if((date_format(from_unixtime(clock),"%H")>=0 and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ') or date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } else { $q = 'select clock,value,valid,if(date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ' and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } //var_dump($q); $qr = mysql_query($q); while ($row = mysql_fetch_array($qr, MYSQL_ASSOC)) { $key = date('Y/m/d', $row['clock']); $data[$key][$id_host . '-' . $id_item][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } // check miising data $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; $obj = $cache->get($key); if ($obj == null) { $cache->set($key, array('clock' => 0, 'value' => 0, 'valid' => 0, 't' => ''), $cacheAge); //$_SESSION['cache'][$key]= array('clock'=>0,'value'=>0,'valid'=>0,'t'=>''); } } } } } if (isset($incache) && !$incache && isset($data)) { foreach ($data as $key => $value) { foreach ($value as $hkey => $hvalue) { $thekey = $key . '-' . $hkey; //echo $thekey . ' '; $cache->set($thekey, $hvalue, $cacheAge); //$_SESSION['cache'][$thekey] = $hvalue; } } } if (isset($allData)) { return array('allData' => $allData, 'historyList' => $historyList, 'hostList' => $hostList, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } else { return array('allData' => null, 'historyList' => null, 'hostList' => null, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } }
/* edition, for createing a weighted average. */ $gStatsWPEditions = array('zh' => 935, 'en' => 387, 'es' => 365, 'hi' => 295, 'ar' => 295); /* Gallery images are picked from pictures */ /* in Wikipedia articles. What WP editions should */ /* we scan for images? */ $gImageSourceWPEditions = array('en', 'es', 'de', 'nl'); // ruwp contains a lot pf portraits as genre pictures, // hence commenting out /* When retriving images from Wikipedia pages, we */ /* want to exclude some pics that are often used */ /* to illustrate navigation boxes and similar. */ /* NB: Space, not underscore in filenames! */ $gImageBlacklist = array('Tom Sawyer 1876 frontispiece.jpg', 'Nobel Prize.png', 'Дмитрий Иванович Менделеев 8.jpg', 'Charles_Darwin_1880.jpg', 'Agnes von Kurowsky in Milan.jpg', 'Merton College front quad.jpg', 'St John\'s Church, Little Gidding.jpg', 'Vivienne Haigh-Wood Eliot 1920.jpg', 'Harper Midway Chicago.jpg', 'University of Minnesota-20031209.jpg', 'Bronze Star medal.jpg', 'Air Medal front.jpg', 'Meritorious Service Medal (United_States).png', 'Purpleheart.jpg', 'Dfc-usa.jpg', 'Us legion of merit legionnaire.png', 'Silver Star medal.png', 'Conservative Elephant.png', '2006 AEGold Proof Obv.png'); /* Cache type. Can be auto, memcache, files, etc. */ /* see http://www.phpfastcache.com/ for full list */ $gCache = phpFastCache("auto"); # Example, using a local Redis server: #$gCache = phpFastCache("redis"); #$gCache->config['redis']['server'] = '127.0.0.1'; #$gCache->config['redis']['port'] = '6379'; /* The number of hours to cache external data on */ /* individual laureates, e.g. Wikipedia images */ $gExternalLaureateDataCacheTime = 720; /* The number of hours to store external stats, */ /* e.g. Wikipedia pageviews */ $gExternalStatsCacheTime = 36; /* Should we cache responses from local API's? If */ /* our caching is not superfast, and API's are on */ /* on the same server, it might be faster not to. */ $gCacheLocal = true; /* Time zone to use when fetching statistics */
if (!$dbh) { echo "<h3>Unable to connect to database. Please check details in configuration file.</h3>"; exit; } mysqli_select_db($dbh, DB_NAME); mysqli_query($GLOBALS['dbh'], "SET NAMES utf8"); mysqli_query($GLOBALS['dbh'], "SET CHARACTER SET utf8"); mysqli_query($GLOBALS['dbh'], "SET COLLATION_CONNECTION = 'utf8_general_ci'"); if (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(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'cache'); phpFastCache::setup("storage", MC_NAME); $memcache = phpFastCache(); $memcache->set('auth', 'o1k', 30); } $usertable = TABLE_PREFIX . DB_USERTABLE; $usertable_username = DB_USERTABLE_NAME; $usertable_userid = DB_USERTABLE_USERID; $body = ''; if (!empty($_POST['username'])) { $_SESSION['cometchat']['cometchat_admin_user'] = $_POST['username']; } if (!empty($_POST['password'])) { $_SESSION['cometchat']['cometchat_admin_pass'] = $_POST['password']; } authenticate(); $module = "dashboard"; $action = "index";
/** * Constructor. * @access public * */ public function __construct() { // Auto-load classes on demand if (function_exists("__autoload")) { spl_autoload_register("__autoload"); } spl_autoload_register(array($this, 'autoload')); // Define constants $this->define_constants(); // Include required files $this->includes(); $this->API_key = "b01d4d3fea131c822c72eb8c3e9d85b83c2beac92ac9fab197e932c4b20a71c0"; //"a871cfc48ef1ee01f27d7c773aacd6a7c5b2ae80203d0401c3f0c1fc8354f0a2"; $this->API_account = "83442"; // Init API $this->api = new LI_API($this->API_key, $this->API_account); // simple Caching with: $this->LI_cache = phpFastCache(); // set xml directory $this->XML_dir_matrices = $this->plugin_path() . '/xml/matrices/'; // set xml directory $this->XML_dir_items = $this->plugin_path() . '/xml/items/'; // set xml directory $this->XML_dir_vendors = $this->plugin_path() . '/xml/vendors/'; $this->XML_dir_manufacturers = $this->plugin_path() . '/xml/manufacturers/'; //$this->options = get_option('lightspeed_inteleck_options'); /*if(is_admin()) { require_once(LSI_DIR_PATH.'views/lsi-options.php'); // include options file $options_page = new lightspeedImportOptions(); add_action('admin_menu', array($options_page, 'add_pages')); // adds page to menu add_action('admin_init', array($options_page, 'register_settings')); }*/ register_activation_hook(__FILE__, array($this, 'lightspeed_import_activation')); register_deactivation_hook(__FILE__, array($this, 'lightspeed_import_deactivation')); add_action('lightspeed_hourly_product_import', array($this, 'lightspeed_import_items')); add_action('lightspeed_hourly_matrices_import', array($this, 'lightspeed_import_matrices')); add_action('lightspeed_hourly_vendors_import', array($this, 'lightspeed_import_vendors')); add_action('lightspeed_hourly_manufacturers_import', array($this, 'lightspeed_import_manufacturers')); }
public function Cache() { $this->control = Control::getControl(); $this->phpFastCache = phpFastCache(); }
public function loadApontamentosDiasDistintos($connection, $tipoApontamento) { $cache = phpFastCache(); $apontamentosCache = $cache->get("ApontamentosDiasDistintos" . $tipoApontamento); if ($apontamentosCache != null) { return $apontamentosCache; } else { $registros = array(); $query = " SELECT *\n FROM apontamentos\n WHERE apo_dtdinicio NOT LIKE '%0000%'\n AND apo_dtdfim NOT LIKE '%0000%'\n AND DAY(apo_dtdinicio) <> DAY(apo_dtdfim) "; if (!Functions::isEmpty($tipoApontamento) && $tipoApontamento == "A") { $query .= " AND apo_cdiatividade IS NOT NULL "; } if (!Functions::isEmpty($tipoApontamento) && $tipoApontamento == "C") { $query .= " AND apo_cdichamado IS NOT NULL "; } $query .= " ORDER BY apo_cdiapontamento "; $stmt = $connection->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(); foreach ($rows as $row) { $vo = $this->populateVo($connection, $row); array_push($registros, $vo); } $cache->set("ApontamentosDiasDistintos" . $tipoApontamento, $registros, 60 * Functions::getParametro('cache')); return $registros; } }
<?php return array('Cache' => function () { $config = (require \App::path() . '/app/config/cache.php'); \phpFastCache::setup($config); return phpFastCache(); }, 'Crypt' => 'Disco\\classes\\Crypt', 'Data' => 'Disco\\classes\\Data', 'DB' => 'Disco\\classes\\PDO', 'Event' => 'Disco\\classes\\Event', 'Email' => 'Disco\\classes\\Email', 'FileHelper' => 'Disco\\classes\\FileHelper', 'Form' => 'Disco\\classes\\Form', 'Html' => 'Disco\\classes\\Html', 'Model' => 'Disco\\classes\\ModelFactory', 'Queue' => 'Disco\\classes\\Queue', 'Request' => 'Disco\\classes\\Request', 'Session' => 'Disco\\classes\\Session', 'Template' => 'Disco\\classes\\Template', 'View' => 'Disco\\classes\\View', 'User' => 'App\\service\\User');
function SetCachedVersion($function, $unique_id, $args_id, $data) { // In your config file // require_once(dirname(__FILE__) . "/phpfastcache.php"); phpFastCache::setup("storage", "redis"); #default global for everywhere. // phpFastCache support "redis", "cookie", "apc", "memcache", "memcached", "wincache" ,"files", "sqlite" and "xcache"; // You don't need to change your code when you change your caching system, blank will use default global: $cache = phpFastCache("files"); $id = md5($function . $unique_id . $args_id); $results = $cache->get("cache_" . $id); if ($results) { return $results; } return $results; // }
<?php /* * Learn how to setup phpFastCache ? */ require_once "../phpfastcache.php"; /* * Now this is Optional Config setup for default 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"); phpFastCache::setup($config); // OR phpFastCache::setup("storage", "files"); phpFastCache::setup("path", dirname(__FILE__)); /* * End Optional Config */ $config = array(); $cache = phpFastCache("files", $config); // this will be $config['storage'] up there; // changing config example $cache->setup("path", "new_path"); $cache2 = phpFastCache("memcache"); // this will use memcache $server = array(array("127.0.0.1", 11211, 1)); $cache2->setup("memcache", $server);
public function __construct() { global $container; $container = new Container(); $container['session'] = function ($container) { $session = new Session(); if (session_id() == '') { $session->start(); } return $session; }; $container['request'] = function ($container) { $request = Request::createFromGlobals(); return $request; }; $container['config'] = function ($container) { $config = new ConfigHelper(); return $config->objInstance; }; $container['translator'] = function ($container) { $request = $container['request']; $translator = new TranslateHelper($request); return $translator->objInstance; }; $container['cacheType'] = $container['config']["fastChatType"]; $container['fastcache'] = function ($container) { phpFastCache::setup("storage", $container['cacheType']); phpFastCache::setup("path", BASE_ROOT . "/cache/fastcache/"); $cache = phpFastCache(); return $cache; }; $container['twig'] = function ($container) { $config = $container['config']; $translator = $container['translator']; $arrayOfFileSystem = [BASE_ROOT . '/pages/Admin/templates/modules', BASE_ROOT . '/pages/Admin/templates/emails', BASE_ROOT . '/pages/Admin/modules/GererItemShop/templates', BASE_ROOT . '/pages/Admin/modules/GererEquipeJeu/templates', BASE_ROOT . '/pages/Admin/modules/GererEquipeSite/templates', BASE_ROOT . '/pages/Admin/modules/Parametres/templates', BASE_ROOT . '/pages/ItemShop/modules/Hipay/templates', BASE_ROOT . '/pages/ItemShop/modules/Starpass/templates', BASE_ROOT . '/pages/Classements/templates/', BASE_ROOT . '/pages/Inscription/templates/modules', BASE_ROOT . '/pages/Inscription/templates/emails', BASE_ROOT . '/pages/ItemShop/templates/modules', BASE_ROOT . '/pages/ItemShop/templates/emails', BASE_ROOT . '/pages/Messagerie/templates/modules', BASE_ROOT . '/pages/Messagerie/templates/emails', BASE_ROOT . '/pages/Marche/templates/modules', BASE_ROOT . '/pages/Marche/templates/emails', BASE_ROOT . '/pages/MonCompte/templates/modules', BASE_ROOT . '/pages/MonCompte/templates/emails', BASE_ROOT . '/pages/MonPersonnage/templates/modules', BASE_ROOT . '/pages/MonPersonnage/templates/emails', BASE_ROOT . '/pages/Statistiques/templates/modules', BASE_ROOT . '/pages/Votes/templates/', BASE_ROOT . '/pages/_LegacyPages/templates/', BASE_ROOT . '/pages/_Home/templates/modules/', BASE_ROOT . '/core/templates/']; if ($config["twigCache"]) { $urlCache = BASE_ROOT . $config["twigCacheUrl"]; } else { $urlCache = false; } $loader = new Twig_Loader_Filesystem($arrayOfFileSystem); $twig = new Twig_Environment($loader, array('cache' => $urlCache)); $twig->addExtension(new Twig_Extensions_Extension_Text()); $twig->addExtension(new StringFunctionExtension()); $twig->addExtension(new FonctionsUtilesExtension()); $twig->addExtension(new HelperExtension()); $twig->addExtension(new ImageFunctionExtension()); $twig->addExtension(new DateFunctionExtension()); $twig->addExtension(new Twig_Extension_Debug()); $twig->addExtension(new EncryptExtension()); include BASE_ROOT . '/pages/Tableaux_Arrays.php'; $twig->addExtension(new \Symfony\Bridge\Twig\Extension\TranslationExtension($translator)); $twig->addGlobal('session', $container['session']); $twig->addGlobal('request', $container['request']); $twig->addGlobal('config', $container['config']); $twig->addGlobal('urlBase', BASE_ROOT); return $twig; }; $container['doctrine.eventManager'] = function ($container) { $eventManager = new \Doctrine\Common\EventManager(); return $eventManager; }; $container['doctrine.connection.default'] = function ($container) { $param = $container['config']; $config = new \Doctrine\DBAL\Configuration(); // build connection parameters $connectionParameters = array('dbname' => "site", 'user' => $param["bdd"]["user"], 'password' => $param["bdd"]["password"], 'host' => $param["bdd"]["host"], 'port' => $param["bdd"]["port"]); switch (strtolower($param["bdd"]["driver"])) { case 'mysql': $connectionParameters['driver'] = 'pdo_mysql'; $connectionParameters['charset'] = strtolower($param["bdd"]["charset"]); break; default: throw new RuntimeException('Database driver ' . $param["bdd"]["driver"] . ' not known by doctrine.'); } /* if (!empty($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'])) { $connectionParameters['driverOptions'] = deserialize($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'], true); } */ $connectionParameters['defaultTableOptions'] = array('collate' => 'utf8_general_ci'); /** @var \Doctrine\Common\EventManager $eventManager */ $eventManager = $container['doctrine.eventManager']; // establish connection $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParameters, $config, $eventManager); $connection->getConfiguration()->setSQLLogger(null); // fix platform differences $platform = $connection->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('bit', 'boolean'); return $connection; }; $container['doctrine.orm.entitiesCacheDir'] = function ($container) { $entitiesCacheDir = BASE_ROOT . '/cache/doctrine/entities'; if (!is_dir($entitiesCacheDir)) { mkdir($entitiesCacheDir, 0777, true); } $classLoader = new \Composer\Autoload\ClassLoader(); $classLoader->add('', array($entitiesCacheDir), true); $classLoader->register(true); $container['doctrine.orm.entitiesClassLoader'] = $classLoader; return $entitiesCacheDir; }; $container['doctrine.orm.proxiesCacheDir'] = function ($container) { $proxiesCacheDir = BASE_ROOT . '/cache/doctrine/proxies'; if (!is_dir($proxiesCacheDir)) { mkdir($proxiesCacheDir, 0777, true); } return $proxiesCacheDir; }; $container['doctrine.orm.repositoriesCacheDir'] = function ($container) { $repositoriesCacheDir = BASE_ROOT . '/cache/doctrine/repositories'; if (!is_dir($repositoriesCacheDir)) { mkdir($repositoriesCacheDir, 0777, true); } return $repositoriesCacheDir; }; $container['doctrine.orm.entityManager'] = function ($container) { $param = $container['config']; $paths = array(BASE_ROOT . '/core/library/Account/Entity', BASE_ROOT . '/core/library/Player/Entity'); $isDevMode = false; $config = \Doctrine\ORM\Tools\Setup::createConfiguration($isDevMode); // Configuration $config = new Doctrine\ORM\Configuration(); $config->addCustomStringFunction('PASSWORD', '\\DoctrinePasswordExtension'); $config->addCustomStringFunction('RAND', '\\DoctrineRandExtension'); $config->addCustomStringFunction('WEEK', '\\DoctrineExtensions\\Query\\Mysql\\WEEK'); $config->addCustomStringFunction('MONTH', '\\DoctrineExtensions\\Query\\Mysql\\MONTH'); $config->addCustomStringFunction('YEAR', '\\DoctrineExtensions\\Query\\Mysql\\YEAR'); $config->addCustomStringFunction('IFELSE', '\\DoctrineExtensions\\Query\\Mysql\\IfElse'); // Proxy Configuration $proxiesCacheDir = $container['doctrine.orm.proxiesCacheDir']; $config->setProxyDir($proxiesCacheDir); $config->setProxyNamespace('entities\\proxies'); switch ($param["bdd"]["cache"]) { case 'apc': $cache = new \Doctrine\Common\Cache\ApcCache(); break; case 'array': $cache = new \Doctrine\Common\Cache\ArrayCache(); break; case false: $cache = false; break; } if (!$cache) { // Mapping Configuration $entitiesCacheDir = $container['doctrine.orm.entitiesCacheDir']; $reader = new \Doctrine\Common\Annotations\FileCacheReader(new \Doctrine\Common\Annotations\AnnotationReader(), $entitiesCacheDir, $debug = false); } else { $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\AnnotationReader(), $cache, $debug = false); } $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $paths); //$driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new \Doctrine\Common\Annotations\AnnotationReader(), $paths); // registering noop annotation autoloader - allow all annotations by default \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists'); $config->setMetadataDriverImpl($driverImpl); // Caching Configuration $cache = new \Doctrine\Common\Cache\ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); //$config->setAutoGenerateProxyClasses(false); /** @var $connection \Doctrine\DBAL\Connection */ $connection = $container['doctrine.connection.default']; /** @var $eventManager \Doctrine\Common\EventManager */ $eventManager = $container['doctrine.eventManager']; /** @var $entityManager \Doctrine\ORM\EntityManager */ $entityManager = \Doctrine\ORM\EntityManager::create($connection, $config, $eventManager); return $entityManager; }; $this->container = $container; }
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; }
public function __construct() { $this->cache = phpFastCache(); }
<!DOCTYPE html> <!-- saved from url=(0071)file:///C:/wamp/www/operator/Dashboard%20Template%20for%20Bootstrap.htm --> <?php require '../vendor/autoload.php'; include "../phpfastcache/phpfastcache.php"; use Parse\ParseClient; use Parse\ParseObject; use Parse\ParseQuery; use Parse\ParseRelation; ParseClient::initialize('qjArPWWC0eD8yFmAwRjKkiCQ82Dtgq5ovIbD5ZKW', '9Yl2TD1DcjR6P1XyppzQ9NerO6ZwWBQnpQiM0MkL', 'MjYJYsSjr5wZVntUFxDvv0VpXGqhPOT8YFpULNB2'); $cache = phpFastCache("files"); //remember to check user login $method = $_SERVER['REQUEST_METHOD']; $incidentHTML = ''; $resourceHTML = ''; $organizationHTML = ''; $saveSuccess = false; $errorMessage = ''; function getAllIncidentFromCacheOrQuery() { global $cache; $results = $cache->get("all_incident"); if ($results == null) { $query = new ParseQuery("Incident"); $results = $query->find(); $cache->set("all_incident", $results, 1800); } return $results; } function getAllResourcesFromCacheOrQuery() {
/** * remove everything from the cache */ public static function clearCache() { $cache = phpFastCache(); $cache->clean(); }
function validUser($user, $pass, $hashed = false) { @(include_once "phpfastcache/phpfastcache.php"); @(include_once realpath("../phpfastcache/phpfastcache.php")); $cache = phpFastCache(); //Hash the password if not hashed. if (!$hashed) { $hashedPass = hashPass($user, $pass); } else { $hashedPass = $pass; } $userData = $cache->get("user_data_" . $user); if ($userData == null) { // Default database connect // $msconf = getDatabaseCredentials(); $dbcon = mysqli_connect($msconf['host'], $msconf['user'], $msconf['pass'], $msconf['db']); if (mysqli_connect_errno($dbcon)) { echo "Failed to connect to MySQL: " . mysqli_connect_errno($dbcon) . " : " . mysqli_connect_error(); die; } $dbcon->query('CREATE TABLE IF NOT EXISTS `Users` (`Username` varchar(16) NOT NULL, `Name` varchar(60) NOT NULL, `PassHash` varchar(256) NOT NULL, `APIKey` varchar(256) NULL, `Permission` varchar(2) NOT NULL DEFAULT \'NN\', UNIQUE KEY `Username` (`Username`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;'); $dbcon->query('CREATE TABLE IF NOT EXISTS `Blog` (`PUID` varchar(200) NOT NULL,`Post` varchar(10000) NOT NULL,`Date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `Author` varchar(16) NOT NULL, `Title` varchar(60) NOT NULL, UNIQUE KEY `PUID` (`PUID`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;'); $dbcon->query('INSERT INTO `Users` (`Username`, `Name`, `PassHash`, `Permission`) VALUES (\'ace\', \'Cory Redmond\', \'2y11$WULjGCfjZEvtGEXfZkL3G.uzF3fRlJPGVsR.jCGguRhKIuph28572\', \'YY\');'); // Default database connect // //Prepare the statment. $preparedStm = $dbcon->prepare("SELECT * FROM `Users` WHERE `Username` = ? AND `PassHash` = ?;"); $preparedStm->bind_param("ss", $user, $hashedPass); //Run the command and get the results. $preparedStm->execute(); $preparedStm->bind_result($f_user, $f_UUID, $f_email, $f_pass, $f_key, $f_permissions, $f_verif); $preparedStm->fetch(); //var_dump($preparedStm); echo "<!-- {$f_verif} -->"; if ($f_verif == null) { return "That account doesn't exist."; } if ($f_verif != "Y") { return "You are not verified. Please check your email inbox!"; } //Return true of false. if (!empty($f_user) && !empty($f_pass) && $f_user == $user && $f_pass == $hashedPass) { $userData = array("user" => $f_user, "perm" => $f_permissions, "hashedPass" => $f_pass, "key" => $f_key, "UUID" => $f_UUID, "email" => $f_email); $cache->set("user_data_" . $f_user, $userData, 600); } else { return false; } } else { echo "<!-- Userdata cached! -->"; } if ($user == $userData['user'] && $hashedPass == $userData['hashedPass']) { return $userData; } return false; }
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); } }
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); }
/** * @return mixed */ protected function backup() { return phpFastCache(phpFastCache::$config['fallback']); }
public function __construct() { //Construct Padre parent::__construct(); //Instancia del core de CI self::$ci =& get_instance(); /* * Cargar el id del modulo actual */ self::$id_modulo = $this->id_modulo(); /* * Cargar el uuid del usuario que esta loguiado. */ self::$uuid_usuario = $this->uuid_usuario(); /* * Cargar el id categoria a la que pertenece el * usuario que esta loguiado. */ self::$id_categoria_usuario = $this->categoria_usuario("id_categoria"); /* * Cargar el uuid categoria a la que pertenece el * usuario que esta loguiado. */ self::$uuid_categoria_usuario = $this->categoria_usuario("uuid_categoria"); self::$categoria_usuario_key = $this->categoria_usuario("key"); //roles del usuario self::$user_role = $this->getRole(); /* * Verificando que este usuario este en estado pendiente para redireccionar */ if ($this->session->userdata('id_usuario') && $this->session->userdata('status') == 'Pendiente') { if (self::$ci->router->fetch_method() != 'ver_usuario' && self::$ci->router->fetch_method() != 'logout') { redirect('/usuarios/ver-usuario/' . $this->session->userdata('id_usuario')); } } //Cargar Libreria Assets $this->load->library('assets'); //carga la libreria de notificaciones //$this->load->library('notificaciones'); //Cargar Libreria para usuario $this->load->library('grafica_usuario'); //Cargar Libreria template $this->load->library('template'); //Cargar Libreria de Autenticacion //Verifica el rol y los permisos //que tiene el usuario. $this->load->library('auth'); $this->load->library('core'); /** * Cargar libreria Subpanel */ $this->load->library('subpanel'); /** * Cargar libreria para utility */ $this->load->library('util'); /** * Cargar libreria para modales */ $this->load->library('modal'); /** * Cargar libreria para jqgrid */ $this->load->library('jqgrid'); /** * Cargar libreria para catalogos */ $this->load->library('catalogos'); /** * carga libreria de jobs */ $this->load->library('jobs'); $this->load->library('notificaciones'); /** * Cargar libreria phpFastCache * * phpFastCache is Lightweight, Fastest & Security, * supported many caching class (APC, MemCached, MemCache, Files, PDO, WinCache) */ $this->load->library('phpfastcache/3.0.0/phpfastcache'); phpFastCache::setup("storage", "auto"); phpFastCache::$config = array("storage" => "auto", "default_chmod" => 0777, "htaccess" => true, "path" => "application/cache", "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"); if (self::$cache == "") { self::$cache = phpFastCache("auto"); } }
/* * 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'; //load vendor autoload.php include $baseDir . 'vendor/autoload.php';
<?php /* * Welcome to Learn Lesson * This is very Simple PHP Code of Caching */ // Require Library require_once "phpfastcache.php"; // simple Caching with: $cache = phpFastCache("redis"); if ($cache->fallback == true) { echo " USE BACK UP DRIVER = " . phpFastCache::$config['fallback'] . " <br>"; } else { echo ' DRIVER IS GOOD <br>'; } // Try to get $products from Caching First // product_page is "identity keyword"; $products = $cache->get("product_page2"); if ($products == null) { $products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS"; // Write products to Cache in 10 minutes with same keyword $cache->set("product_page2", $products, 2); echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> "; } else { echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> "; } // use your products here or return it; echo "Products = " . $products;