//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>"; }
<?php require_once './includes/dbcon.php'; require_once './includes/Images/Images.php'; $status = false; $dbImages = new Images($conn); $list = $dbImages->imageList(); for ($i = count($list) - 1; $i >= 0; $i--) { if ($dbImages->getImage($list[$i][0])[7] == 1) { echo "<article>\n <p>" . htmlspecialchars($list[$i][2]) . "</p>\n <figure class='img'>\n <a href='browse.php?img={$list[$i][0]}'><img src='./img/thumbs/thumb_{$list[$i][1]}'></a>\n </figure>\n <div class='fadeout'></div>\n </article>\n "; } }
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; } if (!$success) { $response = setResponse($response, $api_response_code, 3); } } deliver_response($response);
$nextimg = $rowNumber < count($list) - 1 ? $list[$rowNumber + 1][0] : 0; $previmg = $rowNumber > 0 ? $list[$rowNumber - 1][0] : 0; shuffle($list); $randomimg = $list[0][0]; } if (isset($validReview)) { if (isset($_SESSION['userID']) && $_SESSION['userID'] == $imgOwnerID) { $dbImages->updateImage($imgID, $nafn, $texti, $flokkur, $visibility); $imgname = $nafn; $imgdesc = $texti; } } if (isset($_POST['reviewImage']) && !isset($validReview)) { echo "Gekk ekki"; } if ($dbImages->getImage($_GET["img"])[7] == 3) { if (isset($_SESSION['userID']) && $dbImages->getImage($_GET["img"])[5] == $_SESSION['userID']) { # no errors } else { $error = true; } } if (!$error) { ?> <div> <h3 id="image"><?php echo htmlentities($imgname); ?> </h3> <a href="<?php echo './img/large/' . $imgpath;
<td class="td-tbl-clr"><?php echo Translations::Translate("Select file"); ?> </td> <td class="td-tbl-clr"><?php echo Translations::Translate("Actions"); ?> </td> </tr> <?php foreach ($types as $typeIndex => $fieldName) { ?> <?php $image = Images::getImage($parentType, $parentId, $typeIndex); ?> <tr> <td class="td-tbl-clr" style="width:183px;"> <?php echo Translations::Translate(Constants::getNameOfImgType($typeIndex)); ?> </td> <td class="td-tbl-clr" style="width: 189px;"> <?php if ($image != null) { ?> <img class="image-preview" src="<?php echo AdminFunctions::GetImageUrl($image->picture); ?>