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


PHP FileSystem::chmod方法代码示例

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


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

示例1: saveNewImage

 /**
  * Saves the new image wherever you want
  * @todo    In case the PHP script has no write access to the location set by $this->newImageFile,
  *          the image shall be sent to the output buffer and then be put into the new file
  *          location using the FileSystemFile object.
  * @access  public
  * @param   string    $file             The path for the image file to be written.
  * @param   booelan   $forceOverwrite   Force overwriting existing files if true.
  * @return  boolean                     True on success, false otherwise.
  */
 public function saveNewImage($file, $forceOverwrite = false)
 {
     // TODO: Add some sort of diagnostics (Message) here and elsewhere in this class
     if (!$this->imageCheck) {
         return false;
     }
     if (empty($this->newImage)) {
         return false;
     }
     if (file_exists($file)) {
         if (!$forceOverwrite) {
             return false;
         }
         \Cx\Lib\FileSystem\FileSystem::makeWritable($file);
     } else {
         try {
             $objFile = new \Cx\Lib\FileSystem\File($file);
             $objFile->touch();
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
         }
     }
     // TODO: Unfortunately, the functions imagegif(), imagejpeg() and imagepng() can't use the Contrexx FileSystem wrapper,
     //       therefore we need to set the global write access image files.
     //       This issue might be solved by using the output-buffer and write the image manually afterwards.
     //
     //       IMPORTANT: In case something went wrong (see bug #1441) and the path $strPathNew.$strFileNew refers to a directory
     //       we must abort the operation here, otherwise we would remove the execution flag on a directory, which would
     //       cause to remove any browsing access to the directory.
     if (is_dir($file)) {
         return false;
     }
     \Cx\Lib\FileSystem\FileSystem::chmod($file, 0666);
     //\Cx\Lib\FileSystem\FileSystem::CHMOD_FILE);
     $this->newImageFile = $file;
     if ($this->newImageType == self::IMG_TYPE_PNG) {
         $this->setTransparency();
     }
     switch ($this->newImageType) {
         case self::IMG_TYPE_GIF:
             $function = 'imagegif';
             if (!function_exists($function)) {
                 $function = 'imagejpeg';
             }
             break;
         case self::IMG_TYPE_JPEG:
             $function = 'imagejpeg';
             break;
         case self::IMG_TYPE_PNG:
             // make a jpeg thumbnail, too
             $function = 'imagepng';
             break;
         default:
             return false;
     }
     // Only adjust quality, if it is set.
     if ($this->newImageQuality != '') {
         $function($this->newImage, $this->newImageFile, $this->getQuality());
     } else {
         $function($this->newImage, $this->newImageFile);
     }
     return true;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:73,代码来源:Image.class.php

示例2: _getThumbs

 /**
  * Get thumbnails
  *
  * Get the thumbnails from a day in the archive.
  * Create the thumbnails if they don't already exists.
  *
  * @access private
  */
 function _getThumbs()
 {
     $path = ASCMS_DOCUMENT_ROOT . "/" . $this->camSettings['archivePath'] . '/' . $this->date . '/';
     $objDirectory = @opendir($path);
     $chmoded = false;
     if ($objDirectory) {
         while ($file = readdir($objDirectory)) {
             if ($file != "." && $file != "..") {
                 //check and create thumbs
                 $thumb = ASCMS_DOCUMENT_ROOT . $this->camSettings['thumbnailPath'] . '/tn_' . $this->date . '_' . $file;
                 if (!\Cx\Lib\FileSystem\FileSystem::exists($thumb)) {
                     if (!$chmoded) {
                         \Cx\Lib\FileSystem\FileSystem::chmod($this->camSettings['thumbnailPath'], '777');
                         $chmoded = true;
                     }
                     //create thumb
                     $im1 = @imagecreatefromjpeg($path . $file);
                     //erstellt ein Abbild im Speicher
                     if ($im1) {
                         /* Pr�fen, ob fehlgeschlagen */
                         // check_jpeg($thumb, $fix=false );
                         $size = getimagesize($path . $file);
                         //ermittelt die Gr��e des Bildes
                         $breite = $size[0];
                         //die Breite des Bildes
                         $hoehe = $size[1];
                         //die H�he des Bildes
                         $breite_neu = $this->camSettings['thumbMaxSize'];
                         //die breite des Thumbnails
                         $factor = $breite / $this->camSettings['thumbMaxSize'];
                         //berechnungsfaktor
                         $hoehe_neu = $size[1] / $factor;
                         //die H�he des Thumbnails
                         //$im2=imagecreate($breite_neu,$hoehe_neu); //Thumbnail im Speicher erstellen
                         $im2 = @imagecreatetruecolor($breite_neu, $hoehe_neu);
                         imagecopyresized($im2, $im1, 0, 0, 0, 0, $breite_neu, $hoehe_neu, $breite, $hoehe);
                         imagejpeg($im2, $thumb);
                         //Thumbnail speichern
                         imagedestroy($im1);
                         //Speicherabbild wieder l�schen
                         imagedestroy($im2);
                         //Speicherabbild wieder l�schen
                     }
                 }
                 //show pictures
                 $minHour = date('G', $this->camSettings['showFrom']);
                 $minMinutes = date('i', $this->camSettings['showFrom']);
                 $maxHour = date('G', $this->camSettings['showTill']);
                 $maxMinutes = date('i', $this->camSettings['showTill']);
                 $hour = substr($file, 4, 2);
                 $min = substr($file, 13, 2);
                 $min = !empty($min) ? $min : "00";
                 $time = $hour . ":" . $min . " Uhr";
                 $minTime = mktime($minHour, $minMinutes);
                 $maxTime = mktime($maxHour, $maxMinutes);
                 $nowTime = mktime($hour, $min);
                 /*
                  * only show archive images if they are in range
                  */
                 if ($nowTime <= $maxTime && $nowTime >= $minTime) {
                     if ($this->camSettings['shadowboxActivate'] == 1) {
                         $linkUrl = ASCMS_PATH_OFFSET . $this->camSettings['archivePath'] . '/' . $this->date . '/' . $file;
                     } else {
                         $linkUrl = '?section=Livecam&amp;file=' . $this->date . '/' . $file;
                     }
                     $arrThumbnail = array('link_url' => $linkUrl, 'image_url' => $this->camSettings['thumbnailPath'] . "/tn_" . $this->date . "_" . $file, 'time' => $time);
                     array_push($this->_arrArchiveThumbs, $arrThumbnail);
                 }
             }
         }
         closedir($objDirectory);
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:81,代码来源:Livecam.class.php

示例3: createImages_JPG_GIF_PNG

 /**
  * Create an Image
  * @param     string        $strPathOld: The old path of the image
  * @param     string        $strPathNew: The new path for the created image
  * @param     string        $strFileOld: The name of the old file
  * @param     string        $strFileNew: The name of the new file
  * @param     integer        $intNewWidth: Width of the new image
  * @param     integer        $intNewHeight: Height of the new image
  * @param     integer        $intQuality: Quality of the new image
  */
 function createImages_JPG_GIF_PNG($strPathOld, $strPathNew, $strFileOld, $strFileNew, $intNewWidth, $intNewHeight, $intQuality)
 {
     global $_ARRAYLANG;
     //TODO: sometimes, strings are passed... this is a workaround
     $intNewWidth = intval($intNewWidth);
     $intNewHeight = intval($intNewHeight);
     //copy image
     $intSize = getimagesize($strPathOld . $strFileOld);
     //ermittelt die Gr��e des Bildes
     $intWidth = $intSize[0];
     //die Breite des Bildes
     $intHeight = $intSize[1];
     //die H�he des Bildes
     $strType = $intSize[2];
     //type des Bildes
     if (file_exists($strPathNew . $strFileNew)) {
         \Cx\Lib\FileSystem\FileSystem::makeWritable($strPathNew . $strFileNew);
     } else {
         try {
             $objFile = new \Cx\Lib\FileSystem\File($strPathNew . $strFileNew);
             $objFile->touch();
             $objFile->makeWritable();
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
         }
     }
     // TODO: Unfortunately, the functions imagegif(), imagejpeg() and imagepng() can't use the Cloudrexx FileSystem wrapper,
     //       therefore we need to set the global write access image files.
     //       This issue might be solved by using the output-buffer and write the image manually afterwards.
     //
     //       IMPORTANT: In case something went wrong (see bug #1441) and the path $strPathNew.$strFileNew refers to a directory
     //       we must abort the operation here, otherwise we would remove the execution flag on a directory, which would
     //       cause to remove any browsing access to the directory.
     if (is_dir($strPathNew . $strFileNew)) {
         return false;
     }
     \Cx\Lib\FileSystem\FileSystem::chmod($strPathNew . $strFileNew, 0666);
     //\Cx\Lib\FileSystem\FileSystem::CHMOD_FILE);
     //fix cases of zeroes
     if ($intNewWidth == 0) {
         if ($intNewHeight == 0) {
             $intNewHeight = $this->arrSettings['standard_height_abs'];
         }
         if ($intNewHeight == 0) {
             //set a standard value if the settings default to 0
             $intNewHeight = 100;
         }
         $intNewWidth = round($intWidth * $intNewHeight / $intHeight, 0);
     } else {
         if ($intNewHeight == 0) {
             $intNewHeight = round($intHeight * $intNewWidth / $intWidth, 0);
         }
     }
     $objSystem = new \FWSystem();
     if ($objSystem === false) {
         return false;
     }
     if (is_array($intSize)) {
         $memoryLimit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit'));
         // a $memoryLimit of zero means that there is no limit. so let's try it and hope that the host system has enough memory
         if (!empty($memoryLimit)) {
             $potentialRequiredMemory = $intSize[0] * $intSize[1] * ($intSize['bits'] / 8) * $intSize['channels'] * 1.8 * 2;
             if (function_exists('memory_get_usage')) {
                 $potentialRequiredMemory += memory_get_usage();
             } else {
                 // add a default of 10 MBytes
                 $potentialRequiredMemory += 10 * pow(1024, 2);
             }
             if ($potentialRequiredMemory > $memoryLimit) {
                 // try to set a higher memory_limit
                 @ini_set('memory_limit', $potentialRequiredMemory);
                 $curr_limit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit'));
                 if ($curr_limit < $potentialRequiredMemory) {
                     return false;
                 }
             }
         }
     } else {
         return false;
     }
     switch ($strType) {
         case 1:
             //GIF
             if ($this->boolGifEnabled) {
                 $handleImage1 = ImageCreateFromGif($strPathOld . $strFileOld);
                 $handleImage2 = @ImageCreateTrueColor($intNewWidth, $intNewHeight);
                 ImageCopyResampled($handleImage2, $handleImage1, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight);
                 ImageGif($handleImage2, $strPathNew . $strFileNew);
                 ImageDestroy($handleImage1);
                 ImageDestroy($handleImage2);
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:GalleryManager.class.php


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