本文整理汇总了PHP中string_to_regex函数的典型用法代码示例。如果您正苦于以下问题:PHP string_to_regex函数的具体用法?PHP string_to_regex怎么用?PHP string_to_regex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了string_to_regex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: events_list
function events_list()
{
include_once dirname(__FILE__) . "/ressources/class.status.logs.inc";
$sock = new sockets();
$users = new usersMenus();
$query = base64_encode(string_to_regex($_POST["query"]));
$array = explode("\n", base64_decode($sock->getFrameWork("freeweb.php?query-logs=yes&servername={$_GET["servername"]}&filter={$query}&rp={$_POST["rp"]}&type={$_GET["type"]}")));
if ($_POST["sortorder"] == "desc") {
krsort($array);
} else {
ksort($array);
}
while (list($index, $line) = each($array)) {
$date = null;
if (preg_match("#\\[(.+?)\\]\\s+\\[(.*?)\\]\\s+(.+)#", $line, $re)) {
$date = "{$re[1]}";
$errortype = $re[2];
$line = $re[3];
if (preg_match("#\\[client\\s+(.+?)\\]#", $line, $re)) {
$line = str_replace($re[0], "", $line);
$line = "[" . $re[1] . "] " . $line;
}
}
if (preg_match("#(.+?) - (.*?) \\[(.+?)\\]\\s+(.+)#", $line, $re)) {
$date = "{$re[3]}";
$time = strtotime($date);
if (date('Y-m-d', $time) == date("Y-m-d")) {
$dateText = date("H:i:s", $time);
} else {
$dateText = date("H:i:s - l d", $time);
}
$errortype = $re[2];
$line = "[" . $re[1] . "] " . $re[4];
}
$line = str_replace("HTTP/1.1", "", $line);
$line = str_replace("HTTP/1.0", "", $line);
$img = statusLogs($line);
$m5 = md5($line);
if (trim($dateText) == null) {
if (preg_match("#(.+?)\\s+([0-9:]+)\\s+\\[(.+?)\\]\\s+([0-9]+)\\#[0-9]+:(.+)#", $line, $re)) {
$re[1] = str_replace(date("Y/m/d"), "", $re[1]);
$dateText = $re[1] . " " . $re[2];
$errortype = $re[3];
$line = $re[5];
}
}
$data['rows'][] = array('id' => "dom{$m5}", 'cell' => array("\n\t\t\t\t\t\t<span style='font-size:12px'>{$dateText}</span>", "<span style='font-size:12px'>{$errortype}</span>", "<img src='{$img}'>", "<span style='font-size:12px'>{$line}</span>"));
}
$data['page'] = 1;
$data['total'] = count($array);
echo json_encode($data);
}
示例2: item_rules
function item_rules()
{
$t = $_GET["t"];
$sock = new sockets();
if ($_POST["query"] != null) {
$search = "&search=" . base64_encode(string_to_regex($_POST["query"]));
}
$datas = unserialize(base64_decode($sock->getFrameWork("services.php?iptables-dump=yes&rp={$_POST["rp"]}{$search}")));
if (count($datas) == 0) {
json_error_show("No data");
}
$tpl = new templates();
$data = array();
$data['page'] = 1;
$data['total'] = 0;
$data['rows'] = array();
$c = 0;
while (list($num, $val) = each($datas)) {
if (substr($val, 0, 1) == "#") {
continue;
}
if (!preg_match("#(^[0-9]+)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+)#", $val, $re)) {
continue;
}
$index = $re[1];
$target = $re[2];
$protocol = $re[3];
$opt = $re[4];
$src = $re[5];
$dest = $re[6];
$c++;
if (strpos($dest, "/") > 0) {
$tt = explode("/", $dest);
$dest = $tt[0];
}
if (preg_match("#(.+?)\\s+tcp(.+)#", $dest, $re)) {
$dest = $re[1];
$protocol = $re[2];
}
$protocol = str_replace("dpt:ssh", "SSH (22)", $protocol);
$dest = str_replace("anywhere", "{anywhere}", $dest);
$line = $tpl->_ENGINE_parse_body("{$target} {from} <strong>{$src}</strong> {to} {$dest} {protocol} {$protocol}");
$del = imgsimple("delete-24.png", null, "Delete{$t}('{$index}')");
$data['rows'][] = array('id' => "{$num}", 'cell' => array("<span style='font-size:12px;color:{$color}'>[{$index}]: {$line}</a></span>", "<span style='font-size:12px;color:{$color}'>{$del}</a></span>"));
}
$data['total'] = $c;
echo json_encode($data);
}
示例3: dmesg_search
function dmesg_search()
{
$sock = new sockets();
$array = unserialize(base64_decode($sock->getFrameWork("services.php?dmesg=yes")));
if (!is_array($array)) {
json_error_show("Fatal, no such data");
}
$search = string_to_regex($_POST["query"]);
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$pageEnd = $pageStart + $rp;
if ($pageEnd <= 0) {
$pageEnd = $rp;
}
//json_error_show("Start:$pageStart, end:$pageEnd");
if ($_POST["sortorder"] == "desc") {
krsort($array);
}
$data = array();
$data['page'] = $page;
$data['total'] = count($array);
$data['rows'] = array();
$c = 0;
while (list($key, $line) = each($array)) {
if ($line == null) {
continue;
}
if ($search != null) {
if (!preg_match("#{$search}#i", $line)) {
continue;
}
}
$c++;
if ($c <= $pageStart) {
continue;
}
if ($c > $pageEnd) {
break;
}
$data['rows'][] = array('id' => md5($line), 'cell' => array("{$spanOn}{$line}</span>"));
}
echo json_encode($data);
}
示例4: search
function search()
{
$hostname = $_GET["hostname"];
$tpl = new templates();
$page = CurrentPageName();
$main = new maincf_multi($_GET["hostname"]);
$datas = unserialize(base64_decode($main->GET_BIGDATA("debug_peer_list")));
if (count($datas) == 0) {
json_error_show("No data...");
}
$t = $_GET["t"];
if ($_POST["query"] != null) {
$search = string_to_regex($_POST["query"]);
}
$data = array();
$data['page'] = 1;
$data['total'] = $total;
$data['rows'] = array();
$c = 0;
while (list($num, $ligne) = each($datas)) {
if ($num == null) {
continue;
}
if ($search != null) {
if (!preg_match("#{$search}#i", $num)) {
continue;
}
}
$id = md5($num);
$delete = imgsimple("delete-32.png", "{delete}", "debug_peer_list_del('{$num}','{$id}')");
$c++;
$data['rows'][] = array('id' => $id, 'cell' => array("<strong style='font-size:18px;style='color:{$color}'>{$href}{$num}</a></strong>", $delete));
}
$data['total'] = $c;
echo json_encode($data);
}
示例5: xapsearch
function xapsearch(){
$tpl=new templates();
//$GLOBALS["VERBOSE"]=true;ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);
if(!isset($_POST["xapsearch"])){if(isset($_GET["xapsearch"])){$_POST["xapsearch"]=$_GET["xapsearch"];}}
$xapsearch=url_decode_special_tool($_POST["xapsearch"]);
$ldap=new clladp();
$sock=new sockets();
$XapianDisableAdm=$sock->GET_INFO("XapianDisableAdm");
if(!is_numeric($XapianDisableAdm)){$XapianDisableAdm=0;}
if($XapianDisableAdm==0){
if(preg_match("#phpinfo:(.*?):(.*)#", $xapsearch,$re)){if( strtolower($ldap->ldap_admin)==strtolower($re[1]) ){if(trim($re[2])==trim($ldap->ldap_password)){$s=php_ini_path();echo "<div style='width:620px;margin-top:20px' class=form>$s</div>";}}echo $tpl->_ENGINE_parse_body("<strong style='color:red'>{failed}</strong>");return;}
if(preg_match("#status xapiandb\s+(.*?):(.*)#", $xapsearch,$re)){if( strtolower($ldap->ldap_admin)==strtolower($re[1]) ){if(trim($re[2])==trim($ldap->ldap_password)){status_xapiandb();}}return;}
if(preg_match("#chtitle\s+\"(.*?)\"\s+(.*?):(.*)#", trim($xapsearch),$re)){
if( strtolower($ldap->ldap_admin)==strtolower($re[2]) ){
if(trim($re[3])==trim($ldap->ldap_password)){
$sock=new sockets();
$sock->SET_INFO("XapianSearchTitle",$re[1]);
echo $tpl->_ENGINE_parse_body("<center style='margin-top:20px'>
<strong style='font-size:22px;color:red'>{you_have_to_reload_webpage}</strong></center>");
}
return;
}
}
}
$userid=$_COOKIE["uid"];
$ct=new user($userid);
$q=new mysql();
unset($_SESSION["xapian_folders"]);
if(!isset($_SESSION["xapian_folders"])){
$sql="SELECT * FROM xapian_folders";
$results = $q->QUERY_SQL($sql,"artica_backup");
while ($ligne = mysql_fetch_assoc($results)) {
$directory=string_to_regex($ligne["directory"]);
$_SESSION["xapian_folders"][$directory]["DOWN"]=$ligne["AllowDownload"];
$_SESSION["xapian_folders"][$directory]["FULLP"]=$ligne["DiplayFullPath"];
}
}
if($userid<>null){
$samba=new samba();
$samba_folders=$samba->GetUsrsRights($userid);
}
$users=new usersMenus();
writelogs("$userid ->AllowXapianDownload \"$users->AllowXapianDownload\"",__FUNCTION__,__FILE__);;
$xapian=new XapianSearch($_POST["lang"]);
if($_COOKIE["uid"]<>null){
if(is_dir("/usr/share/artica-postfix/LocalDatabases/xapian-{$_COOKIE["uid"]}")){
$xapian->add_database("/usr/share/artica-postfix/LocalDatabases/xapian-{$_COOKIE["uid"]}");
}
}
foreach (glob("/usr/share/artica-postfix/LocalDatabases/samba.*.db",GLOB_ONLYDIR) as $directory) {
$xapian->add_database($directory);
}
$current=$_GET["p"];
if($current==null){$current=0;}
$xapian->terms=$xapsearch;
$xapian->start=$current;
if(count($xapian->databases)>0){
writelogs("Added ".count($xapian->databases)." databases...",__FUNCTION__,__FILE__,__LINE__);
$array=$xapian->search();
}
$maxdocs=$array["ESTIMATED"];
$ssery_results=$array["DESCRIPTION"];
if($maxdocs>10){
$tabs=generateTabs($maxdocs,$current);
}
if($ct->password==null){$ct->password=$ldap->ldap_password;}
if(is_array($array["RESULTS"])){
while (list ($num, $arr) = each ($array["RESULTS"]) ){
$tr[]=FormatResponse($arr,$users,$ct->password);
}
}
$database=$tpl->_ENGINE_parse_body("{database}");
if(count($xapian->ParsedDatabases)>1){$database=$tpl->_ENGINE_parse_body("{databases}");}
$html="<div style='font-size:16px;font-weight:bold;margin:5px;text-align:right'>
{found} {$array["ESTIMATED"]} {documents} {in} <strong>" . count($xapian->ParsedDatabases)." $database</strong></div>";
$tpl=new templates();
if(is_array($tr)){echo $tpl->_ENGINE_parse_body($html.$tabs.implode("\n",$tr));}else{
if($_GET["tmpmax"]>0){
//.........这里部分代码省略.........
示例6: items
function items()
{
$sock = new sockets();
$datas = unserialize(base64_decode($sock->getFrameWork("services.php?beancounters=yes")));
$res_bytes = "dgramrcvbuf|kmemsize|othersockbuf|tcprcvbuf|tcpsndbuf|";
$bytes["dgramrcvbuf"] = true;
$bytes["kmemsize"] = true;
$bytes["othersockbuf"] = true;
$bytes["tcprcvbuf"] = true;
$bytes["tcpsndbuf"] = true;
$pagesB["privvmpages"] = true;
$pagesB["vmguarpages"] = true;
$pagesB["shmpages"] = true;
if ($_POST["query"] != null) {
$search = string_to_regex($_POST["query"]);
}
$data = array();
$data['page'] = 1;
$data['total'] = 0;
$data['rows'] = array();
$c = 0;
while (list($num, $ligne) = each($datas)) {
$ligne = str_replace("\r", "", $ligne);
$ligne = str_replace("\n", "", $ligne);
if (!preg_match("#.*?\\s+([a-z]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)#", $ligne, $re)) {
continue;
}
$resource = $re[1];
$held = $re[2];
$maxheld = $re[3];
$barrier = $re[4];
$limit = $re[5];
$failcnt = $re[6];
if ($search != null) {
if (!preg_match("#{$search}#", $resource)) {
continue;
}
}
if (isset($bytes[$resource])) {
$held = FormatBytes($held / 1024);
$maxheld = FormatBytes($maxheld / 1024);
$barrier = FormatBytes($barrier / 1024);
$limit = FormatBytes($limit / 1024);
}
if (isset($pagesB[$resource])) {
$held = $held * 4096;
$maxheld = $maxheld * 4096;
$barrier = $barrier * 4096;
$limit = $limit * 4096;
$held = FormatBytes($held / 1024);
$maxheld = FormatBytes($maxheld / 1024);
$barrier = FormatBytes($barrier / 1024);
$limit = FormatBytes($limit / 1024);
}
$failcnt_color = "black";
if ($failcnt > 0) {
$failcnt_color = "#D31B1B";
}
$c++;
$data['rows'][] = array('id' => md5($ligne), 'cell' => array("<span style='font-size:14px'>{$resource}</span>", "<span style='font-size:14px'>{$held}</span>", "<span style='font-size:14px'>{$maxheld}</span>", "<span style='font-size:14px'>{$barrier}</span>", "<span style='font-size:14px'>{$limit}</span>", "<span style='font-size:14px;color:{$failcnt_color}'>{$failcnt}</span>"));
}
$data['total'] = $c;
echo json_encode($data);
}
示例7: items
function items()
{
//ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
$tpl = new templates();
$MyPage = CurrentPageName();
$sock = new sockets();
$tSource = $_GET["t"];
$taskname = $_GET["taskname"];
$taskslogs = unserialize(base64_decode($sock->getFrameWork("klms.php?get-task-logs=yes")));
if (!isset($_GET["taskfile"])) {
$_GET["taskfile"] = $taskslogs[$taskname][0];
}
$search = '';
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if ($_POST["query"] != null) {
$_POST["query"] = string_to_regex($_POST["query"]);
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$limitSql = "LIMIT {$pageStart}, {$rp}";
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$sock = new sockets();
$search = base64_encode(string_to_regex($_POST["query"]));
$events = unserialize(base64_decode($sock->getFrameWork("klms.php?get-task-events=yes&taskfile={$_GET["taskfile"]}&search={$search}&rp={$_POST["rp"]}")));
while (list($taskname, $ligne) = each($events)) {
$id = md5($ligne);
if (trim($ligne) == null) {
continue;
}
if (preg_match("#(.*)\\s+([0-9\\:]+)\\.[0-9]+.*?\\s+[0-9a-z]+\\s+(.*?)\\s+(.*)#", $ligne, $re)) {
$date = strtotime("{$re[1]} {$re[2]}");
$zdate = date("Y-m-d H:i:s");
$pid = $re[3];
$event = $re[4];
} else {
$event = $ligne;
}
$data['rows'][] = array('id' => "Rtask{$id}", 'cell' => array("<span style='font-size:12px;'>{$zdate}</span>", "<span style='font-size:12px;'>{$pid}</span>", "<span style='font-size:12px;'>{$event}</span>"));
$data['total'] = $c;
}
echo json_encode($data);
}
示例8: events_list_list
function events_list_list()
{
$myPage = CurrentPageName();
$tpl = new templates();
$q = new mysql();
$sql = "SELECT events FROM setup_center WHERE CODE_NAME='{$_GET["CODE_NAME"]}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
echo json_error_show("<code>{$q->mysql_error}</code>");
}
if (trim($ligne["events"]) == null) {
if (is_file("ressources/install/{$_GET["CODE_NAME"]}.dbg")) {
$array = file("ressources/install/{$_GET["CODE_NAME"]}.dbg");
}
} else {
$array = explode("\n", $ligne["events"]);
}
$data = array();
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
$rp = $_POST["rp"];
$pageStart = ($page - 1) * $rp;
$pageEnd = $pageStart + $rp;
//echo "<H2>$pageStart -> $pageEnd</H2>";
$data['page'] = $page;
$data['total'] = count($array);
$data['rows'] = array();
$search = $_POST["query"];
$search = string_to_regex($search);
if ($_POST["sortorder"] == "desc") {
krsort($array);
}
$c = 0;
while (list($num, $ligne) = each($array)) {
if (trim($ligne) == null) {
continue;
}
if (preg_match("#\\s+[0-9\\.]+%#", $ligne)) {
continue;
}
if (strpos($ligne, "###") > 0) {
continue;
}
if ($search != null) {
if (!preg_match("#{$search}#", $ligne)) {
continue;
}
}
$c++;
if ($pageStart > 0) {
if ($c <= $pageStart) {
continue;
}
}
if ($c > $pageEnd) {
break;
}
$data['rows'][] = array('id' => md5($ligne), 'cell' => array("<code style='{$style}'>{$ligne}</code>"));
}
echo json_encode($data);
}
示例9: table_list
function table_list()
{
//ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);
$page = 1;
$search = null;
$tpl = new templates();
$sock = new sockets();
if ($_POST["query"] != null) {
$search = string_to_regex($_POST["query"]);
}
$datas = unserialize(base64_decode($sock->getFrameWork("cmd.php?Dir-Files={$_GET["root"]}&queryregex=" . base64_encode($search))));
ksort($datas);
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
$pageStart = ($page - 1) * $rp;
$pageStop = $pageStart + $rp;
$data = array();
$data['page'] = $page;
$data['total'] = count($datas);
$data['rows'] = array();
$dir = str_replace("../", "", base64_decode($_GET["root"]));
$dir = str_replace("//", "/", $dir);
$today = $tpl->_ENGINE_parse_body("{today}");
$c = 0;
while (list($num, $val) = each($datas)) {
if ($pageStart > 0) {
if ($c < $pageStart) {
$c++;
continue;
}
}
$full_path = utf8_encode($dir . "/{$num}");
$array = unserialize(base64_decode($sock->getFrameWork("cmd.php?filestat=" . base64_encode($full_path))));
$owner = $array["owner"]["owner"]["name"];
if (date('Y', $array["time"]["mtime"]) == date('Y')) {
$modified = date('M D d H:i:s', $array["time"]["mtime"]);
} else {
$modified = date('Y-m-d H:i', $array["time"]["mtime"]);
}
if (date('Y-m-d', $array["time"]["mtime"]) == date('Y-m-d')) {
$modified = "{$today} " . date('H:i:s', $array["time"]["mtime"]);
}
$size = $array["size"]["size"];
$ext = Get_extension($num);
$img = "img/ext/def_small.gif";
if ($ext != null) {
if (isset($GLOBALS[$ext])) {
$img = "img/ext/{$ext}_small.gif";
} else {
if (is_file("img/ext/{$ext}_small.gif")) {
$img = "img/ext/{$ext}_small.gif";
$GLOBALS[$ext] = true;
}
}
}
$size_new = FormatBytes($size / 1024);
$text_file = $num;
if (is_dir($full_path)) {
$img = "img/folder.gif";
}
if ($size_new == 0) {
$size_new = $size . " bytes";
}
$id = md5("{$num}");
$delete = imgsimple("delete-24.png", null, "DeleteSingleFile('{$num}','{$id}')");
if ($_SESSION["uid"] != -100) {
if ($owner != $_SESSION["uid"]) {
$delete = " ";
}
}
$c++;
if ($c >= $pageStop) {
break;
}
$data['rows'][] = array('id' => $id, 'cell' => array("<img src='{$img}'>", $text_file, $size_new, $owner, $modified, $delete));
}
echo json_encode($data);
}
示例10: DOMAINSLIST_SEARCH
function DOMAINSLIST_SEARCH()
{
$ldap = new clladp();
$page = CurrentPageName();
$tpl = new templates();
$ou = $_GET["ou"];
include_once "ressources/class.amavis.inc";
$amavis = new amavis();
$amavis_oui = false;
$disclaimer = true;
$users = new usersMenus();
$users->LoadModulesEnabled();
if ($users->AMAVIS_INSTALLED) {
if ($users->EnableAmavisDaemon == 1) {
$amavis_oui = true;
}
}
$POSTFIX_INSTALLED = $users->POSTFIX_INSTALLED;
$sock = new sockets();
$disclaimer = IS_DISCLAIMER();
$HashDomains = $ldap->Hash_associated_domains($ou);
if ($GLOBALS["VERBOSE"]) {
echo count($HashDomains) . " domains for this ou = {$ou}\n";
}
$aliases = new AutoAliases($ou);
$search = string_to_regex($_POST["query"]);
$domainstyle = "font-size:16px";
if (isset($_GET["expand"])) {
$domainstyle = "font-size:18px";
}
$data = array();
$c = 0;
while (list($num, $ligne) = each($HashDomains)) {
if ($search != null) {
if (!preg_match("#{$search}#", $num)) {
continue;
}
}
$c++;
$autoalias = " ";
$disclaimer_domain = " ";
$amavis_infos = " ";
$amavis_duplicate = " ";
$js = "Loadjs('domains.relay.domains.php?domain={$num}&ou={$ou}&local=yes')";
$delete = imgtootltip("delete-24.png", '{label_delete_transport}', "DeleteInternetDomainInside('{$num}')");
if (strlen($aliases->DomainsArray[$num]) > 0) {
$autoalias = "<img src='img/20-check.png'>";
}
if ($amavis_oui) {
$amavis_infos = imgtootltip("24-parameters.png", "AS -> {$num}", "Loadjs('domains.amavis.php?domain={$num}')");
}
if ($amavis->copy_to_domain_array[strtolower($num)]["enable"] == 1) {
$amavis_duplicate = "<strong style='font-size:12px'>{$amavis->copy_to_domain_array[strtolower($num)]["duplicate_host"]}:{$amavis->copy_to_domain_array[strtolower($num)]["duplicate_port"]}";
}
if ($disclaimer) {
$disclaimer_domain = imgtootltip("24-parameters.png", "disclaimer -> {$num}", "Loadjs('domains.disclaimer.php?domain={$num}&ou={$ou}')");
}
$autoalias = $tpl->_ENGINE_parse_body($autoalias);
$data['rows'][] = array('id' => "dom-{$num}", 'cell' => array("\n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='{$domainstyle};font-weight:bold;text-decoration:underline'>{$num}</span>", "<span style='font-size:14px'>{$autoalias}</span>", "<span style='font-size:14px'>{$amavis_infos}</span>", "<span style='font-size:14px'>{$disclaimer_domain}</span>", "<span style='font-size:14px'>{$amavis_duplicate}</span>", $delete));
}
if ($c == 0) {
json_error_show("No Internet domain...");
}
$data['page'] = 1;
$data['total'] = $c;
echo json_encode($data);
}
示例11: networks_items
function networks_items()
{
$q = new mysql();
$net = new networkscanner();
$page = CurrentPageName();
$users = new usersMenus();
$sock = new sockets();
$ipBandEnabled = $sock->GET_INFO("ipBandEnabled");
if (!is_numeric($ipBandEnabled)) {
$ipBandEnabled = 0;
}
if ($ipBandEnabled) {
$q->QUERY_SQL("TRUNCATE TABLE ipband", "artica_events");
}
if (!is_array($net->networklist)) {
json_error_show("No item...");
}
$t = $_GET["t"];
while (list($num, $maks) = each($net->networklist)) {
if (trim($maks) == null) {
continue;
}
$hash[$maks] = $maks;
}
if (!$q->TABLE_EXISTS("ipban", "artica_backup")) {
$q->BuildTables();
}
$search = string_to_regex($_POST["query"]);
$data = array();
$data['page'] = 1;
$data['total'] = $total;
$data['rows'] = array();
$results = $q->QUERY_SQL($sql, "artica_backup");
$divstart = "<span style='font-size:14px;font-weight:bold'>";
$divstop = "</div>";
while (list($num, $maks) = each($hash)) {
if (trim($maks) == null) {
continue;
}
$ipban = 0;
if ($search != null) {
if (!preg_match("#{$search}#", $maks)) {
continue;
}
}
$md5 = md5($maks);
$delete = imgtootltip('delete-32.png', '{delete}', "NetworkDelete{$t}('" . md5($num) . "')");
$sql = "SELECT netinfos FROM networks_infos WHERE ipaddr='{$maks}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
$ligne["netinfos"] = htmlspecialchars($ligne["netinfos"]);
$ligne["netinfos"] = nl2br($ligne["netinfos"]);
if ($ligne["netinfos"] == null) {
$ligne["netinfos"] = "{no_info}";
}
$sql = "SELECT network FROM ipban WHERE network='{$maks}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if ($ligne["network"] != null) {
$ipban = 1;
}
$ipbanopt = Field_checkbox("ipban-{$md5}", 1, $ipban, "IPBanSelect('ipban-{$md5}','{$maks}')");
if (!$users->IPBAN_INSTALLED) {
$jsIpabn[] = "document.getElementById('ipban-{$md5}').disabled=true;";
}
$infos = "<div><a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:GlobalSystemNetInfos('{$maks}')\"\n\t\tstyle='font-size:9px;text-decoration:underline'><i>{$ligne["netinfos"]}</i></a></div>";
if ($net->DefaultNetworkList[$maks]) {
if (!$net->Networks_disabled[$maks]) {
$delete = Field_checkbox("net-{$md5}", 1, 1, "NetWorksDisable{$t}('{$maks}');");
} else {
$delete = Field_checkbox("net-{$md5}", 1, 0, "NetWorksEnable{$t}('{$maks}');");
}
}
if ($ipBandEnabled == 0) {
$ipbanopt = Field_checkbox("ipban-{$md5}", 1, $ipban, "IPBanSelect('ipban-{$md5}','{$maks}')", null, true);
}
$c++;
$data['rows'][] = array('id' => md5($maks), 'cell' => array("<img src='img/folder-network-32.png'>", "<div style='font-size:18px'>{$maks}{$infos}</div>", $delete, $ipbanopt));
}
$data['total'] = $c;
echo json_encode($data);
}
示例12: search
function search()
{
$tpl = new templates();
$MyPage = CurrentPageName();
$users = new usersMenus();
$page = 1;
$total = 0;
$pattern = base64_encode($_GET["search"]);
$sock = new sockets();
$removeService = false;
$maillogpath = $users->maillog_path;
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if ($_POST["qtype"] == "service") {
if ($_POST["query"] != null) {
$_GET["prefix"] = $_POST["query"];
$_POST["query"] = null;
}
}
if ($_POST["qtype"] == "service") {
if ($_POST["query"] != null) {
$_GET["prefix"] = $_POST["query"];
$_POST["query"] = null;
}
}
if ($_GET["force-prefix"] != null) {
if ($_POST["qtype"] == "service") {
$_POST["query"] = null;
}
$_GET["prefix"] = $_GET["force-prefix"];
$removeService = true;
}
if ($_POST["query"] != null) {
$search = base64_encode(string_to_regex($_POST["query"]));
$sock->getFrameWork("klms.php?syslog-query={$search}&prepend={$_GET["prepend"]}&rp={$_POST["rp"]}&prefix={$_GET["prefix"]}&maillog={$maillogpath}");
$array = explode("\n", @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/syslog.query"));
$total = count($array);
} else {
$sock->getFrameWork("klms.php?syslog-query=&prepend={$_GET["prepend"]}&rp={$_POST["rp"]}&prefix={$_GET["prefix"]}&maillog={$maillogpath}");
$array = explode("\n", @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/syslog.query"));
$total = count($array);
}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
if ($_POST["sortname"] != null) {
if ($_POST["sortorder"] == "desc") {
krsort($array);
} else {
ksort($array);
}
}
$c = 0;
while (list($key, $line) = each($array)) {
if (trim($line) == null) {
continue;
}
$date = null;
$host = null;
$service = null;
$pid = null;
$color = "black";
if (preg_match("#(ERROR|WARN|FATAL|UNABLE|crashed|out of date|expires soon)#i", $line)) {
$color = "#D61010";
}
$style = "<span style='color:{$color}'>";
$styleoff = "</span>";
if (preg_match("#^(.*?)\\s+([0-9]+)\\s+([0-9:]+)\\s+(.*?)\\s+(.*?):\\s+(.*)#", $line, $re)) {
$date = "{$re[1]} {$re[2]} " . date('Y') . " {$re[3]}";
$host = $re[4];
$service = $re[5];
$pid = null;
$line = $re[6];
$date = date('m-d H:i:s', strtotime($date));
if ($_GET["prefix"] == "haproxy") {
$line = Parse_haproxy($line);
}
$lines = array();
$lines[] = "{$style}{$date}{$styleoff}";
$lines[] = "{$style}{$line}{$styleoff}";
$c++;
$data['rows'][] = array('id' => md5($line), 'cell' => $lines);
continue;
}
if ($_GET["prefix"] == "haproxy") {
$line = Parse_haproxy($line);
}
$lines = array();
$lines[] = "{$style}{$date}{$styleoff}";
if (!$removeService) {
//.........这里部分代码省略.........
示例13: organization_list
function organization_list()
{
$ldap = new clladp();
$tpl = new templates();
$tools = new DomainsTools();
$t = $_GET["t"];
$localdomains = $ldap->Hash_associated_domains();
$relaydomains = $ldap->Hash_relay_domains();
$sock = new sockets();
$PostfixLocalDomainToRemote = $sock->GET_INFO("PostfixLocalDomainToRemote");
if (!is_numeric($PostfixLocalDomainToRemote)) {
$PostfixLocalDomainToRemote = 0;
}
$PostfixLocalDomainToRemoteAddr = $sock->GET_INFO("PostfixLocalDomainToRemoteAddr");
$forwared = $tpl->_ENGINE_parse_body("{forwarded}");
while (list($domain, $ligne) = each($localdomains)) {
$array[$domain]["DELETE"] = "DeleteLocalDomain{$t}('{$domain}')";
$ou = $ldap->organization_name_from_localdomain($domain);
if ($ou == null) {
$ou = "{none}";
}
$array[$domain]["TEXT"] = "<span style='font-size:18px'>{localdomain}</span><br><span style='font-size:16px'>{organization}: <strong>{$ou}</strong>";
if ($PostfixLocalDomainToRemote == 1) {
$array[$domain]["TEXT"] = "<span style='font-size:18px'>{localdomain}</span><br><span style='font-size:16px'>{organization}: <strong>{$ou}</strong></span><br>{$forwared} -» smtp:{$PostfixLocalDomainToRemoteAddr} ";
}
}
while (list($domain, $ligne) = each($relaydomains)) {
$arr = $tools->transport_maps_explode($ligne);
$ou = $ldap->organization_name_from_transporttable($domain);
$array[$domain]["TEXT"] = "{$arr[1]}:{$arr[2]} ({$ou})";
$array[$domain]["OU"] = $ou;
$array[$domain]["DELETE"] = "DeleteTransportDomain{$t}('{$domain}')";
}
$data = array();
if ($_POST["query"] != null) {
$search = string_to_regex($_POST["query"]);
}
$c = 0;
if ($_POST["sortorder"] == "desc") {
krsort($array);
} else {
ksort($array);
}
while (list($domain, $ligne) = each($array)) {
if ($search != null) {
if (!preg_match("#{$search}#", $domain)) {
continue;
}
}
$c++;
$ligne["TEXT"] = $tpl->_ENGINE_parse_body($ligne["TEXT"]);
$domainenc = urlencode($domain);
$OuEnc = urlencode($ligne["OU"]);
$delete = imgsimple("delete-48.png", '{label_delete_transport}', $ligne["DELETE"]);
$m5 = md5($domain);
$js = "Loadjs('domains.relay.domains.php?domain={$domainenc}&ou={$OuEnc}')";
$data['rows'][] = array('id' => "dom{$m5}", 'cell' => array("\n\t\t<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$js}\" \n\t\t\tstyle='font-size:24px;font-weight:bold;text-decoration:underline'>{$domain}</span>", "<span style='font-size:24px'>{$ligne["TEXT"]}</span>", "<center>{$delete}</center>"));
if ($c > $_POST["rp"]) {
break;
}
}
if ($c == 0) {
json_error_show("no data");
}
$data['page'] = 1;
$data['total'] = $c;
echo json_encode($data);
}
示例14: CheckPattern
function CheckPattern($name, $gpid, $type)
{
if (!is_numeric($gpid)) {
return;
}
if (!is_numeric($type)) {
return;
}
if (!isset($GLOBALS["CACHE_CLEAN_MYSQL"])) {
$GLOBALS["CACHE_CLEAN_MYSQL"] = time();
}
if ($type == 3) {
if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $name)) {
return 0;
}
}
try {
$sql = "SELECT ID,`value` FROM webfilter_aclsdynamic WHERE gpid={$gpid} AND `type`={$type}";
$results = api_QUERY_SQL($sql);
if (mysql_num_rows($results) == 0) {
if ($GLOBALS["DEBUG_LEVEL"] > 1) {
WLOG("CheckPattern()::{$sql} -> NO ROW");
}
return 0;
}
while ($ligne = mysql_fetch_assoc($results)) {
$value = $ligne["value"];
if (preg_match("#re:(.+)#", $value, $re)) {
if (preg_match("#{$re[1]}#i", $name)) {
return $ligne["ID"];
}
continue;
}
$value = string_to_regex($value);
if ($GLOBALS["DEBUG_LEVEL"] > 3) {
WLOG("CheckPattern()::Checks `{$value}` with `{$name}`");
}
if (preg_match("#{$value}#i", $name)) {
if ($GLOBALS["DEBUG_LEVEL"] > 3) {
WLOG("CheckPattern()::Match `{$value}` with `{$name}` = {$ligne["ID"]}");
}
return $ligne["ID"];
}
}
if (DistanceInMns($GLOBALS["CACHE_CLEAN_MYSQL"]) > 5) {
$GLOBALS["CACHE_CLEAN_MYSQL"] = time();
if ($GLOBALS["DEBUG_LEVEL"] > 3) {
WLOG("CheckPattern():: Clean old rules...");
}
$sql = "DELETE FROM `webfilter_aclsdynamic` WHERE `duration`>0 AND `maxtime`>" . time();
api_QUERY_SQL($sql);
}
} catch (Exception $e) {
WLOG($e->getMessage());
return 0;
}
return 0;
}
示例15: ipv6_list
function ipv6_list()
{
$Mypage = CurrentPageName();
$tpl = new templates();
$database = "artica_backup";
$t = $_GET["t"];
$sock = new sockets();
$datas = explode("\n", $sock->GET_INFO("PowerDNSListenAddrV6"));
if (count($datas) == 0) {
json_error_show("All....");
}
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$QUERY = string_to_regex($_POST["query"]);
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$data = array();
$data['page'] = 0;
$data['total'] = $total;
$data['rows'] = array();
$data['total'] = count($datas);
$style = "style='font-size:16px'";
while (list($index, $ipmask) = each($datas)) {
if (trim($ipmask) == null) {
continue;
}
$id = md5($ipmask);
$enabled = 0;
$delete = imgsimple("delete-32.png", "{delete}", "PdnsRemoteDelAddr{$t}('{$ipmask}','{$id}')");
if ($QUERY != null) {
if (!preg_match("#{$QUERY}#", $ipmask)) {
continue;
}
}
$c++;
$data['rows'][] = array('id' => $id, 'cell' => array("<span {$style}><img src='img/folder-network-32.png'></span>", "<span {$style}>{$ipmask}</span>", "<span {$style}>{$delete}</span>"));
}
$data['total'] = $c;
echo json_encode($data);
}