Przeglądaj źródła

Fixe url decode Base64

stany.ferer 2 lat temu
rodzic
commit
4f282cb449

+ 8 - 0
core/class/core.class.php

@@ -244,4 +244,12 @@ class core
         json::delete("excel-proweb");
         file::cleanAllFiles(SFTP_LOCAL);
     }
+
+    public static function base64_url_encode(string $val) {
+        return strtr(base64_encode($val), '+/=', '-_,');
+    }
+
+    public static function base64_url_decode(string $val) {
+        return base64_decode(strtr($val, '-_,', '+/='));
+    }
 }

+ 21 - 1
core/class/event.class.php

@@ -22,7 +22,7 @@ class event
         db::query("SELECT md5 FROM " . DB_T_EVENTS . " WHERE id = :id");
         db::bind(':id', $_id);
         $md5 = db::single()["md5"];
-        $link = base64_encode("https://" . DOMAIN_EVENTS . "/?e=" . $md5);
+        $link = core::base64_url_encode("https://" . DOMAIN_EVENTS . "/?e=" . $md5);
 
         if ($_link == NULL) {
             echo '<img src="/qrcode.php?q= ' . $link . '" width="' . $_width . '" >';
@@ -192,6 +192,26 @@ class event
         return $inscription;
     }
 
+    public static function getInscription(int $_id_event){
+        db::query("SELECT "
+                . "" . DB_T_SALARIES . ".id, "
+                . "" . DB_T_SALARIES . ".loginId, "
+                . "" . DB_T_SALARIES . ".nom, "
+                . "" . DB_T_SALARIES . ".prenom, "
+                . "" . DB_T_SALARIES . ".sexe, "
+                . "" . DB_T_SALARIES . ".contrat, "
+                . "" . DB_T_SALARIES . ".lieu, "
+                . "" . DB_T_SALARIES . ".actif, "
+                . "" . DB_T_EVENTS_INSCRITS . ".id_evenement, "
+                . "" . DB_T_EVENTS_INSCRITS . ".present "
+                . "FROM " . DB_T_SALARIES . " "
+                . "INNER JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_EVENTS_INSCRITS . ".id_salarie = " . DB_T_SALARIES . ".id "
+                . "WHERE " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . $_id_event);
+        return db::resultset();
+    }
+
+
+
     public static function checkEvenementBySalarie(string $_md5)
     {
 

+ 1 - 15
core/json/cms.event-inscrits.php

@@ -1,20 +1,6 @@
 <?php 
 
-db::query("SELECT "
-            . "" . DB_T_SALARIES . ".id, "
-            . "" . DB_T_SALARIES . ".loginId, "
-            . "" . DB_T_SALARIES . ".nom, "
-            . "" . DB_T_SALARIES . ".prenom, "
-            . "" . DB_T_SALARIES . ".sexe, "
-            . "" . DB_T_SALARIES . ".contrat, "
-            . "" . DB_T_SALARIES . ".lieu, "
-            . "" . DB_T_SALARIES . ".actif, "
-            . "" . DB_T_EVENTS_INSCRITS . ".id_evenement, "
-            . "" . DB_T_EVENTS_INSCRITS . ".present "
-            . "FROM " . DB_T_SALARIES . " "
-            . "INNER JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_EVENTS_INSCRITS . ".id_salarie = " . DB_T_SALARIES . ".id "
-            . "WHERE " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . core::getGet("id"));
-            $row = db::resultset();
+$row = event::getInscription(core::getGet("id"));
 if (!empty($row)) {
     echo json_encode($row);
     exit();

+ 1 - 1
core/json/events.list-events.php

@@ -7,7 +7,7 @@ if(session::isConnect("salarie")){
         $return = array();
         foreach ($evenements as $nb => $ev) {
             $ev["nb"] = $nb;
-            $ev["url_qrcode"] = base64_encode("https://" . DOMAIN_CONTROL . "/json.php?jsonData=check-control-emargement&s=".session::getId("salarie")."&e=".$ev["md5"]."&k=".md5($ev["md5"].session::getValue("sel", "salarie"))); 
+            $ev["url_qrcode"] = core::base64_url_encode("https://" . DOMAIN_CONTROL . "/json.php?jsonData=check-control-emargement&s=".session::getId("salarie")."&e=".$ev["md5"]."&k=".md5($ev["md5"].session::getValue("sel", "salarie"))); 
             $ev["startDate"] = core::convertDate($ev["startDate"]);
             $ev["endDate"] = core::convertDate($ev["endDate"]);
             $ev["present"] = (isset($ev["present"])) ? core::convertDate($ev["present"]) : NULL;

+ 1 - 16
core/submit/cms.event-export-inscription.php

@@ -5,22 +5,7 @@ ini_set("display_errors", 1);
 
 if (core::ifGet("from") AND core::getGet("from") == "event-export-inscription") {
 
-    db::query("SELECT "
-                . "" . DB_T_SALARIES . ".id, "
-                . "" . DB_T_SALARIES . ".loginId, "
-                . "" . DB_T_SALARIES . ".nom, "
-                . "" . DB_T_SALARIES . ".prenom, "
-                . "" . DB_T_SALARIES . ".sexe, "
-                . "" . DB_T_SALARIES . ".contrat, "
-                . "" . DB_T_SALARIES . ".lieu, "
-                . "" . DB_T_SALARIES . ".actif, "
-                . "" . DB_T_EVENTS_INSCRITS . ".id_evenement, "
-                . "" . DB_T_EVENTS_INSCRITS . ".present "
-                . "FROM " . DB_T_SALARIES . " "
-                . "INNER JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_EVENTS_INSCRITS . ".id_salarie = " . DB_T_SALARIES . ".id "
-                . "WHERE " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . core::getGet("id"));
-                $row = db::resultset();
-
+    $row = event::getInscription(core::getGet("id"));
     $tmpList = 'inscripts-evenement-' . core::getGet("id") . '.csv';
 
     $csv = fopen(DIR_TEMP . $tmpList , 'w'); 

+ 1 - 1
public-cms/qrcode.php

@@ -8,7 +8,7 @@ require_once DIR_PHP_LAYOUTS . "header.php";
 header ('Content-Type: image/png');
 
 if(core::ifGet("q")){
-    $link = base64_decode(core::getGet("q"));
+    $link = core::base64_url_decode(core::getGet("q"));
 } else {
     $link = "https://".DOMAIN_EVENTS;
 }

+ 1 - 1
public-events/qrcode.php

@@ -8,7 +8,7 @@ require_once DIR_PHP_LAYOUTS . "header.php";
 header ('Content-Type: image/png');
 
 if(core::ifGet("q")){
-    $link = base64_decode(core::getGet("q"));
+    $link = core::base64_url_decode(core::getGet("q"));
 } else {
     $link = "https://".DOMAIN_EVENTS;
 }