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


PHP escapeshellcmd函数代码示例

本文整理汇总了PHP中escapeshellcmd函数的典型用法代码示例。如果您正苦于以下问题:PHP escapeshellcmd函数的具体用法?PHP escapeshellcmd怎么用?PHP escapeshellcmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: sassProcessing

 private function sassProcessing()
 {
     global $IP, $wgSassExecutable, $wgDevelEnvironment;
     wfProfileIn(__METHOD__);
     $tempDir = sys_get_temp_dir();
     //replace \ to / is needed because escapeshellcmd() replace \ into spaces (?!!)
     $tempOutFile = str_replace('\\', '/', tempnam($tempDir, 'Sass'));
     $tempDir = str_replace('\\', '/', $tempDir);
     $params = urldecode(http_build_query($this->mParams, '', ' '));
     $cmd = "{$wgSassExecutable} {$IP}/{$this->mOid} {$tempOutFile} --cache-location {$tempDir}/sass -r {$IP}/extensions/wikia/SASS/wikia_sass.rb {$params}";
     $escapedCmd = escapeshellcmd($cmd) . " 2>&1";
     $sassResult = shell_exec($escapedCmd);
     if ($sassResult != '') {
         Wikia::log(__METHOD__, false, "commandline error: " . $sassResult . " -- Full commandline was: {$escapedCmd}", true);
         Wikia::log(__METHOD__, false, "Full commandline was: {$escapedCmd}", true);
         Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
         if (file_exists($tempOutFile)) {
             unlink($tempOutFile);
         }
         if (!empty($wgDevelEnvironment)) {
             $exceptionMsg = "Problem with SASS processing: {$sassResult}";
         } else {
             $exceptionMsg = 'Problem with SASS processing. Check the PHP error log for more info.';
         }
         throw new Exception("/* {$exceptionMsg} */");
     }
     $this->mContent = file_get_contents($tempOutFile);
     unlink($tempOutFile);
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:AssetsManagerSassBuilder.class.php

示例2: ping

 function ping($host, $timeout = 1)
 {
     $latency = self::PING_DEAD;
     $ttl = escapeshellcmd(1);
     $host = escapeshellcmd($host);
     // Exec string for Windows-based systems.
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         // -n = number of pings; -i = ttl.
         $exec_string = 'ping -n 1 -i ' . $ttl . ' ' . $host;
     } else {
         // -n = numeric output; -c = number of pings; -t = ttl.
         $exec_string = 'ping -n -c 1 -t ' . $ttl . ' ' . $host;
     }
     exec($exec_string, $output, $return);
     // Strip empty lines and reorder the indexes from 0 (to make results more
     // uniform across OS versions).
     $output = array_values(array_filter($output));
     // If the result line in the output is not empty, parse it.
     if (!empty($output[1])) {
         // Search for a 'time' value in the result line.
         $response = preg_match("/time(?:=|<)(?<time>[\\.0-9]+)(?:|\\s)ms/", $output[1], $matches);
         // If there's a result and it's greater than 0, return the latency.
         if ($response > 0 && isset($matches['time'])) {
             $latency = self::PING_ALIVE;
         }
     }
     return $latency;
 }
开发者ID:dem3trio,项目名称:wakeonlan-php,代码行数:28,代码来源:NetUtils.php

示例3: finalize

 /**
  * Finalises the archive by compressing it. Overrides parent's method 
  * @return boolean TRUE on success, FALSE on failure
  */
 function finalize()
 {
     // Get gzip's binary location
     $registry = JoomlapackModelRegistry::getInstance();
     $gzip = escapeshellcmd($registry->get('gzipbinary'));
     // Construct and run command line
     $command = "{$gzip} " . escapeshellcmd($this->_tempFilename);
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerTARGZ :: Calling gzip. The command line is:");
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, $command);
     $result = shell_exec($command);
     // Normally, gzip should be silent as a fish. If anything was sput out,
     // there must have been an error.
     if (strlen(trim($result)) > 0) {
         $errorMessage = "Error calling gzip: " . $result . " \n Command line was: \n " . $command . " \n Please check file permissions and examine the result message for any hints regarding the problem tar faced archiving your files.";
         $this->setError($errorMessage);
         return false;
     }
     // Now, unregister the temp file (which no longer exists), register the gzipped file as
     // a new temp file and try to move it
     JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
     $this->_tempFilename = JoomlapackCUBETempfiles::registerTempFile(basename($this->_archiveFilename));
     copy($this->_tempFilename, $this->_archiveFilename);
     JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
     // If no errors occured, return true
     return true;
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:30,代码来源:targz.php

示例4: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws RuntimeException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $opener = '';
     if (OperatingSystem::isMacOs()) {
         $opener = 'open';
     } elseif (OperatingSystem::isWindows()) {
         $opener = 'start';
     } else {
         // Linux
         if (exec('which xde-open')) {
             $opener = 'xdg-open';
         } elseif (exec('which gnome-open')) {
             $opener = 'gnome-open';
         } elseif (exec('which kde-open')) {
             $opener = 'kde-open';
         }
     }
     if (empty($opener)) {
         throw new RuntimeException('No opener command like xde-open, gnome-open, kde-open was found.');
     }
     $this->detectMagento($output);
     if ($this->initMagento($output)) {
         $store = $this->getHelperSet()->get('parameter')->askStore($input, $output, 'store', true);
         if ($store->getId() == Store::DEFAULT_STORE_ID) {
             $url = $this->getBackendStoreUrl($store);
         } else {
             $url = $this->getFrontendStoreUrl($store);
         }
         $output->writeln('Opening URL <comment>' . $url . '</comment> in browser');
         Exec::run(escapeshellcmd($opener . ' ' . $url));
     }
 }
开发者ID:brentwpeterson,项目名称:n98-magerun2,代码行数:38,代码来源:OpenBrowserCommand.php

示例5: run

 /**
  * run shell command
  * @param string $command command
  * @param boolean $escape escape shell command?
  * @param boolean $arrayResult is result array?
  * @return array
  */
 public function run($command, $escape = true, $arrayResult = false, $shellExec = false)
 {
     if ($escape) {
         if ($arrayResult) {
             exec(escapeshellcmd($command), $output);
             return $output;
         } else {
             if ($shellExec == false) {
                 return exec(escapeshellcmd($command));
             } else {
                 return shell_exec(escapeshellcmd($command));
             }
         }
     } else {
         if ($arrayResult) {
             exec($command, $output);
             return $output;
         } else {
             if ($shellExec == false) {
                 return exec($command);
             } else {
                 return shell_exec($command);
             }
         }
     }
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:33,代码来源:Shell.php

示例6: m_type

function m_type($filename)
{
    $filename = escapeshellcmd($filename);
    $command = "file -b --mime-type -m /usr/share/misc/magic {$filename}";
    $mimeType = shell_exec($command);
    return trim($mimeType);
}
开发者ID:avryhof,项目名称:digital-asset-manager,代码行数:7,代码来源:functions.php

示例7: minify

 /**
  */
 public function minify()
 {
     if (!is_executable($this->_opts['java']) || !is_readable($this->_opts['closure'])) {
         $this->_opts['logger']->log('The java path or Closure location can not be accessed.', Horde_Log::ERR);
         return parent::minify();
     }
     /* --warning_level QUIET - closure default is "DEFAULT" which will
      * cause code with compiler warnings to output bad js (see Bug
      * #13789) */
     $cmd = trim(escapeshellcmd($this->_opts['java']) . ' -jar ' . escapeshellarg($this->_opts['closure']) . ' --warning_level QUIET');
     if (isset($this->_opts['sourcemap']) && is_array($this->_data)) {
         $this->_sourcemap = Horde_Util::getTempFile();
         $cmd .= ' --create_source_map ' . escapeshellarg($this->_sourcemap) . ' --source_map_format=V3';
         $suffix = "\n//# sourceMappingURL=" . $this->_opts['sourcemap'];
     } else {
         $suffix = '';
     }
     if (isset($this->_opts['cmdline'])) {
         $cmd .= ' ' . trim($this->_opts['cmdline']);
     }
     if (is_array($this->_data)) {
         $js = '';
         foreach ($this->_data as $val) {
             $cmd .= ' ' . $val;
         }
     } else {
         $js = $this->_data;
     }
     $cmdline = new Horde_JavascriptMinify_Util_Cmdline();
     return $cmdline->runCmd($js, $cmd, $this->_opts['logger']) . $suffix . $this->_sourceUrls();
 }
开发者ID:horde,项目名称:horde,代码行数:33,代码来源:Closure.php

示例8: exec_swish

 /**
  * Méthode: exec_swish
  *
  * return            void
  */
 function exec_swish()
 {
     //Prépare la ligne de commande
     $this->words = escapeshellcmd($this->words);
     $this->words = str_replace('\\*', '*', $this->words);
     $cmd = $this->str_engine . " " . ' -f ' . $this->str_index_file . ' -w "' . $this->words . '"' . ' -d ' . $this->str_separator;
     //Ajout du paramètre -p si il y a des paramètres
     if (count($this->get_params) > 0) {
         $ligne_params = implode(" ", $this->get_params);
         $cmd .= " -p " . $ligne_params;
     }
     //Ajout du paramètre de tri s'il existe
     if ($this->sort_params != "") {
         $cmd .= " -s " . $this->sort_params;
     }
     //Ajout du paramètre -b pour démarrer au résultat n
     if ($this->first_result != "") {
         $cmd .= " -b " . $this->first_result;
     }
     //Ajout du paramètre -m pour s'arrêter à n lignes
     if ($this->last_result != "") {
         $cmd .= " -m " . $this->last_result;
     }
     //La commande est prete, on l'éxécute
     $this->cmd = $cmd;
     exec($cmd, $this->arry_swish);
     //Le résultat est stockée dans $this->arry_swish
 }
开发者ID:BackupTheBerlios,项目名称:openweb-cms-svn,代码行数:33,代码来源:class.swish.php

示例9: capture

 /**
  * The main public function to implement.
  *
  * @param string $url The URL to capture.
  * @param string $targetPath The saved image path.
  * @param array $options The extra options.
  *
  * @return string The captured image absolute path.
  * @throws Zend_Exception If no image is generated, throw exception
  */
 public function capture($url, $targetPath, $options = array())
 {
     $tokens = array_merge(array('url' => $url, 'targetPath' => $targetPath), $options);
     $script = $this->_renderScriptTemplate($tokens, isset($options['isPdf']) ? $options['isPdf'] : false);
     // Generate the script
     $scriptFilePath = DATA_PATH . md5(serialize($tokens)) . '.js';
     if (file_exists($scriptFilePath)) {
         unlink($scriptFilePath);
     }
     if (false === file_put_contents($scriptFilePath, $script)) {
         throw new Zend_Exception('Can not generate the phantom.js javascript file: ' . $scriptFilePath);
     }
     // Execute phantom.js to generate the image file
     $exec = ($this->_binaryPath ? $this->_binaryPath . DS : '') . $this->_executable . ' --ssl-protocol=any ' . $scriptFilePath;
     //$exec = $this->_binaryPath . DS . $this->_executable . ' --version';
     //$exec = $this->_binaryPath . DS . $this->_executable . ' direction.js';
     $escaped_command = escapeshellcmd($exec);
     // Change directory to the data path
     chdir($this->_workingDir);
     exec($escaped_command);
     //Proc_Close (Proc_Open ($this->_binaryPath . DS . $this->_executable . ' ' . $scriptFilePath . " param1 param2 &", Array (), $foo));
     //exit;
     //DebugBreak('1@127.0.0.1:7869;d=1');
     // Check whether the image is generated
     $imagePath = $this->_workingDir . DS . $targetPath;
     if (!is_file($imagePath)) {
         //throw new Zend_Exception('Failed to generate screenshot: ' . $escaped_command);
     }
     return $imagePath;
 }
开发者ID:beesheer,项目名称:freehdfootage,代码行数:40,代码来源:Phantomjs.php

示例10: execute

 /**
  * Runs the given command.
  *
  * @param array $arguments
  *   Array of arguments and options to pass to the command.
  *
  * @throws \Exception
  */
 public function execute($arguments)
 {
     // Validate on given command.
     if (!isset($this->options['cmd'])) {
         throw new \Exception(sprintf('No command given for "%s"', $this->name));
         exit(1);
     }
     // If a explicit working directory is specifified, we change to that to call
     // the command.
     $workingDir = $this->getWorkingDir();
     if (isset($workingDir)) {
         chdir($workingDir);
     }
     // Execute the command.
     $status = NULL;
     $cmd = $this->options['cmd'];
     // If a explicit command dir is given, we use an absolute path to the command.
     $cmdDir = $this->getCmdDir();
     if (isset($cmdDir)) {
         $cmd = $cmdDir . '/' . $cmd;
     }
     $cmd = escapeshellcmd($cmd);
     // Add passed arguments to the command.
     foreach ($arguments as $arg) {
         $cmd .= ' ' . escapeshellarg($arg);
     }
     passthru($cmd, $status);
     exit($status);
 }
开发者ID:derhasi,项目名称:buddy,代码行数:37,代码来源:CommandShortcut.php

示例11: parse

 /**
  * Parse an RDF document into an EasyRdf_Graph
  *
  * @param string $graph    the graph to load the data into
  * @param string $data     the RDF document data
  * @param string $format   the format of the input data
  * @param string $baseUri  the base URI of the data being parsed
  * @return boolean         true if parsing was successful
  */
 public function parse($graph, $data, $format, $baseUri)
 {
     parent::checkParseParams($graph, $data, $format, $baseUri);
     // Open a pipe to the rapper command
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     $process = proc_open(escapeshellcmd($this->_rapperCmd) . " --quiet " . " --input " . escapeshellarg($format) . " --output json " . " --ignore-errors " . " --input-uri " . escapeshellarg($baseUri) . " --output-uri -" . " - ", $descriptorspec, $pipes, '/tmp', null);
     if (is_resource($process)) {
         // $pipes now looks like this:
         // 0 => writeable handle connected to child stdin
         // 1 => readable handle connected to child stdout
         // 2 => readable handle connected to child stderr
         fwrite($pipes[0], $data);
         fclose($pipes[0]);
         $data = stream_get_contents($pipes[1]);
         fclose($pipes[1]);
         $error = stream_get_contents($pipes[2]);
         fclose($pipes[2]);
         // It is important that you close any pipes before calling
         // proc_close in order to avoid a deadlock
         $returnValue = proc_close($process);
         if ($returnValue) {
             throw new EasyRdf_Exception("Failed to parse RDF ({$returnValue}): " . $error);
         }
     } else {
         throw new EasyRdf_Exception("Failed to execute rapper command.");
     }
     // Parse in the JSON
     return parent::parse($graph, $data, 'json', $baseUri);
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:38,代码来源:Rapper.php

示例12: buildPhalconDir

 /**
  *
  */
 private function buildPhalconDir()
 {
     $config = $this->config;
     $phalconDir = $config->path->phalconDir;
     $distDir = $config->dev->path->distDir;
     $distDirEsc = escapeshellarg($distDir);
     $phalconAppDirEsc = escapeshellarg($phalconDir);
     $phalconDistDirEsc = escapeshellarg($distDir . 'phalcon');
     if (!isset($config['dev']['phpEncode'])) {
         throw new \Exception('The PHP Encoder value is not set.', 1);
     }
     $phpEncode = $config->dev->phpEncode;
     if (empty($phpEncode)) {
         `cp -R {$phalconAppDirEsc} {$phalconDistDirEsc}`;
     } else {
         if (!isset($config->dev->phpEncoders[$phpEncode])) {
             throw new \Exception("The '{$phpEncode}' PHP encoder setting does not exist", 1);
         }
         $encoder = $config->dev->phpEncoders[$phpEncode];
         $encCmdEsc = escapeshellcmd($encoder->path);
         switch ($phpEncode) {
             case 'ioncube':
                 $cmd = "{$encCmdEsc} {$phalconAppDirEsc} --into {$distDirEsc} --merge-target";
                 exec($cmd, $out, $ret);
                 break;
         }
     }
 }
开发者ID:JanOschii,项目名称:webird,代码行数:31,代码来源:BuildTask.php

示例13: tearDownAfterClass

 /**
  * {@inheritdoc}
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     $cmd = sprintf('kill %d', self::$webServerPid);
     exec(escapeshellcmd($cmd));
     self::$webServerPid = null;
 }
开发者ID:lexeo,项目名称:curl,代码行数:10,代码来源:CurlTest.php

示例14: rotate

 /**
  * Rotate an image.  Valid options are degrees
  *
  * @param string     $input_file
  * @param string     $output_file
  * @param array      $options
  */
 static function rotate($input_file, $output_file, $options)
 {
     graphics::init_toolkit();
     module::event("graphics_rotate", $input_file, $output_file, $options);
     // BEGIN mod to original function
     $image_info = getimagesize($input_file);
     // [0]=w, [1]=h, [2]=type (1=GIF, 2=JPG, 3=PNG)
     if (module::get_var("image_optimizer", "rotate_jpg") || $image_info[2] == 2) {
         // rotate_jpg enabled, the file is a jpg.  get args
         $path = module::get_var("image_optimizer", "path_jpg");
         $exec_args = " -rotate ";
         $exec_args .= $options["degrees"] > 0 ? $options["degrees"] : $options["degrees"] + 360;
         $exec_args .= " -copy all -optimize -outfile ";
         // run it - from input_file to tmp_file
         $tmp_file = image_optimizer::make_temp_name($output_file);
         exec(escapeshellcmd($path) . $exec_args . escapeshellarg($tmp_file) . " " . escapeshellarg($input_file), $exec_output, $exec_status);
         if ($exec_status || !filesize($tmp_file)) {
             // either a blank/nonexistant file or an error - log an error and pass to normal function
             Kohana_Log::add("error", "image_optimizer rotation failed on " . $output_file);
             unlink($tmp_file);
         } else {
             // worked - move temp to output
             rename($tmp_file, $output_file);
             $status = true;
         }
     }
     if (!$status) {
         // we got here if we weren't supposed to use jpegtran or if jpegtran failed
         // END mod to original function
         Image::factory($input_file)->quality(module::get_var("gallery", "image_quality"))->rotate($options["degrees"])->save($output_file);
         // BEGIN mod to original function
     }
     // END mod to original function
     module::event("graphics_rotate_completed", $input_file, $output_file, $options);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:42,代码来源:MY_gallery_graphics.php

示例15: getSobel

function getSobel($image)
{
    file_put_contents('tmp/img', base64_decode($image));
    $command = escapeshellcmd('python /var/www/soap/sobel/sobel.py /var/www/soap/tmp/img');
    $output = shell_exec($command);
    return $output;
}
开发者ID:pvorotnikov,项目名称:image-processing-soap,代码行数:7,代码来源:image.php


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