Exemple #1
0
 public function open_PDO()
 {
     require str_replace('\\', '/', __DIR__) . '/../../../application/resonance2/SQL/connect.php';
     self::$pdo = new \PDO('mysql:host=' . $connectIP . ';dbname=' . $selectDB, $connectLog, $connectPass, array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
     \application\resonance2\debug\console::Trace("///PDO connection opened successfully!");
     return self::$pdo;
 }
 public function ADMIN_getGrade($droits)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     if (is_null($this->grades) or is_null($this->numberGrades)) {
         $this->ADMIN_loadGrades();
     }
     if (is_null($droits)) {
         $log = "Class: " . __CLASS__ . " Function: " . __FUNCTION__ . " <u>droits</u> is null";
         \application\resonance2\debug\console::Alert($log);
         throw new \Exception($log);
     }
     $found = false;
     for ($i = 0; $i < $this->numberGrades; $i++) {
         if ($this->grades[$i]["TYPE"] == $droits) {
             $found = true;
             return $this->grades[$i]["TYPE"];
             break;
         } elseif ($i == $this->numberGrades - 1 and $this->grades[$i]["TYPE"] != $droits and $found == false) {
             //If no match
             $log = "Class: " . __CLASS__ . " Function: " . __FUNCTION__ . " <u>droit</u> do not match any condition";
             \application\resonance2\debug\console::Alert($log);
             throw new \Exception($log);
         }
     }
 }
 public function destroy_session()
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $_SESSION = array();
     session_unset();
     session_destroy();
 }
Exemple #4
0
 public function sec_DATA($data)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     if (is_null($data)) {
         throw new \Exception("ERROR: Class:" . __CLASS__ . " Function:" . __FUNCTION__ . " -> data is null or undefinied");
     }
     return $get_data;
 }
Exemple #5
0
 public function ArrayPlus_SortBySpecificKey($array, $key, $alphabetic = null)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $arrayplus = array();
     foreach ($array as $val) {
         $arrayplus[$val[$key]][] = $val;
     }
     $alphabetic == true ? arsort($arrayplus) : asort($arrayplus);
     return $arrayplus;
 }
 public function session_checker($session_var)
 {
     if (!isset($_SESSION[$session_var])) {
         //Access denied, user is redirected at the home page
         \application\resonance2\debug\console::Trace("Access denied");
         \application\resonance2\security\application::disconnect();
     } else {
         //Access granted
         \application\resonance2\debug\console::Trace("Access granted");
     }
 }
Exemple #7
0
 public function PWD_Generate()
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $pwd = null;
     $chaine = "abcdefghijklmnopqrstuvwxyz0123456789";
     $chaine_length = strlen($chaine);
     for ($i = 0; $i < $this->nb_caracter; $i++) {
         $rand = rand(0, $chaine_length);
         $pwd .= substr($chaine, $rand, 1);
     }
     return $pwd;
 }
Exemple #8
0
 public function sec_RQST($data)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     if (is_null($data)) {
         throw new \Exception("ERROR: Class:" . __CLASS__ . " Function:" . __FUNCTION__ . " -> data is null or undefinied");
     }
     $get_data = filter_input(INPUT_POST, "{$data}");
     //In the case of a failure, test another method
     if (!is_string($get_data)) {
         $get_data = $_POST["{$data}"];
     }
     return $get_data;
 }
Exemple #9
0
 public function count_row($table)
 {
     try {
         \application\resonance2\security\application::open_PDO();
         $rqst = "SELECT count(*) FROM `{$table}`";
         $result = open_PDO::$pdo->prepare($rqst);
         $result->execute();
         $this->counter = $result->fetchColumn();
         \application\resonance2\security\application::close_PDO();
         return (double) $this->counter;
     } catch (\Exception $e) {
         \application\resonance2\debug\console::Trace("=> PDO connection problem");
     }
 }
Exemple #10
0
 public function XML_getAttrValWhereAttr($url, $node, $getAttr, $withVal, $findAttr)
 {
     $this->XML_readXML($url);
     $this->XML_parse($node);
     foreach ($this->parsed as $nodule) {
         if ($nodule->getAttribute($getAttr) == $withVal) {
             self::$XML_attr = $nodule->getAttribute($findAttr);
             echo self::$XML_attr;
             break;
         } else {
             //Aucun Node
             \application\resonance2\debug\console::Trace("Attribut not found in XML");
         }
     }
 }
Exemple #11
0
 public function url_checker($url)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $headers = get_headers($url);
     if ($headers[0] == 'HTTP/1.1 404 Not Found' or $headers[0] == 'HTTP/1.1 302 Found') {
         //404 introubable | 302 trouvable après redirection
         \application\resonance2\debug\console::Trace("CLASS: " . __CLASS__ . " Function: " . __FUNCTION__ . " url <u>not</u> find.");
         return "false";
         //URL DOESN'T EXIST
     } else {
         \application\resonance2\debug\console::Trace("CLASS: " . __CLASS__ . " Function: " . __FUNCTION__ . " url find.");
         return "true";
         //URL EXIST
     }
 }
Exemple #12
0
 function DTB_errors($code)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $dtberror = $this->DTB_errors;
     //♪Conversion du nom de la variable
     $dtberror = array(0 => "Une erreur inconnue à été détecté. Si le problème persiste, merci de me contacter à l'aide du formulaire de contact", 1 => "Une erreur de connexion à la base de donnée est survenue. Si le problème persiste, merci de me contacter à l'aide du formulaire de contact");
     //Récupération de l'erreur détécté
     if (array_key_exists($code, $dtberror)) {
         $this->log_error = $dtberror[$code];
         return $this->log_error;
     } else {
         $this->log_error = $dtberror[0];
         return $this->log_error;
     }
     //♪else
 }
Exemple #13
0
 public function MODELS_filterModels()
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     //Récupère le tableau complet de modèle
     $this->MODELS_getModelsList();
     //Vérifie si l'utilisateur est VIP, si oui il à d'office accès à tous les modèles, sinon on vérifie au cas par cas
     if (self::USERS_getUserVIPAccess() == 1) {
         self::$userTable = self::$modelsList;
     } else {
         //Parcours les groupes en 1er
         //Récupère la liste des modèles dont le groupe à accès (si l'utilisateur est lié à groupe)
         $modelsGroupAccess = $this->MODELS_getModelsGroupAccessList();
         //Parcours les droits utilisateur en 2ème
         $modelsUserAccess = $this->MODELS_getModelsUserAccessList();
         if ($modelsGroupAccess == false and $modelsUserAccess == false or count(array_unique(self::$userTable, SORT_REGULAR)) === 0) {
             //L'utilisateur n'à aucun droit de visionnage sur les modèles
             self::$userTable = false;
         }
     }
     //echo "<pre>" . print_r ( self::$userTable, 1 ) . "</pre>";
     return self::$userTable;
 }
Exemple #14
0
 public static function set_disconnect_page($disconnect_page)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     self::$disconnect_page = $disconnect_page;
 }
Exemple #15
0
 public function sendEmail($from, $to, $subject, $message)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $headers = 'Content-type: text/html; charset=utf-8' . "\r\n" . "From: {$from}" . "\r\n" . "Reply-To: {$to}" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
     return mail($to, $subject, $message, $headers);
 }
Exemple #16
0
 private function disconnect()
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     \application\resonance2\debug\console::Trace("Access denied");
     \application\resonance2\application::disconnect();
 }
Exemple #17
0
 public function close_PDO()
 {
     open_PDO::$pdo = null;
     \application\resonance2\debug\console::Trace("///PDO connection closed...");
     return open_PDO::$pdo;
 }
Exemple #18
0
 /**
  * Description courte de la méthode
  *
  * @param integer|string $iCustomerID ID du customer
  * @return object Retourne l'objet Customer correspond à l'ID reçu
  */
 public function SQLPDO_Exceptions()
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     if (self::$exception == null) {
         self::$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
     } elseif (self::$exception === "activate") {
         self::$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     }
 }
Exemple #19
0
 public function DDB_deleteSavedDataBase($url)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     unlink($url);
 }
 public function getDomiColor($url)
 {
     \application\resonance2\debug\console::FunctionTrace(__FUNCTION__);
     $i = imagecreatefromjpeg($url);
     $rTotal = '';
     $bTotal = '';
     $gTotal = '';
     $total = '';
     for ($x = 0; $x < imagesx($i); $x++) {
         for ($y = 0; $y < imagesy($i); $y++) {
             $rgb = imagecolorat($i, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $rTotal += $r;
             $gTotal += $g;
             $bTotal += $b;
             $total++;
         }
     }
     $r = round($rTotal / $total);
     $g = round($gTotal / $total);
     $b = round($bTotal / $total);
     $rgb = array($r, $g, $b);
     return $rgb;
 }