コード例 #1
0
 function readWebValue(&$avalues, &$blobfields, $strWhereClause, $oldValuesRead, &$filename_values)
 {
     $filename = "";
     $this->getPostValueAndType();
     if (FieldSubmitted($this->goodFieldName . "_" . $this->id)) {
         $fileNameForPrepareFunc = securityCheckFileName(postvalue("filename_" . $this->goodFieldName . "_" . $this->id));
         if ($this->pageObject->pageType != PAGE_EDIT) {
             $prepearedFile = prepare_file($this->webValue, $this->field, "file2", $fileNameForPrepareFunc, $this->id);
             if ($prepearedFile !== false) {
                 $this->webValue = $prepearedFile["value"];
                 $filename = $prepearedFile["filename"];
             } else {
                 $this->webValue = false;
             }
         } else {
             if (substr($this->webType, 0, 4) == "file") {
                 $prepearedFile = prepare_file($this->webValue, $this->field, $this->webType, $fileNameForPrepareFunc, $this->id);
                 if ($prepearedFile !== false) {
                     $this->webValue = $prepearedFile["value"];
                     $filename = $prepearedFile["filename"];
                 } else {
                     $this->webValue = false;
                 }
             } else {
                 if (substr($this->webType, 0, 6) == "upload") {
                     if ($this->webType == "upload1") {
                         // file deletion, read filename from the database
                         if (!$oldValuesRead) {
                             $rsold = db_query($this->pageObject->gQuery->gSQLWhere($strWhereClause), $this->conn);
                             $dataold = db_fetch_array($rsold);
                             $oldValuesRead = true;
                         }
                         $fileNameForPrepareFunc = $dataold[$this->field];
                     }
                     $this->webValue = prepare_upload($this->field, $this->webType, $fileNameForPrepareFunc, $this->webValue, "", $this->id, $this->pageObject);
                 }
             }
         }
     } else {
         $this->webValue = false;
     }
     if (!($this->webValue === false)) {
         if ($this->webValue) {
             if ($this->pageObject->pSetEdit->getCreateThumbnail($this->field)) {
                 $ext = CheckImageExtension(GetUploadedFileName("value_" . $this->goodFieldName . "_" . $this->id));
                 $thumb = CreateThumbnail($this->webValue, $this->pageObject->pSetEdit->getThumbnailSize($this->field), $ext);
                 $blobfields[] = $this->pageObject->pSetEdit->getStrThumbnail($this->field);
                 $avalues[$blobfields[count($blobfields) - 1]] = $thumb;
             }
             if ($this->pageObject->pSetEdit->getResizeOnUpload($this->field)) {
                 $ext = CheckImageExtension(GetUploadedFileName("value_" . $this->goodFieldName . "_" . $this->id));
                 $this->webValue = CreateThumbnail($this->webValue, $this->pageObject->pSetEdit->getNewImageSize($this->field), $ext);
             }
         } else {
             if ($this->pageObject->pageType == PAGE_EDIT && $this->pageObject->pSetEdit->getCreateThumbnail($this->field)) {
                 $blobfields[] = $this->pageObject->pSetEdit->getStrThumbnail($this->field);
                 $avalues[$blobfields[count($blobfields) - 1]] = "";
             }
         }
         $blobfields[] = $this->field;
         $avalues[$this->field] = $this->webValue;
     }
     if ($filename && $this->pageObject->pSetEdit->getStrFilename($this->field)) {
         $filename_values[$this->pageObject->pSetEdit->getStrFilename($this->field)] = $filename;
     }
 }
コード例 #2
0
     $albumImages = $smug->images_get("AlbumID={$serverAlbum['id']}", "AlbumKey={$serverAlbum['Key']}", "Heavy=1");
     $albumImages = $smug->APIVer == "1.2.2" ? $albumImages['Images'] : $albumImages;
     if (!empty($albumImages)) {
         foreach ($albumImages as $image) {
             $images[$image['FileName']] = $image;
         }
     }
     echo "done\n";
 } else {
     echo "\t\tAlbum is currently empty\n";
 }
 //Start dealing with files
 echo "\t\tPreparing files...";
 $uploads = array();
 foreach ($files as $file) {
     $uploads[] = prepare_file($file);
     $count++;
     if ($count % 50 == 0) {
         echo ".";
     }
 }
 echo "done\n";
 foreach ($uploads as $upload) {
     // If an image with the same filename has already been uploaded
     if ($images[$upload['filename']]) {
         //Make life a lot easier
         $image = $images[$upload['filename']];
         // Check if the md5 is different
         if ($image['MD5Sum'] != $upload['md5']) {
             echo "\t\tReplacing {$upload['filename']} (ID:{$image['id']})...";
             $smug->images_upload("AlbumID={$serverAlbum['id']}", "File={$upload['path']}", "ImageID={$image['id']}");
コード例 #3
0
$password = '';
// Shouldn't have to change anything below here
$appInfo = '3dgoSmug/0.2';
$apiVersion = '1.2.2';
error_reporting(E_ALL & ~E_NOTICE);
if (count($argv) < 3) {
    echo "Usage: php upload.php 'Album Title' pic1.jpg <pic2.jpg ...>\n";
    die;
}
$albumTitle = $argv[1];
$added = 0;
$mdUpdated = 0;
$replaced = 0;
echo "Preparing file information...";
for ($i = 2; $i < count($argv); $i++) {
    $uploads[] = prepare_file($argv[$i]);
}
echo "done\n";
try {
    echo "Connecting to SmugMug...";
    $smug = new phpSmug("APIKey={$apiKey}", "AppName={$appInfo}", "APIVer={$apiVersion}");
    $smug->login("EmailAddress={$username}", "Password={$password}");
    echo "done\n";
    echo "Finding album information...";
    $albums = $smug->albums_get("Heavy=1");
    // Check each album to find the one we want to work on
    foreach ($albums as $current) {
        if ($current['Title'] == $albumTitle) {
            $album = $current;
        }
    }
コード例 #4
0
 /**
  *
  */
 function readWebValue(&$avalues, &$blobfields, $legacy1, $legacy2, &$filename_values)
 {
     $this->getPostValueAndType();
     if (FieldSubmitted($this->goodFieldName . "_" . $this->id)) {
         $fileNameForPrepareFunc = securityCheckFileName(postvalue("filename_" . $this->goodFieldName . "_" . $this->id));
         if ($this->pageObject->pageType != PAGE_EDIT) {
             $this->webValue = prepare_upload($this->field, "upload2", $fileNameForPrepareFunc, $fileNameForPrepareFunc, "", $this->id, $this->pageObject);
         } else {
             if (substr($this->webType, 0, 4) == "file") {
                 $prepearedFile = prepare_file($this->webValue, $this->field, $this->webType, $fileNameForPrepareFunc, $this->id);
                 if ($prepearedFile !== false) {
                     $this->webValue = $prepearedFile["value"];
                     $filename = $prepearedFile["filename"];
                 } else {
                     $this->webValue = false;
                 }
             } else {
                 if (substr($this->webType, 0, 6) == "upload") {
                     if ($fileNameForPrepareFunc) {
                         $this->webValue = $fileNameForPrepareFunc;
                     }
                     if ($this->webType == "upload1") {
                         // file deletion, read filename from the database
                         $oldValues = $this->pageObject->getOldRecordData();
                         $fileNameForPrepareFunc = $oldValues[$this->field];
                     }
                     $this->webValue = prepare_upload($this->field, $this->webType, $fileNameForPrepareFunc, $this->webValue, "", $this->id, $this->pageObject);
                 }
             }
         }
     } else {
         $this->webValue = false;
     }
     if (!($this->webValue === false)) {
         if ($this->webValue && $this->pageObject->pSetEdit->getCreateThumbnail($this->field)) {
             $contents = GetUploadedFileContents("value_" . $this->goodFieldName . "_" . $this->id);
             $ext = CheckImageExtension(GetUploadedFileName("value_" . $this->goodFieldName . "_" . $this->id));
             $thumb = CreateThumbnail($contents, $this->pageObject->pSetEdit->getThumbnailSize($this->field), $ext);
             $this->pageObject->filesToSave[] = new SaveFile($thumb, $this->pageObject->pSetEdit->GetStrThumbnail($this->field) . $this->webValue, $this->pageObject->pSetEdit->getUploadFolder($this->field), $this->pageObject->pSetEdit->isAbsolute($this->field));
         }
         $avalues[$this->field] = $this->webValue;
     }
 }
コード例 #5
0
ファイル: FileFieldSingle.php プロジェクト: aagusti/padl-tng
 function readWebValue(&$avalues, &$blobfields, $strWhereClause, $oldValuesRead, &$filename_values = null)
 {
     $this->getPostValueAndType();
     if (FieldSubmitted($this->goodFieldName . "_" . $this->id)) {
         $fileNameForPrepareFunc = securityCheckFileName(postvalue("filename_" . $this->goodFieldName . "_" . $this->id));
         if ($this->pageObject->pageType != PAGE_EDIT) {
             $this->webValue = prepare_upload($this->field, "upload2", $fileNameForPrepareFunc, $fileNameForPrepareFunc, "", $this->id, $this->pageObject);
         } else {
             if (substr($this->webType, 0, 4) == "file") {
                 $prepearedFile = prepare_file($this->webValue, $this->field, $this->webType, $fileNameForPrepareFunc, $this->id);
                 if ($prepearedFile !== false) {
                     $this->webValue = $prepearedFile["value"];
                     $filename = $prepearedFile["filename"];
                 } else {
                     $this->webValue = false;
                 }
             } else {
                 if (substr($this->webType, 0, 6) == "upload") {
                     if ($fileNameForPrepareFunc) {
                         $this->webValue = $fileNameForPrepareFunc;
                     }
                     if ($this->webType == "upload1") {
                         // file deletion, read filename from the database
                         if (!$oldValuesRead) {
                             $rsold = db_query($this->pageObject->gQuery->gSQLWhere($strWhereClause), $this->conn);
                             $dataold = db_fetch_array($rsold);
                             $oldValuesRead = true;
                         }
                         $fileNameForPrepareFunc = $dataold[$this->field];
                     }
                     $this->webValue = prepare_upload($this->field, $this->webType, $fileNameForPrepareFunc, $this->webValue, "", $this->id, $this->pageObject);
                 }
             }
         }
     } else {
         $this->webValue = false;
     }
     if (!($this->webValue === false)) {
         if ($this->pageObject->pSet->getResizeOnUpload($this->field) || $this->pageObject->pSet->getCreateThumbnail($this->field)) {
             $contents = GetUploadedFileContents("value_" . $this->goodFieldName . "_" . $this->id);
         }
         if ($this->webValue && $this->pageObject->pSet->getCreateThumbnail($this->field)) {
             $ext = CheckImageExtension(GetUploadedFileName("value_" . $this->goodFieldName . "_" . $this->id));
             $thumb = CreateThumbnail($contents, $this->pageObject->pSet->getThumbnailSize($this->field), $ext);
             $this->pageObject->filesToSave[] = new SaveFile($thumb, $this->pageObject->pSet->GetStrThumbnail($this->goodFieldName) . $this->webValue, $this->pageObject->pSet->getUploadFolder($this->field), $this->pageObject->pSet->isAbsolute($this->field));
         }
         $avalues[$this->field] = $this->webValue;
     }
 }