Przedszkolak
Postów: 62
Data rejestracji: 09.01.2005 19:58
|
Prześledź dokładnie jak to się robi w galerii PHP-Fusion i użyj tych samych komend.
elseif (isset($_POST['save_photo'])) {
$error="";
$photo_title = stripinput($_POST['photo_title']);
$photo_description = stripinput($_POST['photo_description']);
$photo_order = isNum($_POST['photo_order']) ? $_POST['photo_order'] : "";
$photo_comments = isset($_POST['photo_comments']) ? "1" : "0";
$photo_ratings = isset($_POST['photo_ratings']) ? "1" : "0";
$photo_file = ""; $photo_thumb1 = ""; $photo_thumb2 = "";
$photo_watermark = isset($_POST['photo_watermark']) ? "1" : "0";
if (is_uploaded_file($_FILES['photo_pic_file']['tmp_name'])) {
$photo_types = array(".gif",".jpg",".jpeg",".png");
$photo_pic = $_FILES['photo_pic_file'];
$photo_name = strtolower(substr($photo_pic['name'], 0, strrpos($photo_pic['name'], ".")));
$photo_ext = strtolower(strrchr($photo_pic['name'],"."));
$photo_dest = PHOTODIR;
if (!preg_match("/^[-0-9A-Z_\.\[\]]+$/i", $photo_pic['name'])) {
$error = 1;
} elseif ($photo_pic['size'] > $settings['photo_max_b']){
$error = 2;
} elseif (!in_array($photo_ext, $photo_types)) {
$error = 3;
} else {
$photo_file = image_exists($photo_dest, $photo_name.$photo_ext);
move_uploaded_file($photo_pic['tmp_name'], $photo_dest.$photo_file);
chmod($photo_dest.$photo_file, 0644);
$imagefile = @getimagesize($photo_dest.$photo_file);
if ($imagefile[0] > $settings['photo_max_w'] || $imagefile[1] > $settings['photo_max_h']) {
$error = 4;
unlink($photo_dest.$photo_file);
} else {
$photo_thumb1 = image_exists($photo_dest, $photo_name."_t1".$photo_ext);
createthumbnail($imagefile[2], $photo_dest.$photo_file, $photo_dest.$photo_thumb1, $settings['thumb_w'], $settings['thumb_h']);
if ($imagefile[0] > $settings['photo_w'] || $imagefile[1] > $settings['photo_h']) {
$photo_thumb2 = image_exists($photo_dest, $photo_name."_t2".$photo_ext);
createthumbnail($imagefile[2], $photo_dest.$photo_file, $photo_dest.$photo_thumb2, $settings['photo_w'], $settings['photo_h']);
}
}
}
}
if (!$error) {
if ($action == "edit") {
$old_photo_order = dbresult(dbquery("SELECT photo_order FROM ".$db_prefix."photos WHERE photo_id='$photo_id'"),0);
if ($photo_order > $old_photo_order) {
$result = dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order-1) WHERE photo_order>'$old_photo_order' AND photo_order<='$photo_order' AND album_id='$album_id'");
} elseif ($photo_order < $old_photo_order) {
$result = dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order+1) WHERE photo_order<'$old_photo_order' AND photo_order>='$photo_order' AND album_id='$album_id'");
}
$update_photos = $photo_file ? "photo_filename='$photo_file', photo_thumb1='$photo_thumb1', photo_thumb2='$photo_thumb2', " : "";
$result = dbquery("UPDATE ".$db_prefix."photos SET photo_title='$photo_title', photo_description='$photo_description', ".$update_photos."photo_datestamp='".time()."', photo_order='$photo_order', photo_allow_comments='$photo_comments', photo_allow_ratings='$photo_ratings', photo_watermark='$photo_watermark' WHERE photo_id='$photo_id'");
$rowstart = $photo_order > $settings['thumbs_per_page'] ? ((ceil($photo_order / $settings['thumbs_per_page'])-1)*$settings['thumbs_per_page']) : "0";
redirect(FUSION_SELF.$aidlink."&status=savepu&album_id=$album_id&rowstart=$rowstart");
}else{
if (!$photo_order) $photo_order = dbresult(dbquery("SELECT MAX(photo_order) FROM ".$db_prefix."photos WHERE album_id='$album_id'"), 0) + 1;
$result = dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order+1) WHERE photo_order>='$photo_order' AND album_id='$album_id'");
$result = dbquery("INSERT INTO ".$db_prefix."photos (album_id, photo_title, photo_description, photo_filename, photo_thumb1, photo_thumb2, photo_datestamp, photo_user, photo_views, photo_order, photo_allow_comments, photo_allow_ratings, photo_watermark) VALUES ('$album_id', '$photo_title', '$photo_description', '$photo_file', '$photo_thumb1', '$photo_thumb2', '".time()."', '".$userdata['user_id']."', '0', '$photo_order', '$photo_comments', '$photo_ratings', '$photo_watermark')");
$rowstart = $photo_order > $settings['thumbs_per_page'] ? ((ceil($photo_order / $settings['thumbs_per_page'])-1)*$settings['thumbs_per_page']) : "0";
redirect(FUSION_SELF.$aidlink."&status=savepn&album_id=$album_id&rowstart=$rowstart");
}
}
if ($error) {
redirect(FUSION_SELF.$aidlink."&status=savepe&error=$error&album_id=$album_id");
}
}
To jest fragment pliku photos.php w katalogu administration. Tu jest wszystko czego Ci potrzeba.
Kwardym Trzeba Być Nie Mientkim!
|