Skip to content

Commit 0351c28

Browse files
author
root
committed
first commit
0 parents  commit 0351c28

File tree

369 files changed

+204293
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+204293
-0
lines changed

.htaccess

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<IfModule mod_headers.c>
2+
Header set Cache-Control "no-cache, no-store, must-revalidate"
3+
Header set Pragma "no-cache"
4+
Header set Expires 0
5+
</IfModule>

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files.autoSave": "afterDelay"
3+
}

Autoloader.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
class Autoloader
3+
{
4+
static function register()
5+
{
6+
spl_autoload_register(array('Autoloader','Autoload'));
7+
}
8+
9+
static function Autoload($class_name,$name = '')
10+
{
11+
$class_name = str_replace('\\', '/', $class_name);
12+
$name = explode('/',$class_name);
13+
$name = end($name);
14+
if(strpos($name,'PHPExcel')!==0)
15+
{
16+
require $class_name . '.php' ;
17+
}
18+
19+
}
20+
}

app/controller/Authcontroleur.php

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
namespace app\controller;
3+
use app\model\Users;
4+
use app\model\Parametres;
5+
6+
class Authcontroleur extends \core\Controller\controller {
7+
8+
9+
public function connexion()
10+
{
11+
if(isset($_SESSION['id'])) //Si l'utilisateur est connecté au site
12+
{
13+
header('Location:?p=home'); //Afficher le site
14+
}
15+
$error = false;
16+
if(!empty($_POST) AND isset($_POST)) //Si l'utilisateur a rempli les informations
17+
{
18+
$_POST['password'] = $this->hashPassword($_POST['password']);
19+
$users=new users();
20+
$data = $users->connexion($_POST);
21+
if($data) //Si les infos rempli sont juste
22+
{
23+
$_SESSION['id'] = $data->id; //on sauvgarde tt ces données en cas ou on aura besion plutard
24+
$_SESSION['type'] = $data->type;
25+
$_SESSION['identifiant'] = $data->identifiant;
26+
$_SESSION['password'] = $data->password;
27+
header('Location:?p=home'); //Afficher le site
28+
}
29+
else //sinon
30+
{
31+
$error = true;
32+
}
33+
}
34+
require 'app/views/connexion/connexion.php';
35+
}
36+
37+
public function logged()
38+
{
39+
if(!isset($_SESSION['id'])) //Si l'utilisateur n'est pas connecté au site
40+
{
41+
header('location:?p=connexion'); //Afficher formulaire de login
42+
}
43+
$this->render('home'); //Sinon si il a déja connecté on affiche le site
44+
}
45+
46+
public function deconnexion()
47+
{
48+
session_destroy();
49+
header('location:?p=connexion');
50+
}
51+
52+
public function upmyuser() //Update password or identifiant user
53+
{
54+
if(!empty($_POST) AND isset($_POST))
55+
{
56+
$users = new users();
57+
if($_POST['modifier'] == 'password')
58+
{
59+
$_POST['old-password'] = $this->hashPassword($_POST['old-password']);
60+
if($_POST['old-password'] != $_SESSION['password'])
61+
{
62+
$error['old'] = 'old';
63+
}
64+
if($_POST['Rpassword'] != $_POST['password'])
65+
{
66+
$error['new'] = 'new';
67+
}
68+
if(!empty($error))
69+
{
70+
echo json_encode($error);
71+
}
72+
else
73+
{
74+
unset($_POST['Rpassword']);
75+
unset($_POST['modifier']);
76+
unset($_POST['old-password']);
77+
$_POST['password'] = $this->hashPassword($_POST['password']);
78+
$users->modifier($_POST,$_SESSION['id']);
79+
$_SESSION['password'] = $_POST['password'];
80+
header('Location:?p=upmyuser');
81+
}
82+
}
83+
elseif ($_POST['modifier'] == 'identifiant')
84+
{
85+
unset($_POST['modifier']);
86+
$users = new Users();
87+
$array = [];
88+
//Verifier qu'aucun compte exist avec le méme nom
89+
$array['identifiant'] = $_POST['identifiant'];
90+
$data = $users->select($array);
91+
if($data!=FALSE)
92+
{
93+
$error['exist'] = 'exist';
94+
echo json_encode($error);
95+
}
96+
else
97+
{
98+
$users->modifier($_POST,$_SESSION['id']);
99+
$_SESSION['identifiant'] = $_POST['identifiant'];
100+
header('Location:?p=upmyuser');
101+
}
102+
103+
}
104+
}
105+
}
106+
107+
}

0 commit comments

Comments
 (0)