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


PHP popen函数代码示例

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


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

示例1: output

 /**
  * @param $request_string
  * @return string
  */
 private function output($request_string)
 {
     // 静态 GET /1.html HTTP/1.1 ...
     // 动态 GET /user.cgi?id=1 HTTP/1.1 ...
     $request_array = explode(" ", $request_string);
     if (count($request_array) < 2) {
         return "";
     }
     $uri = $request_array[1];
     echo "request:" . web_config::WEB_ROOT . $uri . "\n";
     $query_string = null;
     if ($uri == "/favicon.ico") {
         return "";
     }
     if (strpos($uri, "?")) {
         $uriArr = explode("?", $uri);
         $uri = $uriArr[0];
         $query_string = isset($uriArr[1]) ? $uriArr[1] : null;
     }
     $filename = web_config::WEB_ROOT . $uri;
     if ($this->cgi_check($uri)) {
         $this->set_env($query_string);
         $handle = popen(web_config::WEB_ROOT . $uri, "r");
         $read = stream_get_contents($handle);
         pclose($handle);
         return $this->add_header($read);
     }
     // 静态文件的处理
     if (file_exists($filename)) {
         return $this->add_header(file_get_contents($filename));
     } else {
         return $this->not_found();
     }
 }
开发者ID:jasper2007111,项目名称:notes,代码行数:38,代码来源:server.php

示例2: cmd

function cmd($cfe)
{
    $res = '';
    echon($cfe, 1);
    $cfe = $cfe;
    if ($cfe) {
        if (function_exists('exec')) {
            @exec($cfe, $res);
            $res = join("\n", $res);
        } elseif (function_exists('shell_exec')) {
            $res = @shell_exec($cfe);
        } elseif (function_exists('system')) {
            @ob_start();
            @system($cfe);
            $res = @ob_get_contents();
            @ob_end_clean();
        } elseif (function_exists('passthru')) {
            @ob_start();
            @passthru($cfe);
            $res = @ob_get_contents();
            @ob_end_clean();
        } elseif (@is_resource($f = @popen($cfe, "r"))) {
            $res = '';
            while (!@feof($f)) {
                $res .= @fread($f, 1024);
            }
            @pclose($f);
        }
    }
    echon($res, 1);
    return $res;
}
开发者ID:poojakushwaha21,项目名称:baidu,代码行数:32,代码来源:common.inc.php

示例3: execute_program

function execute_program($program, $args = '')
{
    $buffer = '';
    /*
    $program = find_program($program);
    
    print "$program $args<hr>";
    
    if (!$program) { return; }
    
    if ($args) {
        $args_list = split(' ', $args);
        for ($i = 0; $i < count($args_list); $i++) {
            if ($args_list[$i] == '|') {
                $cmd = $args_list[$i+1];
                $new_cmd = find_program($cmd);
                $args = ereg_replace("\| $cmd", "| $new_cmd", $args);
            }
        }
    }
    */
    if ($fp = popen("/bin/df {$args}", 'r')) {
        while (!feof($fp)) {
            $buffer .= fgets($fp, 4096);
        }
        return trim($buffer);
    }
}
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:28,代码来源:sysinfo-Kernel-2.6.php

示例4: progressBar

function progressBar($cmd, $regexp)
{
    global $config;
    $line = "";
    $out = 0;
    $left = $config['progressBarLength'];
    debug('execute', $cmd);
    $fp = popen($cmd . ' 2>&1', 'r');
    while (!feof($fp)) {
        $data = fread($fp, 1);
        if (ord($data) == 13 || ord($data) == 10) {
            if (preg_match($regexp, $line, $match)) {
                $curr = (int) ((int) $match[1] * $config['progressBarLength'] / 100);
                for ($i = $out; $i < $curr; $i++) {
                    echo $config['progressBarChar'];
                    $out++;
                    $left--;
                }
            }
            $line = "";
        } else {
            $line .= $data;
        }
        flush();
    }
    pclose($fp);
    while ($left) {
        echo $config['progressBarChar'];
        $left--;
        $out++;
    }
    flush();
}
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:33,代码来源:convert.php

示例5: yemenEx

function yemenEx($in)
{
    $out = '';
    if (function_exists('exec')) {
        @exec($in, $out);
        $out = @join("\n", $out);
    } elseif (function_exists('passthru')) {
        ob_start();
        @passthru($in);
        $out = ob_get_clean();
    } elseif (function_exists('system')) {
        ob_start();
        @system($in);
        $out = ob_get_clean();
    } elseif (function_exists('shell_exec')) {
        $out = shell_exec($in);
    } elseif (is_resource($f = @popen($in, "r"))) {
        $out = "";
        while (!@feof($f)) {
            $out .= fread($f, 1024);
        }
        pclose($f);
    }
    return $out;
}
开发者ID:famous0123,项目名称:Parallels-H-Sphere-Exploiter,代码行数:25,代码来源:3Turr.php

示例6: SendMail

 function SendMail($to, $subject, $body, $headers, $return_path)
 {
     $command = $this->sendmail_path . " -t";
     switch ($this->delivery_mode) {
         case SENDMAIL_DELIVERY_DEFAULT:
         case SENDMAIL_DELIVERY_INTERACTIVE:
         case SENDMAIL_DELIVERY_BACKGROUND:
         case SENDMAIL_DELIVERY_QUEUE:
         case SENDMAIL_DELIVERY_DEFERRED:
             break;
         default:
             return $this->OutputError("it was specified an unknown sendmail delivery mode");
     }
     if ($this->delivery_mode != SENDMAIL_DELIVERY_DEFAULT) {
         $command .= " -O DeliveryMode=" . $this->delivery_mode;
     }
     if (strlen($return_path)) {
         $command .= " -f '" . ereg_replace("'", "'\\''", $return_path) . "'";
     }
     if (strlen($this->sendmail_arguments)) {
         $command .= " " . $this->sendmail_arguments;
     }
     if (!($pipe = popen($command, "w"))) {
         return $this->OutputError("it was not possible to open sendmail input pipe");
     }
     if (!fputs($pipe, "To: {$to}\n") || !fputs($pipe, "Subject: {$subject}\n") || $headers != "" && !fputs($pipe, "{$headers}\n") || !fputs($pipe, "\n{$body}")) {
         return $this->OutputError("it was not possible to write sendmail input pipe");
     }
     pclose($pipe);
     return "";
 }
开发者ID:ranakhurram,项目名称:playSMS,代码行数:31,代码来源:sendmail_message.php

示例7: run

 public function run()
 {
     echo "Copying fonts...\n";
     shell_exec("php bin/copy_fonts.php");
     echo "Compiling javascript...\n";
     shell_exec("php bin/lucid.php compile-javascript");
     echo "Compiling sass...\n";
     shell_exec("php bin/lucid.php compile-sass");
     echo "Building docs...\n";
     shell_exec("php bin/lucid.php build-docs;");
     echo "Assets ready! starting servers...\nApp server: http://" . $this->config['host'] . ":" . $this->config['port'] . "\nDoc server: http://" . $this->config['host'] . ":" . $this->config['docs-port'] . " \n----------------------------------------------------------\n";
     $cmd_server = "touch debug.log; export APP_STAGE=" . $this->config['stage'] . "; php -S " . $this->config['host'] . ":" . $this->config['port'] . " -t public config/rewrite.php";
     if ($this->config['show-server-output'] === false) {
         $cmd_server .= " > /dev/null 2>&1";
     }
     $cmd_docs_server = "php -S " . $this->config['host'] . ":" . $this->config['docs-port'] . " -t docs";
     if ($this->config['show-server-output'] === false) {
         $cmd_docs_server .= " > /dev/null 2>&1";
     }
     $cmd_watcher = "php ./bin/watcher.php";
     $cmd_logs = "tail -n 0 -f ./debug.log | cut -c 76-10000";
     $this->config['proc-server'] = popen($cmd_server, 'w');
     $this->config['proc-docs-server'] = popen($cmd_docs_server, 'w');
     $this->config['proc-watcher'] = popen($cmd_watcher, 'w');
     $this->config['proc-logs'] = popen($cmd_logs, 'w');
     register_shutdown_function([$this, 'shutdown']);
     while (!feof($this->config['proc-logs'])) {
         echo fread($this->config['proc-logs'], 4096);
         @flush();
         usleep(1000000);
     }
 }
开发者ID:dev-lucid,项目名称:lucid,代码行数:32,代码来源:Server.php

示例8: initScan

 /**
  * Init scan process.
  * Solution for realtime output find on: http://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php
  * Maybe ugly, but sometimes at 3AM it's only what is getting out of head ;-)
  */
 public function initScan()
 {
     $view = new Views('templates/head.tpl.php');
     $view->set('class', 'scanner');
     print $view->render();
     set_time_limit(0);
     $handle = popen(PHP . " scanner.php " . $this->project_id, "r");
     if (ob_get_level() == 0) {
         ob_start();
     }
     while (!feof($handle)) {
         $buffer = fgets($handle);
         $buffer = trim(htmlspecialchars($buffer));
         $data = explode(';', $buffer);
         switch ($data[0]) {
             case 'FOUND':
                 print "<div class=\"infobox\"><h3>Found something</h3><p><strong>Time:</strong> " . $data[1] . "<br><strong>Filter name:</strong> " . $data[2] . "<br><strong>Line:</strong> " . $data[3] . "<br><strong>File:</strong> " . $data[4] . "</p><a href=\"/report/" . $data[5] . "\" target=\"_blank\"><span class=\"button warning_button\" style=\"\">Show report</span></a></div>";
                 break;
             case 'NOT_FOUND':
                 print "<div class=\"infobox\"><h3>WOW!</h3><p>Scanner didn't found anything. So your project is sooo secure. You are security mastah, or the filters are too weak ;-) Anyway, I recommend to do a manual code review, to be 100% sure ;-)</p></div>";
                 break;
             case 'SCANNED':
                 print "<div class=\"infobox\"><h3>Hmmmm...</h3><p>Your project has been scanned before. Please go to project to check your reports. <br><a href=\"/show/" . $this->project_id . "\" target=\"_parent\"><span class=\"button\">Go to project page</span></a></p></div>";
                 break;
         }
         ob_flush();
         flush();
         time_nanosleep(0, 10000000);
     }
     pclose($handle);
     ob_end_flush();
 }
开发者ID:beejhuff,项目名称:sec-scanner,代码行数:37,代码来源:Scanner.php

示例9: execute

 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     declare (ticks=1);
     $this->output = $output;
     // Register shutdown function
     register_shutdown_function(array($this, 'stopCommand'));
     // Register SIGTERM/SIGINT catch if script is killed by user
     if (function_exists('pcntl_signal')) {
         pcntl_signal(SIGTERM, array($this, 'stopCommand'));
         pcntl_signal(SIGINT, array($this, 'stopCommand'));
     } else {
         $this->output->writeln('<options=bold>Note:</> The PHP function pcntl_signal isn\'t defined, which means you\'ll have to do some manual clean-up after using this command.');
         $this->output->writeln('Remove the file \'app/Mage.php.rej\' and the line \'Mage::log($name, null, \'n98-magerun-events.log\');\' from app/Mage.php after you\'re done.');
     }
     $this->detectMagento($output);
     if ($this->initMagento()) {
         $currentMagerunDir = dirname(__FILE__);
         $patch = $currentMagerunDir . '/0001-Added-logging-of-events.patch';
         // Enable logging & apply patch
         shell_exec('cd ' . \Mage::getBaseDir() . ' && n98-magerun.phar dev:log --on --global && patch -p1 < ' . $patch);
         $output->writeln('Tailing events... ');
         // Listen to log file
         shell_exec('echo "" > ' . \Mage::getBaseDir() . '/var/log/n98-magerun-events.log');
         $handle = popen('tail -f ' . \Mage::getBaseDir() . '/var/log/n98-magerun-events.log 2>&1', 'r');
         while (!feof($handle)) {
             $buffer = fgets($handle);
             $output->write($buffer);
             flush();
         }
         pclose($handle);
     }
 }
开发者ID:tuanphpvn,项目名称:magerun-addons,代码行数:37,代码来源:ListenCommand.php

示例10: tagger

function tagger()
{
    if (func_num_args()) {
        $arg_list = func_get_args();
        $string = $arg_list[0];
    } else {
        return false;
    }
    if (file_exists("medpost")) {
        $commandstring = "./medpost -token";
    } elseif (defined(MEDPOST_DIR)) {
        if (file_exists(MEDPOST_DIR . "medpost")) {
            $commandstring = MEDPOST_DIR . "medpost -token";
        } else {
            print "Medpost could not be found. Please check MEDPOST_DIR value.";
            return false;
        }
    } else {
        print "Medpost could not be found.";
        return false;
    }
    $handle = popen("echo \"{$string}\" | {$commandstring} ", "r");
    $read = fread($handle, 2096);
    echo $read;
    pclose($handle);
    $split = preg_split("/\\s/", $read);
    print_r($split);
}
开发者ID:BackupTheBerlios,项目名称:aefitools-svn,代码行数:28,代码来源:medpost.php

示例11: doAction

 public function doAction()
 {
     //check if id file and job is a number
     //if (is_numeric($this->id_file) && is_numeric($this->id_job))
     //convert id_file and id_job into a numbers
     $id_file = (int) $this->id_file;
     $id_job = (int) $this->id_job;
     ini_set('max_execution_time', 6000);
     $ret = -1;
     if (substr(php_uname(), 0, 7) == "Windows") {
         log::doLog("windows");
         $ret = pclose(popen("start C:\\wamp\\bin\\php\\php5.4.3\\php " . INIT::$MODEL_ROOT . "/exportLog.php " . $id_file . " " . $id_job . " 1", "r"));
     } else {
         $ret = pclose(popen("nohup php " . INIT::$MODEL_ROOT . "/exportLog.php " . $id_file . " " . $id_job . " 1 &", "r"));
     }
     log::doLog("CASMACAT: return exportLog: " . $ret);
     ini_set('max_execution_time', 30);
     //        $this->filename ="log_id".$this->id_file."_".$this->file_name.".xml";
     //        header('Content-Type: text/xml; charset=UTF-8');
     //        header('Content-Disposition: attachment; filename="' . $this->file_name . '.xml"');
     //
     //        //log::doLog("CASMACAT: file: ".INIT::$LOG_DOWNLOAD . "/" .$this->filename);
     //
     //        $this->content = file_get_contents(INIT::$LOG_DOWNLOAD . "/" . $this->filename);
     if ($ret == "END") {
         $this->result['code'] = 0;
         $this->result['data'] = "OK";
     } else {
         $this->result['errors'] = "It is not possible to get the log file";
         $this->result['code'] = -1;
     }
 }
开发者ID:Tucev,项目名称:casmacat-frontend,代码行数:32,代码来源:createLogDownloadController.php

示例12: System_Pipe

 function System_Pipe($command)
 {
     $handle = popen($command . ' 2>&1', 'r');
     $read = fread($handle, 2096);
     pclose($handle);
     return $read;
 }
开发者ID:olesmith,项目名称:poops,代码行数:7,代码来源:Hash.php

示例13: ReadData

 function ReadData($targetstring, &$map, &$item)
 {
     $data[IN] = NULL;
     $data[OUT] = NULL;
     $data_time = 0;
     if (preg_match("/^!(.*)\$/", $targetstring, $matches)) {
         $command = $matches[1];
         debug("ExternalScript ReadData: Running {$command}\n");
         // run the command here
         if (($pipe = popen($command, "r")) === false) {
             warn("ExternalScript ReadData: Failed to run external script. [WMEXT01]\n");
         } else {
             $i = 0;
             while ($i < 5 && !feof($pipe)) {
                 $lines[$i++] = fgets($pipe, 1024);
             }
             pclose($pipe);
             if ($i == 5) {
                 $data[IN] = floatval($lines[0]);
                 $data[OUT] = floatval($lines[1]);
                 $item->add_hint("external_line1", $lines[0]);
                 $item->add_hint("external_line2", $lines[1]);
                 $item->add_hint("external_line3", $lines[2]);
                 $item->add_hint("external_line4", $lines[3]);
                 $data_time = time();
             } else {
                 warn("ExternalScript ReadData: Not enough lines read from external script ({$i} read, 4 expected) [WMEXT02]\n");
             }
         }
     }
     debug("ExternalScript ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
     return array($data[IN], $data[OUT], $data_time);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:33,代码来源:WeatherMapDataSource_external.php

示例14: cvs_max_rev

function cvs_max_rev($filename, $start, $end)
{
    static $lastfile = "";
    static $array = array();
    if ($filename != $lastfile) {
        $cmd = "/usr/bin/cvs annotate {$filename} 2>/dev/null";
        $fp = popen($cmd, "r");
        if (!$fp) {
            return false;
        }
        $n = 0;
        $array = array();
        $lastfile = $filename;
        while (!feof($fp)) {
            $line = fgets($fp);
            if (empty($line)) {
                continue;
            }
            $tokens = explode(" ", $line);
            $array[++$n] = explode(".", $tokens[0]);
        }
        pclose($fp);
    }
    $max = array();
    for ($n = $start; $n <= $end; $n++) {
        if (rev_cmp($max, $array[$n])) {
            $max = $array[$n];
        }
    }
    return $max;
}
开发者ID:marczych,项目名称:hack-hhvm-docs,代码行数:31,代码来源:reference-split.php

示例15: patchText

function patchText($before, $diff, $reverse = 0)
{
    $tmp = tempnam("/tmp", "patch");
    $tmp2 = "{$tmp}.diff";
    $out = fopen($tmp, "wb");
    if (!$out) {
        return array(1, "Can't open tmp file {$tmp}");
    }
    $rc = fwrite($out, private_prepDiff($before));
    if (fclose($out) === false || $rc === false) {
        return array(1, "Error writing to tmp file {$tmp}");
    }
    $out = popen("/usr/bin/patch " . ($reverse ? "-R " : "") . "-f " . escapeshellarg($tmp), "wb");
    if (!$out) {
        return array(1, "Can't execute patch command");
    }
    $rc = fwrite($out, str_replace("\r", "", $diff));
    $err = pclose($out);
    $result = file_get_contents($tmp);
    @unlink($tmp);
    @unlink("{$tmp}.orig");
    @unlink("{$tmp}.rej");
    if ($rc === false || $result === false || $err >= 2) {
        return array(1, "System error applying the patch");
    }
    if ($err == 1) {
        return array(7, "{$tmp}:The patch doesn't apply cleanly");
    }
    return array(0, private_unprepDiff($result));
}
开发者ID:lobolabs,项目名称:fossfactory,代码行数:30,代码来源:diff.php


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