"; if (_count($db,"SELECT COUNT(id) FROM pictures WHERE id=".$bloub)!=0) { $db->queryExec("UPDATE pictures SET valid=0 WHERE id=".$bloub); $res=$db->arrayQuery("SELECT ip FROM pictures WHERE id=".$bloub, SQLITE_NUM); echo "picture from ".$res[0][0]." has been desactivated on the wall"; } else echo "This ID '".$bloub."' doesn't exist."; } else { $upload=(isset($_POST["xx"]))?true:false; if ($upload) { $error=""; $x=intval($_POST["xx"]); $y=intval($_POST["yy"]); if ($x<0) $x=0; if ($y<18) $y=18; $ip=(empty($_SERVER['HTTP_VIA']))?$_SERVER['REMOTE_ADDR']:$_SERVER['HTTP_VIA']; /*if (_count($db,"SELECT COUNT(id) FROM pictures WHERE ip='".$ip."' AND date(datation,'+7 day')>date('now')")!=0) $error="You can only stick one picture on the wall by week with the same IP"; else*/if (!$_FILES["stick0"]["name"]) $error="You have to pick a picture on your computer"; elseif ($_FILES["stick0"]["error"]>0) $error=$_FILES["stick0"]["error"]; elseif ($_FILES["stick0"]["size"]==0) $error="Your picture doesn't exist (no more?) on your computer or is empty"; elseif ($_FILES["stick0"]["type"]!="image/jpeg" && $_FILES["stick0"]["type"]!="image/pjpeg" && $_FILES["stick0"]["type"]!="image/gif") $error="Your file must be a valid picture in jpg or gif format"; elseif ($_FILES["stick0"]["size"]>10240) $error="The weight of your picture must be < 10ko"; elseif (!getimagesize($_FILES['stick0']['tmp_name'])) $error="Invalid picture"; else { list($width, $height, $type, $attr) = getimagesize($_FILES['stick0']['tmp_name']); if ($width>100 || $height>100) $error="The size of your picture must be < 100x100px"; elseif ($width<5 || $height<5) $error="Your picture is very (too) tiny!"; else { if ($x+$width>$W) $x=$W-$width; if ($y+$height>$H) $y=$H-$height; } } if (!$error) { $result = $db->unbufferedQuery("SELECT x1, y1, x2, y2 FROM pictures WHERE valid=1 AND (((x1<=".$x." AND x2>".$x.") OR (x1>".$x." AND x1<".($x+$width).")) AND ((y1<=".$y." AND y2>".$y.") OR (y1>".$y." AND y1<".($y+$height).")))", SQLITE_NUM); foreach($result as $res) { $x1=intval($res[0]); $y1=intval($res[1]); $x2=intval($res[2]); $y2=intval($res[3]); $xr=0; if ($x1>=$x && $x2>$x+$width) $xr=$x+$width-$x1; elseif ($x1<=$x && $x2>=$x+$width) $xr=$width; elseif ($x2>$x && $x2<=$x+$width) $xr=$x2-$x; elseif ($x1>$x && $x2<$x+$width) $xr=$x2-$x1; $yr=0; if ($y1>=$y && $y2>$y+$height) $yr=$y+$height-$y1; elseif ($y1<=$y && $y2>=$y+$height) $yr=$height; elseif ($y2>$y && $y2<=$y+$height) $yr=$y2-$y; elseif ($y1>$y && $y2<$y+$height) $yr=$y2-$y1; if ($xr>($x2-$x1)/4 && $yr>($y2-$y1)/4) { $error="Your picture will cover most of 25% of another picture"; break; } } if (!$error) { $type=($_FILES["stick0"]["type"]=="image/jpeg" || $_FILES["stick0"]["type"]=="image/pjpeg")?1:0; $query=$db->queryExec("INSERT INTO pictures(x1,x2,y1,y2,type,ip,datation,valid) VALUES(".$x.",".($x+$width).",".$y.",".($y+$width).",".$type.",'".$ip."',DATETIME('NOW'),1)", $err); if (!$query) $error=$err; else { $id=$db->lastInsertRowid(); if (!move_uploaded_file($_FILES['stick0']['tmp_name'], 'contents/'.$id.'.'.(($type)?'jpg':'gif'))) { $error="your picture can't be stick on the wall due to a problem on the server."; $db->queryExec("UPDATE pictures SET ip='', valid=0 WHERE id=".$id); } } } } }?> The W@ll >