$val) {
if (substr($k, 0, 5) == "save_") {
$map->addRectangle(unserializeZone($val));
}
}
// perform sql
$sql = sprintf("SELECT COUNT(*) FROM `node` WHERE `title`='%s'", $_POST['title']);
$result = $DB->getOne($sql);
if ($result == 0)
$sql = sprintf("INSERT INTO `%s` SET title='%s', image='%s', map='%s'", 'node', $_POST['title'], $_POST['image'], mysql_escape_string($map->serialize()));
else
$sql = sprintf("UPDATE `%s` SET image='%s', map='%s' WHERE title='%s'", 'node', $_POST['image'], mysql_escape_string($map->serialize()), $_POST['title']);
$result = $DB->query($sql);
if (PEAR::isError($result)) {
echo 'Standard Message: ' . $result->getMessage() . "\n";
echo 'Standard Code: ' . $result->getCode() . "\n";
echo 'DBMS/User Message: ' . $result->getUserInfo() . "\n";
echo 'DBMS/Debug Message: ' . $result->getDebugInfo() . "\n";
//exit;
}
header("Location: index.php?title=" . $_POST['title'] . "&mode=view");
// insert image
//require_once("HTTP/Upload.php");
//
//$upload = new HTTP_Upload("en");
//$file = $upload->getFiles("f");
//
//if ($file->isValid()) {
// $moved = $file->moveTo("uploads/");
// if (!PEAR::isError($moved)) {
// echo "File was moved to uploads/";
// }
//}
function &unserializeZone($str) {
// x + "," + y + "," + h + "," + w + "," + wikilink + text;
$str = str_replace('px','',$str);
$arr = explode(',',$str);
$rect =& new Rectangle($arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5]);
return $rect;
}
//class picture
//{
// var $save_dir; //where file will be saved
// var $filename="spacer.gif"; //default file name initially
// var $error_message=""; //string to be output if neccesary
// var $width; //height of final image
// var $height; //width of final image
//
// function picture($save_directory, $file_array, $max_width, $max_height)
// {
// $this->save_dir = $save_directory;
// $this->width = $max_width;
// $this->height = $max_height;
//
//
// //--change filename to time - make it unique
// $temp_filename = $file_array['name'];
// $ext = explode('.',$temp_filename);
// $ext = $ext[count($ext)-1];
// $temp_filename = time().".".$ext;
// if (!file_exists($file_array['tmp_name']))
// echo "file not exist" . $file_array['tmp_name'];
//
// //--check that it's a jpeg or gif
// if (preg_match('/^(gif|jpe?g)$/',$ext)) {
// // resize in proportion
// list($width_orig, $height_orig) = getimagesize($file_array['tmp_name']);
// if ($this->width && ($width_orig < $height_orig)) {
// $this->width = ($this->height / $height_orig) * $width_orig;
// } else {
// $this->height = ($this->width / $width_orig) * $height_orig;
// }
//
// print_r( $this->width );print_r( $this->height);
// $image_p = imagecreatetruecolor($this->width, $this->height);
//
// //handle gifs and jpegs separately
// if($ext=='gif'){
// $image = imagecreatefromgif($file_array['tmp_name']);
// imagecopyresampled($image_p, $image, 0, 0, 0, 0, $this->width, $this->height, $width_orig, $height_orig);
// imagegif($image_p, $this->save_dir.$temp_filename, 80);
// }
// else
// {
// $image = imagecreatefromjpeg($file_array['tmp_name']);
// imagecopyresampled($image_p, $image, 0, 0, 0, 0, $this->width, $this->height, $width_orig, $height_orig);
// imagejpeg($image_p, $this->save_dir.$temp_filename, 80);
// }
//
// imagedestroy($image_p);
// imagedestroy($image);
//
// $this->filename=$temp_filename;
//
// }else{
// $this->error_message.="
file is not a jpeg or gif picture
";
// }
// }
//}
?>