Browse Source

Modification arborescence

feature/ldap
Chocobozzz 11 years ago
parent
commit
4c5f7a8287
  1. 4
      include/ajax.php
  2. 7
      include/config.php
  3. 0
      include/config.php.example
  4. 6
      include/connexion_bdd.php
  5. 8
      index.php
  6. 6
      js/index.js

4
ajax.php → include/ajax.php

@ -4,7 +4,7 @@
if(!isset($_SESSION['admin_id'])) if(!isset($_SESSION['admin_id']))
exit -1; exit -1;
require('connexion_bdd.php'); require(basename(__FILE__) . 'connexion_bdd.php');
function datetosql($date) { function datetosql($date) {
return implode('-', array_reverse(explode('/', $date))); return implode('-', array_reverse(explode('/', $date)));
@ -178,4 +178,4 @@
$req->execute(array($_POST['del_admin_id'])); $req->execute(array($_POST['del_admin_id']));
} }
?> ?>

7
include/config.php

@ -0,0 +1,7 @@
<?php
$hote='localhost';
$port='3306';
$bd='vpn';
$utilisateur='user';
$mdp="password";
?>

0
connexion_bdd.php.example → include/config.php.example

6
include/connexion_bdd.php

@ -0,0 +1,6 @@
<?php
require(basename(__FILE__) . "/config.php");
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO("mysql:host='.$hote.';port='.$port.';dbname='.$bd, $utilisateur, $mdp, $options);
?>

8
index.php

@ -8,18 +8,14 @@
// Tentative de connexion ? // Tentative de connexion ?
if(isset($_POST['id'], $_POST['pass'])){ if(isset($_POST['id'], $_POST['pass'])){
require('connexion_bdd.php'); require('include/connexion_bdd.php');
$req = $bdd->prepare('SELECT * FROM admin WHERE admin_id = ? AND admin_pass = ?'); $req = $bdd->prepare('SELECT * FROM admin WHERE admin_id = ? AND admin_pass = ?');
$req->execute(array($_POST['id'], sha1($_POST['pass']))); $req->execute(array($_POST['id'], sha1($_POST['pass'])));
if($data = $req->fetch()){ if($data = $req->fetch()){
$_SESSION['admin_id'] = $data['admin_id']; $_SESSION['admin_id'] = $data['admin_id'];
unset($_POST['id'], $_POST['pass']); header("Location: .");
$connexion = true;
}
else{
$connexion = false;
} }
} }
?> ?>

6
js/index.js

@ -7,7 +7,7 @@ $(function () {
// Selection des users // Selection des users
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "ajax.php", url: "include/ajax.php",
dataType: 'json', dataType: 'json',
data: "select=user", data: "select=user",
success: function (json) { success: function (json) {
@ -60,7 +60,7 @@ $(function () {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "ajax.php", url: "include/ajax.php",
dataType: "json", dataType: "json",
data: {del_user_id: id}, data: {del_user_id: id},
error: function () { error: function () {
@ -115,7 +115,7 @@ $(function () {
// Suppression dans la bdd // Suppression dans la bdd
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "ajax.php", url: "include/ajax.php",
dataType: "json", dataType: "json",
data: item, data: item,
error: function () { error: function () {

Loading…
Cancel
Save