Exemplo n.º 1
0
    exit;
}
if (isset($_GET["HamchStat"])) {
    NET_STATUS();
    exit;
}
if (isset($_GET["gateway"])) {
    gateway_config();
    exit;
}
if (isset($_POST["EnableArticaAsGateway"])) {
    gateway_save();
    exit;
}
if (isset($_GET["peer-infos"])) {
    peer_infos();
    exit;
}
if (isset($_GET["net-infos"])) {
    net_infos();
    exit;
}
js();
function edit_net_js()
{
    $q = new mysql();
    $page = CurrentPageName();
    $tpl = new templates();
    $id = $_GET["edit-net-js"];
    $sql = "SELECT pattern FROM hamachi WHERE ID='{$id}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
function popup_list(){
	$tpl=new templates();
	$MyPage=CurrentPageName();
	$q=new mysql();
	$squid=new squidbee();
	$no_backend_defined=$tpl->javascript_parse_text("{no_backend_defined}");
	$search='%';
	$table="squid_parents";
	$MySQLbase="artica_backup";
	$page=1;
	$ORDER="ORDER BY zDate DESC";
	$t=$_GET["t"];
	
	
	$ARR=peer_infos();
	
		
	if(!$q->FIELD_EXISTS("squid_parents","enabled","artica_backup")){
		$sql="ALTER TABLE `squid_parents` ADD `enabled` smallint( 1 ) NOT NULL DEFAULT '1',ADD INDEX ( `enabled` )";
		$q->QUERY_SQL($sql,"artica_backup");
		if(!$q->ok){writelogs("$q->mysql_error\n$sql",__CLASS__.'/'.__FUNCTION__,__FILE__,__LINE__);}
	}
		
	$total=0;
	if($q->COUNT_ROWS($table,$MySQLbase)==0){json_error_show($no_backend_defined,1);}
	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"]="*".$_POST["query"]."*";
		$_POST["query"]=str_replace("**", "*", $_POST["query"]);
		$_POST["query"]=str_replace("**", "*", $_POST["query"]);
		$_POST["query"]=str_replace("*", "%", $_POST["query"]);
		$search=$_POST["query"];
		$searchstring="AND (`{$_POST["qtype"]}` LIKE '$search')";
		$sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE 1 $searchstring";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,$MySQLbase));
		$total = $ligne["TCOUNT"];
		
	}else{
		$sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE 1";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,$MySQLbase));
		$total = $ligne["TCOUNT"];
	}
	
	if (isset($_POST['rp'])) {$rp = $_POST['rp'];}	
	

	
	$pageStart = ($page-1)*$rp;
	$limitSql = "LIMIT $pageStart, $rp";
	if($OnlyEnabled){$limitSql=null;}
	$sql="SELECT *  FROM `$table` WHERE 1 $searchstring $ORDER $limitSql";	
	writelogs($sql,__FUNCTION__,__FILE__,__LINE__);
	$results = $q->QUERY_SQL($sql,$MySQLbase);
	if(!$q->ok){
		
	}
	
	
	$data = array();
	$data['page'] = $page;
	$data['total'] = $total;
	$data['rows'] = array();
	
	if(!$q->ok){
		$data['rows'][] = array('id' => $ligne[time()+1],'cell' => array($q->mysql_error,"", "",""));
		$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));
		echo json_encode($data);
		return;
	}	
	
	//if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));}
	
	while ($ligne = mysql_fetch_assoc($results)) {
		$color="black";
		$md5=md5(serialize($ligne));
		//if($squid->EnableParentProxy==0){$color="#CACACA";}
		if(!is_numeric($ligne["icp_port"])){$ligne["icp_port"]=0;}
		
		if($ligne["enabled"]==0){
			$icon="24-stop.png";
			$action_run=1;
			$color="#CACACA";
		}else{
			$icon="24-run.png";
			$action_run=0;
		}		
		
		$ahref="<a href=\"javascript:blur();\" 
		OnClick=\"javascript:EditSquidParent$t({$ligne["ID"]})\" 
		style='font-size:16px;text-decoration:underline;font-weight:bold;color:$color'>";

		$delete="<a href=\"javascript:blur();\" 
		OnClick=\"javascript:DeleteSquidParent$t({$ligne["ID"]},'$md5')\">
		<img src='img/delete-24.png' style='border:0px;color:$color'>
		</a>";
		
		if($ligne["icp_port"]>0){$ligne["server_port"]=$ligne["server_port"]."&raquo;&nbsp;".$ligne["icp_port"];}
		if($ligne["htcp_port"]>0){$ligne["server_port"]=$ligne["server_port"]."&raquo;&nbsp;".$ligne["htcp_port"];}
		$option=popup_list_options($ligne["options"]);
		if($ligne["icp_port"]==0){
			$option=$option.$tpl->_ENGINE_parse_body("&nbsp;<i style='font-size:11px'>ICP {disabled}</i>");
		}
		
		if($ligne["htcp_port"]==0){
			$option=$option.$tpl->_ENGINE_parse_body("&nbsp;<i style='font-size:11px'>HTCP {disabled}</i>");
		}		
		 
		$needed=$ARR[$ligne["servername"]]["needed"];
		$usable=$ARR[$ligne["servername"]]["usable"];
		$requested=$ARR[$ligne["servername"]]["requested"];
		
		
		$run=imgsimple($icon,null,"ActionRun$t({$ligne["ID"]},$action_run)");
		
	$data['rows'][] = array(
		'id' =>$md5,
		'cell' => array(
				"<img src='img/32-network-server.png'>",
				"$ahref{$ligne["servername"]}:{$ligne["server_port"]}</a>$option",
				"$ahref$needed</a>",
				"$ahref$usable</a>",
				"$ahref$requested</a>",
				"$ahref{$ligne["server_type"]}</a>",
				"$run",
				$delete )
		);
	}
	
	
echo json_encode($data);	
}