/**
  * Override the default method to handle the specific things of the download module and
  * update the database after file was successful 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 $gPreferences, $gL10n, $gDb, $getId, $gCurrentOrganization, $gCurrentUser;
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (!isset($file->error)) {
         try {
             // check filesize against module settings
             if ($file->size > $gPreferences['max_file_upload_size'] * 1024 * 1024) {
                 throw new AdmException('DOW_FILE_TO_LARGE', $gPreferences['max_file_upload_size']);
             }
             // check filename and throw exception if something is wrong
             admStrIsValidFileName($file->name, true);
             // get recordset of current folder from database and throw exception if necessary
             $targetFolder = new TableFolder($gDb);
             $targetFolder->getFolderForDownload($getId);
             // now add new file to database
             $newFile = new TableFile($gDb);
             $newFile->setValue('fil_fol_id', $targetFolder->getValue('fol_id'));
             $newFile->setValue('fil_name', $file->name);
             $newFile->setValue('fil_locked', $targetFolder->getValue('fol_locked'));
             $newFile->setValue('fil_counter', '0');
             $newFile->save();
             // Benachrichtigungs-Email für neue Einträge
             $message = $gL10n->get('DOW_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $file->name, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
             $notification = new Email();
             $notification->adminNotfication($gL10n->get('DOW_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
         } catch (AdmException $e) {
             $file->error = $e->getText();
             unlink($this->options['upload_dir'] . $file->name);
             return $file;
         }
     }
     return $file;
 }
예제 #2
0
파일: get_file.php 프로젝트: bash-t/admidio
}
try {
    // get recordset of current file from databse
    $file = new TableFile($gDb);
    $file->getFileForDownload($getFileId);
} catch (AdmException $e) {
    $e->showHtml();
}
//kompletten Pfad der Datei holen
$completePath = $file->getCompletePathOfFile();
//pruefen ob File ueberhaupt physikalisch existiert
if (!file_exists($completePath)) {
    $gMessage->show($gL10n->get('SYS_FILE_NOT_EXIST'));
}
//Downloadcounter inkrementieren
$file->setValue('fil_counter', $file->getValue('fil_counter') + 1);
$file->save();
//Dateigroese ermitteln
$fileSize = filesize($completePath);
$filename = $file->getValue('fil_name');
// for IE the filename must have special chars in hexadecimal
if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
    $filename = urlencode($filename);
}
// Passenden Datentyp erzeugen.
header('Content-Type: application/octet-stream');
header('Content-Length: ' . $fileSize);
header('Content-Disposition: attachment; filename="' . $filename . '"');
// necessary for IE, because without it the download with SSL has problems
header('Cache-Control: private');
header('Pragma: public');
예제 #3
0
 try {
     // check filename and throw exception if something is wrong
     if (admStrIsValidFileName(urldecode($getName), true)) {
         $getName = urldecode($getName);
         // get recordset of current folder from databse
         $targetFolder = new TableFolder($gDb);
         $targetFolder->getFolderForDownload($getFolderId);
     }
 } catch (AdmException $e) {
     $e->showHtml();
 }
 //Pruefen ob das neue Element eine Datei order ein Ordner ist.
 if (is_file($targetFolder->getCompletePathOfFolder() . '/' . $getName)) {
     //Datei hinzufuegen
     $newFile = new TableFile($gDb);
     $newFile->setValue('fil_fol_id', $targetFolder->getValue('fol_id'));
     $newFile->setValue('fil_name', $getName);
     $newFile->setValue('fil_locked', $targetFolder->getValue('fol_locked'));
     $newFile->setValue('fil_counter', '0');
     $newFile->save();
     //Zurueck zur letzten Seite
     $gNavigation->addUrl(CURRENT_URL);
     $location = 'Location: ' . $g_root_path . '/adm_program/system/back.php';
     header($location);
     exit;
 } elseif (is_dir($targetFolder->getCompletePathOfFolder() . '/' . $getName)) {
     //Ordner der DB hinzufuegen
     $newFolder = new TableFolder($gDb);
     $newFolder->setValue('fol_fol_id_parent', $targetFolder->getValue('fol_id'));
     $newFolder->setValue('fol_type', 'DOWNLOAD');
     $newFolder->setValue('fol_name', $getName);