コード例 #1
0
ファイル: FreshRSS.php プロジェクト: buggithubs/FreshRSS
 /**
  * Initialize the different FreshRSS / Minz components.
  *
  * PLEASE DON'T CHANGE THE ORDER OF INITIALIZATIONS UNLESS YOU KNOW WHAT
  * YOU DO!!
  *
  * Here is the list of components:
  * - Create a configuration setter and register it to system conf
  * - Init extension manager and enable system extensions (has to be done asap)
  * - Init authentication system
  * - Init user configuration (need auth system)
  * - Init FreshRSS context (need user conf)
  * - Init i18n (need context)
  * - Init sharing system (need user conf and i18n)
  * - Init generic styles and scripts (need user conf)
  * - Init notifications
  * - Enable user extensions (need all the other initializations)
  */
 public function init()
 {
     if (!isset($_SESSION)) {
         Minz_Session::init('FreshRSS');
     }
     // Register the configuration setter for the system configuration
     $configuration_setter = new FreshRSS_ConfigurationSetter();
     $system_conf = Minz_Configuration::get('system');
     $system_conf->_configurationSetter($configuration_setter);
     // Load list of extensions and enable the "system" ones.
     Minz_ExtensionManager::init();
     // Auth has to be initialized before using currentUser session parameter
     // because it's this part which create this parameter.
     $this->initAuth();
     // Then, register the user configuration and use the configuration setter
     // created above.
     $current_user = Minz_Session::param('currentUser', '_');
     Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php'), join_path(USERS_PATH, '_', 'config.default.php'), $configuration_setter);
     // Finish to initialize the other FreshRSS / Minz components.
     FreshRSS_Context::init();
     $this->initI18n();
     FreshRSS_Share::load(join_path(DATA_PATH, 'shares.php'));
     $this->loadStylesAndScripts();
     $this->loadNotifications();
     // Enable extensions for the current (logged) user.
     if (FreshRSS_Auth::hasAccess()) {
         $ext_list = FreshRSS_Context::$user_conf->extensions_enabled;
         Minz_ExtensionManager::enableByList($ext_list);
     }
 }
コード例 #2
0
 /**
  * Constructeur
  * Initialise le dispatcher, met à jour la Request
  */
 public function __construct()
 {
     try {
         Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php');
         $this->setReporting();
         Minz_Request::init();
         $url = $this->buildUrl();
         $url['params'] = array_merge($url['params'], Minz_Request::fetchPOST());
         Minz_Request::forward($url);
     } catch (Minz_Exception $e) {
         Minz_Log::error($e->getMessage());
         $this->killApp($e->getMessage());
     }
     $this->dispatcher = Minz_Dispatcher::getInstance();
 }
コード例 #3
0
ファイル: pshb.php プロジェクト: buggithubs/FreshRSS
if ($self !== base64url_decode($canonical64)) {
    //header('HTTP/1.1 422 Unprocessable Entity');
    logMe('Warning: Self URL [' . $self . '] does not match registered canonical URL!: ' . base64url_decode($canonical64));
    //die('Self URL does not match registered canonical URL!');
    $self = base64url_decode($canonical64);
}
Minz_Request::_param('url', $self);
$nb = 0;
foreach ($users as $userFilename) {
    $username = basename($userFilename, '.txt');
    if (!file_exists(USERS_PATH . '/' . $username . '/config.php')) {
        break;
    }
    try {
        Minz_Session::_param('currentUser', $username);
        Minz_Configuration::register('user', join_path(USERS_PATH, $username, 'config.php'), join_path(USERS_PATH, '_', 'config.default.php'));
        FreshRSS_Context::init();
        if ($feedController->actualizeAction($simplePie) > 0) {
            $nb++;
        }
    } catch (Exception $e) {
        logMe('Error: ' . $e->getMessage());
    }
}
$simplePie->__destruct();
unset($simplePie);
if ($nb === 0) {
    header('HTTP/1.1 410 Gone');
    logMe('Error: Nobody is subscribed to this feed anymore after all!: ' . $self);
    die('Nobody is subscribed to this feed anymore after all!');
} elseif (!empty($hubJson['error'])) {
コード例 #4
0
ファイル: greader.php プロジェクト: krisfremen/FreshRSS
    } elseif (strpos($streamId, 'user/-/label/') === 0) {
        $c_name = basename($streamId);
        $categoryDAO = new FreshRSS_CategoryDAO();
        $cat = $categoryDAO->searchByName($c_name);
        $entryDAO->markReadCat($cat === null ? -1 : $cat->id(), $olderThanId);
    } elseif ($streamId === 'user/-/state/com.google/reading-list') {
        $entryDAO->markReadEntries($olderThanId, false, -1);
    }
    echo 'OK';
    exit;
}
logMe('----------------------------------------------------------------' . "\n");
//logMe(debugInfo());
$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']);
$pathInfos = explode('/', $pathInfo);
Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php');
$system_conf = Minz_Configuration::get('system');
if (!$system_conf->api_enabled) {
    serviceUnavailable();
}
Minz_Session::init('FreshRSS');
$user = authorizationToUser();
$conf = null;
if ($user !== '') {
    $conf = get_user_configuration($user);
}
logMe('User => ' . $user . "\n");
Minz_Session::_param('currentUser', $user);
if (count($pathInfos) < 3) {
    badRequest();
} elseif ($pathInfos[1] === 'accounts') {
コード例 #5
0
ファイル: lib_rss.php プロジェクト: krisfremen/FreshRSS
/**
 * Register and return the configuration for a given user.
 *
 * Note this function has been created to generate temporary configuration
 * objects. If you need a long-time configuration, please don't use this function.
 *
 * @param $username the name of the user of which we want the configuration.
 * @return a Minz_Configuration object, null if the configuration cannot be loaded.
 */
function get_user_configuration($username)
{
    $namespace = 'user_' . $username;
    try {
        Minz_Configuration::register($namespace, join_path(USERS_PATH, $username, 'config.php'), join_path(USERS_PATH, '_', 'config.default.php'));
    } catch (Minz_ConfigurationNamespaceException $e) {
        // namespace already exists, do nothing.
    } catch (Minz_FileNotExistException $e) {
        Minz_Log::warning($e->getMessage());
        return null;
    }
    return Minz_Configuration::get($namespace);
}
コード例 #6
0
ファイル: install.php プロジェクト: buggithubs/FreshRSS
function freshrss_already_installed()
{
    $conf_path = join_path(DATA_PATH, 'config.php');
    if (!file_exists($conf_path)) {
        return false;
    }
    // A configuration file already exists, we try to load it.
    $system_conf = null;
    try {
        Minz_Configuration::register('system', $conf_path);
        $system_conf = Minz_Configuration::get('system');
    } catch (Minz_FileNotExistException $e) {
        return false;
    }
    // ok, the global conf exists... but what about default user conf?
    $current_user = $system_conf->default_user;
    try {
        Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php'));
    } catch (Minz_FileNotExistException $e) {
        return false;
    }
    // ok, ok, default user exists too!
    return true;
}