本文整理汇总了PHP中Shell::setFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Shell::setFilter方法的具体用法?PHP Shell::setFilter怎么用?PHP Shell::setFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shell
的用法示例。
在下文中一共展示了Shell::setFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($message)
{
global $pluginManager;
global $t;
$t->setPlugin("netutils");
$reply = "";
$data = $message->getData();
$shell = new Shell();
$execute = true;
$call = $message->getCommand();
array_shift($data);
switch ($call) {
case "nslookup":
$shell->setFilter(array("main" => "nslookup", "subarg" => array()));
$cmd = "nslookup " . implode(" ", $data);
break;
case "dig":
$shell->setFilter(array("main" => "dig", "subarg" => array()));
$cmd = "dig " . implode(" ", $data);
break;
case "nmap":
$shell->setFilter(array("main" => "nmap", "subarg" => array()));
$cmd = "nmap " . implode(" ", $data);
break;
case "whois":
$shell->setFilter(array("main" => "whois", "subarg" => array()));
$cmd = "whois " . implode(" ", $data);
break;
default:
$reply = $t->g("default");
$execute = false;
break;
}
if ($execute) {
$shell->setCmd($cmd);
if ($shell->execute()) {
$reply = "`\$ " . api::encodePlain($cmd) . "\n" . api::encodePlain(implode("\n", $shell->getOutput())) . "`";
} else {
$reply = sprintf($t->g("command_error"), api::encodePlain($cmd));
}
}
// Api::reply($message, $reply, true);
global $api;
$api->sendMessage($message->chat->id, $reply, "Markdown", true);
}