Commit 51681b03 authored by Mindiell's avatar Mindiell
Browse files

Modification de l'architecture pour obtenir un vrai modèle MVC

parent 2e2f305e
......@@ -57,7 +57,7 @@ test-functional: ## Launch functional tests.
@./vendor/bin/codecept run functional
server-start: server-stop ## Launch a local server
@php -S 127.0.0.1:8000 -t ./www/ >> ./var/log/server.log &
@php -S 127.0.0.1:8000 -t ./www/ >> ./log/server.log &
@echo "\033[32mServer running. (http://127.0.0.1:8000)\033[0m"
server-stop: ## Stop local server if running
......
......@@ -3,13 +3,13 @@
AUTOLOAD=../app/
; Répertoire contenant les templates
UI=../templates/
UI=../app/view/
; Répertoire des fichiers temporaires
TEMP=../tmp/
; Répertoire des logs
LOGS=../tmp
LOGS=../log/
; Gestionnaire d'erreur personnalisé
; ONERROR="Main->error"
......
<?php
namespace Controller;
use LQDN\Command\AdminCreateCommand;
use LQDN\Command\AdminDeleteCommand;
......@@ -155,10 +156,10 @@ class Admin extends Controller
// We need to check if there's already a user with this email
$result = $db->query("SELECT id
FROM users
WHERE email='".Utils::asl($email)."'");
WHERE email='".\Utils::asl($email)."'");
if ($result) {
// The user already exist, lets get the user_id
$user_id = $result->fetch(PDO::FETCH_ASSOC);
$user_id = $result->fetch(\PDO::FETCH_ASSOC);
$user_id = $user_id['id'];
} else {
// Let's create the account first
......@@ -167,9 +168,9 @@ class Admin extends Controller
pseudo,
cumul,
total)
VALUES('".Utils::asl($email)."',
'".Utils::asl($pseudo)."',
'".Utils::asl($somme)."',
VALUES('".\Utils::asl($email)."',
'".\Utils::asl($pseudo)."',
'".\Utils::asl($somme)."',
'0')");
$user_id = $db->lastInsertId();
}
......@@ -183,11 +184,11 @@ class Admin extends Controller
status)
VALUES
(now(),
'".Utils::asl($user_id)."',
'".Utils::asl($somme)."',
'".Utils::asl($lang)."',
'".Utils::asl($abo)."',
'".Utils::asl($public)."',
'".\Utils::asl($user_id)."',
'".\Utils::asl($somme)."',
'".\Utils::asl($lang)."',
'".\Utils::asl($abo)."',
'".\Utils::asl($public)."',
1)");
// Récupération de l'id pour passage en mode édition
$id = $db->lastInsertId();
......@@ -201,40 +202,40 @@ class Admin extends Controller
$result = $db->query("SELECT adresse_id,
user_id
FROM dons
WHERE id = ".Utils::asl($f3->get('POST.id')));
$result = $result->fetch(PDO::FETCH_ASSOC);
WHERE id = ".\Utils::asl($f3->get('POST.id')));
$result = $result->fetch(\PDO::FETCH_ASSOC);
// Let's update the adresse first or create the adress
if ($result['adresse_id'] == '0') {
$db->query("INSERT INTO adresses
(nom, adresse, adresse2, codepostal, ville, pays)
VALUES ('".Utils::asl($nom)."',
'".Utils::asl($adresse)."',
'".Utils::asl($adresse2)."',
'".Utils::asl($codepostal)."',
'".Utils::asl($ville)."',
'".Utils::asl($pays)."')");
VALUES ('".\Utils::asl($nom)."',
'".\Utils::asl($adresse)."',
'".\Utils::asl($adresse2)."',
'".\Utils::asl($codepostal)."',
'".\Utils::asl($ville)."',
'".\Utils::asl($pays)."')");
$result['adresse_id'] = $db->lastInsertId();
} else {
$db->query("UPDATE adresses
SET nom='".Utils::asl($nom)."',
adresse='".Utils::asl($adresse)."',
adresse2='".Utils::asl($adresse2)."',
codepostal='".Utils::asl($codepostal)."',
ville='".Utils::asl($ville)."',
pays='".Utils::asl($pays)."'
SET nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."'
WHERE id={$result['adresse_id']}");
}
$db->query("UPDATE users
SET email='".Utils::asl($email)."',
pseudo='".Utils::asl($pseudo)."'
SET email='".\Utils::asl($email)."',
pseudo='".\Utils::asl($pseudo)."'
WHERE id={$result['user_id']}");
$db->query("UPDATE dons
SET somme='".Utils::asl($somme)."',
lang='".Utils::asl($lang)."',
abo='".Utils::asl($abo)."',
public='".Utils::asl($public)."',
SET somme='".\Utils::asl($somme)."',
lang='".\Utils::asl($lang)."',
abo='".\Utils::asl($abo)."',
public='".\Utils::asl($public)."',
adresse_id='".$result['adresse_id']."'
WHERE id='".Utils::asl($_POST['id'])."'");
WHERE id='".\Utils::asl($_POST['id'])."'");
}
}
}
......@@ -253,7 +254,7 @@ class Admin extends Controller
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE d.id=".$id);
$don = $result->fetch(PDO::FETCH_ASSOC);
$don = $result->fetch(\PDO::FETCH_ASSOC);
} else {
$don = array(
'id'=>$id,
......@@ -281,7 +282,7 @@ class Admin extends Controller
$query = "SELECT DISTINCT quoi FROM contreparties;";
$result = $db->query($query);
if ($result) {
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$f3->set($row['quoi'].'_s1', 0);
$f3->set($row['quoi'].'_s2', 0);
}
......@@ -294,7 +295,7 @@ class Admin extends Controller
GROUP BY quoi, status;";
$result = $db->query($query);
if ($result) {
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$f3->set($row['quoi'].'_s'.$row['status'], $row['qte']);
}
}
......@@ -310,7 +311,7 @@ class Admin extends Controller
GROUP BY quoi, taille;";
$result = $db->query($query);
if ($result) {
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$f3->set($row['quoi'].'_t'.$row['taille'], $row['qte']);
}
}
......@@ -400,16 +401,16 @@ class Admin extends Controller
case 0:
break;
case 1:
$query .= " AND c.quoi='".Utils::asl('pibag')."' ";
$query .= " AND c.quoi='".\Utils::asl('pibag')."' ";
break;
case 2:
$query .= " AND c.quoi='".Utils::asl('piplome')."' ";
$query .= " AND c.quoi='".\Utils::asl('piplome')."' ";
break;
case 4:
$query .= " AND c.quoi='".Utils::asl('pishirt')."' ";
$query .= " AND c.quoi='".\Utils::asl('pishirt')."' ";
break;
case 8:
$query .= " AND c.quoi='".Utils::asl('hoodie')."' ";
$query .= " AND c.quoi='".\Utils::asl('hoodie')."' ";
break;
default:
$query .= " AND datec IN (
......@@ -428,14 +429,14 @@ class Admin extends Controller
";
}
if ($status) {
$query .= " AND c.status IN (".Utils::asl($status).") ";
$query .= " AND c.status IN (".\Utils::asl($status).") ";
}
$query .= " ORDER BY c.datec DESC LIMIT 0,".$limite.";";
$result = $db->query($query);
$data = array();
if ($result) {
$i = 0;
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
if ($row['quoi']=='piplome') {
$pdf = $db->query("SELECT d.id AS id,
a.nom AS pseudo,
......@@ -444,7 +445,7 @@ class Admin extends Controller
JOIN adresses a ON a.id = d.adresse_id
WHERE d.id='".$row['taille']."'");
if ($pdf) {
$pdf = $pdf->fetch(PDO::FETCH_ASSOC);
$pdf = $pdf->fetch(\PDO::FETCH_ASSOC);
}
$row['pdf_id'] = $pdf['id'];
$row['pdf_nom'] = $pdf['pseudo'];
......@@ -489,25 +490,25 @@ class Admin extends Controller
$row['taille'] = "N/A";
}
$row['count'] = $count++;
$row['email'] = Utils::clean_encoding($row['email']);
$row['pseudo'] = Utils::clean_encoding($row['pseudo']);
$row['nom'] = Utils::clean_encoding($row['nom']);
$adresse = Utils::clean_encoding($row['adresse']);
$row['email'] = \Utils::clean_encoding($row['email']);
$row['pseudo'] = \Utils::clean_encoding($row['pseudo']);
$row['nom'] = \Utils::clean_encoding($row['nom']);
$adresse = \Utils::clean_encoding($row['adresse']);
$adresse = preg_replace('/\n|\r/', ' ', $adresse);
$adresse = preg_replace('/^'.$row['nom'].'/', '', $adresse);
$row['adresse'] = $adresse;
$adresse2 = Utils::clean_encoding($row['adresse2']);
$adresse2 = \Utils::clean_encoding($row['adresse2']);
$adresse2 = preg_replace('/\n|\r/', ' ', $adresse2);
$adresse2 = preg_replace('/^'.$row['nom'].'/', '', $adresse2);
$row['adresse2'] = $adresse2;
$row['codepostal'] = Utils::clean_encoding($row['codepostal']);
$row['ville'] = Utils::clean_encoding($row['ville']);
$row['pays'] = Utils::clean_encoding($row['pays']);
$row['datec'] = Utils::clean_encoding($row['datec']);
$row['taille'] = Utils::clean_encoding($row['taille']);
$row['pdf_id'] = Utils::clean_encoding($row['pdf_id']);
$row['pdf_nom'] = Utils::clean_encoding($row['pdf_nom']);
$row['commentaire'] = Utils::clean_encoding($row['commentaire']);
$row['codepostal'] = \Utils::clean_encoding($row['codepostal']);
$row['ville'] = \Utils::clean_encoding($row['ville']);
$row['pays'] = \Utils::clean_encoding($row['pays']);
$row['datec'] = \Utils::clean_encoding($row['datec']);
$row['taille'] = \Utils::clean_encoding($row['taille']);
$row['pdf_id'] = \Utils::clean_encoding($row['pdf_id']);
$row['pdf_nom'] = \Utils::clean_encoding($row['pdf_nom']);
$row['commentaire'] = \Utils::clean_encoding($row['commentaire']);
$rows[] = $row;
}
$f3->set('headers', array(
......@@ -572,39 +573,39 @@ class Admin extends Controller
// First, let's retrieve the adresse from the adresse_id if it exists
$result = $db->query("SELECT adresse_id
FROM contreparties
WHERE id = '".Utils::asl($f3->get('POST.id'))."'
WHERE id = '".\Utils::asl($f3->get('POST.id'))."'
AND adresse_id IS NOT NULL");
$result = $result->fetch(PDO::FETCH_ASSOC);
$result = $result->fetch(\PDO::FETCH_ASSOC);
$adresse_id = $result['adresse_id'];
if (!$adresse_id or $adresse_id == 0) {
// We need to create an adresse_id
$db->query("INSERT INTO adresses
VALUES (nom='".Utils::asl($nom)."',
adresse='".Utils::asl($adresse)."',
adresse2='".Utils::asl($adresse2)."',
codepostal='".Utils::asl($codepostal)."',
ville='".Utils::asl($ville)."',
pays='".Utils::asl($pays)."')");
VALUES (nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."')");
$adresse_id = $db->lastInsertId();
}
// Updating the adresses first
$db->query("UPDATE adresses
SET nom='".Utils::asl($nom)."',
adresse='".Utils::asl($adresse)."',
adresse2='".Utils::asl($adresse2)."',
codepostal='".Utils::asl($codepostal)."',
ville='".Utils::asl($ville)."',
pays='".Utils::asl($pays)."'
SET nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."'
WHERE id = $adresse_id");
$db->query("UPDATE contreparties
SET quoi='".Utils::asl($quoi)."',
taille='".Utils::asl($taille)."',
status='".Utils::asl($status)."'
WHERE id='".Utils::asl($_POST['id'])."'");
SET quoi='".\Utils::asl($quoi)."',
taille='".\Utils::asl($taille)."',
status='".\Utils::asl($status)."'
WHERE id='".\Utils::asl($_POST['id'])."'");
// We will update the comment
$db->query("UPDATE users SET commentaire='".Utils::asl($comment)."' WHERE id='".Utils::asl($user_id)."'");
$db->query("UPDATE users SET commentaire='".\Utils::asl($comment)."' WHERE id='".\Utils::asl($user_id)."'");
}
}
......@@ -626,8 +627,8 @@ class Admin extends Controller
JOIN users u ON c.user_id = u.id
LEFT JOIN adresses a ON c.adresse_id = a.id
WHERE c.id=".$id);
if ($result->fetch(PDO::FETCH_ASSOC)) {
$contrepartie = $result->fetch(PDO::FETCH_ASSOC);
if ($result->fetch(\PDO::FETCH_ASSOC)) {
$contrepartie = $result->fetch(\PDO::FETCH_ASSOC);
}
} else {
$contrepartie = array(
......@@ -656,7 +657,7 @@ class Admin extends Controller
AND d.status IN (1,4,101)
AND d.user_id='".$contrepartie['user_id']."'");
if ($result) {
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $pdf) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $pdf) {
$pdfs[] = $pdf;
}
}
......@@ -672,18 +673,18 @@ class Admin extends Controller
public function user($f3, $args)
{
$id = array_key_exists('id', $args) ? Utils::asl($args['id']) : '';
$id = array_key_exists('id', $args) ? \Utils::asl($args['id']) : '';
$f3->set('id', $id);
if ($f3->get('VERB') == 'POST') {
$pseudo = Utils::asl($f3->get('POST.pseudo'));
$pseudo = \Utils::asl($f3->get('POST.pseudo'));
$email = $f3->get('POST.email');
$commentaire = $f3->get('POST.commentaire');
if ($id > 0) {
$f3->get('container')['command_handler']->handle(new UserUpdateByAdminCommand($id, $pseudo, $email, $commentaire));
} else {
$password = hash('sha256', Utils::generate_password());
$password = hash('sha256', \Utils::generate_password());
$db = $f3->get('DB');
$db->query("INSERT INTO users
VALUES pseudo = '".$pseudo."',
......@@ -774,7 +775,7 @@ class Admin extends Controller
$cbs = array();
if ($result) {
$i = 0;
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $data) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $data) {
$cb['id'] = $data['id'];
$cb['email'] = $data['email'];
$time_struct = strptime($data['expiration'], "%Y-%m-%d %H:%M:%S");
......@@ -810,9 +811,9 @@ class Admin extends Controller
$count = 1;
foreach ($cbs as $row) {
$row['count'] = $count++;
$row['id'] = Utils::clean_encoding($row['id']);
$row['email'] = Utils::clean_encoding($row['email']);
$row['expiration'] = Utils::clean_encoding($row['expiration']);
$row['id'] = \Utils::clean_encoding($row['id']);
$row['email'] = \Utils::clean_encoding($row['email']);
$row['expiration'] = \Utils::clean_encoding($row['expiration']);
$row['status'] = $statuts[$row['status']];
$rows[] = $row;
}
......@@ -949,7 +950,7 @@ class Admin extends Controller
// Mise à jour dans la base de données de la date d'expiration
$result = $db->query("SELECT user_id FROM identifiers WHERE identifier='".$identifier."'");
if ($result) {
$user_id = $result->fetch(PDO::FETCH_ASSOC)[0];
$user_id = $result->fetch(\PDO::FETCH_ASSOC)[0];
$total_cbs += 1;
$db->query("UPDATE identifiers SET expiration='".$expire. "' WHERE identifier='".$identifier."'");
if ($expire_date<$today_date) {
......@@ -1023,14 +1024,14 @@ class Admin extends Controller
// Pour un don ponctuel, on recherche un équivalent
$result = $db->query("SELECT COUNT(*) FROM dons WHERE id='".$transaction. "' AND somme='".$amount."' AND status=1");
if ($result) {
$combien = $result->fetch(PDO::FETCH_ASSOC);
$combien = $result->fetch(\PDO::FETCH_ASSOC);
if ($combien[0]>0) {
$dons_ok += 1;
} else {
$dons_nok += 1;
$subresult = $db->query("SELECT id, status, somme FROM dons WHERE id='".$transaction. "'");
if ($subresult) {
$subresult = $subresult->fetch(PDO::FETCH_ASSOC);
$subresult = $subresult->fetch(\PDO::FETCH_ASSOC);
if (count($subresult)>0) {
$dons[] = "Transaction " . $transaction . " de " . $subresult[2] . " € avec un statut " . $subresult[1] . ".";
} else {
......@@ -1054,12 +1055,12 @@ class Admin extends Controller
// Pour un don récurrent, on recherche son équivalent qui peut ne pas exister
$result = $db->query("SELECT email FROM users JOIN identifiers ON identifiers.user_id = users.id WHERE identifiers.identifier='".$identifier. "'");
if ($result) {
$email = $result->fetch(PDO::FETCH_ASSOC);
$email = $result->fetch(\PDO::FETCH_ASSOC);
$email = $email[0];
$result = $db->query("SELECT COUNT(1) FROM dons d JOIN users u ON u.id = d.user_id WHERE u.email='".$email. "' and d.status=102 and d.datec='".$new_effect."'");
if ($result) {
$combien = $result->fetch(PDO::FETCH_ASSOC);
$combien = $result->fetch(\PDO::FETCH_ASSOC);
if ($combien[0]>0) {
// Don récurrent comptabilisé
$recurrents_ok += 1;
......@@ -1157,7 +1158,7 @@ class Admin extends Controller
ON users.id = identifiers.user_id
AND identifiers.identifier='".$identifier. "'");
if ($result) {
$email = $result->fetch(PDO::FETCH_ASSOC);
$email = $result->fetch(\PDO::FETCH_ASSOC);
$email = $email['email'];
// On stocke l'email pour comptabiliser les dons
if (array_key_exists($email, $emails)) {
......@@ -1174,7 +1175,7 @@ class Admin extends Controller
AND d.status=101
AND d.id='".$transaction."' ");
if ($result) {
$cumul = $result->fetch(PDO::FETCH_ASSOC);
$cumul = $result->fetch(\PDO::FETCH_ASSOC);
$cumul = $cumul['id'];
if ($cumul!='') {
$result = $db->query("SELECT COUNT(1)
......@@ -1191,7 +1192,7 @@ class Admin extends Controller
$update ++;
// Don récurrent non comptabilisé, on l'ajoute
$user_id = $db->query("SELECT id FROM users WHERE email='$email'");
$user_id = $user_id->fetch(PDO::FETCH_ASSOC);
$user_id = $user_id->fetch(\PDO::FETCH_ASSOC);
$user_id = $user_id['id'];
$query = "INSERT INTO dons (status,
datec,
......@@ -1288,7 +1289,7 @@ class Admin extends Controller
$f3->reroute('/admin/accounts');
}
$admins = $admins->fetchAll(PDO::FETCH_ASSOC);
$admins = $admins->fetchAll(\PDO::FETCH_ASSOC);
$f3->set('admins', $admins);
$f3->set('block_content', 'backend/admins.html');
}
......
<?php
namespace Controller;
class Bank extends Controller
{
......@@ -14,7 +15,7 @@ class Bank extends Controller
{
@include_once("config.php");
$cb_log = new Log('/cb.log');
$cb_log = new \Log('/cb.log');
$error="";
$result = $f3->get('POST.vads_result');
$status = $f3->get('POST.vads_trans_status');
......@@ -106,7 +107,7 @@ class Bank extends Controller
$id = intval($order_id);
$cb_log->write("Id: ".$order_id);
$res = $db->query("SELECT * FROM dons WHERE id='".$id."';");
$don = $res->fetch(PDO::FETCH_ASSOC);
$don = $res->fetch(\PDO::FETCH_ASSOC);
if (!$don) {
$cb_log->write("Transaction id not found: ".$order_id);
......@@ -144,11 +145,11 @@ class Bank extends Controller
// ok, somme OK, status = completed, transaction found.
$db->query("UPDATE dons SET status=status+1 WHERE id='".$id."';");
$res = $db->query("SELECT status FROM dons WHERE id='".$id."';");
$status = $res->fetch(PDO::FETCH_ASSOC);
$status = $res->fetch(\PDO::FETCH_ASSOC);
$status = $status['status'];
$res = $db->query("SELECT * FROM users WHERE id='".$don['user_id']."';");
$user = $res->fetch(PDO::FETCH_ASSOC);
$user = $res->fetch(\PDO::FETCH_ASSOC);
$cb_log->write("Utilisation d'un utilisateur existant");
// Ajout du nouveau don au cumul actuel
if ($status!=101) {
......@@ -156,7 +157,7 @@ class Bank extends Controller
$db->query("UPDATE users set cumul = cumul + " . $don['somme'] . ", total = total + " . $don['somme'] . " WHERE id='".$don['user_id']."'");
}
$result = $db->query("SELECT cumul FROM users WHERE id='".$don['user_id']."'");
$cumul = $result->fetch(PDO::FETCH_ASSOC);
$cumul = $result->fetch(\PDO::FETCH_ASSOC);
$cumul = $cumul['cumul'];
$cb_log->write("Nouveau cumul: ".$cumul);
$user_id = $user['id'];
......
<?php
namespace Controller;
class Campaign extends Controller
{
......@@ -20,7 +21,7 @@ class Campaign extends Controller
{
parent::afterRoute($f3, $args);
// Rendu HTML de la page
echo Template::instance()->render('campaign/base.html');
echo \Template::instance()->render('campaign/base.html');
}
public static function show($f3, $args)
......@@ -29,8 +30,8 @@ class Campaign extends Controller
// So, get the $db
$db = $f3->get('DB');
// Number of month left for a one-year provisionning since CAMPAIGN_START_DATE
$now = new DateTime('now');
$start = new DateTime(CAMPAIGN_START_DATE);
$now = new \DateTime('now');
$start = new \DateTime(CAMPAIGN_START_DATE);
if ($start > $now) {
$months = 0;
} else {
......@@ -74,7 +75,7 @@ class Campaign extends Controller
// Page d'attente
public function wait($f3)
{
echo Template::instance()->render('campaign/wait.html');
echo \Template::instance()->render('campaign/wait.html');
exit;
}
......@@ -140,29 +141,29 @@ class Campaign extends Controller
// Si l'utilisateur est déjà connecté, on le récupère
if ($f3->get('SESSION.user', true)) {
$user = $db->query("SELECT * FROM users WHERE id = ".$f3->get('SESSION.id'));
$user = $user->fetch(PDO::FETCH_ASSOC);
$user = $user->fetch(\PDO::FETCH_ASSOC);
$email = $user['email'];
$user_id = $user['id'];
$cumul_id = $user['cumul'];
} else {
// Depuis les dons cumulés, on recherche d'abord si le donateur existe déjà (basé sur son email)
$email = Utils::asl($f3->get('email'));
$email = \Utils::asl($f3->get('email'));
$hash = hash('sha256', $f3->get('password'));
$sql = "SELECT id FROM users WHERE email = '".Utils::asl($email)."';";
$sql = "SELECT id FROM users WHERE email = '".\Utils::asl($email)."';";
$result = $db->query($sql);
if ($result->fetchColumn() > 0) {
// We have an existing user, we should try to login with the provided password
// or 403.
$mapper = new DB\SQL\Mapper($f3->get('DB'), 'users');
$mapper = new \DB\SQL\Mapper($f3->get('DB'), 'users');
$auth = new \Auth($mapper, array('id' => 'email', 'pw' => 'hash'));
$login = $auth->login($email, $hash);
if (!$login) {
$f3->error(403);
} else {
$result = $db->query("SELECT id, cumul FROM users WHERE email = '".Utils::asl($email)."'");
$user = $result->fetch(PDO::FETCH_ASSOC);
$result = $db->query("SELECT id, cumul FROM users WHERE email = '".\Utils::asl($email)."'");
$user = $result->fetch(\PDO::FETCH_ASSOC);
$user_id = $user['id'];
$cumul_id = $user['cumul'];
}
......@@ -191,7 +192,7 @@ class Campaign extends Controller
setcookie("donlqdn", md5("SALT!!!".$id."!!!"), 86400, "/");
$target = PAYMENT_URL; //"https://paiement.systempay.fr/vads-payment/";
$transaction_date = new DateTime('now', new DateTimeZone("UTC"));
$transaction_date = new \DateTime('now', new \DateTimeZone("UTC"));
$params = array(
// Champs obligatoires
"vads_trans_date" => $transaction_date->format("YmdHis"),
......@@ -250,7 +251,7 @@ class Campaign extends Controller
$f3->set('signature', $signature);
// Log des informations envoyées pour debug en cas de souci
$don_log = new Log('dons.log');
$don_log = new \Log('dons.log');
$don_log->write('target : '. $target);
$don_log->write('params : ');
foreach ($params as $key=>$value) {
......
<?php
namespace Controller;
class Controller
{
// Constructeur
public function __construct()
{
$f3=Base::instance();
$f3=\Base::instance();
}
// Fonction appelée avant routage
......@@ -62,7 +63,7 @@ class Controller
}
// Log dir
$f3->set('LOGS', LOGS);