1
0
Fork 0
forked from blallo/rss-bridge

Merge branch 'experimental' of github.com:sebsauvage/rss-bridge

This commit is contained in:
Mitsukarenai 2015-12-06 16:01:30 +01:00
commit 6866e508cb
2 changed files with 30 additions and 3 deletions

View file

@ -1,7 +1,6 @@
<?php
/*
TODO :
- manage SSL detection because if library isn't loaded, some bridge crash !
- factorize the annotation system
- factorize to adapter : Format, Bridge, Cache (actually code is almost the same)
- implement annotation cache for entrance page
@ -17,14 +16,19 @@ date_default_timezone_set('UTC');
error_reporting(0);
//ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
require_once __DIR__ . '/lib/RssBridge.php';
// extensions check
if (!extension_loaded('openssl'))
die('"openssl" extension not loaded. Please check "php.ini"');
// FIXME : beta test UA spoofing, please report any blacklisting by PHP-fopen-unfriendly websites
ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0 (rss-bridge/0.1; +https://github.com/sebsauvage/rss-bridge)');
<<<<<<< HEAD
// -------
=======
>>>>>>> a40bbbd2deb5f59d88d61fe2253a16c28deb900b
// cache file purge - delete cache files older than 24 hours
$cacheTimeLimit = time() - 60*60*24 ;
@ -77,9 +81,12 @@ else {
array_pop($whitelist_selection);
}
<<<<<<< HEAD
=======
Cache::purge();
>>>>>>> a40bbbd2deb5f59d88d61fe2253a16c28deb900b
try{
require_once __DIR__ . '/lib/RssBridge.php';
Bridge::setDir(__DIR__ . '/bridges/');
Format::setDir(__DIR__ . '/formats/');

View file

@ -69,4 +69,24 @@ class Cache{
static public function isValidNameCache($nameCache){
return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache);
}
static public function purge() {
$cacheTimeLimit = time() - 60*60*24 ;
$cachePath = 'cache';
if(file_exists($cachePath)) {
$cacheIterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cachePath),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($cacheIterator as $cacheFile) {
if (in_array($cacheFile->getBasename(), array('.', '..')))
continue;
elseif ($cacheFile->isFile()) {
if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit )
unlink( $cacheFile->getPathname() );
}
}
}
}
}