コード例 #1
0
//Check if user is logged in and trying to delete their own image
require_once './includes/session_timeout.php';
require_once './includes/dbcon.php';
if (!isset($_SESSION['username'])) {
    header("Location: login.php");
    die;
}
if (!isset($_GET["id"])) {
    header("Location: index.php");
    die;
}
$id = $_GET["id"];
$userID = $_SESSION['userID'];
require_once './includes/Images/Images.php';
$dbImages = new Images($conn);
$image = $dbImages->getImage($id);
if ($image[5] != $userID) {
    header("Location: userpage.php");
    die;
}
//Safe to delete
unlink("./img/thumbs/thumb_{$image[2]}");
unlink("./img/large/{$image[2]}");
$result = $dbImages->deleteImage($id);
if ($result) {
    header("Location: userpage.php");
    die;
} else {
    echo "Eitthvað bilaði. <a href='userpage.php'>Til baka?</a>";
}
コード例 #2
0
ファイル: index.php プロジェクト: marcteys/pixebble
 $images = new Images();
 $response = setResponse($response, $api_response_code, 1);
 switch ($_SERVER['REQUEST_METHOD']) {
     case 'POST':
         $response['data'] = $images->postImage($_POST);
         $success = true;
         break;
     case 'PUT':
         if (!empty($action)) {
             $response['data'] = $images->setActive($action);
             $success = true;
         }
         break;
     case 'DELETE':
         if (!empty($action)) {
             $response['data'] = $images->deleteImage($action);
             $success = true;
         }
         break;
     case 'GET':
         if ($action == "search") {
             $response['data'] = $images->getImage($_GET['user']);
             $success = true;
         }
         if ($action == null) {
             $response['data'] = $images->getImages();
             $success = true;
         }
         break;
     default:
         break;