Ejemplo n.º 1
0
function deleteAlbum($album_id)
{
    if (albumExists($album_id)) {
        $images = getAlbumImages($album_id);
        foreach ($images as $img) {
            $image_id = $img['ImageID'];
            deleteImage($image_id);
        }
        mysql_query("DELETE FROM `mbg_albums` WHERE `AlbumID` = '{$album_id}'");
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
<?
require_once('session_check.php');
require_once("album.php");
if(existsAlbum($_POST["albumId"])){
  addAlbumPhoto($_POST["albumId"],$_FILES["albumImage"]);
  $eventID = getAlbum($_POST["albumId"])["eid"];
  http_response_code(200);
  if(1){//!isset($_POST["return_json"]) && $_POST["return_json"]){
    echo json_encode(getAlbumImages(getAlbum($_POST["albumId"])));

  }
  else
    header("Location: ../manageAlbums.php?eid=".$eventID);
}
else{
  http_response_code(400);
  header("Location: ../index.php");
}
Ejemplo n.º 3
0
<?php

include '../admin/config.php';
include '../admin/mysql.open.php';
include '../admin/functions.php';
$albums = getAllAlbums('DESC');
$response = [];
foreach ($albums as $album) {
    $albumId = $album['AlbumID'];
    $response[$albumId] = $album;
    $response[$albumId]['images'] = getAlbumImages($albumId, 'DESC');
}
include '../admin/mysql.close.php';
echo json_encode($response);
function uploadImages($images, $imageAlbums)
{
    global $fbo, $key, $uid, $batchSize, $nohash;
    $albumImages = getAlbumImages($imageAlbums);
    $c = count($images);
    $a = 0;
    $b = 0;
    $md5s = array();
    // Loop through all the images. Skip by batch size.
    for ($a = 0; $a < $c; $a += $batchSize) {
        $imagesToUpload = array();
        // empty the array for images to upload.
        // For for the batch size while $b is less than the batch size OR a + b is less than the total number of images.
        for ($b = 0; $b < $batchSize && $a + $b < $c; $b++) {
            $z = $a + $b;
            // Get the "real" image index number.
            $image = $images[$z];
            // Pull out the image to manipulate
            $caption = getCaption($image);
            // Get the caption of the image
            $md5 = md5_file($image);
            // Get the MD5 of the image.
            // Check for duplicate images.
            if (array_key_exists("md5", $albumImages) && array_search($md5, $albumImages["md5"]) !== false) {
                disp("Skipping: {$image} already uploaded (MD5 Check)", 3);
                continue;
            }
            // Check for duplicate images in the queue.
            if (array_search($md5, $md5s) !== false) {
                disp("Skipping: Identical image to {$image} already queued (MD5 Check)", 3);
                continue;
            }
            $md5s[] = $md5;
            list($process, $thumb) = makeThumbBatch($image);
            $temp["image"] = $image;
            $temp["caption"] = $caption;
            $temp["process"] = $process;
            $temp["thumb"] = $thumb;
            $temp["caption"] = $caption . ($nohash ? "" : "\n\n\n" . $md5);
            $temp["uploaded"] = false;
            $temp["errors"] = 0;
            $imagesToUpload[] = $temp;
        }
        while (1) {
            $j = 0;
            for ($i = 0; $i < count($imagesToUpload); $i++) {
                if ($imagesToUpload[$i]["uploaded"]) {
                    continue;
                }
                disp("Waiting for processing to finish on: " . $imagesToUpload[$i]["image"], 5);
                // If the process continues to fail, just mark as uploaded and move on.
                if (waitToProcess($imagesToUpload[$i]["process"])) {
                    disp("Image Conversion Failed, skipping: " . $imagesToUpload[$i]["image"], 2);
                    $imagesToUpload[$i]["uploaded"] = true;
                    continue;
                }
                disp("Finished Processing.", 5);
                try {
                    $fbo->api_client->photos_upload($imagesToUpload[$i]["thumb"], getUploadAID($imageAlbums, $uploadAlbumIdx), $imagesToUpload[$i]["caption"], $uid);
                    $imageAlbums["size"][$uploadAlbumIdx]++;
                    $imagesToUpload[$i]["uploaded"] = true;
                    disp("Uploaded: " . $imagesToUpload[$i]["image"], 3);
                    $j++;
                } catch (Exception $e) {
                    disp($e->getCode() . " " . $e->getMessage(), 5);
                    switch ($e->getCode()) {
                        case 1:
                        case 2:
                        case 5:
                            disp("Non-fatal error: " . $e->getMessage(), 3);
                            break;
                        case 100:
                        case 101:
                        case 103:
                        case 104:
                        case 120:
                        case 200:
                            disp("Fatal error: " . $e->getMessage() . "\n Please submit a bug report: \nhttp://github.com/jedediahfrey/Facebook-PHP-Batch-Picture-Uploader", 1);
                            break;
                        case 102:
                            disp("Could not login. Try creating a new auth code.", 1);
                        case 321:
                            disp($e->getMessage() . ". Should have been caught earlier.", 3);
                            $imageAlbums["size"][$uploadAlbumIdx] = 200;
                            break;
                        case 324:
                            disp($e->getMessage() . ". Bad Graphics/ImageMagick output? Skipping " . $imagesToUpload[$i]["image"], 3);
                            $imagesToUpload[$i]["uploaded"] = true;
                            break;
                        case 325:
                            disp($e->getMessage() . ". Allow php_batch_uploader to upload files directly: \nhttp://www.facebook.com/authorize.php?v=1.0&api_key={$key}&ext_perm=photo_upload\n\n", 1);
                            break;
                    }
                    $imagesToUpload[$i]["errors"]++;
                }
            }
            // If all images have been uploaded, break out of the while loop.
            if ($j == 0) {
                break;
            }
        }
    }
}
Ejemplo n.º 5
0
<?php

$id = $_GET['id'];
if (albumExists($id)) {
    $album = getAlbum($id);
    $images = getAlbumImages($id);
    ?>
<script type="text/javascript" src="js/album_manage.js"></script>
<a href="?action=album&id=<?php 
    echo $id;
    ?>
&edit" class="button" title="Click to edit">Album: <strong><?php 
    echo $album['AlbumName'];
    ?>
</strong></a>
<div class="separator"></div>
<h1>Manage Album</h1>
<?php 
    if (isset($_GET['edit'])) {
        include "edit_album.php";
    }
    ?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
  <input type="hidden" name="album_id" id="album_id" value="<?php 
    echo $album['AlbumID'];
    ?>
">
  <input type="file" name="upload_image" id="upload_image" class="button">
</form>

<?php 
Ejemplo n.º 6
0
session_start();
require_once("database/album.php");
if(!isset($_GET['id'])){
  http_response_code(400);
  ?><p> No album was specified </p><?
  exit;
}

if(!existsAlbum($_GET['id'])){
  http_response_code(404);
  ?><p> The album does not exist in the server </p><?
  exit;
}
$album = getAlbum($_GET['id']);
$eventId = intval(getAlbum($_GET['id'])['eid']);
$albumImages = getAlbumImages($album);
?>

<!DOCTYPE html>
<html>
  <head>
    <?require_once('includes.php');?>
    <script type="text/javascript" src="scripts/view_album.js"></script>
    <link rel="stylesheet" type="text/css" href="stylesheets/album.css" >

  </head>
  <body>
    <?require_once('templates/header.php');?>
    <section id="album">
    <h1> <?echo $album['nome'];?></h1>