コード例 #1
1
 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__);
 }
コード例 #2
1
ファイル: LynxTest.php プロジェクト: siwa-pparzer/newsletter
 private function canRunLynx()
 {
     $this->loadConfiguration();
     $cmd = escapeshellcmd(Tools::confParam('path_to_lynx')) . ' --help';
     exec($cmd, $output, $statusCode);
     return $statusCode == 0;
 }
コード例 #3
0
 public function reRunSuite()
 {
     $args = $_SERVER['argv'];
     $command = $this->buildArgString() . escapeshellcmd($this->getExecutablePath()) . ' ' . join(' ', array_map('escapeshellarg', $args));
     passthru($command, $exitCode);
     exit($exitCode);
 }
コード例 #4
0
 static function item_created($item)
 {
     // Only works on photos
     if (!$item->is_photo()) {
         return;
     }
     // Locate jhead
     if (!is_file($path = exec('which jhead'))) {
         // @todo throw an exception ?
         Kohana::log('error', 'jhead is not installed');
     }
     $binary = str_replace('\\', '/', realpath(dirname($path)));
     $binary .= '/jhead';
     $binary .= PHP_SHLIB_SUFFIX === 'dll' ? '.exe' : '';
     if (!is_file($binary)) {
         // @todo throw an exception ?
         Kohana::log('error', 'Unable to locate jhead binary');
     }
     // Invoke jhead
     if ($error = exec(escapeshellcmd($binary) . ' -q -autorot ' . $item->file_path())) {
         // @todo throw an exception ?
         Kohana::log('error', 'Error during execution of jhead');
     }
     // Update item
     $image_info = getimagesize($item->file_path());
     $item->width = $image_info[0];
     $item->height = $image_info[1];
     $item->resize_dirty = 1;
     $item->thumb_dirty = 1;
     $item->save();
     graphics::generate($item);
 }
コード例 #5
0
ファイル: HttpServer.php プロジェクト: kdyby/selenium
 /**
  * @param string $router
  * @param array $env
  * @return UrlScript
  * @throws \RuntimeException
  */
 public function start($router, $env = array())
 {
     $this->slaughter();
     static $port;
     if ($port === NULL) {
         do {
             $port = rand(8000, 10000);
             if (isset($lock)) {
                 @fclose($lock);
             }
             $lock = fopen(dirname(TEMP_DIR) . '/http-server-' . $port . '.lock', 'w');
         } while (!flock($lock, LOCK_EX | LOCK_NB, $wouldBlock) || $wouldBlock);
     }
     $ini = NULL;
     if (($pid = getmypid()) && ($myprocess = `ps -ww -fp {$pid}`)) {
         $fullArgs = preg_split('~[ \\t]+~', explode("\n", $myprocess)[1], 8)[7];
         if (preg_match('~\\s\\-c\\s(?P<ini>[^ \\t]+)\\s~i', $fullArgs, $m)) {
             $ini = '-c ' . $m['ini'] . ' -n';
         }
     }
     $executable = new PhpExecutableFinder();
     $cmd = sprintf('%s %s -d register_argc_argv=on -t %s -S %s:%d %s', escapeshellcmd($executable->find()), $ini, escapeshellarg(dirname($router)), $ip = '127.0.0.1', $port, escapeshellarg($router));
     if (!is_resource($this->process = proc_open($cmd, self::$spec, $this->pipes, dirname($router), $env))) {
         throw new HttpServerException("Could not execute: `{$cmd}`");
     }
     sleep(1);
     // give him some time to boot up
     $status = proc_get_status($this->process);
     if (!$status['running']) {
         throw new HttpServerException("Failed to start php server: " . stream_get_contents($this->pipes[2]));
     }
     $this->url = new UrlScript('http://' . $ip . ':' . $port);
     return $this->getUrl();
 }
コード例 #6
0
ファイル: spoken_captcha.php プロジェクト: samuell/Core
/**
 * This function will feed the $say parameter to a speech
 * synthesizer and send the resulting audio file to the browser
 *
 * @param string $say
 */
function spamhurdles_spoken_captcha($say)
{
    global $PHORUM;
    $conf = $PHORUM["mod_spamhurdles"]["captcha"];
    if ($conf["spoken_captcha"] && file_exists($conf["flite_location"])) {
        // Generate the command for building the wav file.
        $tmpfile = tempnam($PHORUM["cache"], 'spokencaptcha_');
        $cmd = escapeshellcmd($conf["flite_location"]);
        $cmd .= " -t " . escapeshellarg($say);
        $cmd .= " -o " . escapeshellarg($tmpfile);
        // Build the wav file.
        system($cmd);
        // Did we succeed in building the wav? Then stream it to the user.
        if (file_exists($tmpfile) and filesize($tmpfile) > 0) {
            header("Content-Type: audio/x-wav");
            header("Content-Disposition: attachment; filename=captchacode.wav");
            header("Content-Length: " . filesize($tmpfile));
            readfile($tmpfile);
            unlink($tmpfile);
            exit(0);
            // Something in the setup is apparently wrong here.
        } else {
            die("<h1>Internal Spam Hurdles module error</h1>" . "Failed to generate a wave file using flite.\n" . "Please contact the site maintainer to report this problem.");
        }
    } else {
        die("<h1>Internal Spam Hurdles module error</h1>" . "Spoken captcha requested, but no spoken text is available\n" . "or the speech system has not been enabled/configured. " . "Please contact the site maintainer to report this problem.");
    }
}
コード例 #7
0
ファイル: Pictures.php プロジェクト: jhogan/nplay
 function SnarfMainPicture($url)
 {
     //TODO: Use curl when depedencies are met
     if (trim($url) == '') {
         return;
     }
     $this->MakePictureDirectory();
     if (file_exists($this->MainPicture())) {
         if (!unlink($this->MainPicture())) {
             throw new Exception("Failed to delete existing pic");
         }
     }
     $args = "{$url} -O " . $this->MainPicture();
     $args = escapeshellcmd($args);
     $cmd = "wget {$args}";
     system($cmd, $retVal);
     if ($retVal != 0) {
         throw new Exception("Snarf failed; errno:{$retVal}");
     }
     $args = escapeshellcmd($this->MainPicture());
     $cmd = "touch {$args}";
     system($cmd, $retVal);
     if ($retVal != 0) {
         throw new Exception("Touch failed; errno:{$retVal}");
     }
 }
コード例 #8
0
 /**
  * Perform the file backup.
  *
  * @return bool Whether the backup completed successfully or not.
  */
 public function backup()
 {
     if (!Backup_Utilities::is_exec_available() || !$this->get_zip_executable_path()) {
         return false;
     }
     // cd to the site root
     $command[] = 'cd ' . escapeshellarg(Path::get_root());
     // Run the zip command with the recursive and quiet flags
     $command[] = '&& ' . escapeshellcmd($this->get_zip_executable_path()) . ' -rq';
     // Save the zip file to the correct path
     $command[] = escapeshellarg($this->get_backup_filepath()) . ' ./';
     // Pass exclude rules in if we have them
     if ($this->get_exclude_string()) {
         $command[] = '-x ' . $this->get_exclude_string();
     }
     // Push all output to STDERR
     $command[] = '2>&1';
     $command = implode(' ', $command);
     $output = $return_status = 0;
     exec($command, $output, $return_status);
     // Track any errors
     if ($output) {
         if ($return_status === 0) {
             $this->warning(__CLASS__, implode(', ', $output));
         } else {
             $this->error(__CLASS__, implode(', ', $output));
         }
     }
     return $this->verify_backup();
 }
コード例 #9
0
ファイル: Execute.php プロジェクト: robertbasic/usher
 /**
  * Execute the given command
  *
  * @param string $command Command to execute
  * @param array  $args    Arguments for command
  *
  * @return mixed $return Command output
  */
 public function run($command, $args = null)
 {
     Output::msg('Executing command: "' . $command . '"');
     // filter the command
     $command = escapeshellcmd($command);
     $descSpec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
     $pipes = null;
     $return = null;
     $process = proc_open($command, $descSpec, $pipes);
     if (is_resource($process)) {
         $return = stream_get_contents($pipes[1]);
         if (empty($return)) {
             // probably some sort of error
             if (is_resource($pipes[2])) {
                 $err = trim(stream_get_contents($pipes[2]));
                 fclose($pipes[2]);
                 throw new \Exception($err);
             }
         }
         fclose($pipes[1]);
         $returnCode = proc_close($process);
         Output::msg("Execution result:\n" . $return);
     }
     return $return;
 }
コード例 #10
0
 /**
  * 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
 }
コード例 #11
0
ファイル: Rapper.php プロジェクト: nhukhanhdl/easyrdf
 /**
  * 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);
 }
コード例 #12
0
ファイル: CommandShortcut.php プロジェクト: derhasi/buddy
 /**
  * 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);
 }
コード例 #13
0
ファイル: BuildTask.php プロジェクト: JanOschii/webird
 /**
  *
  */
 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;
         }
     }
 }
コード例 #14
0
 /**
  * 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);
 }
コード例 #15
0
ファイル: NetUtils.php プロジェクト: dem3trio/wakeonlan-php
 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;
 }
コード例 #16
0
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;
}
コード例 #17
0
ファイル: Phantomjs.php プロジェクト: beesheer/freehdfootage
 /**
  * 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;
 }
コード例 #18
0
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);
}
コード例 #19
0
 /**
  * Serialise an EasyRdf_Graph to the RDF format of choice.
  *
  * @param object EasyRdf_Graph $graph   An EasyRdf_Graph object.
  * @param string  $format               The name of the format to convert to.
  * @return string                       The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     parent::checkSerialiseParams($graph, $format);
     $ntriples = parent::serialise($graph, 'ntriples');
     // Open a pipe to the rapper command
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     // Hack to produce more concise RDF/XML
     if ($format == 'rdfxml') {
         $format = 'rdfxml-abbrev';
     }
     $process = proc_open(escapeshellcmd($this->_rapperCmd) . " --quiet " . " --input ntriples " . " --output " . escapeshellarg($format) . " - " . 'unknown://', $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], $ntriples);
         fclose($pipes[0]);
         $output = 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 convert RDF: " . $error);
         }
     } else {
         throw new EasyRdf_Exception("Failed to execute rapper command.");
     }
     return $output;
 }
コード例 #20
0
ファイル: Closure.php プロジェクト: horde/horde
 /**
  */
 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();
 }
コード例 #21
0
ファイル: local.php プロジェクト: WYSAC/oregon-owncloud
 protected function scan($fileView, $filepath)
 {
     $this->status = new Status();
     $fhandler = $this->getFileHandle($fileView, $filepath);
     \OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
     // using 2>&1 to grab the full command-line output.
     $cmd = escapeshellcmd($this->avPath) . " - 2>&1";
     $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     $pipes = array();
     $process = proc_open($cmd, $descriptorSpec, $pipes);
     if (!is_resource($process)) {
         fclose($fhandler);
         throw new \RuntimeException('Error starting process');
     }
     // write to stdin
     $shandler = $pipes[0];
     while (!feof($fhandler)) {
         $chunk = fread($fhandler, $this->chunkSize);
         fwrite($shandler, $chunk);
     }
     fclose($shandler);
     fclose($fhandler);
     $output = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $result = proc_close($process);
     $this->status->parseResponse($output, $result);
     return $this->status->getNumericStatus();
 }
コード例 #22
0
 /**
  * @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));
     }
 }
コード例 #23
0
 public function processControlMenu()
 {
     if (isset($_REQUEST['main_tab'])) {
         $option = $_REQUEST['main_tab'];
         if ($option === 'lights') {
             echo Lightbulb::getLightBulbForm();
         } elseif ($option === 'locks') {
             echo Lock::getLockForm();
         } elseif ($option === 'thermostat') {
             echo Thermostat::getThermostatForm();
         } else {
             if ($option == 'lightGroups') {
                 echo LightGroup::getLightGroupForm();
             } else {
                 echo "<h3>Undefined Tab Selected</h3>";
             }
         }
         //continue with locks
         //thermostat etc.
         $this->display = FALSE;
     } else {
         $command = escapeshellcmd("python /var/www/python/killall.py");
         shell_exec($command);
         $command = escapeshellcmd("python /var/www/python/clear.py");
         shell_exec($command);
     }
 }
コード例 #24
0
ファイル: Shell.php プロジェクト: OCC2/occ2pacs
 /**
  * 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);
             }
         }
     }
 }
コード例 #25
0
 /**
  * Performs minification of file
  *
  * @param $data
  * @param $targetFile
  * @param $debug
  *
  * @return string
  * @throws Exception
  */
 public static function minifyFile($type, $data, $targetFile, $debug = true)
 {
     self::_validate();
     // Creates temporary file to be used for minification - throws error if file can't be created
     $tmpTargetFile = self::_createTmpFilename($targetFile);
     if (!file_put_contents(self::_createTmpFilename($targetFile), $data, LOCK_EX)) {
         throw new Exception('MergeMinify_Minification:could not create temporary file.');
     }
     $output = array();
     $status = 0;
     $command = self::_command($type, $targetFile, $tmpTargetFile, $debug);
     exec(escapeshellcmd($command) . ' 2>&1', $output, $status);
     if ($debug) {
         switch ($type) {
             case 'js':
                 Mage::log($output, null, 'JSCompression.log', true);
                 break;
             case 'css':
                 Mage::log($output, null, 'CSSCompression.log', true);
                 break;
         }
     }
     if ((int) $status != 0) {
         throw new Exception('MergeMinify_Minification:compression execution failed.');
     }
     return $output;
 }
コード例 #26
0
ファイル: pay.inc.php プロジェクト: subashemphasize/test_site
function payready_get_url($url, $post = '')
{
    if (extension_loaded("curl")) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $buffer = curl_exec($ch);
        curl_close($ch);
        return $buffer;
    } else {
        global $config;
        if (substr(php_uname(), 0, 7) == "Windows") {
            $curl = $config['curl'];
            if (!strlen($curl)) {
                fatal_error("cURL path is not set");
            }
        } else {
            $curl = escapeshellcmd($config['curl']);
            if (!strlen($curl)) {
                fatal_error("cURL path is not set");
            }
            //            $post = escapeshellcmd($post);
            $url = escapeshellcmd($url);
        }
        $ret = `{$curl} -d "{$post}" {$url}`;
        return $ret;
    }
}
コード例 #27
0
ファイル: plugin_admin.php プロジェクト: pombredanne/tuleap
function logo_create($file_location, $project_mw_images_dir)
{
    $logofile = $project_mw_images_dir . "/.wgLogo.png";
    if (!is_file($file_location) || !file_exists($file_location)) {
        return _("Invalid file upload");
    }
    $img = getimagesize($file_location);
    if (!$img || $img[2] != IMAGETYPE_PNG) {
        return _("Not a valid PNG image");
    }
    if ($img[0] != 135 || $img[1] != 135) {
        return sprintf(_("Image size is %dx%d pixels, expected %dx%d instead"), $img[0], $img[1], 135, 135);
    }
    if (!is_writable($project_mw_images_dir)) {
        return sprintf(_("Cannot copy file to target directory %s"), $project_mw_images_dir);
    }
    if (file_exists($logofile) && !is_writable($logofile)) {
        return _("Cannot overwrite existing file");
    }
    $cmd = "/bin/mv " . escapeshellcmd($file_location) . " " . escapeshellcmd($logofile);
    exec($cmd, $out);
    if (!file_exists($logofile)) {
        return _("Cannot move file to target location");
    }
    return _("New file installed successfully");
}
コード例 #28
0
 function delete($event_name, $data)
 {
     global $app, $conf;
     $this->update_config();
     exec("nohup /usr/lib/mailman/bin/rmlist -a " . escapeshellcmd($data["old"]["listname"]) . " >/dev/null 2>&1 &");
     exec('nohup ' . $conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
 }
コード例 #29
0
ファイル: targz.php プロジェクト: albertobraschi/Hab
 /**
  * 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;
 }
コード例 #30
-1
ファイル: CurlTest.php プロジェクト: lexeo/curl
 /**
  * {@inheritdoc}
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     $cmd = sprintf('kill %d', self::$webServerPid);
     exec(escapeshellcmd($cmd));
     self::$webServerPid = null;
 }