Esempio n. 1
0
     FlashMessages::addMessage(I18N::translate('No media file was provided.'));
     break;
 } else {
     $fileName = $filename;
 }
 // Now copy the file to the correct location.
 if (!empty($_FILES['mediafile']['name'])) {
     $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName . $fileName;
     if (file_exists($serverFileName)) {
         FlashMessages::addMessage(I18N::translate('The file %s already exists. Use another filename.', $folderName . $fileName));
         break;
     }
     if (move_uploaded_file($_FILES['mediafile']['tmp_name'], $serverFileName)) {
         Log::addMediaLog('Media file ' . $serverFileName . ' uploaded');
     } else {
         FlashMessages::addMessage(I18N::translate('There was an error uploading your file.') . '<br>' . Functions::fileUploadErrorText($_FILES['mediafile']['error']));
         break;
     }
     // Now copy the (optional) thumbnail
     if (!empty($_FILES['thumbnail']['name']) && preg_match('/^image\\/(png|gif|jpeg)/', $_FILES['thumbnail']['type'], $match)) {
         // Thumbnails have either
         // (a) the same filename as the main image
         // (b) the same filename as the main image - but with a .png extension
         if ($match[1] == 'png' && !preg_match('/\\.(png)$/i', $fileName)) {
             $thumbFile = preg_replace('/\\.[a-z0-9]{3,5}$/', '.png', $fileName);
         } else {
             $thumbFile = $fileName;
         }
         $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
         if (move_uploaded_file($_FILES['thumbnail']['tmp_name'], $serverFileName)) {
             Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
Esempio n. 2
0
     return;
 case 'replace_upload':
     $gedcom_id = Filter::postInteger('gedcom_id');
     $keep_media = Filter::post('keep_media', '1', '0');
     $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH');
     $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
     $tree = Tree::findById($gedcom_id);
     if (Filter::checkCsrf() && $tree) {
         $tree->setPreference('keep_media', $keep_media);
         $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
         $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
         if (isset($_FILES['tree_name'])) {
             if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) {
                 $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']);
             } else {
                 FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger');
             }
         } else {
             FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
         }
     }
     header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
     return;
 case 'replace_import':
     $basename = basename(Filter::post('tree_name'));
     $gedcom_id = Filter::postInteger('gedcom_id');
     $keep_media = Filter::post('keep_media', '1', '0');
     $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH');
     $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
     $tree = Tree::findById($gedcom_id);
     if (Filter::checkCsrf() && $tree) {