Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function posterEditeur($id,$nom,$site,$histoire,$membres_importants)
- {
- global $sql;
- $nom = $sql->escape_string(utf8_encode($nom));
- $site = $sql->escape_string(utf8_encode($site));
- $histoire = $sql->escape_string(utf8_encode($histoire));
- $membres_importants = $sql->escape_string(utf8_encode($membres_importants));
- if ($id == 0)
- {
- $sql->query("INSERT INTO editeurs(idediteurs,nom,site_officiel,histoire,membres_importants)
- VALUES('','".$nom."','".$site."','".$histoire."','".$membres_importants."')");
- if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0)
- {
- $rep = '../'.PATH_IMG.PATH_EDITEUR;
- $ext = gestionImages::upload('logo',$rep.$sql->insert_id().'_big',array('jpeg','jpg','png'),$pre='../');
- $image = new gestionImages($rep.$sql->insert_id().'_big.'.$ext,'../');
- //Calcul des dimensions
- if ($ext == 'jpg' || $ext == 'jpeg')
- {
- $img = imagecreatefromjpeg($rep.$sql->insert_id().'_big.'.$ext);
- }
- else if ($ext == 'png')
- {
- $img = imagecreatefrompng($rep.$sql->insert_id().'_big.'.$ext);
- }
- else
- {
- echo 'Type d\'image non supporté';
- exit;
- }
- $largeur_img = imagesx($img);
- $hauteur_img = imagesy($img);
- $ratio = $largeur_img / MAX_LOGO_X;
- $x = $largeur_img / $ratio;
- $y = $hauteur_img / $ratio;
- imagedestroy($img);
- $image->createMiniature($rep.$sql->insert_id().'.'.$ext,$x,$y);
- if ($ratio > 1)
- {
- $image->watermark();
- }
- }
- }
- else
- {
- $sql->query("UPDATE editeurs SET nom = '".$nom."', site_officiel = '".$site."', histoire = '".$histoire."', membres_importants = '".$membres_importants."' WHERE idediteurs = ".$id);
- if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0)
- {
- $rep = '../'.PATH_IMG.PATH_EDITEUR;
- $ext = gestionImages::upload('logo',$rep.$id.'_big',array('jpeg','jpg','png'),$pre='../');
- $image = new gestionImages($rep.$id.'_big.'.$ext,'../');
- //Calcul des dimensions
- if ($ext == 'jpg' || $ext == 'jpeg')
- {
- $img = imagecreatefromjpeg($rep.$id.'_big.'.$ext);
- }
- else if ($ext == 'png')
- {
- $img = imagecreatefrompng($rep.$id.'_big.'.$ext);
- }
- else
- {
- echo 'Type d\'image non supporté';
- exit;
- }
- $largeur_img = imagesx($img);
- $hauteur_img = imagesy($img);
- $ratio = $largeur_img / MAX_LOGO_X;
- $x = $largeur_img / $ratio;
- $y = $hauteur_img / $ratio;
- imagedestroy($img);
- $image->createMiniature($rep.$id.'.'.$ext,$x,$y);
- if ($ratio > 1)
- {
- $image->watermark();
- }
- }
- }
- }
- function modifierEditeur($id)
- {
- global $sql;
- $sql->query("SELECT * FROM editeurs WHERE idediteurs = ".$id);
- $r_editeur = $sql->fetch();
- $rep_logo = '../'.PATH_IMG.PATH_EDITEUR;
- if (file_exists($rep_logo.$id.'.jpg'))
- {
- $ext_logo = 'jpg';
- }
- else
- {
- $ext_logo = 'png';
- }
- return array(
- 'id_editeur' => $id,
- 'nom' => utf8_decode($r_editeur[0]['nom']),
- 'site' => utf8_decode($r_editeur[0]['site_officiel']),
- 'histoire' => utf8_decode($r_editeur[0]['histoire']),
- 'membres_importants' => utf8_decode($r_editeur[0]['membres_importants']),
- 'lien_img' => $rep_logo.$id.'.'.$ext_logo);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement