Commit 40f8846a authored by Erase's avatar Erase
Browse files

Global update

parent ca84fd39
<?php
require 'system/classes/Config.php';
require 'system/classes/Date.php';
require 'system/classes/FeedReader.php';
require 'system/vendor/simplepie/SimplePie.php';
//~ Define the root path
define('TL_ROOT', dirname(__DIR__.'/RSS-Fusion'));
require TL_ROOT.'/system/classes/Config.php';
require TL_ROOT.'/system/classes/Date.php';
require TL_ROOT.'/system/classes/FeedReader.php';
require TL_ROOT.'/system/vendor/simplepie/SimplePie.php';
Config::preload();
......@@ -11,17 +14,17 @@
ini_set('display_errors', (Config::get('displayErrors') ? 1 : 0));
error_reporting((Config::get('displayErrors') || Config::get('logErrors')) ? 1 : 0);
$_links = array(
"http://www.lemonde.fr/rss/une.xml",
"https://rss.framasoft.org/"
);
/*
$_links = array(
"http://www.lemonde.fr/rss/une.xml",
"https://rss.framasoft.org/"
);
$feeds = new FeedReader($_links);
$feeds = new FeedReader($_links);
echo "<pre>";
var_dump($feeds->objParseFeed->items)
echo "<pre>";
var_dump($feeds->objParseFeed->items)
*/
?>
......@@ -86,7 +86,7 @@ class Config
// Include the local configuration file again
if (static::$blnHasLcf)
{
include 'system/config/localconfig.php';
include TL_ROOT.'/system/config/localconfig.php';
}
}
......@@ -127,13 +127,13 @@ class Config
public static function preload()
{
// Load the default files
include 'system/config/default.php';
include 'system/config/agents.php';
include TL_ROOT.'/system/config/default.php';
include TL_ROOT.'/system/config/agents.php';
// Include the local configuration file
if (($blnHasLcf = file_exists('system/config/localconfig.php')) === true)
if (($blnHasLcf = file_exists(TL_ROOT.'/system/config/localconfig.php')) === true)
{
include 'system/config/localconfig.php';
include TL_ROOT.'/system/config/localconfig.php';
}
static::$blnHasLcf = $blnHasLcf;
......@@ -150,7 +150,7 @@ class Config
if (static::$blnHasLcf)
{
$resFile = fopen('system/config/localconfig.php', 'rb');
$resFile = fopen(TL_ROOT.'/system/config/localconfig.php', 'rb');
while (!feof($resFile))
{
......@@ -202,23 +202,23 @@ class Config
$strTemp = md5(uniqid(mt_rand(), true));
// Write to a temp file first
$objFile = fopen('system/cache/' . $strTemp, 'wb');
$objFile = fopen(TL_ROOT.'/system/cache/' . $strTemp, 'wb');
fputs($objFile, $strFile);
fclose($objFile);
// Make sure the file has been written
if (!filesize('system/cache/' . $strTemp))
if (!filesize(TL_ROOT.'/system/cache/' . $strTemp))
{
return;
}
// Then move the file to its final destination
rename('system/cache/' . $strTemp, 'system/config/localconfig.php');
rename(TL_ROOT.'/system/cache/' . $strTemp, TL_ROOT.'/system/config/localconfig.php');
// Reset the Zend OPcache
if (function_exists('opcache_invalidate'))
{
opcache_invalidate('system/config/localconfig.php', true);
opcache_invalidate(TL_ROOT.'/system/config/localconfig.php', true);
}
// Reset the Zend Optimizer+ cache (unfortunately no API to delete just a single file)
......@@ -230,7 +230,7 @@ class Config
// Recompile the APC file
if (function_exists('apc_compile_file') && !ini_get('apc.stat'))
{
apc_compile_file('system/config/localconfig.php');
apc_compile_file(TL_ROOT.'/system/config/localconfig.php');
}
// Purge the eAccelerator cache
......
......@@ -48,7 +48,7 @@ class FeedReader
}
$this->objFeed->set_output_encoding(\Config::get('characterSet'));
$this->objFeed->set_cache_location('system/cache/');
$this->objFeed->set_cache_location(TL_ROOT.'/system/cache/');
$this->objFeed->enable_cache(\Config::get('enableCache'));
$this->objFeed->set_cache_duration(\Config::get('cacheDuration'));
$this->objFeed->enable_order_by_date();
......@@ -99,18 +99,33 @@ class FeedReader
'date_read' => \Date::parse(Config::get('datimFormat'), $this->arrItems[$i]->get_date('U')),
'category' => $this->arrItems[$i]->get_category(0),
'base' => $this->arrItems[$i]->get_base(),
'show' => true // true || false || star
'show' => 'show' // show || hide || star
);
// Where
$where = \Config::get('where');
if(!is_null($where) && $where == 'title'){
$merge_str = strtolower($items[$i]['title']);
}elseif(!is_null($where) && $where == 'description'){
$merge_str = strtolower($items[$i]['description']);
}else{
$merge_str = strtolower($items[$i]['title']." ".$items[$i]['description']);
}
// Bad and star words
$merge_str = strtolower($items[$i]['title']." ".$items[$i]['description']);
if(0 < count(array_intersect(array_map('strtolower', explode(' ', $merge_str)), Config::get('_starWords'))))
{
$items[$i]['show'] = 'star';
if(count(Config::get('_starWords'))){
if($this->isInStr($merge_str, Config::get('_starWords')))
{
$items[$i]['show'] = 'star';
}
}
if(0 < count(array_intersect(array_map('strtolower', explode(' ', $merge_str)), Config::get('_badWords'))))
{
$items[$i]['show'] = 'false';
if(count(Config::get('_badWords'))){
if($this->isInStr($merge_str, Config::get('_badWords')))
{
$items[$i]['show'] = 'hide';
}
}
// Add author
......@@ -130,4 +145,20 @@ class FeedReader
}
public static function isInStr($strString, $varWords)
{
foreach ((array) $varWords as $strWord)
{
if(empty($strWord)){
continue;
}
$t = preg_match("/".preg_quote(htmlentities($strWord), '/')."/i", $strString);
if($t){
return true;
}
}
return false;
}
}
......@@ -48,7 +48,7 @@ $GLOBALS['TL_CONFIG']['MONTHS_SHORT'] = array('Jan', 'Fév', 'Mar', 'Avr', '
* RSS SETTINGS
* -------------------------------------------------------------------------
*/
$GLOBALS['TL_CONFIG']['maxResultsPerBlock'] = 20;
$GLOBALS['TL_CONFIG']['maxResultsPerBlock'] = 50;
$GLOBALS['TL_CONFIG']['enableCache'] = true;
$GLOBALS['TL_CONFIG']['cacheDuration'] = 3600; //~ 1h
$GLOBALS['TL_CONFIG']['RssReaderReferer'] = "RSS-Fusion with SimplePie";
......@@ -56,8 +56,9 @@ $GLOBALS['TL_CONFIG']['RssReaderReferer'] = "RSS-Fusion with SimplePie";
/**
* -------------------------------------------------------------------------
* WORDS SETTINGS
* WORDS AND SEARCH SETTINGS
* -------------------------------------------------------------------------
*/
$GLOBALS['TL_CONFIG']['_starWords'] = array();
$GLOBALS['TL_CONFIG']['_badWords'] = array();
\ No newline at end of file
$GLOBALS['TL_CONFIG']['_badWords'] = array();
$GLOBALS['TL_CONFIG']['where'] = 'all'; //~ (title | description | all)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment