summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ModelPdo.php3
-rw-r--r--lib/Minz/Request.php5
-rw-r--r--lib/Minz/View.php15
-rw-r--r--lib/SimplePie/SimplePie/Parser.php2
-rw-r--r--lib/lib_rss.php14
5 files changed, 34 insertions, 5 deletions
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 45a1e9451..b4bfca746 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -77,6 +77,9 @@ class Minz_ModelPdo {
$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(
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 52f53012f..f7a24c026 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -124,6 +124,11 @@ class Minz_Request {
* > sinon, le dispatcher recharge en interne
*/
public static function forward($url = array(), $redirect = false) {
+ if (!is_array($url)) {
+ header('Location: ' . $url);
+ exit();
+ }
+
$url = Minz_Url::checkUrl($url);
if ($redirect) {
diff --git a/lib/Minz/View.php b/lib/Minz/View.php
index f034ab10b..a0dec1824 100644
--- a/lib/Minz/View.php
+++ b/lib/Minz/View.php
@@ -26,12 +26,19 @@ class Minz_View {
* Détermine si on utilise un layout ou non
*/
public function __construct () {
+ $this->change_view(Minz_Request::controllerName(),
+ Minz_Request::actionName());
+ self::$title = Minz_Configuration::title ();
+ }
+
+ /**
+ * Change le fichier de vue en fonction d'un controller / action
+ */
+ public function change_view($controller_name, $action_name) {
$this->view_filename = APP_PATH
. self::VIEWS_PATH_NAME . '/'
- . Minz_Request::controllerName () . '/'
- . Minz_Request::actionName () . '.phtml';
-
- self::$title = Minz_Configuration::title ();
+ . $controller_name . '/'
+ . $action_name . '.phtml';
}
/**
diff --git a/lib/SimplePie/SimplePie/Parser.php b/lib/SimplePie/SimplePie/Parser.php
index 9300b4ba9..7fb7bd9be 100644
--- a/lib/SimplePie/SimplePie/Parser.php
+++ b/lib/SimplePie/SimplePie/Parser.php
@@ -142,7 +142,7 @@ class SimplePie_Parser
$dom = new DOMDocument();
$dom->recover = true;
$dom->strictErrorChecking = false;
- $dom->loadXML($data);
+ @$dom->loadXML($data);
$this->encoding = $encoding = $dom->encoding = 'UTF-8';
$data2 = $dom->saveXML();
if (function_exists('mb_convert_encoding'))
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 823f53716..31c9cdbc1 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -230,3 +230,17 @@ function cryptAvailable() {
}
return false;
}
+
+function is_referer_from_same_domain() {
+ if (empty($_SERVER['HTTP_REFERER'])) {
+ return false;
+ }
+ $host = parse_url(((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https://' : 'http://') .
+ (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));
+ $referer = parse_url($_SERVER['HTTP_REFERER']);
+ if (empty($host['scheme']) || empty($referer['scheme']) || $host['scheme'] !== $referer['scheme'] ||
+ empty($host['host']) || empty($referer['host']) || $host['host'] !== $referer['host']) {
+ return false;
+ }
+ return (isset($host['port']) ? $host['port'] : 0) === (isset($referer['port']) ? $referer['port'] : 0);
+}