当前位置: 首页>>代码示例>>PHP>>正文


PHP S3::getObjectInfo方法代码示例

本文整理汇总了PHP中S3::getObjectInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::getObjectInfo方法的具体用法?PHP S3::getObjectInfo怎么用?PHP S3::getObjectInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在S3的用法示例。


在下文中一共展示了S3::getObjectInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file_processValue

function file_processValue($Value, $Type, $Field, $Config, $EID)
{
    if (!empty($Value)) {
        //dump($Value);
        //dump($Type);
        //dump($Field);
        //dump($Config);
        //die;
        switch ($Type) {
            case 'image':
                $Value = strtok($Value, '?');
                $imageWidth = $Config['_ImageSizeX'][$Field] == 'auto' ? '100' : $Config['_ImageSizeX'][$Field];
                $imageHeight = $Config['_ImageSizeY'][$Field] == 'auto' ? '100' : $Config['_ImageSizeY'][$Field];
                $iconWidth = $Config['_IconSizeX'][$Field] == 'auto' ? '100' : $Config['_IconSizeX'][$Field];
                $iconHeight = $Config['_IconSizeY'][$Field] == 'auto' ? '100' : $Config['_IconSizeY'][$Field];
                $uploadVars = wp_upload_dir();
                $SourceFile = str_replace($uploadVars['baseurl'], $uploadVars['basedir'], $Value);
                if (!file_exists($SourceFile)) {
                    return 'Image does not exists.';
                }
                $dim = getimagesize($SourceFile);
                $newDim = image_resize_dimensions($dim[0], $dim[1], $iconWidth, $iconHeight, true);
                if (!empty($newDim)) {
                    $Sourcepath = pathinfo($SourceFile);
                    $URLpath = pathinfo($Value);
                    $iconURL = $URLpath['dirname'] . '/' . $URLpath['filename'] . '-' . $newDim[4] . 'x' . $newDim[5] . '.' . $URLpath['extension'];
                    if (!file_exists($Sourcepath['dirname'] . '/' . $Sourcepath['filename'] . '-' . $newDim[4] . 'x' . $newDim[5] . '.' . $Sourcepath['extension'])) {
                        $image = image_resize($SourceFile, $imageWidth, $imageHeight, true);
                        $icon = image_resize($SourceFile, $iconWidth, $iconHeight, true);
                    }
                } else {
                    $iconURL = $Value;
                    $iconWidth = $dim[0];
                    $iconHeight = $dim[1];
                }
                $ClassName = '';
                if (!empty($Config['_ImageClassName'][$Field])) {
                    $ClassName = 'class="' . $Config['_ImageClassName'][$Field] . '" ';
                }
                if (!empty($Config['_IconURLOnly'][$Field])) {
                    return $iconURL;
                }
                return '<img src="' . $iconURL . '" ' . $ClassName . image_hwstring($iconWidth, $iconHeight) . '>';
                break;
            case 'mp3':
                $File = explode('?', $Value);
                $UniID = uniqid($EID . '_');
                //$ReturnData = '<span id="'.$UniID.'">'.$File[1].'</span>';
                $ReturnData = '<audio id="' . $UniID . '" src="' . $File[0] . '">unavailable</audio>';
                $_SESSION['dataform']['OutScripts'] .= "\n\t\t\t\t\tAudioPlayer.embed(\"" . $UniID . "\", {\n\t\t\t\t\t";
                if (!empty($Config['_PlayerCFG']['Autoplay'][$Field])) {
                    $_SESSION['dataform']['OutScripts'] .= " autostart: 'yes', ";
                }
                if (!empty($Config['_PlayerCFG']['Animation'][$Field])) {
                    $_SESSION['dataform']['OutScripts'] .= " animation: 'yes', ";
                }
                $_SESSION['dataform']['OutScripts'] .= "\n                                                transparentpagebg: 'yes',\n\t\t\t\t\t\tsoundFile: \"" . $File[0] . "\",\n\t\t\t\t\t\ttitles: \"" . $File[1] . "\"\n\t\t\t\t\t});\n\n\t\t\t\t";
                $_SESSION['dataform']['OutScripts'] .= "\n                                jQuery(document).ready(function(\$) {\n                                    AudioPlayer.setup(\"" . WP_PLUGIN_URL . "/db-toolkit/data_form/fieldtypes/file/player.swf\", {\n                                        width: '100%',\n                                        initialvolume: 100,\n                                        transparentpagebg: \"yes\",\n                                        left: \"000000\",\n                                        lefticon: \"FFFFFF\"\n                                    });\n                                 });";
                return $ReturnData;
                break;
            case 'file':
            case 'multi':
                if (empty($Config['_fileReturnValue'][$Field])) {
                    $Config['_fileReturnValue'][$Field] = 'iconlink';
                }
                $pathInfo = pathinfo($Value);
                $s3Enabled = false;
                $prime = $Field;
                if (!empty($Config['_CloneField'][$Field]['Master'])) {
                    $prime = $Config['_CloneField'][$Field]['Master'];
                }
                if (!empty($Config['_enableS3'][$prime]) && !empty($Config['_AWSAccessKey'][$prime]) && !empty($Config['_AWSSecretKey'][$prime])) {
                    include_once DB_TOOLKIT . 'data_form/fieldtypes/file/s3.php';
                    $s3 = new S3($Config['_AWSAccessKey'][$prime], $Config['_AWSSecretKey'][$prime]);
                    $s3Enabled = true;
                }
                switch ($Config['_fileReturnValue'][$Field]) {
                    case 'iconlink':
                        if (empty($Value)) {
                            return 'no file uploaded';
                        }
                        if (!empty($Config['_enableS3'][$prime]) && !empty($Config['_AWSAccessKey'][$prime]) && !empty($Config['_AWSSecretKey'][$prime])) {
                            $File = 'http://' . $Config['_AWSBucket'][$prime] . '.s3.amazonaws.com/' . $Value;
                        } else {
                            $File = $Value;
                        }
                        $Dets = pathinfo($File);
                        $ext = strtolower($Dets['extension']);
                        if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/file/icons/' . $ext . '.gif')) {
                            $Icon = '<img src="' . WP_PLUGIN_URL . '/db-toolkit/data_form/fieldtypes/file/icons/' . $ext . '.gif" align="absmiddle" />&nbsp;';
                        } else {
                            $Icon = '<img src="' . WP_PLUGIN_URL . '/db-toolkit/data_form/fieldtypes/file/icons/file.gif" align="absmiddle" />&nbsp;';
                        }
                        return '<a href="' . $File . '">' . $Icon . ' ' . basename($File) . '</a>';
                        break;
                    case 'filesize':
                        if (!empty($s3Enabled)) {
                            $object = $s3->getObjectInfo($Config['_AWSBucket'][$prime], $Value);
                            return file_return_bytes($object['size']);
                        } else {
//.........这里部分代码省略.........
开发者ID:routexl,项目名称:DB-Toolkit,代码行数:101,代码来源:functions.php

示例2: upload

 /**
  * Uploads files to FTP
  *
  * @param array $files
  * @param array $results
  * @param boolean $force_rewrite
  * @return boolean
  */
 function upload($files, &$results, $force_rewrite = false)
 {
     $count = 0;
     $error = null;
     if (!$this->_init($error)) {
         $results = $this->get_results($files, W3_CDN_RESULT_HALT, $error);
         return false;
     }
     foreach ($files as $local_path => $remote_path) {
         if (!file_exists($local_path)) {
             $results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'Source file not found');
             continue;
         }
         if (!$force_rewrite) {
             $info = @$this->_s3->getObjectInfo($this->_config['bucket'], $remote_path);
             if ($info) {
                 $hash = @md5_file($local_path);
                 $s3_hash = isset($info['hash']) ? $info['hash'] : '';
                 if ($hash === $s3_hash) {
                     $results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'Object already exists');
                     continue;
                 }
             }
         }
         $result = @$this->_s3->putObjectFile($local_path, $this->_config['bucket'], $remote_path, S3::ACL_PUBLIC_READ);
         $results[] = $this->get_result($local_path, $remote_path, $result ? W3_CDN_RESULT_OK : W3_CDN_RESULT_ERROR, $result ? 'OK' : 'Unable to put object');
         if ($result) {
             $count++;
         }
     }
     return $count;
 }
开发者ID:alx,项目名称:SBek-Arak,代码行数:40,代码来源:S3.php

示例3: gzencode

 /**
  * Uploads gzip version of file
  *
  * @param string $local_path
  * @param string $remote_path
  * @param boolean $force_rewrite
  * @return array
  */
 function _upload_gzip($local_path, $remote_path, $force_rewrite = false)
 {
     if (!function_exists('gzencode')) {
         return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, "GZIP library doesn't exist.");
     }
     if (!file_exists($local_path)) {
         return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, 'Source file not found.');
     }
     $contents = @file_get_contents($local_path);
     if ($contents === false) {
         return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, 'Unable to read file.');
     }
     $data = gzencode($contents);
     if (!$force_rewrite) {
         $this->_set_error_handler();
         $info = @$this->_s3->getObjectInfo($this->_config['bucket'], $remote_path);
         $this->_restore_error_handler();
         if ($info) {
             $hash = md5($data);
             $s3_hash = isset($info['hash']) ? $info['hash'] : '';
             if ($hash === $s3_hash) {
                 return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'Object up-to-date.');
             }
         }
     }
     $headers = $this->_get_headers($local_path);
     $headers = array_merge($headers, array('Vary' => 'Accept-Encoding', 'Content-Encoding' => 'gzip'));
     $this->_set_error_handler();
     $result = @$this->_s3->putObjectString($data, $this->_config['bucket'], $remote_path, S3::ACL_PUBLIC_READ, array(), $headers);
     $this->_restore_error_handler();
     if ($result) {
         return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'OK');
     }
     return $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf('Unable to put object (%s).', $this->_get_last_error()));
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:43,代码来源:S3.php

示例4: _lookupFileInfo

 private function _lookupFileInfo()
 {
     //look up our real info.
     $s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
     $info = $s3->getObjectInfo($this->args('bucket'), $this->args('key'), true);
     if ($info['size'] == 0) {
         //capture for debug
         ob_start();
         var_dump($args);
         var_dump($info);
         //try it again.
         sleep(1);
         $info = $s3->getObjectInfo($this->args('bucket'), $this->args('key'), true);
         var_dump($info);
         //still bad?
         if ($info['size'] == 0) {
             $text = ob_get_contents();
             $html = "<pre>{$text}</pre>";
             //email the admin
             $admin = User::byUsername('hoeken');
             Email::queue($admin, "upload fail", $text, $html);
             //show us.
             if (User::isAdmin()) {
                 @ob_end_clean();
                 echo "'failed' file upload:<br/><br/>{$html}";
                 exit;
             }
             //$this->set('megaerror', "You cannot upload a blank/empty file.");
         }
         @ob_end_clean();
     }
     //send it back.
     return $info;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:34,代码来源:upload.php

示例5: uploadFile

 public function uploadFile($file, $path, $acl = S3::ACL_PUBLIC_READ, $save = true)
 {
     //is it a real file?
     if (file_exists($file)) {
         //do the actual upload.
         $s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
         $result = $s3->putObjectFile($file, AMAZON_S3_BUCKET_NAME, $path, S3::ACL_PUBLIC_READ);
         //echo "Uploading {$file} to " . AMAZON_S3_BUCKET_NAME . ":{$path}\n";
         //get our info for saving
         $info = $s3->getObjectInfo(AMAZON_S3_BUCKET_NAME, $path, true);
         //save our info.
         $this->set('hash', $info['hash']);
         $this->set('size', $info['size']);
         $this->set('type', $info['type']);
         $this->set('bucket', AMAZON_S3_BUCKET_NAME);
         $this->set('path', $path);
         $this->set('add_date', date("Y-m-d H:i:s"));
         //for non db accessible scripts.
         if ($save) {
             $this->save();
         }
         //yay!
         if ($result !== false) {
             return true;
         }
     } else {
         echo "No file at {$path} or {$file}\n";
     }
     //fail!
     return false;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:31,代码来源:s3file.php

示例6: isExists

 /**
  * Check - file is exists or not
  * 
  * @param string $path Short path
  *  
  * @return boolean
  */
 public function isExists($path)
 {
     try {
         $result = $this->client->getObjectInfo(\XLite\Core\Config::getInstance()->CDev->AmazonS3Images->bucket, $path, false);
     } catch (\S3Exception $e) {
         $result = false;
         \XLite\Logger::getInstance()->registerException($e);
     }
     return $result;
 }
开发者ID:kingsj,项目名称:core,代码行数:17,代码来源:S3.php

示例7: moveSourceFile

 /**
  * @inheritDoc BaseAssetSourceType::moveSourceFile()
  *
  * @param AssetFileModel   $file
  * @param AssetFolderModel $targetFolder
  * @param string           $fileName
  * @param bool             $overwrite
  *
  * @return mixed
  */
 protected function moveSourceFile(AssetFileModel $file, AssetFolderModel $targetFolder, $fileName = '', $overwrite = false)
 {
     if (empty($fileName)) {
         $fileName = $file->filename;
     }
     $newServerPath = $this->_getPathPrefix() . $targetFolder->path . $fileName;
     $conflictingRecord = craft()->assets->findFile(array('folderId' => $targetFolder->id, 'filename' => $fileName));
     $this->_prepareForRequests();
     $settings = $this->getSettings();
     $fileInfo = $this->_s3->getObjectInfo($settings->bucket, $newServerPath);
     $conflict = !$overwrite && ($fileInfo || !craft()->assets->isMergeInProgress() && is_object($conflictingRecord));
     if ($conflict) {
         $response = new AssetOperationResponseModel();
         return $response->setPrompt($this->getUserPromptOptions($fileName))->setDataItem('fileName', $fileName);
     }
     $bucket = $this->getSettings()->bucket;
     // Just in case we're moving from another bucket with the same access credentials.
     $originatingSourceType = craft()->assetSources->getSourceTypeById($file->sourceId);
     $originatingSettings = $originatingSourceType->getSettings();
     $sourceBucket = $originatingSettings->bucket;
     $this->_prepareForRequests($originatingSettings);
     if (!$this->_s3->copyObject($sourceBucket, $this->_getPathPrefix($originatingSettings) . $file->getFolder()->path . $file->filename, $bucket, $newServerPath, \S3::ACL_PUBLIC_READ)) {
         $response = new AssetOperationResponseModel();
         return $response->setError(Craft::t("Could not save the file"));
     }
     @$this->_s3->deleteObject($sourceBucket, $this->_getS3Path($file, $originatingSettings));
     if ($file->kind == 'image') {
         if ($targetFolder->sourceId == $file->sourceId) {
             $transforms = craft()->assetTransforms->getAllCreatedTransformsForFile($file);
             $destination = clone $file;
             $destination->filename = $fileName;
             // Move transforms
             foreach ($transforms as $index) {
                 // For each file, we have to have both the source and destination
                 // for both files and transforms, so we can reliably move them
                 $destinationIndex = clone $index;
                 if (!empty($index->filename)) {
                     $destinationIndex->filename = $fileName;
                     craft()->assetTransforms->storeTransformIndexData($destinationIndex);
                 }
                 $from = $file->getFolder()->path . craft()->assetTransforms->getTransformSubpath($file, $index);
                 $to = $targetFolder->path . craft()->assetTransforms->getTransformSubpath($destination, $destinationIndex);
                 $this->copySourceFile($from, $to);
                 $this->deleteSourceFile($from);
             }
         } else {
             craft()->assetTransforms->deleteAllTransformData($file);
         }
     }
     $response = new AssetOperationResponseModel();
     return $response->setSuccess()->setDataItem('newId', $file->id)->setDataItem('newFileName', $fileName);
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:62,代码来源:S3AssetSourceType.php

示例8: unlink

         if ($i == MAX_TRIES) {
             echo 'Failed to download ', $image, "\n";
             if (file_exists($image)) {
                 unlink($image);
             }
             //Go to next image
             continue 2;
         }
     }
 } else {
     echo 'File ', $image, ' was already downloaded', "\n";
 }
 $dispersionPath = substr($image, $imgPrefixLen);
 foreach ($dimensions as $thumbPrefix => $dimension) {
     $thumb = $thumbPrefix . $dispersionPath;
     $thumbInfo = $s3->getObjectInfo($bucket, $thumb, $compareThumbsBySize);
     //Check if thumb exists in the bucket
     if ($thumbInfo && !$_reuploadThumbs) {
         echo 'Thumb ', $thumb, ' exists', "\n";
         continue;
     }
     if (!file_exists($thumb) || $recalculateThumbs) {
         //Create directories for the thumb
         createDirectory(substr($thumb, 0, strlen($thumbPrefix) + 4));
         $adapter = new Varien_Image_Adapter_Gd2();
         //Default settings from Mage
         $adapter->keepAspectRatio(true);
         $adapter->keepFrame(false);
         $adapter->keepTransparency(true);
         $adapter->constrainOnly(true);
         $adapter->backgroundColor(array(255, 255, 255));
开发者ID:sebastianwahn,项目名称:MVentory_S3CDN,代码行数:31,代码来源:resize-on-s3.php

示例9: getObjectInfo

 /**
  * get information about an object in the current S3 bucket
  * @param string $locationOnS3 - path the file should have on S3 relative to the current bucket
  * @return array
  */
 public function getObjectInfo($locationOnS3)
 {
     return S3::getObjectInfo($this->bucket, $locationOnS3);
 }
开发者ID:dardosordi,项目名称:CakeS3,代码行数:9,代码来源:CakeS3Component.php

示例10: getRemoteFileInfo

 public static function getRemoteFileInfo(Zotero_StorageFileInfo $info)
 {
     self::requireLibrary();
     S3::setAuth(Z_CONFIG::$S3_ACCESS_KEY, Z_CONFIG::$S3_SECRET_KEY);
     $url = self::getPathPrefix($info->hash, $info->zip) . $info->filename;
     $remoteInfo = S3::getObjectInfo(Z_CONFIG::$S3_BUCKET, $url, true);
     if (!$remoteInfo) {
         return false;
     }
     return $remoteInfo;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:11,代码来源:S3.inc.php

示例11: downloadFile

 function downloadFile($filename)
 {
     set_time_limit(0);
     ob_clean();
     if (!isset($filename) || empty($filename)) {
         $var = "<table align='center' width='100%'><tr><td style='font:bold 14px verdana;color:#FF0000;' align='center'>Please specify a file name for download.</td></tr></table>";
         die($var);
     }
     if (USE_S3 == 0) {
         if (strpos($filename, "") !== FALSE) {
             die('');
         }
         $fname = basename($filename);
         if (file_exists(DIR_CASE_FILES . $fname)) {
             $file_path = DIR_CASE_FILES . $fname;
         } else {
             $var = "<table align='center' width='100%'><tr><td style='font:bold 12px verdana;color:#FF0000;' align='center'>Oops! File not found.<br/> File may be deleted or make sure you specified correct file name.</td></tr></table>";
             die($var);
         }
     } else {
         $s3 = new S3(awsAccessKey, awsSecretKey);
         $info = $s3->getObjectInfo(BUCKET_NAME, DIR_CASE_FILES_S3_FOLDER . $filename);
         if ($info) {
             $fileurl = $this->generateTemporaryURL(DIR_CASE_FILES_S3 . $filename);
             //$file_path = DIR_CASE_FILES_S3.$filename;
             $file_path = $fileurl;
         } else {
             $var = "<table align='center' width='100%'><tr><td style='font:bold 12px verdana;color:#FF0000;' align='center'>Oops! File not found.<br/> File may be deleted or make sure you specified correct file name.</td></tr></table>";
             die($var);
         }
     }
     /* Figure out the MIME type | Check in array */
     $known_mime_types = array("pdf" => "application/pdf", "txt" => "text/plain", "html" => "text/html", "htm" => "text/html", "exe" => "application/octet-stream", "zip" => "application/zip", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg", "php" => "text/plain");
     $file_extension = strtolower(substr(strrchr($filename, "."), 1));
     if (array_key_exists($file_extension, $known_mime_types)) {
         $mime_type = $known_mime_types[$file_extension];
     } else {
         $mime_type = "application/force-download";
     }
     // Send file headers
     header("Content-type: {$mime_type}");
     header("Content-Disposition: attachment;filename={$filename}");
     header('Pragma: no-cache');
     header('Expires: 0');
     //$file_path = DIR_CASE_FILES_S3.$filename;
     // Send the file contents.
     readfile($file_path);
 }
开发者ID:programster,项目名称:SCRUMptious,代码行数:48,代码来源:FormatComponent.php

示例12:

 function pub_file_exists($folder, $fileName)
 {
     //echo $fileName;exit;
     $s3 = new S3(awsAccessKey, awsSecretKey);
     $info = $s3->getObjectInfo(BUCKET_NAME, $folder . $fileName);
     if ($info) {
         //File exists
         return true;
     } else {
         //File doesn't exists
         return false;
     }
 }
开发者ID:jgera,项目名称:orangescrum,代码行数:13,代码来源:FormatHelper.php

示例13: tempnam

            echo 'Creating Marker for Folder ' . $awsObjectInfo["name"] . " on CloudFiles\n";
            $objMossoObject = $objMossoContainer->create_object($awsObjectInfo["name"]);
            $objMossoObject->content_type = $directoryType;
            // 'application/directory';
            // Get a Zero-byte file pointer
            $fp = @fopen("php://temp", "wb+");
            $objMossoObject->write($fp, 0);
            @fclose($fp);
            continue;
        }
        // Get object into a TMP file
        $tmpFileName = tempnam(sys_get_temp_dir(), 'S3toMosso');
        echo 'Downloading ' . $awsObjectInfo["name"] . " from Amazon S3 to {$tmpFileName}\n";
        $objS3->getObject($awsBucketName, $awsObjectInfo["name"], $tmpFileName);
        // Send Object to Mosso
        echo 'Creating object ' . $awsObjectInfo["name"] . " in container {$mossoContainerName}\n";
        $objMossoObject = $objMossoContainer->create_object($awsObjectInfo["name"]);
        try {
            $objMossoObject->_guess_content_type($tmpFileName);
        } catch (BadContentTypeException $e) {
            // Get the content type from Amazon
            $info = $objS3->getObjectInfo($awsBucketName, $awsObjectInfo["name"], true);
            $objMossoObject->content_type = $info['type'];
        }
        echo 'Uploading ' . $awsObjectInfo["name"] . ' to Cloud Files Server' . "\n";
        $objMossoObject->load_from_filename($tmpFileName);
        // Remove the TEMP file
        unlink($tmpFileName);
    }
}
////////////////////////////// THE END ///////////////////////////
开发者ID:nzeyimana,项目名称:S3toMosso,代码行数:31,代码来源:S3toMosso.php

示例14: profile

 function profile($img = null)
 {
     $photo = urldecode($img);
     if (defined('USE_S3') && USE_S3) {
         $s3 = new S3(awsAccessKey, awsSecretKey);
         $info = $s3->getObjectInfo(BUCKET_NAME, DIR_USER_PHOTOS_S3_FOLDER . $photo);
     } else {
         if ($photo && file_exists(DIR_USER_PHOTOS . $photo)) {
             $info = 1;
         }
     }
     if ($photo && $info) {
         $checkPhoto = $this->User->find('count', array('conditions' => array('User.photo' => $photo, 'id' => SES_ID)));
         if ($checkPhoto) {
             if (defined('USE_S3') && USE_S3) {
                 $s3->deleteObject(BUCKET_NAME, DIR_USER_PHOTOS_S3_FOLDER . $photo);
             } else {
                 unlink(DIR_USER_PHOTOS . $photo);
             }
             $User['id'] = SES_ID;
             $User['photo'] = $photo_name;
             $this->User->save($User);
             $this->Session->write("SUCCESS", "Profile photo removed successfully");
             $this->redirect(HTTP_ROOT . "users/profile");
         }
     }
     $userdata = $this->User->findById(SES_ID);
     $this->set('userdata', $userdata);
     $this->loadModel('TimezoneName');
     $timezones = $this->TimezoneName->find('all');
     $this->set('timezones', $timezones);
     $email_update = 0;
     if (isset($this->request->data['User'])) {
         if (trim($this->request->data['User']['email']) == "") {
             $this->Session->write("ERROR", "Email cannot be left blank");
             $this->redirect(HTTP_ROOT . "users/profile");
         } else {
             if (trim($this->request->data['User']['email']) != $userdata['User']['email']) {
                 $is_exist = $this->User->find('first', array('conditions' => array('User.email' => trim($this->request->data['User']['email']))));
                 $this->loadmodel('CompanyUser');
                 $is_cmpinfo = $this->CompanyUser->find('count', array('conditions' => array('CompanyUser.user_id' => $is_exist['User']['id'])));
                 if (!$is_cmpinfo) {
                     $this->User->id = $userdata['User']['id'];
                     $userdata['User']['update_email'] = trim($this->request->data['User']['email']);
                     $userdata['User']['update_random'] = $this->Format->generateUniqNumber();
                     $this->User->save($userdata);
                     $email_update = trim($this->request->data['User']['email']);
                     $this->send_update_email_noti($userdata, trim($this->request->data['User']['email']));
                     $this->request->data['User']['email'] = $userdata['User']['email'];
                 } else {
                     $this->Session->write("ERROR", "Opps! Email address already exists.");
                     $this->redirect(HTTP_ROOT . "users/profile");
                 }
             }
         }
         $photo_name = '';
         if (isset($this->request->data['User']['photo'])) {
             if (!empty($this->request->data['User']['photo']) && !empty($this->request->data['User']['exst_photo'])) {
                 $checkProfPhoto = $this->User->find('count', array('conditions' => array('User.photo' => $this->request->data['User']['exst_photo'], 'id' => SES_ID)));
                 if ($checkProfPhoto) {
                     if (defined('USE_S3') && USE_S3) {
                         $s3->deleteObject(BUCKET_NAME, DIR_USER_PHOTOS_S3_FOLDER . $this->request->data['User']['exst_photo']);
                     } else {
                         unlink(DIR_USER_PHOTOS . $this->request->data['User']['exst_photo']);
                     }
                 }
             }
             //$photo_name = $this->Format->uploadPhoto($this->request->data['User']['photo']['tmp_name'],$this->request->data['User']['photo']['name'],$this->request->data['User']['photo']['size'],DIR_USER_PHOTOS,SES_ID);
             //$photo_name = $this->Format->uploadPhoto($this->request->data['User']['photo']['tmp_name'],$this->request->data['User']['photo']['name'],$this->request->data['User']['photo']['size'],DIR_USER_PHOTOS,SES_ID,"profile_img");
             $photo_name = $this->Format->uploadProfilePhoto($this->request->data['User']['photo'], DIR_USER_PHOTOS);
             if ($photo_name == "ext") {
                 $this->Session->write("ERROR", "Opps! Invalid file format! The formats supported are gif, jpg, jpeg & png.");
                 $this->redirect(HTTP_ROOT . "users/profile");
             } elseif ($photo_name == "size") {
                 $this->Session->write("ERROR", "Profile photo size cannot excceed 1mb");
                 $this->redirect(HTTP_ROOT . "users/profile");
             }
         }
         if (trim($this->request->data['User']['name']) == "") {
             $this->Session->write("ERROR", "Name cannot be left blank");
             $this->redirect(HTTP_ROOT . "users/profile");
         } else {
             $this->request->data['User']['id'] = SES_ID;
             if (empty($this->request->data['User']['photo']) && !empty($this->request->data['User']['exst_photo'])) {
                 $this->request->data['User']['photo'] = $this->request->data['User']['exst_photo'];
             } else {
                 $this->request->data['User']['photo'] = $photo_name;
             }
             $this->User->save($this->request->data);
             if ($this->request->data['User']['timezone_id'] != $_COOKIE['USERTZ']) {
                 $this->loadModel('Timezone');
                 $timezn = $this->Timezone->find('first', array('conditions' => array('Timezone.id' => $this->request->data['User']['timezone_id']), 'fields' => array('Timezone.gmt_offset', 'Timezone.dst_offset', 'Timezone.code')));
                 setcookie("USERTZ", '', time() - 3600, '/', DOMAIN_COOKIE, false, false);
                 setcookie("USERTZ", $this->request->data['User']['timezone_id'], COOKIE_TIME, '/', DOMAIN_COOKIE, false, false);
                 $auth_user = $this->Auth->user();
                 $auth_user['timezone_id'] = $this->request->data['User']['timezone_id'];
                 $this->Session->write('Auth.User', $auth_user);
             }
             if ($email_update) {
                 $this->Session->write("SUCCESS", "Profile updated successfully.<br />A confirmation link has been sent to '{$email_update}'.");
//.........这里部分代码省略.........
开发者ID:jgera,项目名称:orangescrum,代码行数:101,代码来源:UsersController.php

示例15: _exists

 /**
  * {@inheritdoc}
  */
 protected function _exists($path)
 {
     return $this->_s3->getObjectInfo($this->_params->bucket, $path, false);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:7,代码来源:s3.php


注:本文中的S3::getObjectInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。