Ejemplo n.º 1
0
 /**
  * Clean up all cache
  */
 public static function clean()
 {
     self::$LASTCLEAN = time();
     if (SessionAccountHandler::getId() === null) {
         self::$cache->clean();
     } else {
         self::$cache->set('LASTCLEAN' . SessionAccountHandler::getId(), self::$LASTCLEAN);
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;
 }
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}");
}
Ejemplo n.º 6
0
<?php

include "php_fast_cache.php";
phpFastCache::$storage = "auto";
// ready ?
// check in case first
$content = phpFastCache::get("keyword1");
if ($content == null) {
    // for testing
    echo "This is not caching, page is render with lot queires and slow speed <br>";
    // do what you want, like get content from cURL | API | mySQL Query and return result to $content
    $content = file_get_contents("http://www.phpfastcache.com/testing.php");
    // rewrite cache for other request in 5 seconds
    phpFastCache::set("keyword1", $content, 5);
} else {
    // use cache
    // node
    echo "THIS TIME USE CACHE, FAST! <br>";
}
echo "TRY F5 to refesh the page to see new SPEED with Cache!<br>";
echo $content;
Ejemplo n.º 7
0
phpFastCache::debug(phpFastCache::systemInfo());
echo "<b>Data will be testing - Included NULL and Emptry String</b>";
phpFastCache::debug($data);
$c = array("red", "blue", "green", "orange", "black", "red", "blue", "green", "orange", "black");
$xx = 0;
foreach ($caching as $st) {
    $dem = 0;
    $color = $c[$xx];
    $xx++;
    phpFastCache::$storage = $st;
    echo "<font color={$color} >\n    ------------------------------------------------- <br>\n    Caching = {$st} <br>";
    if (isset(phpFastCache::$sys['drivers'][$st]) && phpFastCache::$sys['drivers'][$st] == true || $st == "auto") {
        foreach ($data as $string) {
            $dem++;
            echo "SET {$dem} --> ";
            phpFastCache::set("A" . $dem, $string);
            echo "GET {$dem} = ";
            $x = phpFastCache::get("A" . $dem);
            if (is_array($x)) {
                print_r($x);
            } else {
                echo $x;
                if (is_numeric($x)) {
                    phpFastCache::increment("A" . $dem);
                    phpFastCache::increment("A" . $dem);
                    phpFastCache::increment("A" . $dem);
                    $x = phpFastCache::get("A" . $dem);
                    echo " Increase to " . $x;
                    phpFastCache::decrement("A" . $dem);
                    phpFastCache::decrement("A" . $dem);
                    phpFastCache::decrement("A" . $dem);
Ejemplo n.º 8
0
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' && class_exists("Memcache") || $_POST['MC_NAME'] == 'memcached' && class_exists("Memcached")) {
                if ($_POST['MC_NAME'] == 'memcache') {
                    $server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
                    $memcache->option('server', $server);
                }
                if ($_POST['MC_NAME'] == 'memcached') {
                    $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 (!$errorCode) {
        configeditor($_POST);
        $_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}");
}
Ejemplo n.º 9
0
    if (!empty($nonListed)) {
        $content .= "<p>The following ridings are not listed because they don't have enough votes counted yet: {$nonListed}</p>";
    }
    $content .= '<hr /><p><font size="-1">Results as of ' . date($dateFormat) . '</font></p>';
    phpFastCache::set("main", $content, 30);
    $content .= '<p><font size="-1">Non-cached results printed on ' . date($dateFormat) . '</font></p>';
    #$content .= '<pre>';
    #$content .= 'Values for entire jurisdiction: ';
    #$content .= var_export($entireJurisdiction, TRUE);
    #$content .= '</pre>';
    echo $content;
    if (!empty($entireJurisdiction['totalValidVotes']) && $entireJurisdiction['totalValidVotes'] > 0) {
        $number = $entireJurisdiction['wastedVotes'];
        phpFastCache::set("entireJurisdictionResult", $number, 60 * 60 * 24 * 365);
    } else {
        phpFastCache::set("entireJurisdictionResult", -1, 1);
    }
    webCommentPrint("List of parties are:\n");
    sort($listOfParties);
    foreach ($listOfParties as $partyName) {
        webCommentPrint("{$partyName}\n");
    }
    ### End of else for non-cached, fresh results
}
function webCommentPrint($comment)
{
    $comment = rtrim($comment);
    echo "<!-- {$comment} -->\n";
}
?>