/*--------------------------------------------------------------------------------------
VARIABLES DE CONNEXION A LA BASE DE DONNEE
--------------------------------------------------------------------------------------*/
define("_HOST_", "localhost");
define("_USER_", "root");
define("_PWD_", "#SRS@webnet2014");
define ("_DB_", "estacombkf");
session_start();
?>
/*--------------------------------------------------------------------------------------
FONCTION D'AFFICHAGE DES ERREURS DE CONNEXION
--------------------------------------------------------------------------------------*/
function erreur( $message )
{
echo $message ;
exit ;
}
error_reporting(E_ERROR);
/*--------------------------------------------------------------------------------------
FONCTION DE CONNEXION A LA BASE DE DONNEES
--------------------------------------------------------------------------------------*/
function connexion()
{
// connexion au serveur de données
@mysql_connect( _HOST_ , _USER_ , _PWD_ ) or erreur( 'Connexion au serveur de données impossible' ) ;
// sélection de la base de données
@mysql_select_db( _DB_ ) or erreur( 'Sélection de la base de donnée impossible' ) ;
}
/*--------------------------------------------------------------------------------------
FONCTION DE DECONNEXION A LA BASE DE DONNEES
--------------------------------------------------------------------------------------*/
function deconnexion()
{
@mysql_close();
}
/*--------------------------------------------------------------------------------------
FONCTION DE D'EXECUTION D'UNE REQUETE
Entrée :
$adr : requete
Sortie :
$resultat : résultat de la requete
ou
message d'erreur
--------------------------------------------------------------------------------------*/
function requete( $requete )
{
if($resultat = mysql_query( $requete )) return $resultat ;
erreur( "Erreur dans la requête : $requete
" . mysql_error() ) ;
}
/*--------------------------------------------------------------------------------------
FONCTION DE DESACTIVATION DU CACHE DU NAVIGATEUR
--------------------------------------------------------------------------------------*/
function no_cache() {
header("Pragma: no-cache");
header("Cache-Control: no-cache");
}
function cropImage($nw, $nh, $source, $stype, $dest)
{
$size = getimagesize($source);
$w = $size[0];
$h = $size[1];
switch($stype) {
case 'gif':
$simg = imagecreatefromgif($source);
break;
case 'jpg':
$simg = imagecreatefromjpeg($source);
break;
case 'png':
$simg = imagecreatefrompng($source);
break;
}
$dimg = imagecreatetruecolor($nw, $nh);
$wm = $w/$nw;
$hm = $h/$nh;
$h_height = $nh/2;
$w_height = $nw/2;
if($wm> $hm) {
$adjusted_width = $w / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;
imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
} elseif(($wm <$hm) || ($w == $h)) {
$adjusted_height = $h / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;
imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
} else {
imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
}
imagejpeg($dimg,$dest,100);
}
//CHECK IF A TABLE EXIST
function check_table($table,$fields,$types,$key,$error)
{
$sql="SELECT * FROM $table";
$result=@mysql_query($sql);
if (!$result)
{
// Create a MySQL table
$sql = "CREATE TABLE $table(";
$fields = explode(',',$fields);
$types = explode(',',$types);
for($i=0;$i