probleme session avec firefox

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : probleme session avec firefox

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 13:16

si,mais bon c un détail.
montre ce que ca donne

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 11:54

si,mais bon c un détail.

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 11:42

si success pardon
et pas la requete ?

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 11:37

si success pardon

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 11:36

il t'ecrit ni la requête, ni une erreur, ni sucess ?
<?php
session_start();
$ads=$_SESSION["add"];
echo $ads;
require_once('connect.php');
require_once('image.php');
ini_set('mem_size', 32000);
if($_FILES['file']['tmp_name']!=""){
        $file_temp = $_FILES['file']['tmp_name'];
        $file_name = $_FILES['file']['name'];
        chmod("/homez.34/toto/www/photos/",0777);
        $dir ="/homez.34/toto/www/photos/";
        $nom ="photo";
        $nom .= rand();
        $nom .= ".png";
        $file = $dir.$nom;
        $image = new imageResizer($_FILES['file']['tmp_name']);
        $image->resize(400, 400, 400, 100);
        $image->save("".$file."", PNG);
        $queryp = "INSERT INTO `toto`.`photos`(`id`,`id_annonce`,`photo`) VALUES('','".$ads."', '".$nom."');";
        echo $queryp;
        $resultp = mysql_query($queryp) or exit(mysql_error());
        echo "success";
        $image = null;
}
else
{
   echo 'pas de fichier';
}
?>

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 11:33

<?php
session_start();
$ads=$_SESSION["add"];
echo $ads;
require_once('connect.php');
require_once('image.php');
ini_set('mem_size', 32000);
if($_FILES['file']['tmp_name']!=""){
	$file_temp = $_FILES['file']['tmp_name'];
	$file_name = $_FILES['file']['name'];
	chmod("/homez.34/toto/www/photos/",0777);
	$dir ="/homez.34/toto/www/photos/";
	$nom ="photo";
	$nom .= rand();
	$nom .= ".png";
	$file = $dir.$nom;
	$image = new imageResizer($_FILES['file']['tmp_name']);
	$image->resize(400, 400, 400, 100);
	$image->save("".$file."", PNG);
	$queryp = "INSERT INTO `toto`.`photos`(`id`,`id_annonce`,`photo`) VALUES('','".$ads."', '".$nom."');";
	echo $queryp;
	$resultp = mysql_query($queryp) or exit(mysql_error());
	echo "success";
	$image = null;
}
?>

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 11:28

montre le dernier code que t'as fais

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 11:25

bah si, puisque l'image est redimentionnée et charger sur le serveur, et puis la table est alimenté après, c juste que ce foutu 0 je ne sais pas d'où il me le sort.

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 11:20

mon code ne me rend pas d'erreur
c'est qu'il fait pas la condition

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 11:10

mon code ne me rend pas d'erreur

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 11:05

j'ai remis, pareil même probleme il me fou un 0 au lieu de la valeur de la session, je ne comprend pas, j'ai essayer sur une autre machine même probleme.
ton code te rend quoi ?

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 10:58

juste un detail, je suis sur firefox 3.6.3, si ça peut donner des idées.

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 10:51

j'ai remis, pareil même probleme il me fou un 0 au lieu de la valeur de la session, je ne comprend pas, j'ai essayer sur une autre machine même probleme.

Re: probleme session avec firefox

par stealth35 » 01 juin 2010, 10:48

remet ton resize, pour voir, ca que ca donne la requête SQL

Re: probleme session avec firefox

par slash33 » 01 juin 2010, 10:46

alors j'appel le script suivant :(image.php)
<?php
/*
	PHP image resizer
	=============
	made by Martin Withaar
	
	e: [email protected]
	w: www.martienus.com
*/

define("JPG", 0);
define("GIF", 1);
define("PNG", 2);
define("BMP", 3);

define("JPG_QUALITY", 100);
define("PNG_QUALITY", 0);

class imageResizer
{
	private $filename;
	private $image;
	private $data;
	private $copy;
	
	function imageResizer($filename) {
		if(!is_file($filename))
			throw new Exception("File does not exist");
			
		$this->filename = $filename;
		$this->data = getimagesize($this->filename);
		
		switch($this->data['mime']) {
			case 'image/pjpeg'		:
			case 'image/jpeg'		: $this->image = imagecreatefromjpeg($this->filename); break;
			case 'image/gif'		: $this->image = imagecreatefromgif($this->filename); break;
			case 'image/png'		: $this->image = imagecreatefrompng($this->filename); break;
			case 'image/x-ms-bmp'	: $this->image = imagecreatefromwbmp($this->filename); break;
			default					: throw new Exception("File format is not supported"); break;
		}
	}
	
	// Makes a plain copy of the original
	public function duplicate() {
		if(!isset($this->image))
			throw new Exception("No image loaded");
		$this->copy = $this->image;
	}
	
	// Makes a resized copy of the original
	public function resize($wx, $hx, $wm = 0, $hm = 0) {
		
		if(!isset($this->image))
			throw new Exception("No image loaded");

		if($wx != $wm && $hx != $hm && $wm != 0 && $hm != 0)
			throw new Exception("Bad dimensions specified");
				
		$r = $this->data[0] / $this->data[1];
		$rx = $wx / $hx;
		
		if($wm == 0 || $hm == 0)
			$rm = $rx;
		else
			$rm = $wm / $hm;

		$dx=0; $dy=0; $sx=0; $sy=0; $dw=0; $dh=0; $sw=0; $sh=0; $w=0; $h=0;

		if($r > $rx && $r > $rm) {
			$w = $wx;
			$h = $hx;
			$sw = $this->data[1] * $rx;
			$sh = $this->data[1];
			$sx = ($this->data[0] - $sw) / 2;
			$dw = $wx;
			$dh = $hx;
		} elseif($r < $rm && $r < $rx) {
			$w = $wx;
			$h = $hx;
			$sh = $this->data[0] / $rx;
			$sy = ($this->data[1] - $sh) / 2;
			$sw = $this->data[0];
			$dw = $wx;
			$dh = $hx;
		} elseif($r >= $rx && $r <= $rm) {
			$w = $wx;
			$h = $wx / $r;
			$dw = $wx;
			$dh = $wx / $r;
			$sw = $this->data[0];
			$sh = $this->data[1];
		} elseif($r <= $rx && $r >= $rm) {
			$w = $hx * $r;
			$h = $hx;
			$dw = $hx * $r;
			$dh = $hx;
			$sw = $this->data[0];
			$sh = $this->data[1];
		} else {
			throw new Exception("Can't resize the image");
		}
		
		$this->copy = imagecreatetruecolor($w, $h);
		imagecopyresampled($this->copy, $this->image, $dx, $dy, $sx, $sy, $dw, $dh, $sw, $sh);
		
		return true;
	}
	
	// Save copy to file. If no file name omitted it will overwrite the original
	public function save($filename = false, $type = JPG) {
		if(!isset($this->copy))
			throw new Exception("No copy to save");
			
		if(!$filename)
			$filename = $this->filename;
			
		switch($type) {
			case GIF	: imagegif($this->copy, $filename); return true; break;
			case PNG	: imagepng($this->copy, $filename, PNG_QUALITY); return true; break;
			case BMP	: imagewbmp($this->copy, $filename); return true; break;
			case JPG	:
			default		: imagejpeg($this->copy, $filename, JPG_QUALITY); return true; break;
		}
		//throw new Exception("Save failed");
	}
	
	// Save copy to string and return it
	public function getString($type = JPG) {
		if(!isset($this->copy))
			throw new Exception("No copy to return");
		
		$contents = ob_get_contents();
		if ($contents !== false) ob_clean();
		else ob_start();
		
		$this->show($type);
		
		$data = ob_get_contents();
		if ($contents !== false) {
			ob_clean();
			echo $contents;
		}
		else ob_end_clean();
		return $data;
	}
	
	// Output copy to browser
	public function show($type = JPG) {
		if(!isset($this->copy))
			throw new Exception("No copy to show");
		
		switch($type) {
			case GIF	: imagegif($this->copy, null); return true; break;
			case PNG	: imagepng($this->copy, null, PNG_QUALITY); return true; break;
			case BMP	: imagewbmp($this->copy, null); return true; break;
			case JPG	:
			default		: imagejpeg($this->copy, null, JPG_QUALITY); return true; break;
		}
		throw new Exception("Show failed");
	}
	
	public function __destruct()
	{
		imagedestroy($this->image);
		imagedestroy($this->copy);
		$this->filename = null;
		$this->data = null;
	}
}
?>