summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ModelPdo.php12
-rw-r--r--lib/SimplePie/SimplePie.php1
-rw-r--r--lib/http-conditional.php8
-rw-r--r--lib/lib_opml.php31
-rw-r--r--lib/lib_rss.php48
5 files changed, 48 insertions, 52 deletions
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 25999f02b..845aecaae 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -16,7 +16,6 @@ class Minz_ModelPdo {
public static $useSharedBd = true;
private static $sharedBd = null;
private static $sharedPrefix;
- private static $has_transaction = false;
private static $sharedCurrentUser;
protected static $sharedDbType;
@@ -60,8 +59,8 @@ class Minz_ModelPdo {
if ($type === 'mysql') {
$string = 'mysql:host=' . $db['host']
. ';dbname=' . $db['base']
- . ';charset=utf8';
- $driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8';
+ . ';charset=utf8mb4';
+ $driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4';
$this->prefix = $db['prefix'] . $currentUser . '_';
} elseif ($type === 'sqlite') {
$string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite');
@@ -96,18 +95,15 @@ class Minz_ModelPdo {
public function beginTransaction() {
$this->bd->beginTransaction();
- self::$has_transaction = true;
}
- public function hasTransaction() {
- return self::$has_transaction;
+ public function inTransaction() {
+ return $this->bd->inTransaction(); //requires PHP >= 5.3.3
}
public function commit() {
$this->bd->commit();
- self::$has_transaction = false;
}
public function rollBack() {
$this->bd->rollBack();
- self::$has_transaction = false;
}
public static function clean() {
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php
index 8af55c9fd..0f2fdbb87 100644
--- a/lib/SimplePie/SimplePie.php
+++ b/lib/SimplePie/SimplePie.php
@@ -1304,6 +1304,7 @@ class SimplePie
// Check absolute bare minimum requirements.
if (!extension_loaded('xml') || !extension_loaded('pcre'))
{
+ $this->error = 'XML or PCRE extensions not loaded!';
return false;
}
// Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
diff --git a/lib/http-conditional.php b/lib/http-conditional.php
index 59fbef41f..6d3a0a97f 100644
--- a/lib/http-conditional.php
+++ b/lib/http-conditional.php
@@ -35,12 +35,12 @@
... //Rest of the script, just as you would do normally.
?>
- Version 1.7 beta, 2013-12-02, http://alexandre.alapetite.fr/doc-alex/php-http-304/
+ Version 1.8 beta, 2016-08-07, http://alexandre.alapetite.fr/doc-alex/php-http-304/
------------------------------------------------------------------
Written by Alexandre Alapetite, http://alexandre.alapetite.fr/cv/
- Copyright 2004-2013, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
+ Copyright 2004-2016, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
http://creativecommons.org/licenses/by-sa/2.0/fr/
http://alexandre.alapetite.fr/divers/apropos/#by-sa
- Attribution. You must give the original author credit
@@ -96,7 +96,8 @@ function httpConditional($UnixTimeStamp,$cacheSeconds=0,$cachePrivacy=0,$feedMod
if ((!$is412)&&isset($_SERVER['HTTP_IF_MATCH']))
{//rfc2616-sec14.html#sec14.24
$etagsClient=stripslashes($_SERVER['HTTP_IF_MATCH']);
- $is412=(($etagClient!=='*')&&(strpos($etagsClient,$etagServer)===false));
+ $etagsClient=str_ireplace('-gzip','',$etagsClient);
+ $is412=(($etagsClient!=='*')&&(strpos($etagsClient,$etagServer)===false));
}
if ($is304&&isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
{//rfc2616-sec14.html#sec14.25 //rfc1945.txt
@@ -111,6 +112,7 @@ function httpConditional($UnixTimeStamp,$cacheSeconds=0,$cachePrivacy=0,$feedMod
{//rfc2616-sec14.html#sec14.26
$nbCond++;
$etagClient=stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
+ $etagClient=str_ireplace('-gzip','',$etagClient);
$is304=(($etagClient===$etagServer)||($etagClient==='*'));
}
if ((!$is412)&&isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']))
diff --git a/lib/lib_opml.php b/lib/lib_opml.php
index 66b854313..b89e92977 100644
--- a/lib/lib_opml.php
+++ b/lib/lib_opml.php
@@ -12,7 +12,7 @@
*
* @author Marien Fressinaud <dev@marienfressinaud.fr>
* @link https://github.com/marienfressinaud/lib_opml
- * @version 0.2
+ * @version 0.2-FreshRSS~1.5.1
* @license public domain
*
* Usages:
@@ -123,6 +123,32 @@ function libopml_parse_outline($outline_xml, $strict = true) {
return $outline;
}
+/**
+ * Reformat the XML document as a hierarchy when
+ * the OPML 2.0 category attribute is used
+ */
+function preprocessing_categories($doc) {
+ $outline_categories = array();
+ $body = $doc->getElementsByTagName('body')->item(0);
+ $xpath = new DOMXpath($doc);
+ $outlines = $xpath->query('/opml/body/outline[@category]');
+ foreach ($outlines as $outline) {
+ $category = trim($outline->getAttribute('category'));
+ if ($category != '') {
+ $outline_categorie = null;
+ if (!isset($outline_categories[$category])) {
+ $outline_categorie = $doc->createElement('outline');
+ $outline_categorie->setAttribute('text', $category);
+ $body->insertBefore($outline_categorie, $body->firstChild);
+ $outline_categories[$category] = $outline_categorie;
+ } else {
+ $outline_categorie = $outline_categories[$category];
+ }
+ $outline->parentNode->removeChild($outline);
+ $outline_categorie->appendChild($outline);
+ }
+ }
+}
/**
* Parse a string as a XML one and returns the corresponding array
@@ -140,6 +166,9 @@ function libopml_parse_string($xml, $strict = true) {
$dom->loadXML($xml);
$dom->encoding = 'UTF-8';
+ //Partial compatibility with the category attribute of OPML 2.0
+ preprocessing_categories($dom);
+
$opml = simplexml_import_dom($dom);
if (!$opml) {
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index f89baf9b1..82ddced2c 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -15,34 +15,7 @@ if (!function_exists('json_encode')) {
}
}
-if (!function_exists('array_replace_recursive')) { //PHP 5.2
- function arr_recurse($array, $array1) {
- foreach ($array1 as $key => $value) {
- if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) {
- $array[$key] = array(); //create new key in $array, if it is empty or not an array
- }
- if (is_array($value)) {
- $value = arr_recurse($array[$key], $value); // overwrite the value in the base array
- }
- $array[$key] = $value;
- }
- return $array;
- }
- function array_replace_recursive($array, $array1) { //http://php.net/manual/function.array-replace-recursive.php#92574
- // handle the arguments, merge one by one
- $args = func_get_args();
- $array = $args[0];
- if (!is_array($array)) {
- return $array;
- }
- for ($i = 1; $i < count($args); $i++) {
- if (is_array($args[$i])) {
- $array = arr_recurse($array, $args[$i]);
- }
- }
- return $array;
- }
-}
+defined('JSON_UNESCAPED_UNICODE') or define('JSON_UNESCAPED_UNICODE', 256); //PHP 5.3
/**
* Build a directory path by concatenating a list of directory names.
@@ -103,9 +76,7 @@ function checkUrl($url) {
$url = 'http://' . $url;
}
$url = idn_to_puny($url); //PHP bug #53474 IDN
- if (filter_var($url, FILTER_VALIDATE_URL) ||
- (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($url, '-') > 0) && //PHP bug #51192
- ($url === filter_var($url, FILTER_SANITIZE_URL)))) {
+ if (filter_var($url, FILTER_VALIDATE_URL)) {
return $url;
} else {
return false;
@@ -379,19 +350,17 @@ function httpAuthUser() {
}
function cryptAvailable() {
- if (version_compare(PHP_VERSION, '5.3.3', '>=')) {
- try {
- $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG';
- return $hash === @crypt('password', $hash);
- } catch (Exception $e) {
- }
+ try {
+ $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG';
+ return $hash === @crypt('password', $hash);
+ } catch (Exception $e) {
}
return false;
}
function is_referer_from_same_domain() {
if (empty($_SERVER['HTTP_REFERER'])) {
- return false;
+ return true; //Accept empty referer while waiting for good support of meta referrer same-origin policy in browsers
}
$host = parse_url(((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https://' : 'http://') .
(empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));
@@ -416,7 +385,7 @@ 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,
+ 'php' => version_compare(PHP_VERSION, '5.3.3') >= 0,
'minz' => file_exists(LIB_PATH . '/Minz'),
'curl' => extension_loaded('curl'),
'pdo' => $pdo_mysql || $pdo_sqlite,
@@ -440,7 +409,6 @@ function check_install_files() {
'cache' => CACHE_PATH && is_writable(CACHE_PATH),
'users' => USERS_PATH && is_writable(USERS_PATH),
'favicons' => is_writable(DATA_PATH . '/favicons'),
- 'persona' => is_writable(DATA_PATH . '/persona'),
'tokens' => is_writable(DATA_PATH . '/tokens'),
);
}