示例#1
0
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);
}
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
0
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
0
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
0
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){
			$tabs=generateTabs($maxdocs,$current);
		}
		
		echo $tpl->_ENGINE_parse_body($html.$tabs."<p style=\"font-size:16px;font-weight:bold;margin:10px\">{ERR_NO_DOC_FOUND} &laquo;$ssery_results&raquo;</p>"); 
	
		}
	
	
}
示例#6
0
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
0
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
0
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
0
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 = "&nbsp;";
            }
        }
        $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
0
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 = "&nbsp;";
        $disclaimer_domain = "&nbsp;";
        $amavis_infos = "&nbsp;";
        $amavis_duplicate = "&nbsp;";
        $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
0
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
0
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) {
            $lines[] = "{$style}{$service}{$styleoff}";
        }
        $lines[] = "{$style}{$pid}{$styleoff}";
        $lines[] = "{$style}{$line}{$styleoff}";
        $c++;
        $data['rows'][] = array('id' => md5($line), 'cell' => $lines);
    }
    $data['total'] = $c;
    echo json_encode($data);
}
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} -&raquo; 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
0
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
0
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);
}
示例#16
0
function page_events()
{
    $page = CurrentPageName();
    $instance_id = $_GET["instance-id"];
    if (!is_numeric($instance_id)) {
        $instance_id = 0;
    }
    $tpl = new templates();
    $sock = new sockets();
    $time = time();
    $search = null;
    $datas = unserialize(base64_decode($sock->getFrameWork("services.php?mysql-events=yes&instance-id={$instance_id}")));
    ini_set('html_errors', 1);
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($datas);
    $data['rows'] = array();
    if ($_POST["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    while (list($num, $ligne) = each($datas)) {
        if ($search != null) {
            if (!preg_match("#{$search}#i", $ligne)) {
                continue;
            }
        }
        $data['rows'][] = array('id' => md5($ligne), 'cell' => array("<code style='font-size:14px'>{$ligne}</code>"));
    }
    echo json_encode($data);
}
示例#17
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    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["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    $array = file("ressources/logs/web/squid.indebug.log");
    ksort($f);
    $data = array();
    $data['page'] = $page;
    $data['total'] = count($array);
    $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;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#i", $line)) {
                continue;
            }
        }
        $md = md5($line);
        $c++;
        $data['rows'][] = array('id' => $md, 'cell' => array($line));
    }
    echo json_encode($data);
}
function rows_table()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_blackbox();
    $nodeid = $_GET["nodeid"];
    $hostid = $_GET["hostid"];
    $q = new mysql_blackbox();
    $sql = "SELECT UfdbClientLogs FROM nodes WHERE hostid='{$hostid}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}", 1);
    }
    if (strlen($ligne["UfdbClientLogs"]) == 0) {
        json_error_show("UfdbClientLogs No content...", 1);
    }
    $base = base64_decode($ligne["UfdbClientLogs"]);
    $array = unserialize($base);
    if (!is_array($array)) {
        json_error_show(strlen($ligne["UfdbClientLogs"]) . " bytes...Not an array...", 1);
    }
    $page = 1;
    if (count($array) == 0) {
        json_error_show("No rows", 1);
    }
    krsort($array);
    $total = count($array);
    $search = 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();
    $c = 0;
    while (list($index, $ligne) = each($array)) {
        if (trim($ligne) == null) {
            continue;
        }
        $md5 = md5($ligne);
        $color = "black";
        if (preg_match("#([0-9\\-\\s\\:]+)\\s+\\[#", $ligne, $re)) {
            $date = $re[1];
            $ligne = str_replace($date, "", $ligne);
        }
        if ($search != null) {
            if (!preg_match("#{$search}#", $ligne)) {
                continue;
            }
        }
        if (preg_match("#(crashing|failed|No such|FATAL|abnormally|WARNING)#", $ligne["line"])) {
            $color = "red";
        }
        $c++;
        $data['rows'][] = array('id' => $md5, 'cell' => array("<span style='font-size:14px;color:{$color}'>{$date}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne}</span>"));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#19
0
function zoom_transaction_events()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $id = $_GET["id"];
    $q = new mysql();
    $sql = "SELECT transaction FROM smtp_logs WHERE id={$id}";
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
    $array = explode("\n", base64_decode($ligne["transaction"]));
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($array);
    $data['rows'] = array();
    if ($_POST["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    while (list($num, $ligne) = each($array)) {
        if ($ligne == null) {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#", $ligne)) {
                continue;
            }
        }
        $cells = array();
        $cells[] = "{$ligne}";
        $data['rows'][] = array('id' => $line["id"], 'cell' => $cells);
    }
    echo json_encode($data);
}
示例#20
0
function master_events_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $t = $_GET["t"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $sock = new sockets();
    if ($_POST["query"] != null) {
        $query = "&query=" . base64_encode(string_to_regex($_POST["query"]));
    }
    $datasLines = explode("\n", base64_decode($sock->getFrameWork("gluster.php?master-events=yes&rp={$rp}{$query}")));
    $data = array();
    $data['page'] = $page;
    $data['total'] = count($datasLines);
    $data['rows'] = array();
    $TYP["W"] = "warning24.png";
    $TYP["N"] = "info-24.png";
    $TYP["E"] = "danger24.png";
    if ($_POST["sortname"] == "date" && $_POST["sortorder"] == "desc") {
        krsort($datasLines);
    }
    while (list($num, $ligne) = each($datasLines)) {
        if (trim($ligne) == null) {
            continue;
        }
        $zdate = "-";
        $type = "-";
        $function = "-";
        $img = "&nbsp;";
        $events = $ligne;
        //[2012-07-17 01:04:30] W [transport.c:70:transport_load] transport: missing 'option transport-type'. defaulting to "socket"
        if (preg_match("#\\[(.*?)\\]\\s+([A-Z])\\s+\\[(.*?)\\]\\s+(.+)#", $ligne, $re)) {
            $zdate = $re[1];
            $type = $re[2];
            $function = $re[3];
            $events = $re[4];
        }
        if (isset($TYP[$type])) {
            $img = "<img src='img/{$TYP[$type]}'>";
        }
        $data['rows'][] = array('id' => md5($ligne), 'cell' => array("{$img}", "<code style='font-size:12px'>{$zdate}</code>", "<code style='font-size:12px'>{$function}</code>", "<code style='font-size:12px'>{$events}</code>"));
    }
    echo json_encode($data);
}
示例#21
0
function folder_security_users_table()
{
    $folder = $_GET["prop"];
    $t = $_GET["t"];
    $smb = new samba();
    $users = $smb->main_array[$folder]["valid users"] . "," . $smb->main_array[$folder]["write list"] . "," . $smb->main_array[$folder]["read list"];
    $table = explode(",", $users);
    while (list($num, $ligne) = each($table)) {
        if ($ligne != null) {
            $usr[$ligne] = $ligne;
        }
    }
    $query = string_to_regex($_POST["query"]);
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($usr);
    $data['rows'] = array();
    $c = 0;
    while (list($num, $ligne) = each($usr)) {
        if ($query != null) {
            if (!preg_match("#{$query}#", $ligne)) {
                continue;
            }
        }
        if (substr($ligne, 0, 1) == '@') {
            $img = "wingroup.png";
            $Displayname = substr($ligne, 1, strlen($ligne));
        } else {
            $Displayname = $ligne;
            $img = "user-18.png";
        }
        $Displayname = str_replace('"', "", $Displayname);
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $encoded = base64_encode($ligne);
        $c++;
        if ($c > $_POST["rp"]) {
            break;
        }
        $id = md5("RRRIW" . $Displayname);
        $data['rows'][] = array('id' => $id, 'cell' => array("<img src='img/{$img}'>", "<span style='font-size:14px;font-weight:bolder'>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:UserSecurityInfos('{$encoded}');\"\n\t\t\t\tstyle='font-size:14px;font-weight:bolder;text-decoration:underline'>\n\t\t\t\t{$Displayname}</a></span>", imgsimple("delete-24.png", null, "DeleteUserPrivilege{$t}('{$encoded}','{$id}')")));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#22
0
function items()
{
    $cyrus = new cyrus();
    $array = $cyrus->ListUsersBoxes($_POST["query"], $_GET["domain"]);
    if (!is_array($array)) {
        json_error_show("No mailbox");
    }
    if (count($array) == 0) {
        json_error_show("No mailbox");
    }
    $t = $_GET["t"];
    $c = 0;
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($array);
    $data['rows'] = array();
    $search = null;
    if ($_POST["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    while (list($mailbox_name, $ligne) = each($array)) {
        $mailbox_name = trim($mailbox_name);
        if ($mailbox_name == null) {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#", $ligne)) {
                continue;
            }
        }
        if ($_GET["domain"] != null) {
            $mailbox_name = "{$mailbox_name}@{$_GET["domain"]}";
        }
        $delete = imgsimple("delete-24.png", "", "DeleteRealMailBox{$t}('{$mailbox_name}','" . md5($ligne) . "');");
        $c++;
        $data['rows'][] = array('id' => md5($ligne), 'cell' => array("<span style='font-size:16px;color:{$color}'><img src='img/32-mailbox.png'></span>", "<span style='font-size:16px;color:{$color}'>{$mailbox_name}</a></span>", "<span style='font-size:16px;color:{$color}'>{$delete}</a></span>"));
    }
    if ($c == 0) {
        json_error_show("No mailbox");
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#23
0
    $db_destination_number = check_str($_POST["db_destination_number"]);
    $destination_caller_id_name = check_str($_POST["destination_caller_id_name"]);
    $destination_caller_id_number = check_str($_POST["destination_caller_id_number"]);
    $destination_cid_name_prefix = check_str($_POST["destination_cid_name_prefix"]);
    $destination_context = check_str($_POST["destination_context"]);
    $fax_uuid = check_str($_POST["fax_uuid"]);
    $destination_enabled = check_str($_POST["destination_enabled"]);
    $destination_description = check_str($_POST["destination_description"]);
    $destination_sell = check_float($_POST["destination_sell"]);
    $currency = check_str($_POST["currency"]);
    $destination_buy = check_float($_POST["destination_buy"]);
    $currency_buy = check_str($_POST["currency_buy"]);
    $destination_accountcode = check_str($_POST["destination_accountcode"]);
    $destination_carrier = check_str($_POST["destination_carrier"]);
    //convert the number to a regular expression
    $destination_number_regex = string_to_regex($destination_number);
    $_POST["destination_number_regex"] = $destination_number_regex;
}
//unset the db_destination_number
unset($_POST["db_destination_number"]);
//process the http post
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
    //get the uuid
    if ($action == "update") {
        $destination_uuid = check_str($_POST["destination_uuid"]);
    }
    //check for all required data
    $msg = '';
    if (strlen($destination_type) == 0) {
        $msg .= $text['message-required'] . " " . $text['label-destination_type'] . "<br>\n";
    }
示例#24
0
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"];
    $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();
    $tasks = unserialize(base64_decode($sock->getFrameWork("klms.php?get-task-list=yes")));
    $taskslogs = unserialize(base64_decode($sock->getFrameWork("klms.php?get-task-logs=yes")));
    while (list($taskname, $ligne) = each($tasks)) {
        if ($_POST["query"] != null) {
            if (!preg_match("#{$_POST["query"]}#i", $taskname)) {
                continue;
            }
        }
        $c++;
        $logs = null;
        $id = $ligne["ID"];
        $State = $ligne["State"];
        $RID = $ligne["RID"];
        $delete = imgsimple("delete-24.png", null, "ItemDelete{$tSource}('{$id}')");
        $img = "danger24.png";
        $action = imgsimple("24-run.png", null, "item_start{$tSource}({$id})");
        if (strtolower($State) == "started") {
            $img = "ok24.png";
            $action = imgsimple("24-stop.png", null, "item_stop{$tSource}({$id})");
        }
        if (strtolower($State) == "failed") {
            $img = "warning-panneau-24.png";
            $action = imgsimple("24-run.png", null, "item_start{$tSource}({$id})");
        }
        if (strtolower($State) == "starting") {
            $img = "warning24.png";
            $action = null;
        }
        if (isset($taskslogs[$taskname])) {
            $logs = imgsimple("events-24.png", null, "Loadjs('klms.tasks.logs.php?taskname={$taskname}');");
        }
        $taskContent = null;
        if (is_file("/usr/share/artica-postfix/ressources/logs/web/KlmsTask{$id}.txt")) {
            $taskContent = trim(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/KlmsTask{$id}.txt"));
            if ($taskContent != null) {
                $taskContent = "<div><i style='font-size:11px;font-weight:bold'>{$taskContent}</i></div>";
            }
        }
        $enable = Field_checkbox("enable-{$id}", 1, $ligne["enabled"], "ItemEnable{$tSource}('{$id}')");
        $ligne["describe"] = stripslashes($ligne["describe"]);
        $ligne["pattern"] = base64_decode($ligne["pattern"]);
        $uri = "<a href=\"javascript:blur();\" OnClick=\"javascript:ItemForm{$tSource}({$id});\" style='font-size:16px;text-decoration:underline'>";
        $data['rows'][] = array('id' => "Rtask{$id}", 'cell' => array("<span style='font-size:16px;'>{$id}</span>", "<span style='font-size:16px;'>{$taskname} ({$State})</span>{$taskContent}</span>", $logs, "<img src='img/{$img}'>", $action));
        $data['total'] = $c;
    }
    echo json_encode($data);
}
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"];
    $privilege = true;
    if (GetRights_aliases() == 0) {
        $privilege = false;
    }
    $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'] = 0;
    $data['rows'] = array();
    $user = new user($_GET["userid"]);
    $aliases = $user->aliases;
    $c = 0;
    while (list($num, $ligne) = each($aliases)) {
        if ($_POST["query"] != null) {
            if (!preg_match("#{$_POST["query"]}#i", $ligne)) {
                continue;
            }
        }
        $c++;
        $logs = null;
        $id = md5($ligne);
        //Loadjs('$page?delete-aliases=yes&mail=$ligne&uid=$userid')
        $delete = imgsimple('delete-32.png', '{delete aliase}', "ItemDelete{$tSource}('{$ligne}','{$id}')");
        $test = imgsimple('test-message-32.png', null, "Loadjs('postfix.sendtest.mail.php?rcpt={$ligne}')");
        if (!$privilege) {
            $delete = null;
        }
        $data['rows'][] = array('id' => "{$id}", 'cell' => array("<code style='font-size:22px;font-weight:bold'>{$ligne}</code>", $test, $delete));
        $data['total'] = $c;
    }
    if ($c == 0) {
        json_error_show("no alias");
    }
    echo json_encode($data);
}
示例#26
0
function banmail()
{
    $pattern = $_POST["banmail"];
    $describe = "Bann {$pattern} " . date('Y-m-d H:i:s');
    $pattern = string_to_regex($pattern);
    $pattern = str_replace("@", "\\@", $pattern);
    $pattern = base64_encode($pattern);
    $describe = addslashes($describe);
    $header = "From";
    $sql = "INSERT INTO spamassassin_rules (`describe`,`pattern`,`header`,`score1`,`score2`,`score3`,`score4`,`enabled`) \n\t\tVALUES('{$describe}','{$pattern}','{$header}','9.00','9.00','9.00','9.00',1)\n\t\t";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $tpl = new templates();
    echo $tpl->javascript_parse_text(" {rule} {added}: ID {$q->last_id}");
}
示例#27
0
function domains_show_list()
{
    $sock = new sockets();
    $t = $_GET["t"];
    //wbinfoalldom
    $array = unserialize(base64_decode($sock->getFrameWork("samba.php?wbinfo-m-verb=yes")));
    while (list($num, $ligne) = each($array)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<div><code style='font-size:14px'>{$ligne}</code></div>";
        }
        if (preg_match("#^([A-Z]+)\\s+(.*?)\\s+([A-Za-z]+)\\s+(Yes|No)\\s+(Yes|No)\\s+(Yes|No)#", $ligne, $re)) {
            $DOMAINS[trim($re[1])] = array("DNS" => trim($re[2]), "TRUST" => $re[3], "TRANS" => $re[4], "IN" => $re[5], "OUT" => $re[6]);
        }
    }
    $array = unserialize(base64_decode($sock->getFrameWork("samba.php?wbinfoalldom=yes")));
    while (list($num, $ligne) = each($array)) {
        if (preg_match("#^(.*?):(.*)#", $ligne, $re)) {
            $DOMAINS[trim($re[1])]["ONLINE"] = trim($re[2]);
        }
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (function_exists("string_to_regex")) {
        if ($_POST["query"] != null) {
            $search = string_to_regex($_POST["query"]);
        }
    }
    $c = 0;
    while (list($WORKGROUP, $array) = each($DOMAINS)) {
        if ($search != null) {
            if (!preg_match("#{$search}#", $WORKGROUP)) {
                continue;
            }
        }
        $transitive = "ok24-grey.png";
        $online = "ok24-grey.png";
        $in = "ok24-grey.png";
        $out = "ok24-grey.png";
        if (trim($array["TRANS"]) == "Yes") {
            $transitive = "ok24.png";
        }
        if (trim($array["ONLINE"]) == "online") {
            $online = "ok24.png";
        }
        if (trim($array["IN"]) == "Yes") {
            $in = "ok24.png";
        }
        if (trim($array["OUT"]) == "Yes") {
            $out = "ok24.png";
        }
        $c++;
        $data['rows'][] = array('id' => $md, 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"javascript:DomainINFO{$t}('{$WORKGROUP}');\" style='font-size:16px;text-decoration:underline'>{$WORKGROUP}</span>", "<span style='font-size:16px'>{$array["DNS"]}</span>", "<span style='font-size:16px'>{$array["TRUST"]}</span>", "<img src='img/{$transitive}'>", "<img src='img/{$online}'>", "<img src='img/{$in}'>", "<img src='img/{$out}'>"));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#28
0
function browse_imap()
{
    $fetch = new Fetchmail_settings();
    $rule = $fetch->LoadRule($_GET["ruldeid"]);
    $port = 143;
    $tls = "notls";
    if ($rule["ssl"] == 1) {
        $port = 993;
        $tls = "ssl/novalidate-cert";
    }
    if ($rule["poll"] == null) {
        json_error_show("Fatal, No IMAP server defined for rule id:{$_GET["ruldeid"]}");
        return;
    }
    //$host,$username,$password,$folder='INBOX',$port=143,$tls='notls
    $imap = new ImapRead($rule["poll"], $rule["user"], $rule["pass"], "INBOX", $port, $tls);
    if ($imap->is_connected == 0) {
        json_error_show("could not connect to {$rule["poll"]}:{$port}<div>{$imap->imap_error}</div>");
        return;
    }
    $array = $imap->returnMailboxListArr();
    $sql = "SELECT folders FROM fetchmail_rules WHERE ID='{$_GET["ruldeid"]}'";
    $q = new mysql();
    $arrayF = array();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $arrayF = unserialize(base64_decode($ligne["folders"]));
    $page = 1;
    $data = array();
    $data['page'] = $page;
    $data['total'] = count($array);
    $data['rows'] = array();
    $search = null;
    if ($_POST["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    while (list($num, $ligne) = each($array)) {
        if (preg_match("#^\\{.*?\\}(.+)#", $ligne, $re)) {
            $folder = $re[1];
        }
        if (preg_match("#^.*?INBOX\\/(.+)#", $ligne, $re)) {
            $folder = $re[1];
        }
        if ($folder == "INBOX") {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#i", $folder)) {
                continue;
            }
        }
        $c++;
        $md = md5($folder);
        $base = base64_encode($folder);
        $enabledv = 0;
        if (isset($arrayF[$md])) {
            $enabledv = 1;
        }
        $enable = Field_checkbox("ck_{$md}", 1, $enabledv, "EnableImapf('{$md}','{$base}')");
        $span = "<span style='font-size:16px;font-weight:bolder'>";
        $data['rows'][] = array('id' => $md, 'cell' => array($span . $href . $folder . "</a></span>", $enable));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#29
0
function BindInterfaceTable()
{
    $sock = new sockets();
    $table = explode("\n", $sock->GET_INFO("PostfixBinInterfaces"));
    if ($GLOBALS["VERBOSE"]) {
        print_r($table);
    }
    if (!is_array($table)) {
        $table[] = "all";
    }
    if (count($table) == 0) {
        $table[] = "all";
    }
    $PostfixBindInterfacePort = $sock->GET_INFO("PostfixBindInterfacePort");
    if (!is_numeric($PostfixBindInterfacePort)) {
        $PostfixBindInterfacePort = 25;
    }
    while (list($num, $val) = each($table)) {
        $val = trim($val);
        if ($val == null) {
            continue;
        }
        $tt[$num] = $val;
    }
    if (!is_array($tt)) {
        $tt[] = "all";
    }
    if (count($tt) == 0) {
        $tt[] = "all";
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($table);
    $data['rows'] = array();
    $search = string_to_regex($_POST["query"]);
    $c = 0;
    while (list($num, $val) = each($tt)) {
        if (isset($alreadymd[$val])) {
            continue;
        }
        $md = md5($val);
        $alreadymd[$val] = true;
        if ($search != null) {
            if (!preg_match("#{$search}#i", $val)) {
                continue;
            }
        }
        $delete = imgsimple('delete-24.png', '{delete} {inet_interface}', "PostfixDeleteInterface({$num},'{$md}')");
        if ($val == "all") {
            $delete = null;
        }
        $c++;
        $data['rows'][] = array('id' => $md, 'cell' => array("<img src='img/folder-network-32.png'>", "<span style='font-size:16px;font-weight:bold'>{$val}:<a href=\"javascript:blur();\" OnClick=\"javascript:ChangePostfixBindInterfacePort('{$PostfixBindInterfacePort}')\" style='font-size:16px;font-weight:bold;text-decoration:underline'>{$PostfixBindInterfacePort}</a></span>", $delete));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
示例#30
0
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 {
        if (!class_exists("mysql_squid_builder")) {
            include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
        }
        $q = new mysql_squid_builder();
        $sql = "SELECT ID,`value`  FROM webfilter_aclsdynamic WHERE gpid={$gpid} AND `type`={$type}";
        $results = $q->QUERY_SQL($sql);
        if (!$q->ok) {
            WLOG("CheckPattern()::ERROR SQL: {$sql}");
            WLOG("CheckPattern()::ERROR SQL: `{$q->mysql_error}`");
            return 0;
        }
        if (mysql_num_rows($results) == 0) {
            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();
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                WLOG("CheckPattern()::{$q->mysql_error},{$sql}");
            }
        }
    } catch (Exception $e) {
        WLOG($e->getMessage());
        return 0;
    }
    return 0;
}