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


PHP eZSys::escapeShellArgument方法代码示例

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


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

示例1: convert

 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     // Issue EZP-21357:
     // ImageMagick has it's own meta-characters support, hence:
     //     $ convert 'File*.jpg'' ...
     // Still expand File*.jpg as the shell would do, however, this is only true for the file's basename part and not
     // for the whole path.
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['dirpath'] . DIRECTORY_SEPARATOR . addcslashes($sourceMimeData['filename'], '~*?[]{}<>'));
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     system($systemString, $returnCode);
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:71,代码来源:ezimageshellhandler.php

示例2: convert

 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['url']);
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     system($systemString, $returnCode);
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
开发者ID:legende91,项目名称:ez,代码行数:66,代码来源:ezimageshellhandler.php

示例3: publish

 function publish($contentObjectID, $contentObjectVersion)
 {
     // fetch object
     $object = eZContentObject::fetch($contentObjectID);
     // get content class object
     $contentClass = $object->attribute('content_class');
     if ($contentClass->attribute('identifier') == 'file' || $contentClass->attribute('identifier') == 'nettopp') {
         $contentObjectAttributes = $object->contentObjectAttributes();
         $loopLenght = count($contentObjectAttributes);
         // Find image and file attribute
         for ($i = 0; $i < $loopLenght; $i++) {
             switch ($contentObjectAttributes[$i]->attribute('contentclass_attribute_identifier')) {
                 case 'image':
                     $image = $contentObjectAttributes[$i];
                     break;
                 case 'file':
                     $file = $contentObjectAttributes[$i];
                     break;
             }
         }
         if (!$file->hasContent()) {
             return;
         }
         if (!is_object($image)) {
             eZDebug::writeNotice("Image field was not found", "pdf2image");
             return;
         }
         // Get previous version and check that file has changed
         if ((int) $file->Version > 0 && $image->hasContent()) {
             $previousFile = eZContentObjectAttribute::fetch($file->ID, $file->Version - 1, true);
             if (is_object($previousFile) && $previousFile->hasContent()) {
                 if ($previousFile->content()->Filename == $file->content()->Filename) {
                     eZDebug::writeNotice("File hasn't changed", "pdf2image");
                     return;
                 }
             }
         }
         // Check that file is PDF
         if ($file->content()->MimeType != "application/pdf") {
             eZDebug::writeNotice("File not application/pdf", "pdf2image");
             return;
         }
         $source = $file->content()->filePath();
         if (!file_exists($source) or !is_readable($source)) {
             eZDebug::writeError("File not readable or doesn't exist", "pdf2image");
             return;
         }
         $page = 0;
         $width = 1000;
         $height = 1000;
         $target = eZSys::cacheDirectory() . "/" . md5(time() . 'pdf2image') . ".jpg";
         // Run conversion and redirect error to stdin
         $cmd = "convert " . "-density 200 " . eZSys::escapeShellArgument($source . "[" . $page . "]") . " " . "-colorspace rgb " . "-resize " . eZSys::escapeShellArgument($width . "x" . $height) . " " . eZSys::escapeShellArgument($target) . " 2>&1";
         eZDebug::writeNotice("Converting '" . $cmd . "'", "pdf2image");
         $out = shell_exec($cmd);
         // If we got a message somthing went wrong
         if ($out) {
             eZDebug::writeError("Conversion return error message '" . $out . "'", "pdf2image");
             // but it doesn't necessarily mean that it failed
             if (!is_readable($target)) {
                 return;
             }
         }
         // Add imagefile to image handler and save
         $imageContent = $image->content();
         $imageContent->initializeFromFile($target, $object->Name);
         if ($imageContent->isStorageRequired()) {
             $imageContent->store($image);
         }
         unlink($target);
     }
 }
开发者ID:jjohnsen,项目名称:jajbase,代码行数:72,代码来源:jajbasehandler.php


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