// +----------------------------------------------------------------------+
// | Copyright (c) 2004 |
// | author: Jason Taylor |
// | Neo-era : mofocases |
// | edit_images.php |
// +----------------------------------------------------------------------+
/**
* Manages the images for a case
*
* @package www
*
* $Id: edit_gallery_images.php,v 1.1 2010/10/30 21:48:35 catherine Exp $
*/
$GALLERY = true;
include "../../includes/config.inc.php";
include "includes/bike_gallery.inc.php";
include "includes/image.inc.php";
if (!USERID) {
$smarty->assign("error","You must be logged in as a registered user to add a galery image.");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
include BASE_PATH.'includes/nfs_disabled_preprocess.inc.php';
$error = null;
$type = nBase::get_value("type", $_GET, $_POST, "", nBase::VALIDATE_ALPHANUMERIC);
$action = nBase::get_value("action", $_POST, $_GET, "");
if ($action == "Add Image") {
$pic = new Image($_FILES["myimage"]['tmp_name']);
$comment = nBase::get_value("comment", $_POST, NULL, "");
$banned_word_list = db_get_banned_words();
$error .= validate_words($comment, "Comment",$banned_word_list);
if ($pic->width <= 100 || $pic->height <= 100) {
$error .= "Image size has to be atleast 100 x 100.
";
}
if(!$error) {
// checking to see if hte directories exist and if not make them
$file_dir = UPLOAD_PATH;
$mod = USERID % 64;
$file_dir .= "$mod/";
if (!file_exists($file_dir)) {
mkdir($file_dir);
chmod($file_dir, 0777);
}
$extra = md5(mktime() + mktime());
$thumb_name = "$mod/" . USERID . "_thumb_" . $extra;
$medium_name = "$mod/" . USERID . "_medium_" . $extra;
$large_name = "$mod/" . USERID . "_large_" . $extra;
$thumb_name = $pic->save_bg($thumb_name, 200, 150, 77);
$medium_name = $pic->save_bg($medium_name, 250, 250);
$large_name = $pic->save_bg($large_name, 1024, 768);
// test code to add tons of images in galleries
/*for($i = 0; $i < 45; $i++) {
$user_id = rand(1,17);
db_save_image($type, 0, $user_id, $thumb_name, $medium_name, $large_name, $i . " " .$comment);
}*/
db_save_image($type, 0, USERID, $thumb_name, $medium_name, $large_name, $comment);
} else {
$comment = stripslashes($comment);
$smarty->assign("comment",$comment);
}
}
if ($action == "remove") {
$image_id = nBase::get_value("image_id", $_GET, NULL, 0);
$pic = db_get_image($image_id);
if ($pic->user_id != USERID && !ISADMIN) {
$smarty->assign("error","You can not edit or modify a images for a gallery image that doesn't belong to you.");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
$smarty->assign("type",$type);
$smarty->assign("pic",$pic);
$smarty->assign("image_id",$image_id);
$smarty->assign("page_tpl", TEMPLATE_DIR . "gallery/edit_gallery_images_confirm.tpl.smrt");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
if ($action == "Delete") {
$image_id = nBase::get_value("image_id", $_POST, NULL, 0);
$pic = db_get_image($image_id);
if ($pic->user_id != USERID && !ISADMIN) {
$smarty->assign("error","You can not edit or modify a images for a gallery image that doesn't belong to you.");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
db_remove_image($image_id);
$smarty->assign("message","Image was removed for $type gallery.
Return to $type Gallery |
Return to $type Gallery Image Manager");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
list($images,$num) = db_get_images($type,USERID, 0,0);
$smarty->assign("images",$images);
$smarty->assign("type",$type);
$smarty->assign("error",$error);
$smarty->assign("page_tpl", TEMPLATE_DIR . "gallery/edit_gallery_images.tpl.smrt");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");