Example #1
0
<?require_once('session_check.php');
if(!isset($_GET["id"])){
  http_response_code(400);
  exit();
}

require_once("album.php");
$owners = getAlbumAllowedEditors($_GET["id"]);

if(!isset($_SESSION["id"]) || !in_array($_SESSION["id"], $owners, TRUE)){
  http_response_code(403);
  exit();
}

if(!existsAlbum($_GET["id"])){
  http_response_code(404);
  exit();
}
$album = getAlbum($_GET["id"]);

$deleted = deleteAlbum($_GET["id"]);
var_dump($deleted);
if(!$deleted){
  http_response_code(500);
  exit;
}
http_response_code(200);

header("Location: ../event.php?id=".$album["eid"]);
?>
<?require_once('session_check.php');
if(!isset($_POST["aid"]) || !isset($_POST["iid"])){
  http_response_code(400);
  exit();
}

require_once("album.php");
$owners = getAlbumAllowedEditors($_POST["aid"]);
$album = getAlbum($_POST["aid"]);
if(!isset($_SESSION["id"]) || !in_array($_SESSION["id"], $owners, TRUE) ){
  http_response_code(403);
  exit();
}

if(!existsAlbum($_POST["aid"])|| !imageInAlbum($_POST["iid"], $_POST["aid"])){
  http_response_code(404);
  exit();
}

require("connect.php");
$stmt2 = $db->prepare("DELETE FROM ImageAlbum WHERE iid=? and aid=?");
$res2 = $stmt2->execute(array($_POST["iid"], $_POST["aid"]));
$stmt = $db->prepare('DELETE FROM Image WHERE iid=?');
$res = $stmt->execute(array($_POST["iid"]));

if(!$res || !$res2){
  http_response_code(500);
  var_dump($_POST["iid"]);
  exit;
}
http_response_code(200);
Example #3
0
        <input type="file" name="albumImage" id="albumImage"/>
      </label>
      <input type="number" name="return_json" value="1" hidden="hidden"/>
      <input type="submit" value="Upload Image!">
    </form>

    <form id="renameAlbumForm" enctype="multipart/form-data" hidden="hidden">
      <input type="hidden" name="csrf" value="<?echo $_SESSION['tok']?>" />
      <label >New Album Name:
        <input type="text" name="newName" min="0" value=""/>
      </label>
      <input id="uploadImageAlbumNumber" type="number" name="aid" min="0" value="<?echo $_GET['id']?>" hidden="hidden"/>
      <input type="submit" value="Rename!">
    </form>

    <?if(isset($_SESSION["id"]) && in_array( $_SESSION["id"], getAlbumAllowedEditors($_GET["id"]) )){?>
    <ul class="options">
        <?if(!isMainAlbum($_GET["id"])){?><li><a href="database/action_deleteAlbum.php?id=<?echo $_GET['id']?>">Delete Album</a></li><?}?>
        <li><a href="javascript:;" id="addImage">Add Image</a></li>
        <li><a href="javascript:;" id="renameAlbum">Rename Album</a></li>
    </ul>
    <?}?>
    <ul class="albumImageList">


    <? foreach($albumImages as $image){
      ?>
        <li>
          <a href="<? echo $image['fpath']?>"><img src="<?echo $image['fpath']; ?>" alt="Album image" /></a>
          <button type="button" class="deleteImage" data-iid="<?echo $image['iid'];?>">x</button>
        </li>
Example #4
0
if(!isset($_POST["aid"]) || !isset($_POST["newName"])){
  http_response_code(400);
  exit;
}

if(strlen($_POST['newName']) == 0 || strlen($_POST['newName']) > 50){
  http_response_code(400);
  exit();
}

if(!isset($_SESSION["id"])){
  http_response_code(401);
  exit;
}

if(!in_array($_SESSION["id"], getAlbumAllowedEditors($_POST["aid"]))){
  http_response_code(403);
  exit;
}

if(!existsAlbum($_POST["aid"])){
  http_response_code(404);
  exit();
}

$res = renameAlbum($_POST["aid"], $_POST["newName"]);

if(!$res)
{
  http_response_code(500);
  exit;