Пример #1
0
 if ($_FILES['userfile']['error'][0] == 1) {
     $gMessage->show($gL10n->get('PRO_PHOTO_FILE_TO_LARGE', round(admFuncMaxUploadSize() / pow(1024, 2))));
 }
 //Kontrolle ob Fotos ausgewaehlt wurden
 if (file_exists($_FILES['userfile']['tmp_name'][0]) == false) {
     $gMessage->show($gL10n->get('PRO_PHOTO_NOT_CHOOSEN'));
 }
 //Dateiendung
 $image_properties = getimagesize($_FILES['userfile']['tmp_name'][0]);
 if ($image_properties['mime'] != 'image/jpeg' && $image_properties['mime'] != 'image/png') {
     $gMessage->show($gL10n->get('PRO_PHOTO_FORMAT_INVALID'));
 }
 //Auflösungskontrolle
 $image_dimensions = $image_properties[0] * $image_properties[1];
 if ($image_dimensions > admFuncProcessableImageSize()) {
     $gMessage->show($gL10n->get('PRO_PHOTO_RESOLUTION_TO_LARGE', round(admFuncProcessableImageSize() / 1000000, 2)));
 }
 // Foto auf entsprechende Groesse anpassen
 $user_image = new Image($_FILES['userfile']['tmp_name'][0]);
 $user_image->setImageType('jpeg');
 $user_image->scale(130, 170);
 //Ordnerspeicherung
 if ($gPreferences['profile_photo_storage'] == 1) {
     $user_image->copyToFile(null, SERVER_PATH . '/adm_my_files/item_photos/' . $getItemId . '_new.jpg');
 } else {
     //Foto in PHP-Temp-Ordner übertragen
     $user_image->copyToFile(null, $_FILES['userfile']['tmp_name'][0]);
     // Foto aus PHP-Temp-Ordner einlesen
     $user_image_data = fread(fopen($_FILES['userfile']['tmp_name'][0], 'r'), $_FILES['userfile']['size'][0]);
     // Zwischenspeichern des neuen Fotos in der Session
     $gCurrentSession->setValue('ses_binary', $user_image_data);
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
    $form->addStaticControl('memory_limit', $gL10n->get('SYS_MEMORY_LIMIT'), ini_get('memory_limit'));
} else {
    $form->addStaticControl('memory_limit', $gL10n->get('SYS_MEMORY_LIMIT'), $gL10n->get('SYS_NOT_SET'));
}
if (ini_get('file_uploads') == 1) {
    $html = '<span class="text-success"><strong>' . $gL10n->get('SYS_ON') . '</strong></span>';
} else {
    $html = '<span class="text-danger"><strong>' . $gL10n->get('SYS_OFF') . '</strong></span>';
}
$form->addCustomContent($gL10n->get('SYS_FILE_UPLOADS'), $html);
if (ini_get('upload_max_filesize') != '') {
    $form->addStaticControl('upload_max_filesize', $gL10n->get('SYS_UPLOAD_MAX_FILESIZE'), ini_get('upload_max_filesize'));
} else {
    $form->addStaticControl('upload_max_filesize', $gL10n->get('SYS_UPLOAD_MAX_FILESIZE'), $gL10n->get('SYS_NOT_SET'));
}
$form->addStaticControl('max_processable_image_size', $gL10n->get('SYS_MAX_PROCESSABLE_IMAGE_SIZE'), round(admFuncProcessableImageSize() / 1000000, 2) . ' ' . $gL10n->get('SYS_MEGA_PIXEL'));
$html = '<a href="preferences_function.php?mode=4" target="_blank">phpinfo()</a>';
$form->addCustomContent($gL10n->get('SYS_PHP_INFO'), $html);
if ($gDebug) {
    $html = '<span class="text-danger"><strong>' . $gL10n->get('SYS_ON') . '</strong></span>';
} else {
    $html = '<span class="text-success"><strong>' . $gL10n->get('SYS_OFF') . '</strong></span>';
}
$form->addCustomContent($gL10n->get('SYS_DEBUG_MODUS'), $html);
$page->addHtml($form->show(false));
$page->addHtml('</div>
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="tabs-modules">
Пример #4
0
                     <td>' . $gL10n->get('SYS_COUNTRY') . '</td>
                     <td><b>' . $gL10n->get('SYS_COUNTRY_EG') . '</b></td>
                     <td>' . $gL10n->get('LST_COUNTRY_ISO') . '</td>
                 </tr>
             </tbody>
         </table>';
     break;
     // Profil
 // Profil
 case 'profile_photo_up_help':
     echo '
         <h3>' . $gL10n->get('SYS_RESTRICTIONS') . '</h3>
         <ul>
             <li>' . $gL10n->get('PRO_RESTRICTIONS_HELP_1') . '</li>
             <li>' . $gL10n->get('PRO_RESTRICTIONS_HELP_2') . '</li>
             <li>' . $gL10n->get('PRO_RESTRICTIONS_HELP_3', round(admFuncProcessableImageSize() / 1000000, 2)) . '</li>
             <li>' . $gL10n->get('PRO_RESTRICTIONS_HELP_4', round(admFuncMaxUploadSize() / pow(1024, 2), 2)) . '</li>
         </ul>';
     break;
 default:
     // im Standardfall wird mit der ID der Text aus der Sprachdatei gelesen
     // falls die Textvariable gefuellt ist, pruefen ob dies auch eine ID aus der Sprachdatei ist
     $msg_var1 = '';
     if ($getMessageVar1 !== '') {
         if (strpos($getMessageVar1, '_') === 3) {
             $msg_var1 = $gL10n->get($getMessageVar1);
         } else {
             $msg_var1 = $getMessageVar1;
         }
     }
     echo $gL10n->get(strtoupper($getMessageId), $msg_var1);