Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1);
- if($_GET['task'] == "edit_photos")
- {
- if($_GET['do'] == "delete" && $_GET['id'] != "")
- {
- $id = intval($_GET['id']);
- $result = mysql_query("DELETE FROM `photos` WHERE `id` = ".$id);
- if(!$result)
- {
- echo mysql_error();
- }
- else
- {
- $a = unlink('../gallery/'.$id.'.jpg');
- $b = unlink('../gallery/'.$id.'_thub.jpg');
- if($a == true && $b == true)
- {
- echo "<span style='color:red;'>Photo deleted!</span>";
- }
- else
- {
- echo "<span style='color:red;'>Deletetion failed.!</span>";
- }
- }
- }
- else if($_GET['do'] == "update")
- {
- if($_POST['select'] != "")
- {
- foreach($_POST['select'] as $key => $value)
- {
- $id = $value;
- $title = mysql_real_escape_string($_POST['title_'.$id]);
- if($_FILES['photo_'.$id]['name'] != "")
- {
- if(unlink('../gallery/'.$id.'.jpg') == true)
- {
- $target_path = "../gallery/";
- $target_path = $target_path . basename( $_FILES['photo_'.$id]['name']);
- $upload = move_uploaded_file($_FILES['photo_'.$id]['tmp_name'], $target_path);
- if($upload == true)
- {
- rename($target_path,"../gallery/".$id.".".end(explode('.', $_FILES['photo_'.$id]['name'])));
- }
- }
- else
- {
- echo "Failed to delete file";
- }
- }
- if($_FILES['thub_'.$id]['name'] != "")
- {
- $del2 = unlink('../gallery/'.$id.'_thub.jpg');
- if($de2 == true)
- {
- $target_path = "../gallery/";
- $target_path = $target_path . basename( $_FILES['thub_'.$id]['name']);
- $upload = move_uploaded_file($_FILES['thub_'.$id]['tmp_name'], $target_path);
- if($upload == true)
- {
- rename($target_path2,"../gallery/".$id."_thub.".end(explode('.', $_FILES['thub_'.$id]['name'])));
- }
- }
- else
- {
- echo "Failed to delete file";
- }
- }
- $result = mysql_query("UPDATE `photos` SET `title` = '".$title."' WHERE `id` = ".$id);
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement