function uploadPhoto($ip, $image, $nick, $email, $path, $albumName) { $existsAlbum = isAlbum($nick, $albumName); if (!$existsAlbum) { if (!newAlbum($ip, $nick, $email, $albumName, "private", "DEFAULT")) { return '1'; } } if (uploadImage($image, $path)) { $newPhoto = addPhoto($nick, $path, $albumName); if (!newPhoto and !$existsAlbum) { deleteAlbum($nick, $albumName); // Remove Photo return '2'; } addAction($nick, $email, $ip, 'new_photo'); return '0'; } return '3'; }
/** * Processes loading of this sample code through a web browser. Uses AuthSub * authentication and outputs a list of a user's albums if succesfully * authenticated. * * @return void */ function processPageLoad() { global $_SESSION, $_GET; if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) { requestUserLogin('Please login to your Google Account.'); } else { $client = getAuthSubHttpClient(); if (!empty($_REQUEST['command'])) { switch ($_REQUEST['command']) { case 'retrieveSelf': outputUserFeed($client, "default"); break; case 'retrieveUser': outputUserFeed($client, $_REQUEST['user']); break; case 'retrieveAlbumFeed': outputAlbumFeed($client, $_REQUEST['user'], $_REQUEST['album']); break; case 'retrievePhotoFeed': outputPhotoFeed($client, $_REQUEST['user'], $_REQUEST['album'], $_REQUEST['photo']); break; } } // Now we handle the potentially destructive commands, which have to // be submitted by POST only. if (!empty($_POST['command'])) { switch ($_POST['command']) { case 'addPhoto': addPhoto($client, $_POST['user'], $_POST['album'], $_FILES['photo']); break; case 'deletePhoto': deletePhoto($client, $_POST['user'], $_POST['album'], $_POST['photo']); break; case 'addAlbum': addAlbum($client, $_POST['user'], $_POST['name']); break; case 'deleteAlbum': deleteAlbum($client, $_POST['user'], $_POST['album']); break; case 'addComment': addComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']); break; case 'addTag': addTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']); break; case 'deleteComment': deleteComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']); break; case 'deleteTag': deleteTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']); break; default: break; } } // If a menu parameter is available, display a submenu. if (!empty($_REQUEST['menu'])) { switch ($_REQUEST['menu']) { case 'user': displayUserMenu(); break; case 'photo': displayPhotoMenu(); break; case 'album': displayAlbumMenu(); break; case 'logout': logout(); break; default: header('HTTP/1.1 400 Bad Request'); echo "<h2>Invalid menu selection.</h2>\n"; echo "<p>Please check your request and try again.</p>"; } } if (empty($_REQUEST['menu']) && empty($_REQUEST['command'])) { displayMenu(); } } }
Flight::redirect('http://localhost/php/App/playlists'); } else { Flight::redirect('http://localhost/php/App/'); } }); Flight::route('GET /track/@id/destroy', function ($id) { $response = json_decode(deleteTrack($id)); $request = Flight::request(); if ($response->stat) { Flight::redirect($request->referrer); } else { Flight::redirect('http://localhost/php/App/'); } }); Flight::route('GET /album/@id/destroy', function ($id) { $response = json_decode(deleteAlbum($id)); if ($response->stat) { Flight::redirect('http://localhost/php/App/albums'); } else { Flight::redirect('http://localhost/php/App/'); } }); Flight::route('GET /playlist/@id/edit', function ($id) { $request = Flight::request(); $playlist = json_decode(getPlayList($id)); if (!isset($playlist->error)) { Flight::render('editPlayList', array('playlist' => $playlist), 'body_content'); Flight::render('layout', array('Titre' => 'Modifier un track à ' . $playlist[0]->titre)); } else { Flight::redirect($request->referrer); }
<?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"]); ?>
<?php include_once './functions/database_logic.php'; include './functions/photo_logic.php'; session_start(); $ip = get_client_ip(); $nick = $_SESSION['nick']; $email = $_SESSION['email']; $role = getRole($nick); $albumName = $_GET['albumName']; if (strcmp($role, "admin") == 0) { $targetNick = $_GET['nick']; } else { $targetNick = $nick; } if (deleteAlbum($targetNick, $albumName, $email, $ip)) { //HACE FALTA EL NOMBRE DEL USER ORIGINAL echo "Se ha borrado el �lbum correctamente."; } else { echo "No se ha podido borrar el �lbum, no existe."; } //En eliminar album deberia contemplarse la opcion de eliminar todas las fotos. //Si el mismo usuario borra y crea el mismo album recupera todas las fotos. ?>
<?php include_once './functions/database_logic.php'; include_once './functions/user_logic.php'; session_start(); $ip = get_client_ip(); $nick = $_SESSION['nick']; $email = $_SESSION['email']; $role = getRole($nick); $target = $_GET['user']; if ($role == "admin") { $albums = getAlbums($nick); foreach ($albums as $album) { $myAlbum = $album['name']; deleteAlbum($target, $albumName, $email, $ip); } removeUser($target); } ?>
} } if ($index === 0) { $errors[] = 'Please select albumss to be ' . $act_name . '!'; } else { $messages[] = 'Successfully ' . $act_name . ' ' . $index . ' (selected) albums!'; } } $remove = NULL; if (isset($_GET['a']) && $_GET['a'] != '') { $action = trim($_GET['a']); $AID = isset($_GET['AID']) && is_numeric($_GET['AID']) && albumExists($_GET['AID']) ? intval(trim($_GET['AID'])) : NULL; if ($AID) { switch ($action) { case 'delete': deleteAlbum($AID); $messages[] = 'Album was successfully removed!'; $remove = '&a=delete&AID=' . $AID; break; case 'suspend': case 'activate': $status = $action == 'activate' ? 1 : 0; $sql = "UPDATE albums SET status = '" . $status . "' WHERE AID = " . $AID . " LIMIT 1"; $conn->execute($sql); if ($action == 'activate') { send_album_approve_email($AID); } $messages[] = 'Album was successfully ' . $action . 'ed!'; break; } } else {
<?php if (isset($_POST["envoyer"])) { $idAlbum = idAlbum($_POST['nomAlbum']); deleteAlbum($_POST['nomAlbum']); supprimePhotoAlbumInBDD($idAlbum); recursiveRmdir("vues/images/album/" . $_POST['nomAlbum']); ?> <section class="slice bg-3"> <div class="w-section inverse"> <div class="container"> <div class="row"> <div class="col-md-7"> <p>Information :</p> <ul class="list-check"> <li><i class="fa fa-check"></i> L'album a bien été supprimé !</li> </ul> </div> </div> </div> </div> </section> <?php } else { ?> <section class="slice bg-3"> <div class="w-section inverse"> <div class="container"> <div class="row"> <div class="col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3">
<?php // Delete if ($id = $_GET['deletealbum']) { if (deleteAlbum($id)) { define('_SUCCESS_', 'Album has been deleted successfully.'); } else { define('_ERROR_', "Album doesn't exists or it has been deleted before!"); } } // Move Up if ($id = $_GET['moveup']) { moveAlbumUP($id); } // Move Down if ($id = $_GET['movedown']) { moveAlbumDOWN($id); } // Create New Album if (isset($_POST['create_album'])) { $name = mysql_real_escape_string($_POST['album_name']); $description = mysql_real_escape_string($_POST['description']); $thumbnail1 = $_POST['thumbnail1']; $size1 = strtolower($_POST['size1']); $thumbnail2 = $_POST['thumbnail2']; $size2 = strtolower($_POST['size2']); $thumbnail3 = $_POST['thumbnail3']; $size3 = strtolower($_POST['size3']); if ($name) { $date_created = time(); $order_id = time();