diff --git a/controllers/ControllerAdmin.php b/controllers/ControllerAdmin.php index 29a5f51..c4727e6 100644 --- a/controllers/ControllerAdmin.php +++ b/controllers/ControllerAdmin.php @@ -50,9 +50,11 @@ class controllerAdmin { } function ajoutSource() { - global $con,$vues; - if(isset($_REQUEST["linkSource"])) { - $gate = new GatewaySources($con); + global $dsn,$user,$pass,$vues; + $error =[]; + $link = $_REQUEST["linkSource"]; + if(isset($_REQUEST["linkSource"]) && Validation::url_form($link,$error)) { + $gate = new GatewaySources(new Connection($dsn,$user,$pass)); $source = new Sources($_REQUEST["linkSource"]); $gate->addSources($source); } diff --git a/vues/Validation.php b/vues/Validation.php index be41d37..cef220f 100644 --- a/vues/Validation.php +++ b/vues/Validation.php @@ -38,19 +38,21 @@ } - static function url_form(string &$url,array &$dVueEreur) + static function url_form(string $url,array &$dVueEreur) { - if (!isset($url)||$url=="") { $dVueEreur[] = "pas d'url"; $url=""; + return false; } - if ($url != filter_var($name, FILTER_VALIDATE_URL)) + if (!filter_var($url, FILTER_VALIDATE_URL)) { $dVueEreur[] = "url invalide"; $url=""; + return false; } + return true; } diff --git a/vues/administration.php b/vues/administration.php index 05e9cb7..278acee 100644 --- a/vues/administration.php +++ b/vues/administration.php @@ -1,7 +1,9 @@ -
+ + +