This file is part of YSM libagregator.
YSM libagregator is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
YSM libagregator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with YSM libagregator. If not, see .
*/
// ** note **
// include your agregator configuration file before including this file
// **********
// require
require_once dirname(__FILE__).'/libagregator.php';
if (array_key_exists('configFile', $_GET) && array_key_exists('action', $_GET)) {
$action = $_GET['action'];
if ($action == 'run') {
agregator_run($_GET['configFile']);
}
}
function agregator_run($configFile) {
$_SERVER['argv'] = array(0=>'agregator.php', 1=>$configFile);
require_once dirname(__FILE__) . '/agregator.php';
}
/** Selected Config File (without path), '' if none */
$gConfigFile = '';
/** Full path to Config File selected, '' if none */
$gConfigFilePath = '';
/** Full path to Config File selected, false if doesn't exist yet */
$gConfigExist = false;
// list of error
$gErrorList = array();
// loading GET options
/** get configFile selected (should be valid, and writable) */
if ( isset($_GET['configFile'])) {
$gConfigFile = $_GET['configFile'];
} else if ( isset($_POST['configFile'])) {
$gConfigFile = $_POST['configFile'];
}
if ( $gConfigFile != '' ) {
$gConfigFilePath = $agregatorRSSConfigPath .'/'. $gConfigFile .'.php';
if ( is_file($gConfigFilePath)) {
if (is_writable($gConfigFilePath) ) {
$gConfigExist = true;
} else {
$gErrorList[] = agregatorTr('Configuration file "$1" is not readable and writable.', $gConfigFile);
}
}
}
if ( isset($_POST['DEFINETXT']) ) {
$defineArray = array();
foreach($_POST['DEFINETXT'] as $i=>$defineName) {
$defineArray[$defineName] = $_POST['DEFINE'][$i];
}
$tmpTabFilInfo = array();
for($iFil = 0; $iFil < $_POST['newnbrss']; $iFil++) {
if ($_POST['newrss'.$iFil] != '') {
$tmpTabFilInfo[] = array($_POST['newrss'.$iFil],
$_POST['newname'.$iFil],
$_POST['newsite'.$iFil],
'entities'=>isset($_POST['newentities'.$iFil]),
'description'=>isset($_POST['newdescription'.$iFil]),
'error'=>'',
'errorTimes'=>0,
'count'=>0,
'lastcount'=>0,
'lastdate'=>''
);
}
}
for($iFil = 0; $iFil < $_POST['nbrss']; $iFil++) {
if ($_POST['rss'.$iFil] != '') {
$tmpTabFilInfo[] = array($_POST['rss'.$iFil],
$_POST['name'.$iFil],
$_POST['site'.$iFil],
'entities'=>isset($_POST['entities'.$iFil]),
'description'=>isset($_POST['description'.$iFil]),
'error'=>$_POST['error'.$iFil],
'errorTimes'=>intval($_POST['errorTimes'.$iFil]),
'count'=>intval($_POST['count'.$iFil]),
'disabled'=>isset($_POST['disabled'.$iFil]),
'lastcount'=>intval($_POST['lastcount'.$iFil]),
'lastdate'=>$_POST['lastdate'.$iFil]
);
}
}
copy($gConfigFilePath, $gConfigFilePath.'.bak');
agregatorWriteConf($gConfigFilePath, $defineArray, $tmpTabFilInfo);
}
// output configuration
?>
'.agregatorTr('Configuration file').'';
$configFileList = getConfigFileList($agregatorRSSConfigPath);
if ($configFileList === FALSE) {
$gErrorList[] = agregatorTr('Invalid configuration of variable $agregatorRSSConfigPath : "$1"', "$agregatorRSSConfigPath");
} else {
echo '
'.agregatorTr('Configuration file').'
';
echo '
';
foreach($configFileList as $fileName) {
$fileBasename = basename($fileName, '.php');
$className = $fileBasename == $gConfigFile ? ' class="current"' : '';
echo '- '.htmlspecialchars($fileBasename).'
'."\n";
}
$labelNew = agregatorTr('New');
$labelCreate = agregatorTr('Create');
$linew = <<
EOF;
echo $linew.'
'."\n";
echo '
'."\n";
}
if ( $gConfigFile != '' ) {
if ( $gConfigExist === true) {
echo '
'.agregatorTr('Configuration is loaded').'
'."\n";
echo '
Run | ';
echo 'View HTML
'."\n";
include $gConfigFilePath;
}
if (array_key_exists('action', $_GET)) {
$action = $_GET['action'];
if ($action == 'viewhtml' || $action == 'run') {
echo '
';
if (file_exists(OUTPUT_FILE)) {
readfile(OUTPUT_FILE);
}
echo '
';
}
}
echo '
';
} // if ConfigFile
if (count($gErrorList)) {
echo '
'.agregatorTr('Errors').'
';
foreach($gErrorList as $errorString) {
echo '- '.htmlspecialchars($errorString).'
'."\n";
}
echo '
';
}
?>