Beispiel #1
0
 /**
  * getLovedSongs()
  * Gets user's loved songs. From cache file or from the feed.
  *
  * @return array $songs Returns formatted songs
  */
 public static function getLovedSongs($username = '', $num_songs = 30)
 {
     if (!self::isValidUsername($username)) {
         return array(self::$error);
     }
     // Check Feeder and Cache classes are accessible
     if (!class_exists('Feeder')) {
         return array('Could not find Feeder.class.php.');
     }
     if (!class_exists('Cache')) {
         return array('Could not find Cache.class.php.');
     }
     self::$username = $username;
     self::$num_songs = $num_songs;
     $cache_filename = self::$username . '-loved-tracks.cache';
     $cache_life = 86400;
     // 1 day
     Cache::init($cache_filename, $cache_life);
     if (Cache::cacheFileExists()) {
         return Cache::getCache();
     }
     $song_data = Feeder::getItems(self::getLovedSongsFeed(), self::$num_songs, array('title', 'link'));
     if (!is_array($song_data)) {
         self::$error = "Last.fm loved tracks feed not found";
         return array(self::$error);
     }
     $songs = self::formatSongData($song_data);
     Cache::setCache($songs);
     return $songs;
 }
Beispiel #2
0
function word_stem($word)
{
    $word = strtolower($word);
    $cache = Cache::getCache('stemming');
    if ($cache->has($word)) {
        return $cache->get($word);
    }
    $stemmed = @stemm_es::stemm($word);
    $cache->set($word, $stemmed);
    return $stemmed;
}
 /**
  * getBooksFromShelf()
  * Gets the array of books from a cache_file if found (and less than a week old).
  * If no cache_file is found it creates this array of books and adds them to the cache_file - for fast loading next time
  *
  * @return array Returns a nicely formatted array of books
  */
 private static function getBooksFromShelf()
 {
     $cache_filename = self::$goodreads_id . '-' . self::$shelf . '.cache';
     $cache_life = 604800;
     // 1 week
     Cache::init($cache_filename, $cache_life);
     if (Cache::cacheFileExists()) {
         return Cache::getCache();
     }
     $book_data = Feeder::getItems(self::getGoodreadsFeed(), self::$num_books, array('title', 'author_name'));
     if (!is_array($book_data)) {
         self::$error = "Goodreads feed does not exist. Check user: "******" and shelf: '" . self::$shelf . "' exist";
         return array(self::$error);
     }
     $books = self::formatBookData($book_data);
     Cache::setCache($books);
     return $books;
 }
 /**
  * Check Field Values
  * @param string $field IDX Field Name
  * @return boolean
  * @TODO Move this to IDX_Feed
  */
 public static function checkField($field)
 {
     // IDX Feed
     $idx = Util_IDX::getIdx();
     $db_idx = Util_IDX::getDatabase();
     // IDX Field
     $field = $idx->field($field);
     // Require Field
     if (empty($field)) {
         return false;
     }
     // Cache Key
     $index = __METHOD__ . ':' . $idx->getName() . ':' . $db_idx->db() . ':' . $idx->getTable() . ':' . $field;
     // Is Cached (Server-Wide)
     $cache = static::$useCache && !static::$reCache ? Cache::getCache($index, true) : null;
     if (!is_null($cache)) {
         $check = $cache;
         // Not Cached
     } else {
         // Check for Values
         $check = $db_idx->fetchQuery("SELECT SQL_CACHE `" . $field . "` FROM `" . $idx->getTable() . "` WHERE `" . $field . "` IS NOT NULL AND `" . $field . "` != '' LIMIT 1;");
         // Return Boolean
         $check = !empty($check);
         // Save Cache (Server-Wide)
         if (static::$useCache || static::$reCache) {
             Cache::setCache($index, $check, true);
         }
     }
     // Return Check
     return $check;
 }
Beispiel #5
0
}
$Core->LoadUserPlugins();
$Core->trigger('OnBeforeInitPage');
$Core->DefineDefaultPage();
$html = "";
$errorPage = null;
if ($Filter->get($_GET, 'pid', DEFAULT_PAGE) == NOT_FOUND) {
    if ($errorPage = $Router->pageNotFound()) {
        $_GET['pid'] = $errorPage->id;
    } else {
        header("HTTP/1.0 404 Not Found");
        die(NO_404_PAGE);
    }
}
if ($Filter->get($config, 'use_cache', 0) && $Cache->isCached()) {
    $html = $Cache->getCache();
}
if (empty($html)) {
    $Skin = new Skin($Filter->get($_GET, 'pid', DEFAULT_PAGE));
    $html = $Skin->getHtml();
    $html = str_replace(TOKEN_SKYBLUE_INFO_LINK, SKYBLUE_INFO_LINK, $html);
    $html = str_replace(TOKEN_BODY_CLASS, null, $html);
}
$html = $Core->trigger('OnBeforeShowPage', $html);
$html = $Core->trigger('OnRenderPage', $html);
if ($Filter->get($config, 'use_cache', 0)) {
    $Cache->saveCache($html);
    $html .= "\n<!-- page caching enabled -->\n";
}
if ($errorPage) {
    header("HTTP/1.0 404 Not Found");
Beispiel #6
0
/**
 * Strip-It Rss
 *
 * @license http://www.gnu.org/licenses/gpl.html GPL
 * @copyright 2009 Johann Dréo, Simon Leblanc
 * @author Johann "nojhan" Dréo <*****@*****.**>
 * @author Simon Leblanc <*****@*****.**>
 * @package stripit
 */
require_once 'inc/functions.php';
//Launch Cron
Cron::exec();
// Obtain the Config
$config = new Config();
// Obtain the cache
$cache = Cache::getCache();
// Obtain the id asked
$last = Cache::getLastId();
// Obtain the limit
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
    $limit = $_GET['limit'];
    if ($limit <= 0 || $limit > $last + 1) {
        $limit = $last + 1;
    }
} else {
    $limit = $last + 1;
}
$end = $last - $limit;
// Obtain the strips
$list = array();
for ($i = $last; $i > $end; $i--) {
Beispiel #7
0
if (isset($theme) && $theme) {
    $_SESSION['theme'] = $theme;
}
$page = new Page();
$movie = new Movie();
$show = new Show();
$cache = new Cache($basepath);
$misc = new Misc();
$request = new Request();
$plugins = new Plugins();
$hascache = 0;
$cache_writeable = $cache->checkDir();
if ($cache_writeable) {
    $cachekey_plain = date("YmdH") . @$_SERVER['HTTP_HOST'] . @$_SERVER['REQUEST_URI'] . @json_encode($_GET) . @json_encode($_POST) . @json_encode($_SESSION) . @json_encode($_COOKIE) . "_" . $language;
    $cachekey = md5($cachekey_plain);
    $hascache = $cache->getCache($cachekey);
}
$hascache = 0;
if ($hascache) {
    print $hascache;
} else {
    @ob_start();
    if (!isset($_SESSION['theme']) || !$_SESSION['theme']) {
        $theme = $settings->getSetting("theme");
        if (!count($theme)) {
            $theme = 'svarog';
        } else {
            $theme = $theme->theme;
        }
    } else {
        $theme = $_SESSION['theme'];
Beispiel #8
0
<?php

error_reporting(0);
include 'lib/core.class.php';
include 'lib/slickr.class.php';
include 'lib/cache.class.php';
@(include 'config.php');
if (!defined('USER')) {
    header('Location: admin/install.php');
}
$slickr = new Slickr(USER);
$cache = new Cache($_SERVER['REQUEST_URI']);
$cache->getCache();
if (!empty($_GET['id'])) {
    // on affiche les photos
    list($images, $parent) = $slickr->getPhotos();
    @(include 'templates/' . TEMPLATE . '/images.php');
} elseif (!empty($_GET['c_id'])) {
    // on affiche des photosets
    list($collecSets, $sets, $parent) = $slickr->getPhotosets();
    @(include 'templates/' . TEMPLATE . '/collecphotosets.php');
} elseif (!empty($_GET['b_id'])) {
    // on affiche des collections dans des collections
    list($collections, $parent) = $slickr->getCollections();
    $collections = $collections[$slickr->getBid()]['collection'];
    @(include 'templates/' . TEMPLATE . '/collections.php');
} else {
    // page par defaut
    if (HOMEPAGE == 'collections') {
        //(collections)
        list($collections, $parent) = $slickr->getCollections();
Beispiel #9
0
require_once 'cache.php';
//error_reporting(0);
$result = array('status' => 'error_unknown');
if (!isset($_GET['term'])) {
    $result['status'] = 'error_search_term';
    $result['error'] = 'No search term was specified';
} else {
    $queryResult = twitter_query($_GET['term']);
    if (isset($queryResult['errors'])) {
        $result['status'] = 'error_api';
        $result['error'] = 'API returned errors';
        $result['api_errors'] = $queryResult['errors'];
    } else {
        $result['status'] = 'ok';
        $result['summary'] = array('positive' => 0, 'neutral' => 0, 'negative' => 0);
        $stemCache = Cache::getCache('stemming');
        $stemCache->load();
        $lexicon = lexicon_stem(lexicon_read('lexicon.txt'));
        $statuses = $queryResult['statuses'];
        $result['tweets'] = process_tweets($statuses, $lexicon);
        foreach ($result['tweets'] as $tweet) {
            $val = array_sum($tweet['words']);
            if ($val > 0.01) {
                $result['summary']['positive']++;
            } else {
                if ($val < -0.01) {
                    $result['summary']['negative']++;
                } else {
                    $result['summary']['neutral']++;
                }
            }
Beispiel #10
0
 /**
  * Create cache for one or all necessary strips
  *
  * @param string $file The filename of the strip for which we must regenerate cache or null if we must regenerate all cache file necessary
  * @access public
  * @static
  */
 public static function createCache($file = null)
 {
     if ($file === null) {
         // we must regenerate all SVG cache
         $actual_cache = Cache::getCache();
         Cache::setCache();
         $new_cache = Cache::getCache();
         $compare = array_diff($new_cache, $actual_cache);
         foreach ($compare as $filename => $time) {
             $strip = new Strip($filename, true);
             $strip->setCache();
         }
     } else {
         $strip = new Strip($file, true);
         $strip->setCache();
     }
 }