Exemple #1
0
// Create file object
$file = new File();
// Create folder object
$folder = new Folder();
// Get values
$folderId = getValue("folderId");
$name = getValue("folderName");
// Check if user has permission to create a folder
if (!$login->isAdmin()) {
    $login->printLoginForm();
    exit;
}
// Create folder
if (!empty($_GET["mode"])) {
    // Create folder
    $errors = $folder->createFolder($name, $folderId);
    // Redirect to parent folder
    if (!$errors->hasErrors()) {
        redirect(scriptUrl . "/" . folderFilesAdmin . "/index.php?folderId=" . $folder->id);
    }
}
// Generate navigation
$site->addNavigationLink(scriptUrl . "/" . folderAdmin, $lAdminIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderFilesAdmin, $lFileIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderFilesAdmin . "/" . fileFilesCreateFolder, $lFileCreateFolder["Header"]);
// Print common header
$site->printHeader();
// Print description
echo "<p>" . $lFileCreateFolder["HeaderText"] . "</p>";
// Print errors if any
if ($errors->hasErrors()) {
  uploadPicture.php uploads the picture onto the machine and keeps the image in the upload folder
-->

<?php 
include 'createFolder.php';
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
$extension = strtolower($extension);
$uploadholder = dirname(__FILE__) . "/upload";
$uploadFolder = new Folder();
if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/jpg" || $_FILES["file"]["type"] == "image/pjpeg" || $_FILES["file"]["type"] == "image/x-png" || $_FILES["file"]["type"] == "image/png") && $_FILES["file"]["size"] < 500000 && in_array($extension, $allowedExts)) {
    if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    } else {
        $uploadFolder->createFolder($uploadholder);
        if (file_exists("upload/" . $_FILES["file"]["name"])) {
            echo '<p><hr>';
            echo $_FILES["file"]["name"] . " already exists. ";
            echo '<p><hr>';
            $moviepic = "NULL";
        } else {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
            $moviepic = "upload/" . $_FILES["file"]["name"];
        }
        // end of else
    }
    // end of else
} else {
    if (empty($_FILES["file"]["type"])) {
        echo " ";
Exemple #3
0
        $thumb_length = 1;
        if (file_exists($ordner . '/thumbnails/' . $getPhotoNr . '.jpg')) {
            // Ermittlung der Original Bildgroesse
            $bildgroesse = getimagesize($ordner . '/thumbnails/' . $getPhotoNr . '.jpg');
            $thumb_length = $bildgroesse[1];
            if ($bildgroesse[0] > $bildgroesse[1]) {
                $thumb_length = $bildgroesse[0];
            }
        }
        // Nachsehen ob Bild als Thumbnail in entsprechender Groesse hinterlegt ist
        // Wenn nicht anlegen
        if (!file_exists($ordner . '/thumbnails/' . $getPhotoNr . '.jpg') || $thumb_length != $gPreferences['photo_thumbs_scale']) {
            // Nachsehen ob Thumnailordner existiert und wenn nicht SafeMode ggf. anlegen
            if (!file_exists($ordner . '/thumbnails')) {
                $folder = new Folder($ordner);
                $folder->createFolder('thumbnails', true);
            }
            // nun das Thumbnail anlegen
            $image = new Image($picpath);
            $image->scaleLargerSide($gPreferences['photo_thumbs_scale']);
            $image->copyToFile(null, $ordner . '/thumbnails/' . $getPhotoNr . '.jpg');
        } else {
            header('content-type: image/jpg');
            echo readfile($ordner . '/thumbnails/' . $getPhotoNr . '.jpg');
        }
    } else {
        // kein Bild uebergeben, dann NoPix anzeigen
        $image = new Image(THEME_SERVER_PATH . '/images/nopix.jpg');
        $image->scaleLargerSide($gPreferences['photo_thumbs_scale']);
    }
} else {
 /**
  * Override the default method to handle the specific things of the photo module and
  * update the database after file was succesful uploaded.
  * This method has the same parameters as the default.
  * @param  $uploaded_file
  * @param  $name
  * @param  $size
  * @param  $type
  * @param  $error
  * @param  $index
  * @param  $content_range
  * @return stdClass
  */
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     global $photoAlbum, $gPreferences, $gL10n;
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (!isset($file->error)) {
         try {
             $fileLocation = SERVER_PATH . '/adm_my_files/photos/upload/' . $file->name;
             $albumFolder = SERVER_PATH . '/adm_my_files/photos/' . $photoAlbum->getValue('pho_begin', 'Y-m-d') . '_' . $photoAlbum->getValue('pho_id');
             // create folder if not exists
             if (!file_exists($albumFolder)) {
                 $error = $photoAlbum->createFolder();
                 if ($error['text'] !== '') {
                     $file->error = $gL10n->get($error['text'], $error['path']);
                     return $file;
                 }
             }
             $newFotoFileNumber = $photoAlbum->getValue('pho_quantity') + 1;
             // read image size
             $imageProperties = getimagesize($fileLocation);
             $imageDimensions = $imageProperties[0] * $imageProperties[1];
             if ($imageDimensions > admFuncProcessableImageSize()) {
                 $errorText = $gL10n->get('PHO_RESOLUTION_MORE_THAN') . ' ' . round(admFuncProcessableImageSize() / 1000000, 2) . ' ' . $gL10n->get('MEGA_PIXEL');
                 throw new AdmException($errorText);
             }
             // check mime type and set file extension
             if ($imageProperties['mime'] === 'image/jpeg') {
                 $fileExtension = 'jpg';
             } elseif ($imageProperties['mime'] === 'image/png') {
                 $fileExtension = 'png';
             } else {
                 throw new AdmException('PHO_PHOTO_FORMAT_INVALID');
             }
             // create image object and scale image to defined size of preferences
             $image = new Image($fileLocation);
             $image->setImageType('jpeg');
             $image->scaleLargerSide($gPreferences['photo_save_scale']);
             $image->copyToFile(null, $albumFolder . '/' . $newFotoFileNumber . '.jpg');
             $image->delete();
             // if enabled then save original image
             if ($gPreferences['photo_keep_original'] == 1) {
                 if (!file_exists($albumFolder . '/originals')) {
                     $folder = new Folder($albumFolder);
                     $folder->createFolder('originals', true);
                 }
                 rename($fileLocation, $albumFolder . '/originals/' . $newFotoFileNumber . '.' . $fileExtension);
             }
             // save thumbnail
             if (!file_exists($albumFolder . '/thumbnails')) {
                 $folder = new Folder($albumFolder);
                 $folder->createFolder('thumbnails', true);
             }
             $image = new Image($fileLocation);
             $image->scaleLargerSide($gPreferences['photo_thumbs_scale']);
             $image->copyToFile(null, $albumFolder . '/thumbnails/' . $newFotoFileNumber . '.jpg');
             $image->delete();
             // delete image from upload folder
             if (file_exists($fileLocation)) {
                 unlink($fileLocation);
             }
             // if image was successfully saved in filesystem then update image count of album
             if (file_exists($albumFolder . '/' . $newFotoFileNumber . '.jpg')) {
                 $photoAlbum->setValue('pho_quantity', $photoAlbum->getValue('pho_quantity') + 1);
                 $photoAlbum->save();
             } else {
                 throw new AdmException('PHO_PHOTO_PROCESSING_ERROR');
             }
         } catch (AdmException $e) {
             $file->error = $e->getText();
             unlink($this->options['upload_dir'] . $file->name);
             return $file;
         }
     }
     return $file;
 }