Advertisement
Guest User

Untitled

a guest
May 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. <?php
  2.  
  3. function posterEditeur($id,$nom,$site,$histoire,$membres_importants)
  4. {
  5. global $sql;
  6.  
  7. $nom = $sql->escape_string(utf8_encode($nom));
  8. $site = $sql->escape_string(utf8_encode($site));
  9. $histoire = $sql->escape_string(utf8_encode($histoire));
  10. $membres_importants = $sql->escape_string(utf8_encode($membres_importants));
  11.  
  12. if ($id == 0)
  13. {
  14. $sql->query("INSERT INTO editeurs(idediteurs,nom,site_officiel,histoire,membres_importants)
  15. VALUES('','".$nom."','".$site."','".$histoire."','".$membres_importants."')");
  16. if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0)
  17. {
  18. $rep = '../'.PATH_IMG.PATH_EDITEUR;
  19. $ext = gestionImages::upload('logo',$rep.$sql->insert_id().'_big',array('jpeg','jpg','png'),$pre='../');
  20. $image = new gestionImages($rep.$sql->insert_id().'_big.'.$ext,'../');
  21. //Calcul des dimensions
  22. if ($ext == 'jpg' || $ext == 'jpeg')
  23. {
  24. $img = imagecreatefromjpeg($rep.$sql->insert_id().'_big.'.$ext);
  25. }
  26. else if ($ext == 'png')
  27. {
  28. $img = imagecreatefrompng($rep.$sql->insert_id().'_big.'.$ext);
  29. }
  30. else
  31. {
  32. echo 'Type d\'image non supporté';
  33. exit;
  34. }
  35.  
  36. $largeur_img = imagesx($img);
  37. $hauteur_img = imagesy($img);
  38. $ratio = $largeur_img / MAX_LOGO_X;
  39.  
  40. $x = $largeur_img / $ratio;
  41. $y = $hauteur_img / $ratio;
  42. imagedestroy($img);
  43. $image->createMiniature($rep.$sql->insert_id().'.'.$ext,$x,$y);
  44. if ($ratio > 1)
  45. {
  46. $image->watermark();
  47. }
  48. }
  49. }
  50. else
  51. {
  52. $sql->query("UPDATE editeurs SET nom = '".$nom."', site_officiel = '".$site."', histoire = '".$histoire."', membres_importants = '".$membres_importants."' WHERE idediteurs = ".$id);
  53. if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0)
  54. {
  55. $rep = '../'.PATH_IMG.PATH_EDITEUR;
  56. $ext = gestionImages::upload('logo',$rep.$id.'_big',array('jpeg','jpg','png'),$pre='../');
  57. $image = new gestionImages($rep.$id.'_big.'.$ext,'../');
  58. //Calcul des dimensions
  59. if ($ext == 'jpg' || $ext == 'jpeg')
  60. {
  61. $img = imagecreatefromjpeg($rep.$id.'_big.'.$ext);
  62. }
  63. else if ($ext == 'png')
  64. {
  65. $img = imagecreatefrompng($rep.$id.'_big.'.$ext);
  66. }
  67. else
  68. {
  69. echo 'Type d\'image non supporté';
  70. exit;
  71. }
  72.  
  73. $largeur_img = imagesx($img);
  74. $hauteur_img = imagesy($img);
  75. $ratio = $largeur_img / MAX_LOGO_X;
  76.  
  77. $x = $largeur_img / $ratio;
  78. $y = $hauteur_img / $ratio;
  79. imagedestroy($img);
  80. $image->createMiniature($rep.$id.'.'.$ext,$x,$y);
  81. if ($ratio > 1)
  82. {
  83. $image->watermark();
  84. }
  85. }
  86. }
  87. }
  88.  
  89. function modifierEditeur($id)
  90. {
  91. global $sql;
  92.  
  93. $sql->query("SELECT * FROM editeurs WHERE idediteurs = ".$id);
  94. $r_editeur = $sql->fetch();
  95.  
  96. $rep_logo = '../'.PATH_IMG.PATH_EDITEUR;
  97. if (file_exists($rep_logo.$id.'.jpg'))
  98. {
  99. $ext_logo = 'jpg';
  100. }
  101. else
  102. {
  103. $ext_logo = 'png';
  104. }
  105.  
  106. return array(
  107. 'id_editeur' => $id,
  108. 'nom' => utf8_decode($r_editeur[0]['nom']),
  109. 'site' => utf8_decode($r_editeur[0]['site_officiel']),
  110. 'histoire' => utf8_decode($r_editeur[0]['histoire']),
  111. 'membres_importants' => utf8_decode($r_editeur[0]['membres_importants']),
  112. 'lien_img' => $rep_logo.$id.'.'.$ext_logo);
  113. }
  114. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement