diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Favicon/DataAccess.php | 52 | ||||
| -rw-r--r-- | lib/Favicon/Favicon.php | 3 | ||||
| -rw-r--r-- | lib/lib_install.php | 35 | ||||
| -rw-r--r-- | lib/lib_rss.php | 10 |
4 files changed, 64 insertions, 36 deletions
diff --git a/lib/Favicon/DataAccess.php b/lib/Favicon/DataAccess.php index ae7509881..4c1a29541 100644 --- a/lib/Favicon/DataAccess.php +++ b/lib/Favicon/DataAccess.php @@ -9,33 +9,33 @@ namespace Favicon; **/ class DataAccess { public function retrieveUrl($url) { - $this->set_context(); - return @file_get_contents($url); + $this->set_context(); + return @file_get_contents($url); } - + public function retrieveHeader($url) { - $this->set_context(); + $this->set_context(); $headers = @get_headers($url, 1); - return $headers ? array_change_key_case($headers) : array(); + return is_array($headers) ? array_change_key_case($headers) : array(); + } + + public function saveCache($file, $data) { + file_put_contents($file, $data); + } + + public function readCache($file) { + return file_get_contents($file); + } + + private function set_context() { + stream_context_set_default( + array( + 'http' => array( + 'method' => 'GET', + 'timeout' => 10, + 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n", + ) + ) + ); } - - public function saveCache($file, $data) { - file_put_contents($file, $data); - } - - public function readCache($file) { - return file_get_contents($file); - } - - private function set_context() { - stream_context_set_default( - array( - 'http' => array( - 'method' => 'GET', - 'timeout' => 10, - 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n", - ) - ) - ); - } -}
\ No newline at end of file +} diff --git a/lib/Favicon/Favicon.php b/lib/Favicon/Favicon.php index 1912050d6..8571a1b95 100644 --- a/lib/Favicon/Favicon.php +++ b/lib/Favicon/Favicon.php @@ -89,6 +89,9 @@ class Favicon $loop = TRUE; while ($loop && $max_loop-- > 0) { $headers = $this->dataAccess->retrieveHeader($url); + if (empty($headers)) { + return false; + } $exploded = explode(' ', $headers[0]); if( !isset($exploded[1]) ) { diff --git a/lib/lib_install.php b/lib/lib_install.php index c5cae4293..76871c98a 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -5,14 +5,36 @@ define('BCRYPT_COST', 9); Minz_Configuration::register('default_system', join_path(DATA_PATH, 'config.default.php')); Minz_Configuration::register('default_user', join_path(USERS_PATH, '_', 'config.default.php')); -function checkRequirements() { +function checkRequirements($dbType = '') { $php = version_compare(PHP_VERSION, '5.3.3') >= 0; $minz = file_exists(join_path(LIB_PATH, 'Minz')); $curl = extension_loaded('curl'); $pdo_mysql = extension_loaded('pdo_mysql'); $pdo_sqlite = extension_loaded('pdo_sqlite'); $pdo_pgsql = extension_loaded('pdo_pgsql'); - $pdo = $pdo_mysql || $pdo_sqlite || $pdo_pgsql; + $message = ''; + switch ($dbType) { + case 'mysql': + $pdo_sqlite = $pdo_pgsql = true; + $pdo = $pdo_mysql; + break; + case 'sqlite': + $pdo_mysql = $pdo_pgsql = true; + $pdo = $pdo_sqlite; + break; + case 'pgsql': + $pdo_mysql = $pdo_sqlite = true; + $pdo = $pdo_pgsql; + break; + case '': + $pdo = $pdo_mysql || $pdo_sqlite || $pdo_pgsql; + break; + default: + $pdo_mysql = $pdo_sqlite = $pdo_pgsql = true; + $pdo = false; + $message = 'Invalid database type!'; + break; + } $pcre = extension_loaded('pcre'); $ctype = extension_loaded('ctype'); $fileinfo = extension_loaded('fileinfo'); @@ -44,8 +66,9 @@ function checkRequirements() { 'users' => $users ? 'ok' : 'ko', 'favicons' => $favicons ? 'ok' : 'ko', 'http_referer' => $http_referer ? 'ok' : 'ko', + 'message' => $message ?: 'ok', 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $fileinfo && $dom && $xml && - $data && $cache && $users && $favicons && $http_referer ? + $data && $cache && $users && $favicons && $http_referer && $message == '' ? 'ok' : 'ko' ); } @@ -77,7 +100,11 @@ function checkDb(&$dbOptions) { break; case 'sqlite': include_once(APP_PATH . '/SQL/install.sql.sqlite.php'); - $dsn = 'sqlite:' . join_path(USERS_PATH, $dbOptions['default_user'], 'db.sqlite'); + $path = join_path(USERS_PATH, $dbOptions['default_user']); + if (!is_dir($path)) { + mkdir($path); + } + $dsn = 'sqlite:' . join_path($path, 'db.sqlite'); $driver_options = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 560e5b256..4298e90bf 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -69,10 +69,10 @@ function idn_to_puny($url) { } function checkUrl($url) { - if (empty ($url)) { + if ($url == '') { return ''; } - if (!preg_match ('#^https?://#i', $url)) { + if (!preg_match('#^https?://#i', $url)) { $url = 'http://' . $url; } $url = idn_to_puny($url); //PHP bug #53474 IDN @@ -285,7 +285,7 @@ function uSecString() { } function invalidateHttpCache($username = '') { - if (($username == '') || (!ctype_alnum($username))) { + if (!FreshRSS_user_Controller::checkUsername($username)) { Minz_Session::_param('touch', uTimeString()); $username = Minz_Session::param('currentUser', '_'); } @@ -299,13 +299,11 @@ function listUsers() { scandir($base_path), array('..', '.', '_') )); - foreach ($dir_list as $file) { - if (is_dir(join_path($base_path, $file))) { + if ($file[0] !== '.' && is_dir(join_path($base_path, $file)) && file_exists(join_path($base_path, $file, 'config.php'))) { $final_list[] = $file; } } - return $final_list; } |
