- query('SELECT nom, admin FROM copains WHERE id='.$modif);
- $donnees = $req->fetch();
- $req->closeCursor();
- ?>
-
Modifier un copain
-
-
-
-
-
diff --git a/favicon.ico b/favicon.ico
deleted file mode 100644
index bebacd5..0000000
Binary files a/favicon.ico and /dev/null differ
diff --git a/include.php b/include.php
deleted file mode 100644
index 240e1ad..0000000
--- a/include.php
+++ /dev/null
@@ -1,36 +0,0 @@
-query("SET NAMES 'utf8'");
-
- session_start();
-
- date_default_timezone_set('Europe/Paris'); //Definition of the clock
-
- if($protect) //If user must be logged in
- {
- if(empty($_SESSION['nom']))
- {
- header('location:connexion.php');
- exit();
- }
- }
- if($admin) //If he must be an admin
- {
- if(empty($_SESSION['admin']))
- {
- header('location: message.php?id=7');
- exit();
- }
- }
-
- $CONFIG['base_url'] = 'localhost/Bouffe@Ulm/';
- $CONFIG['domain'] = '';
- $CONFIG['salt'] = '62407efbf5e8508baf096e1e23f497991e12a3bd';
- }
diff --git a/index.php b/index.php
deleted file mode 100644
index e2c09ba..0000000
--- a/index.php
+++ /dev/null
@@ -1,425 +0,0 @@
-31,
- 2=>28+date('L'),
- 3=>31,
- 4=>30,
- 5=>31,
- 6=>30,
- 7=>31,
- 8=>31,
- 9=>30,
- 10=>31,
- 11=>30,
- 12=>31);
- $fin_mois = mktime(23, 59, 59, $num_mois, $dernier_jour[$num_mois], $annee);
- $bornes = array($debut_mois, $fin_mois);
- return $bornes;
- }
-
- //Return what A must pay to B
- function dettes($A, $B, $debut_mois, $fin_mois)
- {
- global $bdd;
- //When A paid and B was here
- $reqA_B = $bdd->prepare('SELECT id, date, montant, copains, invites FROM depenses WHERE date>'.$debut_mois.' AND date<'.$fin_mois.' AND de=:param1 AND (copains LIKE "%,'.(int) $B.',%" OR copains LIKE "%,'.(int)$B.'" OR copains LIKE "'.(int) $B.',%" OR copains LIKE "'.(int) $B.'")');
- $reqA_B->bindvalue(':param1',$A);
- $reqA_B->execute();
- //When B paid and A was here
- $reqB_A = $bdd->prepare('SELECT id, date, montant, copains, invites FROM depenses WHERE date>'.$debut_mois.' AND date<'.$fin_mois.' AND de=:param1 AND (copains LIKE "%,'.(int) $A.',%" OR copains LIKE "%,'.(int)$A.'" OR copains LIKE "'.(int) $A.',%" OR copains LIKE "'.(int) $A.'")');
- $reqB_A->bindvalue(':param1',$B);
- $reqB_A->execute();
- //What A already paid to B for the current month
- $reqPaiementsA_B = $bdd -> prepare('SELECT paiements.montant AS montant FROM paiements LEFT JOIN depenses ON paiements.id_depense=depenses.id WHERE depenses.date >'.$debut_mois.' AND depenses.date<'.$fin_mois.' AND paiements.de=:de AND paiements.a=:a');
- $reqPaiementsA_B->bindvalue(':de',$A);
- $reqPaiementsA_B->bindvalue(':a',$B);
- $reqPaiementsA_B->execute();
- //Same thing for B to A
- $reqPaiementsB_A = $bdd -> prepare('SELECT paiements.montant AS montant FROM paiements LEFT JOIN depenses ON paiements.id_depense=depenses.id WHERE depenses.date >'.$debut_mois.' AND depenses.date<'.$fin_mois.' AND paiements.de=:de AND paiements.a=:a');
- $reqPaiementsB_A->bindvalue(':de',$B);
- $reqPaiementsB_A->bindvalue(':a',$A);
- $reqPaiementsB_A->execute();
- //$deltaAB : What A must pay to B
- $deltaAB = 0;
-
- while($donneesA_B = $reqA_B->fetch())
- {
- //We get the price of the meal, divided by the number of people who ate
- //nbre de virgule + 1
- $deltaAB -= $donneesA_B['montant']/(substr_count($donneesA_B['copains'], ',') + 1 + $donneesA_B['invites']);
- }
- while($donneesB_A = $reqB_A->fetch()) //idem
- {
- $deltaAB += $donneesB_A['montant']/(substr_count($donneesB_A['copains'], ',') + 1 + $donneesB_A['invites']);
- }
- while($donneesPaiementsA_B = $reqPaiementsA_B->fetch()) //idem
- {
- $deltaAB -= $donneesPaiementsA_B['montant'];
- }
- while($donneesPaiementsB_A = $reqPaiementsB_A->fetch()) //idem
- {
- $deltaAB += $donneesPaiementsB_A['montant'];
- }
- return $deltaAB;
- }
-
- if(isset($_GET['del'])) //If we want to delete an expenditure
- {
- if(empty($_GET['valide']) OR empty($_GET['token']) OR $_GET['token'] != $_SESSION['token_del_depense'] OR $_SESSION['token_del_depense_time'] < time() - (15*60) OR strpos($_SERVER['HTTP_REFERER'], 'http://'.$CONFIG['base_url'].'/index.php') > 0 OR strpos($_SERVER['HTTP_REFERER'], 'https://'.$CONFIG['base_url'].'/index.php') > 0) //If we didn't click the link to validate the deletion and the token is not valid (not present or older than 15 minutes) or if the referer is not ok
- {
- $_SESSION['token_del_depense'] = sha1(uniqid(rand(), true)); //We generate a token and store it in a session variable
- $_SESSION['token_del_depense_time'] = time(); //We also store the time at which the token has been generated
- $lien = 'index.php?del='.$_GET['del'] .'&valide=1&token='.$_SESSION['token_del_depense'];
-?>
-
-
-
-
- Bouffe@Ulm
-
-
-
-
-
-
-
-
-query('DELETE FROM depenses WHERE id='.$id);
- $bdd->query('DELETE FROM paiements WHERE id_depense='.$id);
-
- header('location: message.php?id=1');
- exit();
- }
-
- //This get all the friends' name (we need it next)
- $req2 = $bdd->query('SELECT id, nom FROM copains ORDER BY nom ASC');
- while($copain = $req2->fetch())
- {
- $copains[$copain['id']] = $copain['nom']; //And put it in an array
- }
-
- $req_jeu = $bdd->prepare('SELECT COUNT(*) AS nbre_jeu FROM depenses WHERE de=:de');
- $req_jeu->bindValue(':de', $_SESSION['id']);
- $req_jeu->execute();
-
- $donnees_jeu = $req_jeu->fetch(); //To define wether we display the game or not
-
- //SESSION token for the update of what people must pay to us (modif.php)
- $_SESSION['token_validate_single'] = sha1(uniqid(rand(), true)); //We generate a token and store it in a session variable
- $_SESSION['token_validate_single_time'] = time(); //We also store the time at which the token has been generated
-?>
-
-
-
-
- Bouffe@Ulm
-
-
- = 1 || $_SESSION['admin'] == 1)
- {
- ?>
-
-
-
-
-
-
-