summaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-31 16:57:11 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-31 16:57:11 +0100
commit54479a5027d83b5dc8deee5e2795c9d89c732ba0 (patch)
tree7ae55930f3ab6d5e2a548784e4d7561809f7c68c /lib/lib_rss.php
parentcff8636e770b2072a41928cd918b37654c0dafbb (diff)
parent724e13f0a6419b046b33da71e66058e279551edd (diff)
Merge branch 'dev' into beta
Conflicts: CHANGELOG README.fr.md README.md app/Controllers/feedController.php app/Controllers/indexController.php app/i18n/en.php app/i18n/fr.php app/views/helpers/view/normal_view.phtml app/views/stats/index.phtml app/views/stats/repartition.phtml constants.php p/scripts/main.js
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php92
1 files changed, 82 insertions, 10 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 31c9cdbc1..e7ca95aba 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -56,12 +56,14 @@ function checkUrl($url) {
}
}
-function formatNumber($n, $precision = 0) {
- return str_replace(' ', ' ', //Espace insécable //TODO: remplacer par une espace _fine_ insécable
- number_format($n, $precision, '.', ' ')); //number_format does not seem to be Unicode-compatible
+function format_number($n, $precision = 0) {
+ // number_format does not seem to be Unicode-compatible
+ return str_replace(' ', ' ', //Espace fine insécable
+ number_format($n, $precision, '.', ' ')
+ );
}
-function formatBytes($bytes, $precision = 2, $system = 'IEC') {
+function format_bytes($bytes, $precision = 2, $system = 'IEC') {
if ($system === 'IEC') {
$base = 1024;
$units = array('B', 'KiB', 'MiB', 'GiB', 'TiB');
@@ -73,15 +75,15 @@ function formatBytes($bytes, $precision = 2, $system = 'IEC') {
$pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
$pow = min($pow, count($units) - 1);
$bytes /= pow($base, $pow);
- return formatNumber($bytes, $precision) . ' ' . $units[$pow];
+ return format_number($bytes, $precision) . ' ' . $units[$pow];
}
function timestamptodate ($t, $hour = true) {
- $month = Minz_Translate::t (date('M', $t));
+ $month = _t(date('M', $t));
if ($hour) {
- $date = Minz_Translate::t ('format_date_hour', $month);
+ $date = _t('format_date_hour', $month);
} else {
- $date = Minz_Translate::t ('format_date', $month);
+ $date = _t('format_date', $month);
}
return @date ($date, $t);
@@ -106,10 +108,12 @@ function html_only_entity_decode($text) {
}
function customSimplePie() {
+ $limits = Minz_Configuration::limits();
$simplePie = new SimplePie();
- $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
+ $simplePie->set_useragent(_t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
$simplePie->set_cache_location(CACHE_PATH);
- $simplePie->set_cache_duration(800);
+ $simplePie->set_cache_duration($limits['cache_duration']);
+ $simplePie->set_timeout($limits['timeout']);
$simplePie->strip_htmltags(array(
'base', 'blink', 'body', 'doctype', 'embed',
'font', 'form', 'frame', 'frameset', 'html',
@@ -244,3 +248,71 @@ function is_referer_from_same_domain() {
}
return (isset($host['port']) ? $host['port'] : 0) === (isset($referer['port']) ? $referer['port'] : 0);
}
+
+
+/**
+ * Check PHP and its extensions are well-installed.
+ *
+ * @return array of tested values.
+ */
+function check_install_php() {
+ $pdo_mysql = extension_loaded('pdo_mysql');
+ $pdo_sqlite = extension_loaded('pdo_sqlite');
+ return array(
+ 'php' => version_compare(PHP_VERSION, '5.2.1') >= 0,
+ 'minz' => file_exists(LIB_PATH . '/Minz'),
+ 'curl' => extension_loaded('curl'),
+ 'pdo' => $pdo_mysql || $pdo_sqlite,
+ 'pcre' => extension_loaded('pcre'),
+ 'ctype' => extension_loaded('ctype'),
+ 'dom' => class_exists('DOMDocument'),
+ 'json' => extension_loaded('json'),
+ 'zip' => extension_loaded('zip'),
+ );
+}
+
+
+/**
+ * Check different data files and directories exist.
+ *
+ * @return array of tested values.
+ */
+function check_install_files() {
+ return array(
+ 'data' => DATA_PATH && is_writable(DATA_PATH),
+ 'cache' => CACHE_PATH && is_writable(CACHE_PATH),
+ 'logs' => LOG_PATH && is_writable(LOG_PATH),
+ 'favicons' => is_writable(DATA_PATH . '/favicons'),
+ 'persona' => is_writable(DATA_PATH . '/persona'),
+ 'tokens' => is_writable(DATA_PATH . '/tokens'),
+ );
+}
+
+
+/**
+ * Check database is well-installed.
+ *
+ * @return array of tested values.
+ */
+function check_install_database() {
+ $status = array(
+ 'connection' => true,
+ 'tables' => false,
+ 'categories' => false,
+ 'feeds' => false,
+ 'entries' => false,
+ );
+
+ try {
+ $dbDAO = FreshRSS_Factory::createDatabaseDAO();
+
+ $status['tables'] = $dbDAO->tablesAreCorrect();
+ $status['categories'] = $dbDAO->categoryIsCorrect();
+ $status['feeds'] = $dbDAO->feedIsCorrect();
+ $status['entries'] = $dbDAO->entryIsCorrect();
+ } catch(Minz_PDOConnectionException $e) {
+ $status['connection'] = false;
+ }
+
+ return $status;
+}