示例#1
0
$projectId = strtolower(str_replace(' ', '_', $projectId));
$password = $_POST['password'];
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
    // create new directories for this gallery
    mkdir("../gallery/" . $projectId . "/");
    mkdir("../gallery/" . $projectId . "/thumbnail/");
    $thumbpath = "../gallery/" . $projectId . "/thumbnail/";
    mkdir("../gallery/" . $projectId . "/original/");
    $originalpath = "../gallery/" . $projectId . "/original/";
    // Loop $_FILES to execute all files
    foreach ($_FILES['files']['name'] as $f => $name) {
        // if there are no errors, move uploaded file and create thumbnails
        if ($_FILES["files"]["error"][$f] == UPLOAD_ERR_OK) {
            // move uploaded original files
            if (move_uploaded_file($_FILES["files"]["tmp_name"][$f], $originalpath . $name)) {
                $count++;
            }
            // Number of successfully uploaded file
            $originalfile = $originalpath . $name;
            // create thumbnails and save them to this project's thumbnail directory
            saveThumb($originalfile, $thumbpath, 150);
        } else {
            echo "<p class='alert-danger'>Ein Fehler ist aufgetreten: " . $_FILES["files"]["error"][$f] . "</p>";
            continue;
            // Skip file if any error found
        }
    }
    echo "<p class='alert-info'>" . $count . " files successfully uploaded!</p>";
    createGalleryPage();
    echo "<a class='btn' href='../admin.php'>go back</a>";
}
示例#2
0
<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/constants.php';
require __DIR__ . '/functions.php';
$storage = file_get_contents(__DIR__ . '/storage.txt');
$storage = unserialize($storage);
$client = new Tumblr\API\Client(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, SECRET);
$response = $client->getDashboardPosts(array('limit' => 1));
$post = $response->posts[0];
$lastPostId = $post->id;
if ($post->type == 'photo' && $post->followed == 1) {
    if ($storage['last_post_id'] != $lastPostId) {
        deleteThumb($storage['last_post_id']);
        saveThumb($post);
        $storage['last_post_id'] = $lastPostId;
        echo json_encode(['blog_name' => $post->blog_name, 'image' => getThumbPath($lastPostId)]);
    } else {
        echo "FALSE";
    }
} else {
    echo "FALSE";
}
file_put_contents(__DIR__ . '/storage.txt', serialize($storage));
示例#3
0
    $path_parts = pathinfo($targetFile);
    //get array of info about the file - for the extension
    $ext = $path_parts['extension'];
    //get the extension of the file
    $newName = $uniqueName . '.' . $ext;
    //this is the new file name
    $originalRenamedFile = $path2storeOriginal . $newName;
    //so rename doesnt move the thing
    //$ThumbnailRenamedFile = $path2storeThumb . $newName;
    rename($targetFile, $originalRenamedFile);
    //rename the file
    makejpg($originalRenamedFile);
    // force the file to be a jpg
    $newName = $uniqueName . '.jpg';
    //this is the new file name
    saveThumb($newName);
    //create the thumbnail
    rewriteJavascript();
    //make the change relevant
}
function saveThumb($pic)
{
    $ds = DIRECTORY_SEPARATOR;
    $galleryRoot = dirname(dirname(dirname(__FILE__)));
    $filename = $galleryRoot . $ds . 'store' . $ds . 'original' . $ds . $pic;
    $image = imagecreatefromjpeg($filename);
    $thumb_width = file_get_contents('settings/thumbWidth.txt');
    $thumb_height = file_get_contents('settings/thumbHeight.txt');
    $width = imagesx($image);
    $height = imagesy($image);
    $original_aspect = $width / $height;