function setImageName($image_id, $new_name) { if (imageExists($image_id)) { mysql_query("UPDATE `mbg_images` SET `Name` = '" . mysql_real_escape_string($new_name) . "' WHERE `ImageID` = '{$image_id}'"); } }
function delete($setup) { //Get the image ID $id = htmlentities($setup['imageId']); //Check the file extension to make sure that it's valid checkExtension($id); //Get the directory to get the images from $dir = getDir($setup); //Make sure that it is actually a directory checkImageDirectoryExists($dir); //Check to make sure that the image actually exists if (imageExists($dir . '/' . $id)) { //Delete the file unlink($dir . '/' . $id); echo json_encode(['success' => true, 'message' => 'Image successfully deleted.']); exit; } else { echo json_encode(['success' => false, 'message' => 'That image could not be found.']); exit; } }
<?php $id = $_GET['id']; ?> <div class="separator"></div> <?php if (imageExists($id)) { $image = getImage($id); $name = $image['Name']; $image_path = $image['ImagePath']; $thumbnail_0 = dirname($image_path) . '/th_' . basename($image_path); $thumbnail_1 = dirname($image_path) . '/th1_' . basename($image_path); $thumbnail_2 = dirname($image_path) . '/th2_' . basename($image_path); $thumbnail_3 = dirname($image_path) . '/th3_' . basename($image_path); ?> <br /> <a class="view_image" href="<?php echo $image_path; ?> " title="Click to view original size"> <img src="<?php echo $image_path; ?> " width="800" /> </a> <div class="clear"></div> <div class="thumbnails"> <strong>Thumbnails</strong><br /> <?php if (file_exists($thumbnail_0)) {
$photo_name = str_replace(" ", "_", strtolower(substr($_FILES['file']['name'], 0, strrpos($_FILES['file']['name'], ".")))); $photo_ext = strtolower(strrchr($_FILES['file']['name'], ".")); $targetPath = IMAGES . "mg_photos/"; $new_name = generateName(); while (file_exists($targetPath . $new_name . $photo_ext)) { $new_name = generateName(); } $targetName = $new_name . $photo_ext; $tempFile = $_FILES['file']['tmp_name']; $targetFile = $targetPath . $targetName; move_uploaded_file($tempFile, $targetFile); $origin = $targetName; $size = @getimagesize($targetPath . $origin); if ($size[0] > $mg_settings['photo_width'] || $size[1] > $mg_settings['photo_height']) { $t1 = imageExists($targetPath, $new_name . "_t1" . $photo_ext); createthumbnail($size[2], $targetPath . $origin, $targetPath . $t1, $mg_settings['photo_width'], $mg_settings['photo_height']); } else { $t1 = $origin; } if ($size[0] > $mg_settings['thumb_width'] || $size[1] > $mg_settings['thumb_height']) { $t2 = imageExists($targetPath, $new_name . "_t2" . $photo_ext); createthumbnail($size[2], $targetPath . $origin, $targetPath . $t2, $mg_settings['thumb_width'], $mg_settings['thumb_height']); } else { $t2 = $origin; } if ($mg_settings['upload_original'] == 0) { $origin = ""; } $result = dbquery("INSERT INTO " . DB_MG_PHOTOS . " (photo_title, photo_desc, photo_date, photo_user, photo_album, photo_file, photo_t1, photo_t2) VALUES ('', '', '" . time() . "', '" . $userdata['user_id'] . "', '" . $_REQUEST['album_id'] . "', '" . $origin . "', '" . $t1 . "', '" . $t2 . "')"); // Return JSON-RPC response die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');