/** * Permet de retourner les logs de façon à n'avoir que * ceux que l'on veut réellement * @param $logs les logs rangés par catégories (error, warning, notice) * @return la liste des logs, sans catégorie, * > en fonction de l'environment */ private static function processLogs($logs) { $conf = Minz_Configuration::get('system'); $env = $conf->environment; $logs_ok = array(); $error = array(); $warning = array(); $notice = array(); if (isset($logs['error'])) { $error = $logs['error']; } if (isset($logs['warning'])) { $warning = $logs['warning']; } if (isset($logs['notice'])) { $notice = $logs['notice']; } if ($env == 'production') { $logs_ok = $error; } if ($env == 'development') { $logs_ok = array_merge($error, $warning, $notice); } return $logs_ok; }
/** * 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); } }
/** * Initialize the extension manager by loading extensions in EXTENSIONS_PATH. * * A valid extension is a directory containing metadata.json and * extension.php files. * metadata.json is a JSON structure where the only required fields are * `name` and `entry_point`. * extension.php should contain at least a class named <name>Extension where * <name> must match with the entry point in metadata.json. This class must * inherit from Minz_Extension class. */ public static function init() { $list_potential_extensions = array_values(array_diff(scandir(EXTENSIONS_PATH), array('..', '.'))); $system_conf = Minz_Configuration::get('system'); self::$ext_auto_enabled = $system_conf->extensions_enabled; foreach ($list_potential_extensions as $ext_dir) { $ext_pathname = EXTENSIONS_PATH . '/' . $ext_dir; if (!is_dir($ext_pathname)) { continue; } $metadata_filename = $ext_pathname . '/' . self::$ext_metaname; // Try to load metadata file. if (!file_exists($metadata_filename)) { // No metadata file? Invalid! continue; } $meta_raw_content = file_get_contents($metadata_filename); $meta_json = json_decode($meta_raw_content, true); if (!$meta_json || !self::isValidMetadata($meta_json)) { // metadata.json is not a json file? Invalid! // or metadata.json is invalid (no required information), invalid! Minz_Log::warning('`' . $metadata_filename . '` is not a valid metadata file'); continue; } $meta_json['path'] = $ext_pathname; // Try to load extension itself $extension = self::load($meta_json); if (!is_null($extension)) { self::register($extension); } } }
/** * Enregistre un message dans un fichier de log spécifique * Message non loggué si * - environment = SILENT * - level = WARNING et environment = PRODUCTION * - level = NOTICE et environment = PRODUCTION * @param $information message d'erreur / information à enregistrer * @param $level niveau d'erreur * @param $file_name fichier de log */ public static function record($information, $level, $file_name = null) { try { $conf = Minz_Configuration::get('system'); $env = $conf->environment; } catch (Minz_ConfigurationException $e) { $env = 'production'; } if (!($env === 'silent' || $env === 'production' && $level >= Minz_Log::NOTICE)) { if ($file_name === null) { $file_name = join_path(USERS_PATH, Minz_Session::param('currentUser', '_'), 'log.txt'); } switch ($level) { case Minz_Log::ERROR: $level_label = 'error'; break; case Minz_Log::WARNING: $level_label = 'warning'; break; case Minz_Log::NOTICE: $level_label = 'notice'; break; case Minz_Log::DEBUG: $level_label = 'debug'; break; default: $level_label = 'unknown'; } $log = '[' . date('r') . ']' . ' [' . $level_label . ']' . ' --- ' . $information . "\n"; if (file_put_contents($file_name, $log, FILE_APPEND | LOCK_EX) === false) { throw new Minz_PermissionDeniedException($file_name, Minz_Exception::ERROR); } } }
/** * Affiche une Url formatée selon que l'on utilise l'url_rewriting ou non * si oui, on cherche dans la table de routage la correspondance pour formater * @param $url l'url à formater définie comme un tableau : * $url['c'] = controller * $url['a'] = action * $url['params'] = tableau des paramètres supplémentaires * $url['protocol'] = protocole à utiliser (http par défaut) * ou comme une chaîne de caractère * @param $encodage pour indiquer comment encoder les & (& ou & pour html) * @return l'url formatée */ public static function display($url = array(), $encodage = 'html', $absolute = false) { $isArray = is_array($url); if ($isArray) { $url = self::checkUrl($url); } $url_string = ''; if ($absolute) { if ($isArray && isset($url['protocol'])) { $protocol = $url['protocol']; } elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $protocol = 'https:'; } else { $protocol = 'http:'; } $url_string = $protocol . '//' . Minz_Request::getDomainName() . Minz_Request::getBaseUrl(); } else { $url_string = $isArray ? '.' : PUBLIC_RELATIVE; } if ($isArray) { $router = new Minz_Router(); if (Minz_Configuration::useUrlRewriting()) { $url_string .= $router->printUriRewrited($url); } else { $url_string .= self::printUri($url, $encodage); } } else { $url_string .= $url; } return $url_string; }
/** * Enregistre un message dans un fichier de log spécifique * Message non loggué si * - environment = SILENT * - level = WARNING et environment = PRODUCTION * - level = NOTICE et environment = PRODUCTION * @param $information message d'erreur / information à enregistrer * @param $level niveau d'erreur * @param $file_name fichier de log, par défaut LOG_PATH/application.log */ public static function record($information, $level, $file_name = null) { $env = Minz_Configuration::environment(); if (!($env === Minz_Configuration::SILENT || $env === Minz_Configuration::PRODUCTION && $level >= Minz_Log::NOTICE)) { if ($file_name === null) { $file_name = LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log'; } switch ($level) { case Minz_Log::ERROR: $level_label = 'error'; break; case Minz_Log::WARNING: $level_label = 'warning'; break; case Minz_Log::NOTICE: $level_label = 'notice'; break; case Minz_Log::DEBUG: $level_label = 'debug'; break; default: $level_label = 'unknown'; } $log = '[' . date('r') . ']' . ' [' . $level_label . ']' . ' --- ' . $information . "\n"; if (file_put_contents($file_name, $log, FILE_APPEND | LOCK_EX) === false) { throw new Minz_PermissionDeniedException($file_name, Minz_Exception::ERROR); } } }
public function nonceAction() { header('Content-Type: application/json; charset=UTF-8'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T')); header('Expires: 0'); header('Cache-Control: private, no-cache, no-store, must-revalidate'); header('Pragma: no-cache'); $user = isset($_GET['user']) ? $_GET['user'] : ''; if (ctype_alnum($user)) { try { $conf = new FreshRSS_Configuration($user); $s = $conf->passwordHash; if (strlen($s) >= 60) { $this->view->salt1 = substr($s, 0, 29); //CRYPT_BLOWFISH Salt: "$2a$", a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z". $this->view->nonce = sha1(Minz_Configuration::salt() . uniqid(mt_rand(), true)); Minz_Session::_param('nonce', $this->view->nonce); return; //Success } } catch (Minz_Exception $me) { Minz_Log::record('Nonce failure: ' . $me->getMessage(), Minz_Log::WARNING); } } $this->view->nonce = ''; //Failure $this->view->salt1 = ''; }
/** * Initialize the context. * * Set the correct configurations and $categories variables. */ public static function init() { // Init configuration. self::$system_conf = Minz_Configuration::get('system'); self::$user_conf = Minz_Configuration::get('user'); $catDAO = FreshRSS_Factory::createCategoryDAO(); self::$categories = $catDAO->listCategories(); }
public static function createDatabaseDAO($username = null) { $conf = Minz_Configuration::get('system'); if ($conf->db['type'] === 'sqlite') { return new FreshRSS_DatabaseDAOSQLite($username); } else { return new FreshRSS_DatabaseDAO($username); } }
/** * Inclus le fichier de langue qui va bien * l'enregistre dans $translates */ public static function init() { $l = Minz_Configuration::language(); self::$language = Minz_Session::param('language', $l); $l_path = APP_PATH . '/i18n/' . self::$language . '.php'; if (file_exists($l_path)) { self::$translates = (include $l_path); } }
public function __construct($params) { $this->seq = isset($params['seq']) ? $params['seq'] : 0; $this->user = Minz_Session::param('currentUser', ''); $this->method = $params['op']; $this->params = $params; $this->system_conf = Minz_Configuration::get('system'); if ($this->user != '') { $this->user_conf = get_user_configuration($this->user); } }
public function deleteUser($username) { require_once APP_PATH . '/sql.php'; $db = Minz_Configuration::dataBase(); $sql = sprintf(SQL_DROP_TABLES, $db['prefix'] . $username . '_'); $stm = $this->bd->prepare($sql); if ($stm && $stm->execute()) { return true; } else { $info = $stm->errorInfo(); Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR); return false; } }
public function size($all = false) { $db = Minz_Configuration::dataBase(); $sql = 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = ?'; $values = array($db['base']); if (!$all) { $sql .= ' AND table_name LIKE ?'; $values[] = $this->prefix . '%'; } $stm = $this->bd->prepare($sql); $stm->execute($values); $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); return $res[0]; }
public static function createDatabaseDAO($username = null) { $conf = Minz_Configuration::get('system'); switch ($conf->db['type'] === 'sqlite') { case 'sqlite': return new FreshRSS_DatabaseDAOSQLite($username); break; case 'pgsql': return new FreshRSS_DatabaseDAOpgSQL($username); break; default: return new FreshRSS_DatabaseDAO($username); } }
/** * Initialise le Router en déterminant le couple Controller / Action * Mets à jour la Request * @exception RouteNotFoundException si l'uri n'est pas présente dans * > la table de routage */ public function init() { $url = array(); if (Minz_Configuration::useUrlRewriting()) { try { $url = $this->buildWithRewriting(); } catch (Minz_RouteNotFoundException $e) { throw $e; } } else { $url = $this->buildWithoutRewriting(); } $url['params'] = array_merge($url['params'], Minz_Request::fetchPOST()); Minz_Request::forward($url); }
public function firstAction() { if (!$this->view->loginOk) { // Token is useful in the case that anonymous refresh is forbidden // and CRON task cannot be used with php command so the user can // set a CRON task to refresh his feeds by using token inside url $token = $this->view->conf->token; $token_param = Minz_Request::param('token', ''); $token_is_ok = $token != '' && $token == $token_param; $action = Minz_Request::actionName(); if (!(($token_is_ok || Minz_Configuration::allowAnonymousRefresh()) && $action === 'actualize')) { Minz_Error::error(403, array('error' => array(Minz_Translate::t('access_denied')))); } } }
/** * Constructeur * Initialise le router et le dispatcher */ public function __construct() { if (LOG_PATH === false) { $this->killApp('Path not found: LOG_PATH'); } try { Minz_Configuration::init(); Minz_Request::init(); $this->router = new Minz_Router(); $this->router->init(); } catch (Minz_RouteNotFoundException $e) { Minz_Log::record($e->getMessage(), Minz_Log::ERROR); Minz_Error::error(404, array('error' => array($e->getMessage()))); } catch (Minz_Exception $e) { Minz_Log::record($e->getMessage(), Minz_Log::ERROR); $this->killApp($e->getMessage()); } $this->dispatcher = Minz_Dispatcher::getInstance($this->router); }
/** * Créé la connexion à la base de données à l'aide des variables * HOST, BASE, USER et PASS définies dans le fichier de configuration */ public function __construct($currentUser = null) { if (self::$useSharedBd && self::$sharedBd != null && $currentUser === null) { $this->bd = self::$sharedBd; $this->prefix = self::$sharedPrefix; $this->current_user = self::$sharedCurrentUser; return; } $conf = Minz_Configuration::get('system'); $db = $conf->db; if ($currentUser === null) { $currentUser = Minz_Session::param('currentUser', '_'); } $this->current_user = $currentUser; self::$sharedCurrentUser = $currentUser; $driver_options = isset($conf->db['pdo_options']) && is_array($conf->db['pdo_options']) ? $conf->db['pdo_options'] : array(); try { $type = $db['type']; if ($type === 'mysql') { $string = 'mysql:host=' . $db['host'] . ';dbname=' . $db['base'] . ';charset=utf8'; $driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8'; $this->prefix = $db['prefix'] . $currentUser . '_'; } elseif ($type === 'pgsql') { $string = 'pgsql:host=' . $db['host'] . ';dbname=' . $db['base']; $this->prefix = $db['prefix'] . $currentUser . '_'; } elseif ($type === 'sqlite') { $string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite'); //$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $this->prefix = ''; } else { throw new Minz_PDOConnectionException('Invalid database type!', $db['user'], Minz_Exception::ERROR); } self::$sharedDbType = $type; self::$sharedPrefix = $this->prefix; $this->bd = new MinzPDO($string, $db['user'], $db['password'], $driver_options); if ($type === 'sqlite') { $this->bd->exec('PRAGMA foreign_keys = ON;'); } self::$sharedBd = $this->bd; } catch (Exception $e) { throw new Minz_PDOConnectionException($string, $db['user'], Minz_Exception::ERROR); } }
/** * Permet de retourner les logs de façon à n'avoir que * ceux que l'on veut réellement * @param $logs les logs rangés par catégories (error, warning, notice) * @return la liste des logs, sans catégorie, * > en fonction de l'environment */ private static function processLogs($logs) { $env = Minz_Configuration::environment(); $logs_ok = array(); $error = array(); $warning = array(); $notice = array(); if (isset($logs['error'])) { $error = $logs['error']; } if (isset($logs['warning'])) { $warning = $logs['warning']; } if (isset($logs['notice'])) { $notice = $logs['notice']; } if ($env == Minz_Configuration::PRODUCTION) { $logs_ok = $error; } if ($env == Minz_Configuration::DEVELOPMENT) { $logs_ok = array_merge($error, $warning, $notice); } return $logs_ok; }
/** * Constructeur * Détermine si on utilise un layout ou non */ public function __construct() { $this->view_filename = APP_PATH . self::VIEWS_PATH_NAME . '/' . Minz_Request::controllerName() . '/' . Minz_Request::actionName() . '.phtml'; self::$title = Minz_Configuration::title(); }
/** * Return the base_url from configuration and add a suffix if given. * * @param $base_url_suffix a string to add at base_url (default: empty string) * @return the base_url with a suffix. */ public static function getBaseUrl($base_url_suffix = '') { $conf = Minz_Configuration::get('system'); $url = rtrim($conf->base_url, '/\\') . $base_url_suffix; return filter_var($url, FILTER_SANITIZE_URL); }
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'])) {
function checkToken($conf, $token) { //http://code.google.com/p/google-reader-api/wiki/ActionToken $user = Minz_Session::param('currentUser', '_'); logMe('checkToken(' . $token . ")\n"); $system_conf = Minz_Configuration::get('system'); if ($token === str_pad(sha1($system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z')) { return true; } unauthorized(); }
private function loadStylesAndScripts($loginOk) { $theme = FreshRSS_Themes::load($this->conf->theme); if ($theme) { foreach ($theme['files'] as $file) { Minz_View::appendStyle(Minz_Url::display('/themes/' . $theme['id'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['id'] . '/' . $file))); } } switch (Minz_Configuration::authType()) { case 'form': if (!$loginOk) { Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'))); } break; case 'persona': Minz_View::appendScript('https://login.persona.org/include.js'); break; } $includeLazyLoad = $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param('output') === 'reader'); Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad); if ($includeLazyLoad) { Minz_View::appendScript(Minz_Url::display('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js'))); } Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); }
function unlock() { $lock = TMP_PATH . '/' . md5(Minz_Configuration::salt() . $this->url) . '.freshrss.lock'; @unlink($lock); }
/** * Parse un fichier de configuration * @exception Minz_PermissionDeniedException si le CONF_PATH_NAME n'est pas accessible * @exception Minz_BadConfigurationException si CONF_PATH_NAME mal formaté */ private static function parseFile() { $ini_array = (include DATA_PATH . self::CONF_PATH_NAME); if (!is_array($ini_array)) { throw new Minz_PermissionDeniedException(DATA_PATH . self::CONF_PATH_NAME, Minz_Exception::ERROR); } // [general] est obligatoire if (!isset($ini_array['general'])) { throw new Minz_BadConfigurationException('[general]', Minz_Exception::ERROR); } $general = $ini_array['general']; // salt est obligatoire if (!isset($general['salt'])) { if (isset($general['sel_application'])) { //v0.6 $general['salt'] = $general['sel_application']; } else { throw new Minz_BadConfigurationException('salt', Minz_Exception::ERROR); } } self::$salt = $general['salt']; if (isset($general['environment'])) { switch ($general['environment']) { case 'silent': self::$environment = Minz_Configuration::SILENT; break; case 'development': self::$environment = Minz_Configuration::DEVELOPMENT; break; case 'production': self::$environment = Minz_Configuration::PRODUCTION; break; default: if ($general['environment'] >= 0 && $general['environment'] <= 2) { // fallback 0.7-beta self::$environment = $general['environment']; } else { throw new Minz_BadConfigurationException('environment', Minz_Exception::ERROR); } } } if (isset($general['base_url'])) { self::$base_url = $general['base_url']; } if (isset($general['use_url_rewriting'])) { self::$use_url_rewriting = $general['use_url_rewriting']; } if (isset($general['title'])) { self::$title = $general['title']; } if (isset($general['language'])) { self::$language = $general['language']; } if (isset($general['cache_enabled'])) { self::$cache_enabled = $general['cache_enabled']; if (CACHE_PATH === false && self::$cache_enabled) { throw new FileNotExistException('CACHE_PATH', Minz_Exception::ERROR); } } if (isset($general['delay_cache'])) { self::$delay_cache = inval($general['delay_cache']); } if (isset($general['default_user'])) { self::$default_user = $general['default_user']; } if (isset($general['auth_type'])) { self::_authType($general['auth_type']); } if (isset($general['allow_anonymous'])) { self::$allow_anonymous = (bool) $general['allow_anonymous'] && $general['allow_anonymous'] !== 'no'; } if (isset($general['allow_anonymous_refresh'])) { self::$allow_anonymous_refresh = (bool) $general['allow_anonymous_refresh'] && $general['allow_anonymous_refresh'] !== 'no'; } // Base de données if (isset($ini_array['db'])) { $db = $ini_array['db']; if (empty($db['host'])) { throw new Minz_BadConfigurationException('host', Minz_Exception::ERROR); } if (empty($db['user'])) { throw new Minz_BadConfigurationException('user', Minz_Exception::ERROR); } if (!isset($db['password'])) { throw new Minz_BadConfigurationException('password', Minz_Exception::ERROR); } if (empty($db['base'])) { throw new Minz_BadConfigurationException('base', Minz_Exception::ERROR); } if (!empty($db['type'])) { self::$db['type'] = $db['type']; } self::$db['host'] = $db['host']; self::$db['user'] = $db['user']; self::$db['password'] = $db['password']; self::$db['base'] = $db['base']; if (isset($db['prefix'])) { self::$db['prefix'] = $db['prefix']; } } }
public function archivingAction() { if (Minz_Request::isPost()) { $old = Minz_Request::param('old_entries', 3); $keepHistoryDefault = Minz_Request::param('keep_history_default', 0); $this->view->conf->_old_entries($old); $this->view->conf->_keep_history_default($keepHistoryDefault); $this->view->conf->save(); invalidateHttpCache(); $notif = array('type' => 'good', 'content' => Minz_Translate::t('configuration_updated')); Minz_Session::_param('notification', $notif); Minz_Request::forward(array('c' => 'configure', 'a' => 'archiving'), true); } Minz_View::prependTitle(Minz_Translate::t('archiving_configuration') . ' · '); $entryDAO = new FreshRSS_EntryDAO(); $this->view->nb_total = $entryDAO->count(); $this->view->size_user = $entryDAO->size(); if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) { $this->view->size_total = $entryDAO->size(true); } }
function printStep3() { $system_default_config = Minz_Configuration::get('default_system'); ?> <?php $s3 = checkStep3(); if ($s3['all'] == 'ok') { ?> <p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?> </span> <?php echo _t('install.bdd.conf.ok'); ?> </p> <?php } elseif ($s3['conn'] == 'ko') { ?> <p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?> </span> <?php echo _t('install.bdd.conf.ko'), empty($_SESSION['bd_error']) ? '' : ' : ' . $_SESSION['bd_error']; ?> </p> <?php } ?> <form action="index.php?step=3" method="post"> <legend><?php echo _t('install.bdd.conf'); ?> </legend> <div class="form-group"> <label class="group-name" for="type"><?php echo _t('install.bdd.type'); ?> </label> <div class="group-controls"> <select name="type" id="type" onchange="mySqlShowHide()" tabindex="1" > <?php if (extension_loaded('pdo_mysql')) { ?> <option value="mysql" <?php echo isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'mysql' ? 'selected="selected"' : ''; ?> > MySQL </option> <?php } ?> <?php if (extension_loaded('pdo_sqlite')) { ?> <option value="sqlite" <?php echo isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'sqlite' ? 'selected="selected"' : ''; ?> > SQLite </option> <?php } ?> </select> </div> </div> <div id="mysql"> <div class="form-group"> <label class="group-name" for="host"><?php echo _t('install.bdd.host'); ?> </label> <div class="group-controls"> <input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?> " tabindex="2" /> </div> </div> <div class="form-group"> <label class="group-name" for="user"><?php echo _t('install.bdd.username'); ?> </label> <div class="group-controls"> <input type="text" id="user" name="user" maxlength="16" pattern="[0-9A-Za-z_.-]{1,16}" value="<?php echo isset($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?> " tabindex="3" /> </div> </div> <div class="form-group"> <label class="group-name" for="pass"><?php echo _t('install.bdd.password'); ?> </label> <div class="group-controls"> <input type="password" id="pass" name="pass" value="<?php echo isset($_SESSION['bd_password']) ? $_SESSION['bd_password'] : ''; ?> " tabindex="4" /> </div> </div> <div class="form-group"> <label class="group-name" for="base"><?php echo _t('install.bdd'); ?> </label> <div class="group-controls"> <input type="text" id="base" name="base" maxlength="64" pattern="[0-9A-Za-z_]{1,64}" value="<?php echo isset($_SESSION['bd_base']) ? $_SESSION['bd_base'] : ''; ?> " tabindex="5" /> </div> </div> <div class="form-group"> <label class="group-name" for="prefix"><?php echo _t('install.bdd.prefix'); ?> </label> <div class="group-controls"> <input type="text" id="prefix" name="prefix" maxlength="16" pattern="[0-9A-Za-z_]{1,16}" value="<?php echo isset($_SESSION['bd_prefix']) ? $_SESSION['bd_prefix'] : $system_default_config->db['prefix']; ?> " tabindex="6" /> </div> </div> </div> <script> function mySqlShowHide() { document.getElementById('mysql').style.display = document.getElementById('type').value === 'mysql' ? 'block' : 'none'; if (document.getElementById('type').value !== 'mysql') { document.getElementById('host').value = ''; document.getElementById('user').value = ''; document.getElementById('pass').value = ''; document.getElementById('base').value = ''; document.getElementById('prefix').value = ''; } } mySqlShowHide(); </script> <div class="form-group form-actions"> <div class="group-controls"> <button type="submit" class="btn btn-important" tabindex="7" ><?php echo _t('gen.action.submit'); ?> </button> <button type="reset" class="btn" tabindex="8" ><?php echo _t('gen.action.cancel'); ?> </button> <?php if ($s3['all'] == 'ok') { ?> <a class="btn btn-important next-step" href="?step=4" tabindex="9" ><?php echo _t('install.action.next_step'); ?> </a> <?php } ?> </div> </div> </form> <?php }
/** * 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); }
public function deleteAction() { if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) { require_once APP_PATH . '/sql.php'; $username = Minz_Request::param('username'); $ok = ctype_alnum($username); if ($ok) { $ok &= strcasecmp($username, Minz_Configuration::defaultUser()) !== 0; //It is forbidden to delete the default user } if ($ok) { $configPath = DATA_PATH . '/' . $username . '_user.php'; $ok &= file_exists($configPath); } if ($ok) { $userDAO = new FreshRSS_UserDAO(); $ok &= $userDAO->deleteUser($username); $ok &= unlink($configPath); //TODO: delete Persona file } invalidateHttpCache(); $notif = array('type' => $ok ? 'good' : 'bad', 'content' => Minz_Translate::t($ok ? 'user_deleted' : 'error_occurred', $username)); Minz_Session::_param('notification', $notif); } Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true); }