Exemplo n.º 1
0
             $error .= $pgv_lang["upload_error"] . "<br />" . file_upload_error_text($_FILES["mediafile"]["error"]) . "<br />";
         } else {
             @chmod(filename_decode($newFile), PGV_PERM_FILE);
             AddToLog("Media file {$folderName}{$mediaFile} uploaded");
         }
     }
 }
 if ($error == "" && !empty($_FILES["thumbnail"]["name"])) {
     $newThum = $realThumbFolderName . $mediaFile;
     // Copy user-supplied thumbnail file into the destination directory
     if (file_exists(filename_decode($newThum))) {
         $error .= $pgv_lang["media_thumb_exists"] . "&nbsp;&nbsp;" . $newThum . "<br />";
     } else {
         if (!move_uploaded_file($_FILES["thumbnail"]["tmp_name"], filename_decode($newThum))) {
             // the file cannot be copied
             $error .= $pgv_lang["upload_error"] . "<br />" . file_upload_error_text($_FILES["thumbnail"]["error"]) . "<br />";
         } else {
             @chmod(filename_decode($newThum), PGV_PERM_FILE);
             AddToLog("Media file {$thumbFolderName}{$mediaFile} uploaded");
         }
     }
 }
 if ($error == "" && empty($_FILES["mediafile"]["name"]) && !empty($_FILES["thumbnail"]["name"])) {
     // Copy user-supplied thumbnail file into the main destination directory
     $whichFile1 = $realThumbFolderName . $mediaFile;
     $whichFile2 = $realFolderName . $mediaFile;
     if (!copy(filename_decode($whichFile1), filename_decode($whichFile2))) {
         // the file cannot be copied
         $error .= $pgv_lang["upload_error"] . "<br />" . print_text('copy_error', 0, 1) . "<br />";
     } else {
         @chmod(filename_decode($whichFile2), PGV_PERM_FILE);
Exemplo n.º 2
0
     // NOTE: When uploading a file check if it doesn't exist yet
     if ($action == "replace" || !in_array($GEDFILENAME, get_all_gedcoms()) && !file_exists($upload_path . $GEDFILENAME)) {
         if (move_uploaded_file($_FILES['GEDCOMPATH']['tmp_name'], $upload_path . $GEDFILENAME)) {
             AddToLog("Gedcom " . $path . $GEDFILENAME . " uploaded");
             $GEDCOMPATH = $upload_path . $GEDFILENAME;
         } else {
             $error = print_text("upload_error", 0, 1) . "<br />" . file_upload_error_text($_FILES['GEDCOMPATH']['error']);
             $action = "upload_form";
         }
     } else {
         // NOTE: If the file exists we will make a backup file
         if (move_uploaded_file($_FILES['GEDCOMPATH']['tmp_name'], $upload_path . $GEDFILENAME . ".bak")) {
             $bakfile = $upload_path . $GEDFILENAME . ".bak";
             $GEDCOMPATH = $upload_path . $GEDFILENAME;
         } else {
             $error = print_text("upload_error", 0, 1) . "<br />" . file_upload_error_text($_FILES['GEDCOMPATH']['error']);
             $action = "upload_form";
         }
     }
 }
 //-- check if there was an error during the upload
 if (empty($error)) {
     // NOTE: Extract the GEDCOM filename
     if (!empty($path)) {
         $GEDFILENAME = basename($path);
     } else {
         $GEDFILENAME = basename($GEDCOMPATH);
     }
     // NOTE: Check if the input contains a valid path otherwise check if there is one in the GEDCOMPATH
     if (!is_dir($path)) {
         if (!empty($path)) {
Exemplo n.º 3
0
     $error = "";
     if (isset($_FILES['mediafile'])) {
         if (!move_uploaded_file($_FILES['mediafile']['tmp_name'], $MEDIA_DIRECTORY . $_FILES['mediafile']['name'])) {
             $error .= "ERROR 19: " . $pgv_lang["upload_error"] . " " . file_upload_error_text($_FILES['mediafile']['error']);
         } else {
             if (!isset($_FILES['thumbnail'])) {
                 $filename = $MEDIA_DIRECTORY . $_FILES['mediafile']['name'];
                 $thumbnail = $MEDIA_DIRECTORY . "thumbs/" . $_FILES['mediafile']['name'];
                 generate_thumbnail($filename, $thumbnail);
                 //if (!$thumbgenned) $error .= "ERROR 19: ".$pgv_lang["thumbgen_error"].$filename;
             }
         }
     }
     if (isset($_FILES['thumbnail'])) {
         if (!move_uploaded_file($_FILES['thumbnail']['tmp_name'], $MEDIA_DIRECTORY . "thumbs/" . $_FILES['thumbnail']['name'])) {
             $error .= "\nERROR 19: " . $pgv_lang["upload_error"] . " " . file_upload_error_text($_FILES['thumbnail']['error']);
         }
     }
     if (!empty($error)) {
         addDebugLog($action . " {$error}");
         print $error . "\n";
     } else {
         addDebugLog($action . " SUCCESS");
         print "SUCCESS\n";
     }
     exit;
 case 'getchanges':
     $lastdate = new GedcomDate(safe_REQUEST($_REQUEST, 'date', '\\d\\d \\w\\w\\w \\d\\d\\d\\d'));
     if ($lastdate->isOK()) {
         if ($lastdate->MinJD() < server_jd() - 180) {
             addDebugLog($action . " ERROR 24: You cannot retrieve updates for more than 180 days.");
Exemplo n.º 4
0
         $factrec .= "2 TEMP {$TEMP}\n";
     }
     if (!empty($RESN)) {
         $factrec .= "2 RESN {$RESN}\n";
     }
     //-- make sure that there is at least a Y
     if (preg_match("/\n2 \\w*/", $factrec) == 0 && empty($DESC)) {
         $factrec = "1 {$newfact} Y\n";
     }
     $gedrec .= "\n" . $factrec;
     $updated = true;
 }
 //-- check for photo update
 if (!empty($_FILES["FILE"]['tmp_name'])) {
     if (!move_uploaded_file($_FILES['FILE']['tmp_name'], $MEDIA_DIRECTORY . basename($_FILES['FILE']['name']))) {
         $error .= "<br />" . $pgv_lang["upload_error"] . "<br />" . file_upload_error_text($_FILES['FILE']['error']);
     } else {
         $filename = $MEDIA_DIRECTORY . basename($_FILES['FILE']['name']);
         $thumbnail = $MEDIA_DIRECTORY . "thumbs/" . basename($_FILES['FILE']['name']);
         generate_thumbnail($filename, $thumbnail);
         if (isset($_REQUEST['TITL'])) {
             $TITL = $_REQUEST['TITL'];
         }
         $objrec = "0 @new@ OBJE\n";
         $objrec .= "1 FILE " . $filename . "\n";
         if (!empty($TITL)) {
             $objrec .= "2 TITL {$TITL}\n";
         }
         $objid = append_gedrec($objrec);
         $factrec = "1 OBJE @" . $objid . "@\n";
         if (empty($replace)) {
Exemplo n.º 5
0
     $fileName = $filename;
 }
 // Now copy the file to the correct location.
 if (!empty($_FILES['mediafile' . $i]['name'])) {
     $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName . $fileName;
     if (file_exists($serverFileName)) {
         WT_FlashMessages::addMessage(WT_I18N::translate('The file %s already exists.  Use another filename.', $folderName . $fileName));
         $filename = '';
         break;
     }
     if (move_uploaded_file($_FILES['mediafile' . $i]['tmp_name'], $serverFileName)) {
         WT_FlashMessages::addMessage(WT_I18N::translate('The file %s was uploaded.', '<span class="filename">' . $serverFileName . '</span>'));
         chmod($serverFileName, WT_PERM_FILE);
         Log::addMediaLog('Media file ' . $serverFileName . ' uploaded');
     } else {
         WT_FlashMessages::addMessage(WT_I18N::translate('There was an error uploading your file.') . '<br>' . file_upload_error_text($_FILES['mediafile' . $i]['error']));
         $filename = '';
         break;
     }
     // Now copy the (optional thumbnail)
     if (!empty($_FILES['thumbnail' . $i]['name']) && preg_match('/^image\\/(png|gif|jpeg)/', $_FILES['thumbnail' . $i]['type'], $match)) {
         $extension = $match[1];
         $thumbFile = preg_replace('/\\.[a-z0-9]{3,5}$/', '.' . $extension, $fileName);
         $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
         if (move_uploaded_file($_FILES['thumbnail' . $i]['tmp_name'], $serverFileName)) {
             WT_FlashMessages::addMessage(WT_I18N::translate('The file %s was uploaded.', '<span class="filename">' . $serverFileName . '</span>'));
             chmod($serverFileName, WT_PERM_FILE);
             Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
         }
     }
 }
Exemplo n.º 6
0
 //-- check for photo update
 if (count($_FILES) > 0) {
     if (isset($_REQUEST['folder'])) {
         $folder = $_REQUEST['folder'];
     }
     $uploaded_files = array();
     if (substr($folder, 0, 1) == "/") {
         $folder = substr($folder, 1);
     }
     if (substr($folder, -1, 1) != "/") {
         $folder .= "/";
     }
     foreach ($_FILES as $upload) {
         if (!empty($upload['tmp_name'])) {
             if (!move_uploaded_file($upload['tmp_name'], $MEDIA_DIRECTORY . $folder . basename($upload['name']))) {
                 $error .= "<br />" . $pgv_lang["upload_error"] . "<br />" . file_upload_error_text($upload['error']);
                 $uploaded_files[] = "";
             } else {
                 $filename = $MEDIA_DIRECTORY . $folder . basename($upload['name']);
                 $uploaded_files[] = $MEDIA_DIRECTORY . $folder . basename($upload['name']);
                 if (!is_dir($MEDIA_DIRECTORY . "thumbs/" . $folder)) {
                     mkdir($MEDIA_DIRECTORY . "thumbs/" . $folder);
                 }
                 $thumbnail = $MEDIA_DIRECTORY . "thumbs/" . $folder . basename($upload['name']);
                 generate_thumbnail($filename, $thumbnail);
                 if (!empty($error)) {
                     echo "<span class=\"error\">", $error, "</span>";
                 }
             }
         } else {
             $uploaded_files[] = "";