You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

83 lines
2.1 KiB

<?php
//~ Include RSS Fusion
require_once 'vendor/RSS-Fusion/index.php';
//~ Array for return
$_d = array(
'sucess' => false,
'message' => "",
'data' => array()
);
//~ Check data
if(array_key_exists('flux', $_POST) && !empty($_POST['flux'])){
$_links = array_unique(
array_map('trim',
explode(',', $_POST['flux'])
)
);
//~ Where to look
if(array_key_exists('where', $_POST) && !empty($_POST['where'])){
\Config::set('where', $_POST['where']);
}
//~ Show or hide keywords
if(array_key_exists('filter', $_POST) && !empty($_POST['filter'])){
$mode = "_starWords";
if($_POST['filter'] === 'hide'){
$mode = "_badWords";
}
if(!empty($_POST['words'])){
Config::set($mode, array_unique(
array_map('trim',
explode(',', $_POST['words'])
)
));
}
}
$oFeeds = new FeedReader($_links);
if(!is_null($oFeeds->objParseFeed)){
//~ Config is ok ! Storage
$conf_storage = json_encode(array(
'flux' => $_links,
'where' => \Config::get('where'),
'_starWords' => \Config::get('_starWords'),
'_badWords' => \Config::get('_badWords')
));
session_start();
$conf_name = str_replace('.', '', uniqid(rand(), true));
if(file_put_contents(TL_ROOT . '/../../c/'.$conf_name, $conf_storage)){
//~ Generate link to return
$_d['sucess'] = true;
$_d['message'] = "Voici le lien RSS relatif à votre configuration";
$_d['data'] = array(
'file' => './flux.php?c='.$conf_name,
'_' => $_POST
);
}else{
//~ Error
$_d['sucess'] = false;
$_d['message'] = "Une erreur est survenue lors de l'enregistrement de votre configuration";
}
}else{
$_d['sucess'] = false;
$_d['message'] = "Une erreur est survenue lors du chargement de flux RSS";
}
}else{
//~ No data
$_d['sucess'] = false;
$_d['message'] = "Merci de renseigner au moins une URL de flux RSS";
}
header('Content-type: text/json');
echo json_encode($_d);
exit;