Ajout de CI et update depuis la prod
Some checks failed
Déploiement DEV / deploy (push) Failing after 13s
Some checks failed
Déploiement DEV / deploy (push) Failing after 13s
This commit is contained in:
11
config/connexion_sql.php
Normal file
11
config/connexion_sql.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// Connexion à la base de données
|
||||
try
|
||||
{
|
||||
$bdd = new PDO('mysql:host=localhost:3306;dbname=ecurie', 'ccbuser', 'HO9A#x@qD6Wl',array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
die('Erreur : '.$e->getMessage());
|
||||
}
|
||||
9
config/constants.php
Normal file
9
config/constants.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
define('VISITEUR',1);
|
||||
define('INSCRIT',2);
|
||||
define('MODO',3);
|
||||
define('ADMIN',4);
|
||||
define('ERR_IS_CO','Vous ne pouvez pas accéder à cette page si vous n\'êtes pas connecté');
|
||||
?>
|
||||
|
||||
|
||||
68
config/functions.php
Normal file
68
config/functions.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
function erreur($err='')
|
||||
{
|
||||
$mess=($err!='')? $err:'Une erreur inconnue s\'est produite';
|
||||
exit('
|
||||
<div class="container-fluid">
|
||||
<section id="content" class="page-content">
|
||||
<div class="container text-center">
|
||||
<h2>Vous êtes pas autorisé a passer ici</h2><br>
|
||||
<p> '.$mess.' </p>
|
||||
<p>Cliquez <a href="./espace_membre.php">ici</a> pour revenir à la page d\'accueil</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>');
|
||||
}
|
||||
function edit_avatar($avatar, $pseudo)
|
||||
{
|
||||
if (isset ($avatar)){
|
||||
$imagename = $avatar['name'];// exemple.png
|
||||
$source = $avatar['tmp_name'];// /volume1/@tmp/phpiES0qN
|
||||
$locate = "./images/avatars/".$pseudo."/";
|
||||
$dir = $locate."img_user.jpeg";
|
||||
move_uploaded_file($source,$dir);
|
||||
changeToJpeg($dir,$dir);
|
||||
resize_avatar($dir,$dir);
|
||||
$rdir = substr($dir,1);
|
||||
return $rdir;
|
||||
}
|
||||
}
|
||||
|
||||
function changeToJpeg($source, $dir)
|
||||
{
|
||||
$ext = substr($_FILES['avatar']['type'],6); //jpeg
|
||||
switch($ext) {
|
||||
case 'jpg':
|
||||
$image = imagecreatefromjpeg($source);
|
||||
break;
|
||||
|
||||
case 'jpeg':
|
||||
$image = imagecreatefromjpeg($source);
|
||||
break;
|
||||
|
||||
case 'png':
|
||||
$image = imagecreatefrompng($source);
|
||||
break;
|
||||
|
||||
case 'gif':
|
||||
$image = imagecreatefromgif($source);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown image type.');
|
||||
}
|
||||
imagejpeg($image, $dir);
|
||||
}
|
||||
|
||||
function resize_avatar($dir,$out )
|
||||
{
|
||||
list($width, $height) = getimagesize($dir);
|
||||
$modwidth = 150; //target width
|
||||
$diff = $width / $modwidth;
|
||||
$modheight = $height / $diff;
|
||||
|
||||
$tn = imagecreatetruecolor($modwidth, $modheight);
|
||||
$image = imagecreatefromjpeg($dir);
|
||||
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
|
||||
imagejpeg($tn, $out);
|
||||
}
|
||||
?>
|
||||
12
config/init.php
Normal file
12
config/init.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
include_once(__DIR__ . '/constants.php');
|
||||
include_once(__DIR__ . '/functions.php');
|
||||
|
||||
$lvl = isset($_SESSION['privilege']) ? (int)$_SESSION['privilege'] : 1;
|
||||
$id = isset($_SESSION['ideleve']) ? (int)$_SESSION['ideleve'] : 0;
|
||||
$pseudo = isset($_SESSION['pseudo']) ? $_SESSION['pseudo'] : '';
|
||||
?>
|
||||
Reference in New Issue
Block a user