本文整理汇总了PHP中find_program函数的典型用法代码示例。如果您正苦于以下问题:PHP find_program函数的具体用法?PHP find_program怎么用?PHP find_program使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_program函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute_program
function execute_program($program, $args = '')
{
$buffer = '';
$program = find_program($program);
if (!$program) {
return;
}
// see if we've gotten a |, if we have we need to do patch checking on the cmd
if ($args) {
$args_list = preg_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 = preg_replace('/\\| ' . preg_quote($cmd, '/') . '/', '| ' . $new_cmd, $args);
}
}
}
// we've finally got a good cmd line.. execute it
if ($fp = popen($program . ' ' . $args, 'r')) {
while (!feof($fp)) {
$buffer .= fgets($fp, 4096);
}
return trim($buffer);
}
}
示例2: execute_program
function execute_program($strProgramname, $strArgs = '', &$strBuffer, $booErrorRep = true)
{
$error = Error::singleton();
$strBuffer = '';
$strError = '';
$strProgram = find_program($strProgramname);
if (!$strProgram) {
if ($booErrorRep) {
$error->addError('find_program(' . $strProgramname . ')', 'program not found on the machine');
}
return false;
}
// see if we've gotten a |, if we have we need to do patch checking on the cmd
if ($strArgs) {
$arrArgs = explode(' ', $strArgs);
for ($i = 0; $i < count($arrArgs); $i++) {
if ($arrArgs[$i] == '|') {
$strCmd = $arrArgs[$i + 1];
$strNewcmd = find_program($strCmd);
$strArgs = ereg_replace("\\| " . $strCmd, "| " . $strNewcmd, $strArgs);
}
}
}
// no proc_open() below php 4.3
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$process = proc_open($strProgram . " " . $strArgs, $descriptorspec, $pipes);
if (is_resource($process)) {
while (!feof($pipes[1])) {
$strBuffer .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
while (!feof($pipes[2])) {
$strError .= fgets($pipes[2], 1024);
}
fclose($pipes[2]);
}
$return_value = proc_close($process);
$strError = trim($strError);
$strBuffer = trim($strBuffer);
//if( ! empty( $strError ) || $return_value <> 0 ) {
if (!empty($strError)) {
if ($booErrorRep) {
$error->addError($strProgram, $strError . "\nReturn value: " . $return_value);
}
return false;
}
return true;
}
示例3: execute_program
function execute_program($program, $args = '')
{
$buffer = '';
$program = find_program($program);
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);
}
}
}
}
示例4: DeleteRules
function DeleteRules()
{
$d = 0;
$iptables_save = find_program("iptables-save");
exec("{$iptables_save} > /etc/artica-postfix/iptables-mikrotik.conf");
$data = file_get_contents("/etc/artica-postfix/iptables-mikrotik.conf");
$datas = explode("\n", $data);
$pattern2 = "#.+?ArticaMikroTik#";
$iptables_restore = find_program("iptables-restore");
while (list($num, $ligne) = each($datas)) {
if ($ligne == null) {
continue;
}
if (preg_match($pattern2, $ligne)) {
echo "Remove {$ligne}\n";
$d++;
continue;
}
$conf = $conf . $ligne . "\n";
}
file_put_contents("/etc/artica-postfix/iptables-mikrotik.new.conf", $conf);
system("{$iptables_restore} < /etc/artica-postfix/iptables-mikrotik.new.conf");
}
示例5: ini_set
<?php
ini_set('display_errors', 1);
ini_set('html_errors', 0);
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
$iptables_save = find_program("iptables-save");
$iptables_restore = find_program("iptables-restore");
system("{$iptables_save} > /etc/artica-postfix/iptables.conf");
$data = file_get_contents("/etc/artica-postfix/iptables.conf");
$datas = explode("\n", $data);
$pattern = "#.+?ArticaIpRoute2#";
$d = 0;
$conf = null;
while (list($num, $ligne) = each($datas)) {
if ($ligne == null) {
continue;
}
if (preg_match($pattern, $ligne)) {
$d++;
continue;
}
$conf = $conf . $ligne . "\n";
}
file_put_contents("/etc/artica-postfix/iptables.new.conf", $conf);
system("{$iptables_restore} < /etc/artica-postfix/iptables.new.conf");
function find_program($strProgram)
{
global $addpaths;
$arrPath = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin', '/usr/kerberos/bin', '/usr/libexec');
if (function_exists("is_executable")) {
示例6: execute_program
function execute_program($programname, $args = '', $booErrorRep = true)
{
global $error;
$buffer = '';
$program = find_program($programname);
if (!$program) {
if ($booErrorRep) {
$error->addError('find_program(' . $programname . ')', 'program not found on the machine', __LINE__, __FILE__);
}
return;
}
// see if we've gotten a |, if we have we need to do patch checking on the cmd
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);
}
}
}
// we've finally got a good cmd line.. execute it
if ($fp = popen("({$program} {$args} > /dev/null) 3>&1 1>&2 2>&3", 'r')) {
while (!feof($fp)) {
$buffer .= fgets($fp, 4096);
}
pclose($fp);
$buffer = trim($buffer);
if (!empty($buffer)) {
if ($booErrorRep) {
$error->addError($program, $buffer, __LINE__, __FILE__);
}
}
}
if ($fp = popen("{$program} {$args}", 'r')) {
$buffer = "";
while (!feof($fp)) {
$buffer .= fgets($fp, 4096);
}
pclose($fp);
}
$buffer = trim($buffer);
return $buffer;
}
示例7: GetMacFromIP
function GetMacFromIP($ipaddr)
{
$ipaddr = trim($ipaddr);
$ttl = date('YmdH');
if (count($GLOBALS["CACHEARP"]) > 3) {
unset($GLOBALS["CACHEARP"]);
}
if (isset($GLOBALS["CACHEARP"][$ttl][$ipaddr])) {
return $GLOBALS["CACHEARP"][$ttl][$ipaddr];
}
if (!isset($GLOBALS["SBIN_ARP"])) {
$GLOBALS["SBIN_ARP"] = find_program("arp");
}
if (!isset($GLOBALS["SBIN_ARPING"])) {
$GLOBALS["SBIN_ARPING"] = find_program("arping");
}
if (strlen($GLOBALS["SBIN_ARPING"]) > 3) {
$cmd = "{$GLOBALS["SBIN_ARPING"]} {$ipaddr} -c 1 -r 2>&1";
exec($cmd, $results);
while (list($num, $line) = each($results)) {
if (preg_match("#^([0-9a-zA-Z\\:]+)#", $line, $re)) {
$GLOBALS["CACHEARP"][$ttl][$ipaddr] = $re[1];
return $GLOBALS["CACHEARP"][$ttl][$ipaddr];
}
}
}
$results = array();
if (strlen($GLOBALS["SBIN_ARP"]) < 4) {
return;
}
if (!isset($GLOBALS["SBIN_PING"])) {
$GLOBALS["SBIN_PING"] = find_program("ping");
}
if (!isset($GLOBALS["SBIN_NOHUP"])) {
$GLOBALS["SBIN_NOHUP"] = find_program("nohup");
}
$cmd = "{$GLOBALS["SBIN_ARP"]} -n \"{$ipaddr}\" 2>&1";
WLOG($cmd);
exec($cmd, $results);
while (list($num, $line) = each($results)) {
if (preg_match("#^[0-9\\.]+\\s+.+?\\s+([0-9a-z\\:]+)#", $line, $re)) {
if ($re[1] == "no") {
continue;
}
$GLOBALS["CACHEARP"][$ttl][$ipaddr] = $re[1];
return $GLOBALS["CACHEARP"][$ttl][$ipaddr];
}
}
if (!isset($GLOBALS["PINGEDHOSTS"][$ipaddr])) {
shell_exec("{$GLOBALS["SBIN_NOHUP"]} {$GLOBALS["SBIN_PING"]} {$ipaddr} -c 3 >/dev/null 2>&1 &");
$GLOBALS["PINGEDHOSTS"][$ipaddr] = true;
}
}
示例8: disable_iptables
function disable_iptables()
{
$d = 0;
$data = file_get_contents("/etc/artica-postfix/iptables.conf");
$datas = explode("\n", $data);
$pattern2 = "#.+?ArticaWCCP3#";
$iptables_save = find_program("iptables-save");
$conf = null;
while (list($num, $ligne) = each($datas)) {
if ($ligne == null) {
continue;
}
if (preg_match($pattern2, $ligne)) {
$d++;
continue;
}
$conf = $conf . $ligne . "\n";
}
if ($d == 0) {
return;
}
$iptables_restore = find_program("iptables-restore");
file_put_contents("/etc/artica-postfix/iptables.new.conf", $conf);
system("{$iptables_restore} < /etc/artica-postfix/iptables.new.conf");
build_progress("Removing {$d} iptables rule(s) done", 50);
echo "Starting......: " . date("H:i:s") . " Squid Check WCCP mode: removing {$d} iptables rule(s) done...\n";
}
示例9: execute_program
function execute_program($strProgramname, $strArgs = '', $booErrorRep = true)
{
global $error;
$strBuffer = '';
$strProgram = find_program($strProgramname);
if (!$strProgram) {
if ($booErrorRep) {
$error->addError('find_program(' . $strProgramname . ')', 'program not found on the machine', __LINE__, __FILE__);
}
return "ERROR";
}
// see if we've gotten a |, if we have we need to do patch checking on the cmd
if ($strArgs) {
$arrArgs = split(' ', $strArgs);
for ($i = 0; $i < count($arrArgs); $i++) {
if ($arrArgs[$i] == '|') {
$strCmd = $arrArgs[$i + 1];
$strNewcmd = find_program($strCmd);
$strArgs = ereg_replace("\\| " . $strCmd, "| " . $strNewcmd, $strArgs);
}
}
}
// we've finally got a good cmd line.. execute
if ($fp = popen("(" . $strProgram . " " . $strArgs . " > /dev/null) 3>&1 1>&2 2>&3", 'r')) {
while (!feof($fp)) {
$strBuffer .= fgets($fp, 4096);
}
pclose($fp);
$strBuffer = trim($strBuffer);
if (!empty($strBuffer)) {
if ($booErrorRep) {
$error->addError($strProgram, $strBuffer, __LINE__, __FILE__);
}
return "ERROR";
}
}
if ($fp = popen($strProgram . " " . $strArgs, 'r')) {
$strBuffer = "";
while (!feof($fp)) {
$strBuffer .= fgets($fp, 4096);
}
pclose($fp);
}
$strBuffer = trim($strBuffer);
return $strBuffer;
}
示例10: find_program
return $year . '-' . $month . '-' . $day . ' ' . $time;
}
function find_program($program, $url)
{
$content = file($url);
$result = array();
$i = 0;
$row = 0;
foreach ($content as $c) {
if (strpos($c, $program) != 0) {
$row = $i;
break;
}
$i++;
}
if ($row) {
$broadcast_row = $content[$row + 1];
$target_row = clear_elements($content[$row + 3]);
$broadcast_date = format_date(clear_elements($broadcast_row));
$pid = substr($target_row, 0, strpos($target_row, '&'));
return array('program' => $program, 'pid' => $pid, 'broadcast_date' => $broadcast_date, 'broadcast_timestamp' => strtotime($broadcast_date));
}
return 'No program found';
}
$data[] = array('url' => 'http://www.iplayerconverter.co.uk/r/1/aod/default.aspx', 'program' => 'Ready for the Weekend');
$data[] = array('url' => 'http://www.iplayerconverter.co.uk/r/56/aod/default.aspx', 'program' => 'Graham Torrington Night Time');
$data[] = array('url' => 'http://www.iplayerconverter.co.uk/r/4/aod/default.aspx', 'program' => 'Material World');
$data[] = array('url' => 'http://www.iplayerconverter.co.uk/r/4/aod/default.aspx', 'program' => 'Farming Today');
foreach ($data as $d) {
scraperwiki::save(array('program'), find_program($d['program'], $d['url']));
}
示例11: x_lvdisplay_size
function x_lvdisplay_size($vg, $lv)
{
if ($lv == null) {
writelogs_framework("{$vg}: LV is null", __FUNCTION__, __FILE__, __LINE__);
return array();
}
$unix = new unix();
$df = find_program("df");
$mapper = "/dev/mapper/{$vg}-{$lv}";
$cmd = "{$df} -B K {$mapper} 2>&1";
exec($cmd, $results);
writelogs_framework("{$cmd} " . count($results) . " rows", __FUNCTION__, __FILE__, __LINE__);
while (list($num, $line) = each($results)) {
if (preg_match("#([0-9]+)K\\s+([0-9]+)K\\s+([0-9]+)K\\s+([0-9]+)%\\s+\\/#", $line, $re)) {
return array("USED" => $re[2], "FREE" => $re[3], "POURC" => $re[4]);
}
}
return array();
}
示例12: UseStatsAppliance
function UseStatsAppliance()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$sock = new sockets();
$unix = new unix();
$tempdir = $unix->TEMP_DIR();
$RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
$RemoteStatisticsApplianceSettings["SSL"] = 1;
}
if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
$RemoteStatisticsApplianceSettings["PORT"] = 9000;
}
$GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
$GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
$GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
$unix = new unix();
$hostname = $unix->hostname_g();
if ($GLOBALS["REMOTE_SSL"] == 1) {
$refix = "https";
} else {
$refix = "http";
}
$uri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases/dnsmasq.conf";
$curl = new ccurl($uri, true);
if (!$curl->GetFile("{$tempdir}/dnsmasq.conf")) {
ufdbguard_admin_events("Failed to download dnsmasq.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "dns-compile");
return;
}
$mv = $unix->find_program("mv");
$cp = unix - find_program("cp");
$chmod = $unix->find_program("chmod");
shell_exec("{$mv} {$tempdir}/dnsmasq.conf /etc/dnsmasq.conf");
shell_exec("cp /etc/dnsmasq.conf /etc/artica-postfix/settings/Daemons/DnsMasqConfigurationFile");
$dnsmasqbin = $unix->find_program("dnsmasq");
if (is_file($dnsmasqbin)) {
$pid = $unix->PIDOF($dnsmasqbin);
if (is_numeric($pid)) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} reloading PID:`{$pid}`\n";
$kill = $unix->find_program("kill");
unix_system_HUP($pid);
}
}
}
示例13: SquidParentRemove
function SquidParentRemove()
{
$iptables_save = find_program("iptables-save");
$iptables_restore = find_program("iptables-restore");
$conf = null;
system("{$iptables_save} > /etc/artica-postfix/iptables.conf");
$data = file_get_contents("/etc/artica-postfix/iptables.conf");
$datas = explode("\n", $data);
$pattern = "#.+?ArticaSquidChilds#";
$d = 0;
while (list($num, $ligne) = each($datas)) {
if ($ligne == null) {
continue;
}
if (preg_match($pattern, $ligne)) {
$d++;
continue;
}
$conf = $conf . $ligne . "\n";
}
file_put_contents("/etc/artica-postfix/iptables.new.conf", $conf);
system("{$iptables_restore} < /etc/artica-postfix/iptables.new.conf");
echo "Starting......: " . date("H:i:s") . " Squid Check Parent mode: removing {$d} iptables rule(s) done...\n";
}
示例14: execute_program
function execute_program($strProgramname, $strArgs = '', $booErrorRep = true)
{
global $error;
$strBuffer = '';
$strError = '';
$strProgram = find_program($strProgramname);
if (!$strProgram) {
if ($booErrorRep) {
$error->addError('find_program(' . $strProgramname . ')', 'program not found on the machine', __LINE__, __FILE__);
}
return "ERROR";
}
// see if we've gotten a |, if we have we need to do patch checking on the cmd
if ($strArgs) {
$arrArgs = split(' ', $strArgs);
for ($i = 0; $i < count($arrArgs); $i++) {
if ($arrArgs[$i] == '|') {
$strCmd = $arrArgs[$i + 1];
$strNewcmd = find_program($strCmd);
$strArgs = ereg_replace("\\| " . $strCmd, "| " . $strNewcmd, $strArgs);
}
}
}
// no proc_open() below php 4.3
if (function_exists('proc_open')) {
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$process = proc_open($strProgram . " " . $strArgs, $descriptorspec, $pipes);
if (is_resource($process)) {
while (!feof($pipes[1])) {
$strBuffer .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
while (!feof($pipes[2])) {
$strError .= fgets($pipes[2], 1024);
}
fclose($pipes[2]);
}
$return_value = proc_close($process);
} else {
if ($fp = popen("(" . $strProgram . " " . $strArgs . " > /dev/null) 3>&1 1>&2 2>&3", 'r')) {
while (!feof($fp)) {
$strError .= fgets($fp, 4096);
}
pclose($fp);
}
$strError = trim($strError);
if ($fp = popen($strProgram . " " . $strArgs, 'r')) {
while (!feof($fp)) {
$strBuffer .= fgets($fp, 4096);
}
$return_value = pclose($fp);
}
}
$strError = trim($strError);
$strBuffer = trim($strBuffer);
if (!empty($strError) || $return_value != 0) {
if ($booErrorRep) {
$error->addError($strProgram, $strError . "\nReturn value: " . $return_value, __LINE__, __FILE__);
}
}
return $strBuffer;
}