diff -uNr packages_org/config/surftool/check_and_activate.php packages/config/surftool/check_and_activate.php
--- packages_org/config/surftool/check_and_activate.php	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/check_and_activate.php	2015-08-08 18:42:44.000000000 +0200
@@ -0,0 +1,79 @@
+<?php
+/*
+	check_and_activate.php
+	Copyright (C) 2015 H-T Reimers <reimers@mail.de>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+
+	//Read configuration
+	$config=parse_ini_file ("surftool.cfg");
+
+	$debug=0;
+	$max_execution_time=5;
+
+	$commandpath="/tmp/surftool";
+	
+	
+
+	$delay=2;
+	if(isset($argv[1])){
+		if($argv[1]>=0 AND $argv[1]<600){
+			$delay=$argv[1];
+		}
+	}
+	
+	//check
+	set_time_limit($max_execution_time);
+	if (ini_get('max_execution_time') != $max_execution_time){
+		echo "Warning max_execution_time is ".ini_get('max_execution_time')."s should be ".$max_execution_time."s\n";
+	}
+
+	include "surftool3.inc";
+
+	$sgcommands= new commandReader($commandpath);
+
+	//Are there any changes?
+	if($sgcommands->changes){
+
+		//read squidGuard.conf
+		$sgconf = new surftoolSquidGuardConf($config);
+
+		//activate domain changes
+		$sgconf->setDomains("onplus",$sgcommands->domainsOnplusAdd,$sgcommands->domainsOnplusRemove);
+		$sgconf->setDomains("only",$sgcommands->domainsOnlyAdd,$sgcommands->domainsOnlyRemove);
+
+		$sgconf->write_squidGuardDomains();
+		
+		//activate acl mode changes
+		$sgconf->setAclMode($sgcommands->aclChangeMode);
+		$sgconf->write_squidGuardConf();
+
+		//Reload Squid Configuration
+		$sgconf->squidReload();
+
+		$sgcommands->deleteCommandFiles();
+				
+	}
+
+?>
diff -uNr packages_org/config/surftool/index.php packages/config/surftool/index.php
--- packages_org/config/surftool/index.php	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/index.php	2015-08-08 18:42:51.000000000 +0200
@@ -0,0 +1,84 @@
+<?php
+/*
+	index.php
+	Copyright (C) 2015 H-T Reimers <reimers@mail.de>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+
+	session_start();
+	//Read configuration
+	$config=parse_ini_file ("surftool.cfg");		
+
+
+	if(isset($_POST["logout"])){
+		session_unset();
+		$logout=true;
+	}
+	if(isset($_SESSION["login"])) $login=$_SESSION["login"];
+	else $login=false;
+	
+	if( isset($_GET["secret"])  ){
+		if($_GET["secret"]==$config["redirect_secret"] ){
+			$login=true;
+			$_SESSION["login"]=true;
+		}	
+	}
+	if( isset($_POST["loginname"]) AND isset($_POST["passwd"]) ){
+		$user=$_POST["loginname"];
+		$passwd=$_POST["passwd"];
+		if($user==$config["user_name"] AND $passwd==$config["user_password"]){
+			$login=true;
+			$_SESSION["login"]=true;
+		}
+	}
+	
+	if($logout){
+		header("Location: ".$config["logout_target"]);
+		$meta="<meta http-equiv='refresh' content='0; URL=".$config["logout_target"]."'>"; //When redirect with header is not supported
+	}
+	else if($login){
+		header("Location: set.php");
+		$meta="<meta http-equiv='refresh' content='0; URL=set.php'>"; //When redirect with header is not supported
+	}
+	else $meta="";
+	echo "<!DOCTYPE html><html><head>$meta<title>Surftool</title></head><body>";
+	
+	if($login){
+		echo "<a href='set.php'> weiter </a>"; //When redirect with header and meta is not supported
+		echo "<form action='index.php' method='post'>
+			<input type='submit' name='logout' value='logout'>
+		</form> ";
+	}
+	else if(!$login){
+		echo "
+		<form action='' method='post'>
+			Loginname:<input type='text' name='loginname'><br>
+			Password:<input type='password' name='passwd'><br>
+			<input type='submit' value='login'>
+		</form> ";
+	}
+	
+	
+	echo "</body></html>";
+?>
\ No newline at end of file
diff -uNr packages_org/config/surftool/set.php packages/config/surftool/set.php
--- packages_org/config/surftool/set.php	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/set.php	2015-08-08 18:42:58.000000000 +0200
@@ -0,0 +1,438 @@
+<?php
+/*
+	set.php
+	Copyright (C) 2015 H-T Reimers <reimers@mail.de>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+	session_start();
+	$encoding="ISO-8859-1";
+	mb_internal_encoding("$encoding");
+
+	//Read configuration
+	$config=parse_ini_file ("surftool.cfg");
+
+	function print_header($meta=""){
+		echo "
+		<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
+		'http://www.w3.org/TR/html4/loose.dtd'>
+			<html>
+			<head>
+			$meta
+			<title>Internet freischalten </title>
+				<meta http-equiv='cache-control' content='max-age=0'>
+				<meta http-equiv='cache-control' content='no-cache'>
+				<meta http-equiv='expires' content='-1'>
+				<meta http-equiv='Pragma' CONTENT='no-cache'>
+
+				<style type='text/css'>
+					.Color_on { 
+						background-color:darkgreen;
+						color:black;
+					}
+					.Color_onplus { 
+						background-color:springgreen;
+						color:black;			
+					}
+					.Color_only { 
+						background-color:gold;
+						color:black;
+					}
+					.Color_off { 
+						background-color:red;
+						color:black;
+					}
+					.Color_adminfree { 
+						background-color:black;
+						color:white;
+					}
+					.showMode{
+						width:100px;
+						valign:middle;
+						align:center; 
+						padding:0.3em;
+						font-weight: bolder;
+						font-size: 12pt;
+					}
+					.Button{ 
+						width:200px;
+						height:60px;
+						valign:middle;
+						align:center; 
+						padding:1.5em;
+						font-weight: bolder;
+						font-size: 15pt;
+					}
+				</style>
+
+
+				<script language='JavaScript'>
+				<!--
+
+				function switch_2_expert(){
+					document.getElementById('ModusSimpleHeader').style.display = 'none'; //Link - ModusSimple verbergen
+					document.getElementById('ModusSimpleLink').style.display = 'none'; //Link - ModusSimple verbergen
+					document.getElementById('ModusExpertLink').style.display = 'block'; //Link - ModusExpert anzeigen
+					document.getElementById('ModusExpertHeader').style.display = 'block'; //Link - ModusExpert anzeigen
+					document.getElementById('ModusExpertSettings').style.display = 'block'; //ModusExpert anzeigen
+					document.getElementById('ModusNormalRadio').checked = 'true';		
+
+				}
+
+				function switch_2_simple(){
+					document.getElementById('ModusSimpleHeader').style.display = 'block'; //ModusSimple anzeigen
+					document.getElementById('ModusSimpleLink').style.display = 'block'; //ModusSimple anzeigen
+					document.getElementById('ModusExpertHeader').style.display = 'none'; //ModusExpert verbergen 
+					document.getElementById('ModusExpertLink').style.display = 'none'; //ModusExpert verbergen 
+					document.getElementById('ModusExpertSettings').style.display = 'none'; //ModusExpert verbergen
+				}
+
+
+				function switch_mode(newmode){
+
+					if(newmode=='on'){
+						document.getElementById('showmodus').firstChild.nodeValue = 'gewählter Modus: Normale Freigabe';
+						document.getElementById('whitelist').style.display = 'none'; //Whitelist verbergen
+						document.getElementById('onlylist').style.display = 'none'; //Onlylist verbergen
+					}
+					else if(newmode=='off'){
+						document.getElementById('showmodus').firstChild.nodeValue = 'gewählter Modus: Internetzugang ausschalten';
+						document.getElementById('whitelist').style.display = 'none'; //Whitelist verbergen
+						document.getElementById('onlylist').style.display = 'none'; //Onlylist verbergen
+					}
+					else if(newmode=='onplus'){
+						document.getElementById('showmodus').firstChild.nodeValue = 'gewählter Modus: Erweiterte Freigabe mit zusätzlichen Seiten';
+						document.getElementById('whitelist').style.display = 'block'; //Whitelist anzeigen
+						document.getElementById('onlylist').style.display = 'none'; //Onlylist verbergen
+					}
+					else if(newmode=='only'){
+						document.getElementById('showmodus').firstChild.nodeValue = 'gewählter Modus: Nur bestimmte Seiten freigeben';
+						document.getElementById('whitelist').style.display = 'none'; //Whitelist verbergen
+						document.getElementById('onlylist').style.display = 'block'; //Onlylist anzeigen
+					}
+					else if(newmode=='adminfree'){
+						document.getElementById('showmodus').firstChild.nodeValue = 'gewählter Modus: Administrative Freigabe';
+						document.getElementById('whitelist').style.display = 'none'; //Whitelist verbergen
+						document.getElementById('onlylist').style.display = 'none'; //Onlylist verbergen
+					}
+
+					
+				}
+				//-->
+				</script>
+				
+			    <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $encoding; ?>'>
+			    <link rel='stylesheet' title='Schulkonsole' href='surftoolstyle.css' type='text/css'>
+			   
+			    
+			    <meta name='copyright' content='Copyright 2012 H. Reimers, reimers@mail.de'>
+			    <meta name='description' content='Surftool'>
+			<script language='JavaScript'>
+			<!--
+
+			window.onload = function() {
+				//alert('I am an alert box!');
+				//location.replace('index.php');
+			}
+			//-->
+			</script>
+			</head>
+			<body bgcolor= #fefae8>";
+	}
+
+
+
+	$debug=1;
+	if(isset($config["debuglevel"])) $debug=$config["debuglevel"];
+	
+	$switchtime=2;
+	if(isset($config["refresh_time"])) $switchtime=$config["refresh_time"]+1;
+	
+	include "surftool3.inc";
+ 
+ 	if(!isset($_SESSION["login"])){
+		$meta="<meta http-equiv='refresh' content='0; URL=index.php'>";
+		print_header($meta);
+		echo "login first <a href='index.php'> weiter </a>";
+		exit(0);
+	}
+	else if(isset($_POST["mode"])){
+		$meta="<meta http-equiv='refresh' content='".$switchtime."' />";
+		print_header($meta);
+	}
+	else{
+		$meta="";
+		print_header($meta);
+	}
+	
+
+
+	//Print logout button
+	echo "<form action='index.php' method='post'>
+		<input type='submit' name='logout' value='logout'>
+	</form> ";	
+
+
+	function write_domains_command($mode,$add,$remove){
+		write_command("'set_domains','$mode','$add','$remove'");
+	}
+
+	function write_acl_command($aclname, $newmode){
+		write_command("'set_acl_mode','$aclname','$newmode'");
+	}
+
+	function write_command($command){
+		$i=0;
+		$path="/tmp/surftool/";
+		$filename="/tmp/surftool/surftool-".date("Y-m-d-H-i")."-";
+		
+		if(!file_exists($path)){
+			if (!mkdir($path, 0700, true)) {
+				die('Failed to create folders...');
+			}
+		}
+		
+		//don't change existing files
+		while(  file_exists($filename.$i.".txt")  ){
+			$i++;
+		}
+
+		$fp = fopen($filename.$i.".txt", "a");
+		fwrite($fp, "$command");
+		fclose($fp);
+	}
+
+	function print_switch_mode($squidGuardOnlyDomains, $squidGuardWhiteDomains,$admin=true){
+		$html = "<h2 id='ModusSimpleHeader'>Modus: normal</h2>";
+		$html.= "<h2 id='ModusExpertHeader' style='display:none;'>Modus: erweitert</h2>";
+		$html.= "<a href='#' id='ModusSimpleLink' onclick='switch_2_expert();return false'>(Hier klicken für den erweiterten Modus)</a>";
+		$html.= "<a href='#' id='ModusExpertLink' onclick='switch_2_simple();return false' style='display:none;'>(Hier klicken für den normalen Modus)</a>";
+
+		//=== Print Expert Modus	
+		$html.= "<table id='ModusExpertSettings' style='display:none;'>";
+		$html.= " <tr><td colspan='2'><h2>Erweiterter Modus</h2></td></tr>\n";
+		$html.= "	<tr><td colspan='2' id='showmodus'>gewählter Modus: on</td></tr>\n
+			<tr><td><input type='radio' name='mode' value='on' checked id='ModusNormalRadio' onclick='switch_mode(\"on\");' >Normale Freigabe</td>     <td class='Color_on showMode'> Raum </td></tr>\n
+			<tr><td><input type='radio' name='mode' value='onplus' onclick='switch_mode(\"onplus\");' >Erweiterte Freigabe mit zusätzlichen Seiten</td><td class='Color_onplus showMode'> Raum </td></tr>\n
+			<tr><td><input type='radio' name='mode' value='only' onclick='switch_mode(\"only\");' >Nur bestimmte Seiten freigeben</td>                 <td class='Color_only showMode'> Raum </td></tr>\n
+			<tr><td><input type='radio' name='mode' value='off' onclick='switch_mode(\"off\");' >Internetzugang ausschalten</td>                       <td class='Color_off showMode'> Raum </td></tr>\n";
+
+
+		if($admin){
+			$html.= "<tr><td><input type='radio' name='mode' value='adminfree' onclick='switch_mode(\"adminfree\");' >Administrative Freigabe<br></td>    <td class='Color_adminfree showMode'> Raum </td></tr>\n";
+		}
+
+	//      
+		$html.= "</table>";
+		
+		$html.= "<table border='0' id='whitelist' style='display:none;'>
+			<tr>
+				<td><h2>Liste der <u>zusätzlich</u> freigegebenen Seiten</h2></td>
+			</tr>
+			<tr>
+				<td><textarea name='domains_onplus' cols='80' rows='15' >$squidGuardWhiteDomains</textarea></td>\n
+			</tr>
+			<tr>
+				<td>Hinweis: Diese Seiten/Domain erweitert die normale Freigabe.  Änderungen dieser Liste werden durch einen Klick auf den gewünschten Raum übernommen.
+				    Diese Liste gilt für alle Räume in diesem Modus. Aus diesem Grund sollten Änderungen nicht leichtfertig erfolgen.
+				 Änderungen werden protokoliert.
+				    Erweiterungen der Freigaben sind nur für pädagogisch unterrichtsrelevante Seiten zulässig. </td>\n
+			</tr>
+		      </table>";
+
+		$html.= "<table border='0' id='onlylist' style='display:none;'>
+			<tr>
+				<td><h2>Liste der <u>einzigen</u> freigegebenen Seiten</h2></td>
+			</tr>
+			<tr>
+				<td><textarea name='domains_only' cols='80' rows='15'>$squidGuardOnlyDomains</textarea></td>\n
+			</tr>
+			<tr>
+				<td>Hinweis: Nur diese Seiten/Domain werden freigegeben. Änderungen dieser Liste werden durch einen Klick auf den gewünschten Raum übernommen.
+				    Diese Liste gilt für alle Räume in diesem Modus. Aus diesem Grund sollten Änderungen nicht leichtfertig erfolgen.
+				 Änderungen werden protokoliert.
+				    Freigaben sind nur für pädagogisch unterrichtsrelevante Seiten zulässig. </td>\n
+			</tr>
+		      </table>";
+
+		$html.= "</td></tr></table>";
+		return $html;
+		
+	}
+
+
+	function preecho($data){
+		echo "<PRE>";
+		print_r($data);
+		echo "</PRE>";
+	}
+
+
+	function create_room_button($aclname,$mode){
+		echo "	<td><input type='submit' name='group' value='$aclname' class='Color_$mode Button'></td>\n";
+	}
+
+	function print_table($acls){
+	
+		if(sizeof($acls)>0){
+			$spalten=4;
+			$i=0;
+			echo "<table border='0'>\n<tr>\n";
+			foreach($acls["acl"] AS $acl){
+				$i++;
+				echo create_room_button($acl["acl-name"],$acl[mode]);
+
+				if($i%$spalten==0){
+					echo "\n    </tr>\n    <tr>\n";
+				}
+			}
+			$rest=$spalten-$i%$spalten;
+			if($rest>0){
+				echo "  <td colspan=$rest>&nbsp;<td>\n</tr>\n";
+			}
+			echo "</table>\n";
+		}
+		else{
+			echo "keine<br>";
+		}
+	}
+
+	
+	
+	$sgconf = new surftoolSquidGuardConf($config);
+	
+
+	$changes=false;
+	//preecho($_POST);
+	//Check Post-Data
+	if(isset($_POST["group"]) AND isset($_POST["mode"]) ){
+		$group=$_POST["group"];
+		$mode=$_POST["mode"];
+		if(isset($sgconf->squidGuardConf["acl"]["$group"])){
+			if($mode=="on" AND $sgconf->squidGuardConf["acl"]["$group"]["mode"]=="on") $mode="off";
+			write_acl_command($group, $mode);
+			echo "Switch $group to $mode<br>\n";
+			$changes=true;
+		}
+		else{
+			echo "Error unknown group:'$group'<br>\n";
+		}
+		
+	}
+
+	if(isset($_POST["mode"]) AND isset($_POST["domains_onplus"]) ){
+		if($_POST["mode"]=="onplus"){
+			//Any Changes?
+			if($_POST["domains_onplus"] != $sgconf->squidGuardOnplusDomains){
+				//What Changes?
+				$changes=$sgconf->compare_domains_onplus( $_POST["domains_onplus"] );
+
+				write_domains_command("onplus", $changes["add"],$changes["remove"] );
+				echo "<br>".$changes["msg"];
+				$changes=true;
+			}
+			else{
+				if($debug>2) echo "OnplusDomains: no changees<br>\n";
+			}
+		}
+	}
+	
+	if(isset($_POST["mode"]) AND isset($_POST["domains_only"]) ){
+		if($_POST["mode"]=="only"){
+			//Any Changes?
+			if($_POST["domains_only"] != $sgconf->squidGuardOnlyDomains){
+				//What Changes?
+				$changes=$sgconf->compare_domains_only( $_POST["domains_only"] );
+				
+				write_domains_command("only", $changes["add"],$changes["remove"] );
+				echo "<br>".$changes["msg"];
+				$changes=true;
+			}
+			else{
+				if($debug>2) echo "OnlyDomains: no changees<br>\n";
+			}
+		}
+	}	
+
+	if($changes){
+		echo "<br>Please wait ".$switchtime."s<br>";
+		echo "<br><a href=''>Switch an other group</a><br>"; 
+		exit(0);
+	}
+		
+	//===
+	echo "\n<form action='' method='post'>\n";
+	echo "<form accept-charset='$encoding'> ";
+	echo print_switch_mode($sgconf->squidGuardOnlyDomains, $sgconf->squidGuardOnplusDomains);
+	
+	//Get groups/acls
+	$groupsAll=$sgconf->squidGuardConf;
+
+	//=== Find Groups with similar ip.
+	// ip adresses ar in $groupsAll["src"]["NAME"] and acls are in => $groupsAll["acl"]["NAME"]
+	$ip = $_SERVER["REMOTE_ADDR"];
+	$lastpoint=strripos($ip,'.');
+	$firstpart=substr($ip,0,$lastpoint);
+	$groupsNear=array();
+	foreach($groupsAll["src"] AS $srcname => $src){
+		if(isset($src["ip"])){
+			foreach($src["ip"] AS $ip){
+				$pos = strpos($ip, $firstpart);
+				if( $pos !== false){
+					if(isset($groupsAll["acl"]["$srcname"])){
+						$groupsNear["acl"]["$srcname"]=$groupsAll["acl"]["$srcname"];
+					}
+					else{
+						echo "Warning: no acl:'$srcname'<br>\n ";
+					}
+				}
+			}
+		}
+		else echo "no src<br>\n";
+	}
+
+
+	echo "<pre>";
+	//print_r($sgconf);
+	echo "</pre>";
+	
+	echo "<h2>Vorschläge</h2>";
+	print_table($groupsNear);	
+	echo "<h2>Alle Räume</h2>";
+	print_table($groupsAll);
+
+
+	echo "\n</form>\n";
+	
+
+
+	//if($debug>1) preecho($data);
+
+	echo"
+	<form action='index.php' method='post'>
+		<input type='submit' name='logout' value='logout'>
+	</form> ";	
+
+
+
+?>
diff -uNr packages_org/config/surftool/surftool.cfg packages/config/surftool/surftool.cfg
--- packages_org/config/surftool/surftool.cfg	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/surftool.cfg	2015-07-13 17:36:42.000000000 +0200
@@ -0,0 +1,15 @@
+; Surftool configuration
+	language = "eng"
+	refresh_time = "1"
+	squid_binary_path = "/usr/local/sbin/squid"
+	squidGuard_binary_path = "/usr/local/bin/squidGuard"
+	squidGuard_configfile = "/usr/pbi/squidguard-amd64/etc/squidGuard/squidGuard.conf"
+	squidGuard_database = "/var/db/squidGuard/"
+	group_onplus = "surftool_onplus"
+	group_only = "surftool_only"
+	command_path = "/tmp/surftool"  
+	user_name = "admin"  
+	user_password = "pfsense"  
+	logfile= "/var/log/surftool.log"
+	logout_target= "http://10.12.0.10/index.php"
+	redirect_secret = "geheim"
diff -uNr packages_org/config/surftool/surftool.inc packages/config/surftool/surftool.inc
--- packages_org/config/surftool/surftool.inc	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/surftool.inc	2015-08-08 18:43:52.000000000 +0200
@@ -0,0 +1,326 @@
+<?php
+/*
+	surftool.inc
+	Copyright (C) 2015 H-T Reimers <reimers@mail.de>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once('globals.inc');
+require_once('config.inc');
+require_once('util.inc');
+require_once('pfsense-utils.inc');
+require_once('pkg-utils.inc');
+require_once('filter.inc');
+require_once('service-utils.inc');
+
+if (file_exists('surftool.inc')) {
+  require_once('surftool.inc');
+}
+else update_log("File 'surftool.inc' not found.");
+
+global $pfs_version;
+$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+switch ($pfs_version) {
+	case "2.1":
+		break;
+	case "2.2":
+		break;
+	default:
+		break;
+}
+
+define ('CMD_PKGDELETE', 'pkg_delete surftool-0.01');
+
+// enable GUI debug
+define('SURFTOOL_GUI_DEBUG', 'on');
+define('SURFTOOL_LOG_FILE',  '/tmp/surftool_gui.log');
+
+// configuration settings !-- CHECK THIS --!
+define('SURFTOOL_WWWPATH',			'/usr/local/www/surftool/');
+define('SURFTOOL_WWWCONFIGFILE',		SURFTOOL_WWWPATH.'surftool.cfg');
+define('SURFTOOL_STARTUP_SCRIPT', '/usr/local/etc/rc.d/surftooldaemon.sh');
+
+// xml variables
+define('SURFTOOL_LANGUAGE',				'surftool_lang');
+define('SURFTOOL_REFRESH_TIME',				'surftool_refresh_time');
+define('SURFTOOL_SQUID_BINARY_PATH',			'surftool_squid_binary');
+define('SURFTOOL_SQUIDGUARD_BINARY_PATH',	'surftool_sg_binary');
+define('SURFTOOL_SQUIDGUARD_CONFIGFILE',	'surftool_sg_config_file');
+define('SURFTOOL_SQUIDGUARD_DATABASE',		'surftool_sg_db');
+define('SURFTOOL_GROUP_ONPLUS',			'surftool_group_onplus_name');
+define('SURFTOOL_GROUP_ONLY',				'surftool_group_only_name');
+define('SURFTOOL_DEBUGLEVEL',				'surftool_debuglevel');
+define('SURFTOOL_LOGFILE',					'surftool_logfile');
+define('SURFTOOL_CMD_PATH',					'surftool_command_path');
+define('SURFTOOL_LOGOUT_TARGET',					'surftool_logout_target');
+define('SURFTOOL_REDIRECT_SECRET',					'surftool_redirect_secret');
+define('SURFTOOL_USER_NAME',					'surftool_user_name');
+define('SURFTOOL_USER_PASSWORD',					'surftool_user_password');
+
+
+  
+
+function surftool_install() {
+	global $pfs_version;
+	global $g, $config;
+	$SURFTOOL_STARTUP_SCRIPT=SURFTOOL_STARTUP_SCRIPT;
+	update_log("surftool_install: started" );
+	//Write rc.d script
+	surftool_write_rcfile();
+	//mwexec(SURFTOOL_STARTUP_SCRIPT."  start");
+	//mwexec("/usr/local/etc/rc.d/surftool.sh  start");
+	update_log("surftool_install: stopped");
+	
+}
+
+function surftool_deinstall() {
+	global $g, $config;
+	update_log("surftool_deinstall: started");
+	//exec(SURFTOOL_STARTUP_SCRIPT . " stop");
+	// delete cron task's
+	//ls_setup_cron("lightsquid_squid_rotate", "", "", false);
+	//ls_setup_cron("lightsquid_parser", "", "", false);
+
+
+	update_log("surftool_deinstall: stopped");
+}
+
+
+
+function surftool_resync() {
+	global $config, $pfs_version;
+	surftool_wirte_config_file();
+	surftool_write_rcfile();
+}
+
+
+function surftool_validate(&$post, &$input_errors){
+	global $config;
+	$cfg = $config['installedpackages']['surftool']['config'][0];
+
+	$surftool_refresh_time = trim($cfg[SURFTOOL_REFRESH_TIME]);
+	$surftool_squid_binary = $cfg[SURFTOOL_SQUID_BINARY_PATH];
+	$surftool_sg_binary = $cfg[SURFTOOL_SQUIDGUARD_BINARY_PATH];
+	$surftool_sg_config_file = $cfg[SURFTOOL_SQUIDGUARD_CONFIGFILE];
+	$surftool_sg_db = $cfg[SURFTOOL_SQUIDGUARD_DATABASE];
+	$surftool_group_onplus_name = $cfg[SURFTOOL_GROUP_ONPLUS];
+	$surftool_group_only_name = $cfg[SURFTOOL_GROUP_ONLY];
+	$surftool_debuglevel = $cfg[SURFTOOL_DEBUGLEVEL];
+	$surftool_logfile = $cfg[SURFTOOL_LOGFILE];
+  $surftool_command_path = $cfg[SURFTOOL_CMD_PATH];
+
+//	if(!is_numeric($surftool_refresh_time)) $input_errors[] = "Refresh time: '$surftool_refresh_time' is not numeric";
+//	if(!file_exists($surftool_squid_binary)) $input_errors[] = "The file: '$surftool_squid_binary' do not exists";
+}
+
+
+function surftool_wirte_config_file(){
+	global $config;
+	$cfg = $config['installedpackages']['surftool']['config'][0];
+
+
+	$surftool_lang = $cfg[SURFTOOL_LANGUAGE];
+	$surftool_refresh_time = $cfg[SURFTOOL_REFRESH_TIME];
+	$surftool_squid_binary = $cfg[SURFTOOL_SQUID_BINARY_PATH];
+	$surftool_sg_binary = $cfg[SURFTOOL_SQUIDGUARD_BINARY_PATH];
+	$surftool_sg_config_file = $cfg[SURFTOOL_SQUIDGUARD_CONFIGFILE];
+	$surftool_sg_db = $cfg[SURFTOOL_SQUIDGUARD_DATABASE];
+	$surftool_group_onplus_name = $cfg[SURFTOOL_GROUP_ONPLUS];
+	$surftool_group_only_name = $cfg[SURFTOOL_GROUP_ONLY];
+	$surftool_debuglevel = $cfg[SURFTOOL_DEBUGLEVEL];
+	$surftool_logfile = $cfg[SURFTOOL_LOGFILE];
+  $surftool_command_path = $cfg[SURFTOOL_CMD_PATH];
+	$surftool_logout_target = $cfg[SURFTOOL_LOGOUT_TARGET];
+  $surftool_redirect_secret = $cfg[SURFTOOL_REDIRECT_SECRET];
+  $surftool_user_name = $cfg[SURFTOOL_USER_NAME];
+  $surftool_user_password = $cfg[SURFTOOL_USER_PASSWORD];
+
+
+	$stc="; Surftool configuration
+	language = \"".$surftool_lang."\"
+	refresh_time = \"".$surftool_refresh_time."\"
+	squid_binary_path = \"".$surftool_squid_binary ."\"
+	squidGuard_binary_path = \"".$surftool_sg_binary."\"
+	squidGuard_configfile = \"".$surftool_sg_config_file."\"
+	squidGuard_database = \"".$surftool_sg_db."\"
+	group_onplus = \"".$surftool_group_onplus_name."\"
+	group_only = \"".$surftool_group_only_name."\"
+	command_path = \"".$surftool_command_path."\"  
+	user_name = \"".$surftool_user_name."\"  
+	user_password = \"".$surftool_user_password."\"  
+	logfile= \"".$surftool_logfile."\"
+	logout_target= \"".$surftool_logout_target."\"
+	redirect_secret = \"".$surftool_redirect_secret."\"\n";
+
+	file_put_contents(SURFTOOL_WWWCONFIGFILE,$stc);
+
+
+
+}
+
+
+// setup cron tasks
+// original source from '/etc/inc/pfsense-utils.inc' function 'tdr_install_cron'
+// this function safe for other tasks
+// *****************************************************************************
+// - $task_name: cron task name (for config identification) /for searching my cron tasks/
+// - $options:   array=[0:minute][1:hour][2:mday][3:month][4:wday][5:who][6:cmd]
+// - $task_key:  cron command key for searching
+// - $on_off:	true-'on task', false-'off' task
+// required: $task_nameand $on_off
+// *****************************************************************************
+
+
+/*
+define('FIELD_TASKNAME', 'task_name');
+
+function ls_setup_cron($task_name, $options, $task_key, $on_off) {
+	global $config;
+	update_log("ls_setup_cron: start task_name=$task_name, task_key=$task_key, on_off=$on_off");
+
+	// check input params
+	if(!$task_name) {
+		update_log("ls_setup_cron: exit - uncomplete input params.");
+		return;
+	}
+
+	// delete old task(s)
+	if (is_array($config['cron']['item'])) {
+		foreach ($config['cron']['item'] as $key => $item) {
+		# unset crontask by name
+		if (!empty($task_name) && ($item[FIELD_TASKNAME] == $task_name)) {
+			unset($config['cron']['item'][$key]);
+		} else
+		# unset crontask by cmd
+		if ($options[6] && (strpos($item['command'], $options[6]) !== false)) {
+			unset($config['cron']['item'][$key]);
+		}
+		}
+	}
+
+	# install cron task
+	if ($on_off) {
+		if ($task_key) {
+		if (is_array($options)) {
+			# add new
+			$cron_item = array();
+			$cron_item[FIELD_TASKNAME]	= $task_name;
+			$cron_item['minute']		= $options[0];
+			$cron_item['hour']		= $options[1];
+			$cron_item['mday']		= $options[2];
+			$cron_item['month']		= $options[3];
+			$cron_item['wday']		= $options[4];
+			$cron_item['who']		= $options[5];
+			$cron_item['command']		= $options[6];
+
+			# check options
+			if (!$cron_item['who']) $cron_item['who'] = "nobody";
+
+			$config['cron']['item'][] = $cron_item;
+			update_log("ls_setup_cron: add cron task '{$task_name}'='{$cron_item['command']}'");
+		}
+		} else
+		// log
+		update_log("ls_setup_cron: input prm 'task_key' not defined");
+	}
+
+	write_config("Installed cron task '$task_name' for 'lightsquid' package");
+	configure_cron();
+	update_log("ls_setup_cron: Apply new cron settings.");
+}
+*/
+    
+function update_log($log) {
+	if (SURFTOOL_GUI_DEBUG === 'on') {
+		$t_st_log = '';
+		if (file_exists(SURFTOOL_LOG_FILE))
+			$t_st_log = file_get_contents(SURFTOOL_LOG_FILE);
+		$t_st_log .= "\n$log";
+		file_put_contents(SURFTOOL_LOG_FILE, $t_st_log);
+	}
+}
+
+function refresh_now() {
+//	$cmd = CRONTAB_LS_TEMPLATE . " today";
+	update_log("surftool refresh_now: execute command '$cmd'");
+	// create lightsquid report catalog
+
+/*	if (!file_exists(LS_REPORTPATH)) {
+		update_log("lightsquid_install: Create report dir " . LS_REPORTPATH);
+		mwexec("mkdir -p " . LS_REPORTPATH);
+	}
+	mwexec_bg($cmd);
+*/
+}
+
+//check to see if the service is installed if it is return the id
+	function get_service_id ($service_array, $fieldname, $fieldvalue) {
+		$x = 0;
+		$id = '';
+		foreach($service_array as $rowhelper) {
+			if ($rowhelper[$fieldname] == $fieldvalue) {
+				$id = $x; //return the id
+			}
+			$x++;
+		}
+		if (strlen($id) > 0) {
+			return ($id);
+		}
+		else {
+			return false;
+		}
+	}
+
+
+function surftool_write_rcfile() {
+	global $config;
+	$cfg = $config['installedpackages']['surftool']['config'][0];
+	$surftool_refresh_time = $cfg[SURFTOOL_REFRESH_TIME];
+	$surftool_logfile = $cfg[SURFTOOL_LOGFILE];
+  $surftool_command_path = $cfg[SURFTOOL_CMD_PATH];
+	$rc = array();
+	$SURFTOOL_LOCALBASE = "/usr/local/share/surftool/" ; //SURFTOOL_LOCALBASE;
+	$rc['file'] = 'surftooldaemon.sh';
+	$rc['start'] = <<<EOD
+mkdir -p $surftool_command_path
+	{$SURFTOOL_LOCALBASE}surftooldaemon.sh $surftool_refresh_time $surftool_logfile $surftool_command_path &
+EOD;
+	$rc['stop'] = <<<EOD
+touch $surftool_command_path/stoppdaemon
+	sleep 2
+	ps ax | grep surftooldaemon.sh | grep -v grep | awk '{print $1}' | xargs kill
+	ps ax | grep surftool/check_and_activate.php | grep -v grep | awk '{print $1}' | xargs kill
+EOD;
+	$rc['restart'] = <<<EOD
+	rc_stop
+	rc_start
+EOD;
+	conf_mount_rw();
+	write_rcfile($rc);
+	conf_mount_ro();
+
+}
+
+
+?>
diff -uNr packages_org/config/surftool/surftool.xml packages/config/surftool/surftool.xml
--- packages_org/config/surftool/surftool.xml	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/surftool.xml	2015-08-08 18:43:37.000000000 +0200
@@ -0,0 +1,275 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
+<packagegui>
+        <copyright>
+        <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+    surftool.xml
+    part of pfSense (http://www.pfSense.com)
+    Copyright (C) 2015 H. Reimers <reimers@mail.de>.
+    All rights reserved.
+                                                                              */
+/* ========================================================================== */
+/*
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+     1. Redistributions of source code must retain the above copyright notice,
+        this list of conditions and the following disclaimer.
+
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+    POSSIBILITY OF SUCH DAMAGE.
+    
+                                                                              */
+/* ========================================================================== */
+        ]]>
+        </copyright>
+	<description>Manage your squidguard groups. You can set every group very easily. The modes on/off/only/on plus and adminfree are available. This tool was made for schools.</description>
+	<requirements>This package needs squidguard</requirements>
+	<faq>Currently there are no FAQ items provided.</faq>
+	<name>surftool</name>
+	<version>0.01</version>
+	<title>Services: Surftool -> Settings</title>
+	<category>Services</category>
+	<include_file>/usr/local/pkg/surftool.inc</include_file>
+	<service>
+		<name>surftool</name>
+		<rcfile>surftooldaemon.sh</rcfile>
+		<executable>/bin/sh /usr/local/share/surftool/surftooldaemon.sh</executable>
+		<description>Surftool--Service</description>
+		<custom_php_service_status_command>$surftool_ret = exec('/bin/pgrep -anf surftooldaemon.sh'); if($surftool_ret>0) {return true;} else {return false;};</custom_php_service_status_command>
+	</service>
+	<menu>
+		<name>Surftool</name>
+		<tooltiptext>Manage your squidguard groups</tooltiptext>
+		<section>Services</section>
+		<url>/pkg_edit.php?xml=surftool.xml&amp;id=0</url>
+	</menu>
+        <tabs>
+                <tab>
+                        <text>Settings</text>
+                        <url>/pkg_edit.php?xml=surftool.xml&amp;id=0</url>
+                        <active/>
+                </tab>
+                <tab>
+                        <text>Switch groups</text>
+                        <url>/surftool/index.php</url>
+                </tab>
+        </tabs>
+        <additional_files_needed>
+               <prefix>/usr/local/pkg/</prefix>
+               <chmod>0755</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/surftool.inc</item>
+        </additional_files_needed>
+        <additional_files_needed>
+               <prefix>/usr/local/www/surftool/</prefix>
+               <chmod>0644</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/index.php</item>
+        </additional_files_needed>
+	<additional_files_needed>
+               <prefix>/usr/local/www/surftool/</prefix>
+               <chmod>0644</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/surftool3.inc</item>
+        </additional_files_needed>
+        <additional_files_needed>
+               <prefix>/usr/local/www/surftool/</prefix>
+               <chmod>0644</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/check_and_activate.php</item>
+        </additional_files_needed>
+        <additional_files_needed>
+               <prefix>/usr/local/www/surftool/</prefix>
+               <chmod>0644</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/set.php</item>
+        </additional_files_needed>
+        <additional_files_needed>
+               <prefix>/usr/local/share/surftool/</prefix>
+               <chmod>0755</chmod>
+               <item>http://10.12.0.3/packages/config/surftool/surftooldaemon.sh</item>
+        </additional_files_needed>
+
+
+        <fields>
+                <field>
+                        <fielddescr>Language</fielddescr>
+                        <fieldname>surftool_lang</fieldname>
+                        <description>Select language</description>
+                        <type>select</type>
+                        <value>eng</value>
+                        <options>
+                                 <option><name>English</name><value>eng</value></option>
+                                 <option><name>German</name><value>deu</value></option>
+                        </options>
+                </field>
+		<field>
+			<fielddescr>Refresh time</fielddescr>
+			<fieldname>surftool_refresh_time</fieldname>
+			<value>2</value>
+			<type>input</type>
+			<description>
+				<![CDATA[Look every x seconds for changes <br>
+				Default:<b>1</b>]]>
+			</description>
+			<size>4</size>
+		</field>   
+		<field>
+			<fielddescr>Path to the squid binary</fielddescr>
+			<fieldname>surftool_squid_binary</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path to the squid binary. <br>
+				Default for amd64:<b>/usr/pbi/squid-amd64/local/sbin/squid</b>]]>
+			</description>
+			<size>70</size>
+		</field>  
+		<field>
+			<fielddescr>Path to the squidGuard binary</fielddescr>
+			<fieldname>surftool_sg_binary</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path to the squidGuard binary. <br>
+				Default:<b>/usr/local/bin/squidGuard</b>]]>
+			</description>
+			<size>70</size>
+		</field>  		
+		<field>
+			<fielddescr>Path to the squidGuard configuration file</fielddescr>
+			<fieldname>surftool_sg_config_file</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path to the squidGuard configuration file. <br>
+				Default for amd64:<b>/usr/pbi/squidguard-amd64/etc/squidGuard/squidGuard.conf</b>]]>
+			</description>
+			<size>70</size>
+		</field>  			
+		<field>
+			<fielddescr>Path to the squidGuard database</fielddescr>
+			<fieldname>surftool_sg_db</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path to the squidGuard database. <br>
+				Default:<b>/var/db/squidGuard/</b>]]>
+			</description>
+			<size>70</size>
+		</field>  			
+		<field>
+			<fielddescr>Name of the squidGuard group onplus</fielddescr>
+			<fieldname>surftool_group_onplus_name</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the name of the squidguard group onplus. <br>
+				Default:<b>surftool_onplus</b>]]>
+			</description>
+		</field>         		
+		<field>
+			<fielddescr>Name of the squidGuard group only</fielddescr>
+			<fieldname>surftool_group_only_name</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the name of the squidguard group only. <br>Default:<b>surftool_only</b>]]>
+			</description>
+		</field>   
+		<field>
+			<fielddescr>command path</fielddescr>
+			<fieldname>surftool_command_path</fieldname>
+			<value>/tmp/surftool</value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path for the command files. <br>Default:<b>/tmp/surftool</b>]]>
+			</description>
+		</field>    
+		<field>
+			<fielddescr>logfile</fielddescr>
+			<fieldname>surftool_logfile</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the path and name of the logfile. <br>Default:<b>/var/log/surftool.log</b>]]>
+			</description>
+			<size>70</size>
+		</field>    
+
+		<field>
+			<fielddescr>loglevel</fielddescr>
+			<fieldname>surftool_debuglevel</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter the loglevel. <br>0 less<br>9 much<br>Default:<b>0</b>]]>
+			</description>
+			<size>3</size>
+		</field>   
+		<field>
+			<fielddescr>logout target</fielddescr>
+			<fieldname>surftool_logout_target</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Enter a link for auto redirection after logout<br>Maybe:<b>http://10.12.0.10/index.php</b>]]>
+			</description>
+			<size>70</size>
+		</field> 
+		<field>
+			<fielddescr>Secret external link</fielddescr>
+			<fieldname>surftool_redirect_secret</fieldname>
+			<type>password</type>
+			<description>
+				<![CDATA[A secret for others system, which refer with a link to the surftool site<br>Default:<b>not set</b>]]>
+			</description>
+		</field>
+		<field>
+			<fielddescr>user name</fielddescr>
+			<fieldname>surftool_user_name</fieldname>
+			<value></value>
+			<type>input</type>
+			<description>
+				<![CDATA[Username for the local user<br>Default:<b>admin</b>]]>
+			</description>
+			<size>20</size>
+		</field>   
+		<field>
+			<fielddescr>user password</fielddescr>
+			<fieldname>surftool_user_password</fieldname>
+			<type>password</type>
+			<description>
+				<![CDATA[Password for the local user<br>Default:<b>admin</b>]]>
+			</description>
+		</field>
+	</fields>
+	<custom_php_validation_command>
+		surftool_validate($_POST, $input_errors);
+	</custom_php_validation_command>
+	<custom_php_resync_config_command>
+		exec("/bin/rm -f /usr/local/etc/rc.d/surftool*");
+	  	surftool_resync();
+	</custom_php_resync_config_command>
+	<custom_php_install_command>
+		surftool_install();
+		surftool_resync();
+	</custom_php_install_command>
+	<custom_php_deinstall_command>
+		surftool_deinstall();
+		exec("/bin/rm -f /usr/local/etc/rc.d/surftool*");
+		exec("/bin/rm -f -r /usr/local/share/surftool/");
+	</custom_php_deinstall_command>
+</packagegui>
diff -uNr packages_org/config/surftool/surftool3.inc packages/config/surftool/surftool3.inc
--- packages_org/config/surftool/surftool3.inc	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/surftool3.inc	2015-08-08 18:43:16.000000000 +0200
@@ -0,0 +1,773 @@
+<?php
+/*
+	surftool3.inc
+	Copyright (C) 2015 H-T Reimers <reimers@mail.de>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+	class surftoolSquidGuardConf{
+
+		var $debug=8;
+		var $squidGuardConfPath="/usr/pbi/squidguard-amd64/etc/squidGuard/squidGuard.conf";
+		var $squidGuardOnlyName="surftool_only";
+		var $squidGuardOnlyPath="/var/db/squidGuard/surftool_only/domains";
+		var $squidGuardOnplusName="surftool_onplus";
+		var $squidGuardOnplusPath="/var/db/squidGuard/surftool_onplus/domains";
+		var $squidBinary = "/usr/local/bin/squid";
+		var $squidGuardBinary = "/usr/local/bin/squidGuard";
+
+		var $squidGuardConfText = ""; //Array: The hole Text of the config file - one line <=> one field
+		var $squidGuardConf = array(); //
+
+		//Onplus Domains
+		var $OnplusChangesActiv=false;
+		var $squidGuardOnplusDomains=""; //String, seperator: " "
+		
+		//Only Domains
+		var $OnlyChangesActiv=false;
+		var $squidGuardOnlyDomains=""; //String, seperator: " "
+
+		//ACL-Modes changes
+		var $aclChangeModeActiv=false;
+		
+		//Reload squid config 
+		var $squidReloadActiv=false;
+
+
+		function __construct($config){
+		
+		//$squidGuardConfPathNew, $squidGuardOnplusPathNew, $squidGuardOnlyPathNew) {
+
+			$this->aclChangeModeActiv=false; //No changes at beginning
+			$this->squidReloadActiv=false; //No changes at beginning
+			
+			//Get Systemconfiguration
+			$this->squidGuardConfPath = $config["squidGuard_configfile"];
+			$this->squidGuardOnplusName = $config["group_onplus"];
+			$this->squidGuardOnplusPath = $config["squidGuard_database"].$config["group_onplus"]."/domains";
+			$this->squidGuardOnlyName = $config["group_only"];
+			$this->squidGuardOnlyPath = $config["squidGuard_database"].$config["group_only"]."/domains";
+			$this->squidBinary = $config["squid_binary_path"];
+			$this->squidGuardBinary = $config["squidGuard_binary_path"];
+			
+			//Check data
+			$this->check();
+			
+			//Get Data from squidGuard.conf
+			$this->parse_squidGuard();
+			//Get Group Mode (on,off,only,onplus,adminfree)
+			$this->getAclMode();
+
+			//Get Array with domains for onplus mode
+			$this->squidGuardOnplusDomains=$this->parse_squidGuardDomains($this->squidGuardOnplusPath);
+			
+			//Get Array with domains for only mode
+			$this->squidGuardOnlyDomains=$this->parse_squidGuardDomains($this->squidGuardOnlyPath);
+			
+			
+			
+			//print_r($this->squidGuardOnplusDomains );
+
+		}
+		
+		function check(){
+			$error_msg=array();			
+			if( !file_exists($this->squidBinary)){
+				$error_msg[]="Warning: squid binary '$this->squidBinary' do not exists\n";
+			}
+			if( !file_exists($this->squidGuardBinary)){
+				$error_msg[]="Warning: squidGuard binary '$this->squidGuardBinary' do not exists\n";
+			}
+			if( !file_exists($this->squidGuardConfPath)){
+				$error_msg[]="Warning: squidGuard configuration file '$this->squidGuardConfPath' do not exists\n";
+			}
+			if( !file_exists($this->squidGuardOnplusPath)){
+				$error_msg[]="Warning: onplus group - file '$this->squidGuardOnplusPath' do not exists\n";
+			}
+			if( !file_exists($this->squidGuardOnlyPath)){
+				$error_msg[]="Warning: only group - file '$this->squidGuardOnlyPath' do not exists\n";
+			}			
+			if(sizeof($error_msg)>0) print_r($error_msg);
+		}
+		
+		function squidReload(){
+			if($this->squidReloadActiv){
+				$command=$this->squidBinary." -k reconfigure"; //#Squid/SquidGuard Config reload 
+				$output=array();
+				$return_var="";
+				exec (  $command, $output , $return_var );
+				if($return_var!=0 AND $this->debug>=2) echo "Error: squidReload: Can't exec '$command'!\n";
+				else if($this->debug>=3) echo "Info - squidReload: exec '$command' returns: '$return_var'!\n";
+				else if($this->debug>=6) print_r($output);
+			}
+			else{
+				if($this->debug>=3) echo "Info - squidReload: no reload\n";
+			}
+		}
+		
+		function write_squidGuardConf(){
+			if($this->aclChangeModeActiv==true){
+				// Array-->String (with End Of Line)
+				$str = implode(PHP_EOL, $this->squidGuardConfText );
+				file_put_contents("$this->squidGuardConfPath", $str);
+				$this->squidReloadActiv=true;
+			}
+			else{
+				if($this->debug>=2) echo "Info - write_squidGuardConf: no changes\n"; 
+			}
+			
+		}
+
+		function parse_squidGuardDomains($file){
+			if(!file_exists($file)){
+				echo "parse_squidGuardDomains - Error: Can't access '$file'<br>\n";
+			}
+			else{
+				$t = file_get_contents($file);
+				$t = str_replace("\r\n", "\n", $t);
+				$t = str_replace("\n", " ", $t);
+				$domains=explode(" ",$t);
+				$t="";
+				//Search wrong entries
+				foreach($domains AS $domain){
+					$t.=" ".$this->clean_domain($domain);
+				}
+				return $t;
+			}
+		}
+
+		function endsWith( $haystack, $needle,$debug=0){
+			$length = strlen($needle);
+			if ($length == 0) {
+				return true;
+			}
+			if($debug>=3) echo "endsWith".$length.substr($haystack, -$length)."\n";
+			return (substr($haystack, -$length) === $needle);
+		}
+
+		function setDomains($group,$add,$remove){
+			
+			if( sizeof($remove)>0 OR sizeof($add)>0 ){
+				if($group=="onplus" ){
+					$this->OnplusChangesActiv=true; 
+					$target=&$this->squidGuardOnplusDomains;
+				}
+				else if($group=="only" ){
+					$this->OnlyChangesActiv=true; 
+					$target=&$this->squidGuardOnlyDomains;
+				}
+				else {
+					echo "Error setDomains: unknown group: '$group'\n";
+				}			
+			}
+			
+			//Search wrong entries
+			$domains=explode(" ",$target);
+			$target="";
+			foreach($domains AS $domain){
+				$target.=" ".$this->clean_domain($domain);
+			}
+
+			
+			if(sizeof($remove)>0){
+				foreach($remove AS $domain){
+					if($this->debug>=2) echo "remove $domain from $group<br>\n";
+					$target=str_replace("$domain","",$target);
+				}
+			}
+			if(sizeof($add)>0){
+				foreach($add AS $domain){
+					if($this->debug>=2) echo "add $domain to $group<br>\n";
+					//First replace -> no double entries
+					$target=str_replace("$domain","",$target);
+					$target.=" ".$domain;
+				}
+			}
+			//Remove double blanks
+			$target = preg_replace ('#\s+#' , ' ' , $target );
+			$target = trim($target );
+		}
+		
+		function write_squidGuardDomains(){
+	
+			if($this->OnplusChangesActiv){
+				//echo $this->squidGuardOnplusDomains; //String, seperator: " "
+				$str=trim($str);
+				$str =str_replace(" ","\n",$this->squidGuardOnplusDomains);
+
+				//file_put_contents("$this->squidGuardOnplusPath", $str);
+				$fp = fopen("$this->squidGuardOnplusPath","w");
+				fwrite($fp, $str);
+				fclose($fp);
+			
+				//Activate new domainlist
+				$command=$this->squidGuardBinary." -C ".$this->squidGuardOnplusName."/domains -c ".$this->squidGuardConfPath; 
+				$return_var="";
+				system($command, $return_var );
+
+				//Activation ok?
+				if($return_var!=0 AND $this->debug>=1) echo "error: write_squidGuardDomains: Can't exec '$command' returns retval:'$return_var'!\n";
+				if($this->debug>=3) echo "Info - write_squidGuardDomains: Exec '$command' with retval: $return_var !\n";
+				if($this->debug>=6) print_r($output);
+				//Set flag to reload squid configuration
+				$this->squidReloadActiv=true;
+			}
+			else{
+				if($this->debug>=6) echo "Info - write_squidGuardDomains: OnplusChangesActiv not activ !\n";
+			}
+
+			if($this->OnlyChangesActiv){
+				//echo $this->squidGuardOnlyDomains; //String, seperator: " "
+				$str=trim($str);
+				$str =str_replace(" ","\n",$this->squidGuardOnlyDomains);
+				//file_put_contents("$this->squidGuardOnlyPath", $str);
+				$fp = fopen("$this->squidGuardOnlyPath","w");
+				fwrite($fp, $str);
+				fclose($fp);
+				
+				//Activate new domainlist
+				$command=$this->squidGuardBinary." -C ".$this->squidGuardOnlyName."/domains -c ".$this->squidGuardConfPath." > /dev/null 2>&1"; 
+				$return_var="";
+				system($command, $return_var );
+
+				//Activation ok?
+				if($return_var!=0 AND $this->debug>=1) echo "Error: write_squidGuardDomains: Can't exec '$command'!\n";
+				if($this->debug>=3) echo "Info - write_squidGuardDomains: Exec '$command' with retval: $return_var !\n";
+				if($this->debug>=6) print_r($output);
+				//Set flag to reload squid configuration
+				$this->squidReloadActiv=true;
+			}
+			else{
+				if($this->debug>=6) echo "Info - write_squidGuardDomains: OnlyChangesActiv not activ !\n";
+			}
+
+		}
+
+
+		function setAclModeText($oldpasstext,$newmode){
+			//echo "<br>$oldpasstext->$newmode<br>";
+			//Make a clear start point
+			$oldpasstext=str_replace("pass ","",$oldpasstext);
+			$oldpasstext=str_replace("adminfree ","",$oldpasstext);
+			$oldpasstext=str_replace($this->squidGuardOnlyName." ","",$oldpasstext);
+			$oldpasstext=str_replace($this->squidGuardOnplusName." ","",$oldpasstext);
+
+			 if($this->endsWith( $oldpasstext, "none" )){
+				$oldpasstext=str_replace(" none","",$oldpasstext);
+			 }
+			 if($this->endsWith( $oldpasstext, "all" )){
+				$oldpasstext=str_replace(" all","",$oldpasstext);
+			 }
+			 
+			 
+			if($newmode=="on"){ //Normale freigabe
+				$oldpasstext="pass ".$oldpasstext." all";
+			}
+			else if($newmode=="onplus"){ //Erweiterte Freigabe (Normal+WhiteList)
+				$oldpasstext="pass ".$this->squidGuardOnplusName." ".$oldpasstext." all";
+			}
+			else if($newmode=="only"){ //Erweiterte Freigabe (Normal+WhiteList)
+				$oldpasstext="pass ".$this->squidGuardOnlyName." ".$oldpasstext." none";
+			}
+			else if($newmode=="adminfree"){ //Alles mittels der Dest adminfree freigeben;
+				$oldpasstext="pass adminfree ".$oldpasstext." all";
+			}
+			else{
+				//Default:OFF
+				$oldpasstext="pass ".$oldpasstext." none";
+			}
+			//echo "<br>a:$oldpasstext<br>";
+			$oldpasstext = preg_replace ('#\s+#' , ' ' , $oldpasstext ); 
+			return $oldpasstext;
+		}
+
+		function setAclMode(&$aclChangeMode){
+			if(sizeof($this->squidGuardConfText)>2){
+				if(is_array($aclChangeMode)){
+					foreach($aclChangeMode AS $aclname => $mode){
+						//Is there a acl with this name?
+						if(isset($this->squidGuardConf["acl"]["$aclname"])){
+							if($this->debug>=2) echo "$aclname from '".$this->squidGuardConf["acl"]["$aclname"]["mode"]." to '$mode'\n";
+							//Are there any changes?
+							if($this->squidGuardConf["acl"]["$aclname"]["mode"] != $mode){
+								$pass_linenr = $this->squidGuardConf["acl"]["$aclname"]["pass-linenr"];
+								//Is there line with this number?
+								if(isset($this->squidGuardConfText["$pass_linenr"])){
+									//There are changes to write
+									$this->aclChangeModeActiv=true;
+									//Change the text of the acl pass line
+									$this->squidGuardConfText["$pass_linenr"]=$this->setAclModeText($this->squidGuardConfText["$pass_linenr"],$mode);
+									//echo "<br>pass_linenr:".$pass_linenr."<br>pass_text1:".$pass_text1."<br>pass_text2:".$pass_text2."<br>";
+								}
+								else{
+									echo "error in surftoolSquidGuardConf->setAclMode: can't find line nr '$pass_linenr' in  squidGuardConfText! <br>\n";
+								}
+ 								
+							}
+						}
+						else{
+							echo "error in surftoolSquidGuardConf->setAclMode: can't find acl '$acl'! ";
+						}
+					}
+				}
+				else{
+					echo "error in surftoolSquidGuardConf->setAclMode: aclChangeMode no array";
+				}
+			}
+			else{
+				echo "error in surftoolSquidGuardConf->setAclMode: squidGuardConf empty or to short";
+			}
+		}
+
+		function getAclMode(){
+			
+			foreach($this->squidGuardConf["acl"] AS $aclname => $acl){
+				$pass=trim($acl["pass"]);
+				
+				if(strstr($pass,"adminfree ") ){
+					$mode="adminfree";
+				}		
+				else if($this->endsWith( $pass, "none" )){
+					if(strstr($pass,$this->squidGuardOnlyName." ") ){
+						$mode="only";
+					}
+					else{
+						$mode="off";
+					}
+				}
+				else if($this->endsWith( $pass, "all" )){
+					if(strstr($pass,$this->squidGuardOnplusName." ") ){
+						$mode="onplus";
+					}
+					else{
+						$mode="on";
+					}
+				}
+				else{
+					$mode="unknown";
+				}	
+				
+				$this->squidGuardConf["acl"][$aclname]["mode"]=$mode;
+				if($debug>=3) echo "getAclMode: $aclname - mode:$mode - $pass<br>\n";
+			}
+			
+
+		}
+
+		function compare_domains_onplus($destination){
+			return  $this->compare_domains($this->squidGuardOnplusDomains, $destination);
+		}
+
+		function compare_domains_only($destination){
+			return  $this->compare_domains($this->squidGuardOnlyDomains, $destination);
+		}
+
+
+		function clean_domain($domain){
+
+			//no http://
+			$part = str_replace(array("http://", "http:/", "http:",   "http//", "http/"), ' ', $part);
+			//Clean domain
+			$domain = str_replace(array(",", ";","'",":"," ","\r\n", "\r", "\n"), '', $domain); 
+			//Remove double blanks
+			$domain = preg_replace ('#\s+#' , ' ' , $domain ); 
+			//only domains makes www.bbs2leer/school -> www.bbs2leer.de
+
+			if(strpos($domain, '/')>0){
+				$domain = substr($domain, 0, strpos($domain, '/'));
+			}
+
+			//Clean domain
+			$domain=trim($domain);
+
+			//test top level domain
+			$domainparts = explode(".", $domain);
+
+			//min 2 parts like "aaa.de" 
+			if(sizeof($domainparts)<2){
+				return false;
+			}
+			
+			return $domain;
+			
+		}
+
+		function compare_domains(&$destination_on_server, &$destination){
+
+			//Output for user
+			$msg="";
+			//Clean URLs
+			$destination = str_replace(array(",", ";","'"), ' ', $destination); 
+			//Remove double blanks
+			$destination = preg_replace ('#\s+#' , ' ' , $destination ); 
+
+			$destination_parts = explode(" ", $destination);
+			$destination="";
+
+
+			foreach($destination_parts AS $part){
+				//no http://
+				$part = str_replace(array("http://", "http:/", "http:",   "http//", "http/"), ' ', $part);
+				//no Enter and NewLine
+				$part = str_replace(array("\r\n", "\r", "\n"), ' ', $part); 
+				
+				//only domains makes www.bbs2leer/school -> www.bbs2leer.de
+				if(strpos($part, '/')>0){
+					$part = substr($part, 0, strpos($part, '/'));
+				}
+
+				$part = trim($part);
+				if(strlen($part)>2){
+					$part_clean=preg_replace('/[^0-9a-zA-Z. -]/', '', $part);
+
+					//test top level domain
+					$domainparts = explode(".", $part);
+					
+					
+					if(sizeof($domainparts)<2){
+						$msg .= "<br>Fehler: Der Eintrag '<b>$part</b>' ist keine Domain.<br>";
+					}
+					else if($part_clean!=$part){
+						$msg .= "<br>Fehler: Der Eintrag <b>$part</b> enthält ungültige Zeichen! Es sind nur die Zeichen a-z,A-Z,0-9,- und . erlaubt <br>";
+					}
+					else if(strlen($part)>0 AND strlen($part)<4){
+						$msg .= "<br>Fehler: Eintrag <b>$part_clean</b> ist zu kurz (Nur ".strlen($part)." Zeichen)!<br>";
+					}
+					else{
+						$destination.=$part_clean." ";
+					}
+				}
+			}
+
+
+
+			//Find Changes
+			$old = explode(" ", $destination_on_server);
+			$new = explode(" ", trim($destination));
+
+			$add_domain = array_diff($new, $old);
+			foreach($add_domain AS $entry){
+				$add_domain_text.=$entry." ";
+			}
+			
+			$remove_domain = array_diff($old, $new);
+			foreach($remove_domain AS $entry){
+				$remove_domain_text.=$entry." ";
+			}
+			
+			$msg .= "ADD: $add_domain_text<br>REMOVE: $remove_domain_text<br>";
+
+			$retval=array();
+			$retval["msg"]=$msg;
+			$retval["add"]=$add_domain_text;
+			$retval["remove"]=$remove_domain_text;
+			return $retval;
+
+		}
+
+
+
+		/**
+		* $t = Text from file squidGuard.conf.
+		*/
+		function parse_squidGuard(){
+		
+			//Get Data from squidGuard.conf
+			//$squidGuardConfText
+			$t=file_get_contents($this->squidGuardConfPath);
+			
+			/* replace line breaks */
+			$t = str_replace("\r\n", "\n", $t);
+			/* replace tabs */
+			$t = str_replace("\t", " ", $t);	
+			/* replace multiple spaces */
+			//$t=preg_replace('#[\s]{2,}#s', ' ', $t);
+
+			/** Read squidGuard.conf
+			**   { - open a subgroup
+			**   } - close a subgroup
+			**
+			*/
+			$data=array();
+			$data["src"]=array();
+			$data["acl"]=array();
+			$this->squidGuardConfText=explode("\n",$t);
+			$s=$this->squidGuardConfText;
+			for($i=0;$i<sizeof($s);$i++){
+				$s[$i]=trim($s[$i]);
+				$s[$i]=explode("{",$s[$i]);
+				//Found a "{"
+				for($j=0;$j<sizeof($s[$i]);$j++){
+					$s[$i][$j]=trim($s[$i][$j]);
+					$s[$i][$j]=explode("}",$s[$i][$j]);
+					//Found a "}"
+					for($k=0;$k<sizeof($s[$i][$j]);$k++){
+						$s[$i][$j][$k]=trim($s[$i][$j][$k]);
+					}
+				}
+			}
+
+
+			/** parser squidGuard.conf
+			**   acl 
+			**
+			*/
+			$aclname=""; 	//Declare Variable
+			$linenr=0;	//Declare Variable
+			$depth=0;
+			$aclarea=false;
+			$comment_last="";
+			for($i=0;$i<sizeof($s);$i++){
+				for($j=0;$j<sizeof($s[$i]);$j++){
+					for($k=0;$k<sizeof($s[$i][$j]);$k++){
+						
+						//Split configuration an comment part from a line
+						$poshashkey=strpos($s[$i][$j][$k],"#");
+						if($poshashkey!==false){
+							$line=substr($s[$i][$j][$k],0,$poshashkey-1);
+							$comment=substr($s[$i][$j][$k],$poshashkey+1);
+							$comment_last=$comment;
+						}
+						else{
+							$line=$s[$i][$j][$k];
+							$comment="";
+						}
+						
+						$line=preg_replace('#[\s]{2,}#s', ' ', $line);
+						$linee=explode(" ",$line);
+						//print_r($linee);
+						
+						//Search a acl name
+						if($depth==1 AND sizeof($linee) >= 1 AND $aclarea AND strlen($linee[0])>1){
+							$aclname=$linee[0];
+							if($debug>2) echo "Found acl: '$aclname'";
+							$acl=array();
+							$acl["acl-name"]=$aclname;
+							$acl["acl-linenr"]=$i;
+							$data["acl"]["$aclname"]=$acl;
+						}
+						
+						//Search a "pass" part from a acl
+						if($depth==2 AND $aclarea==true){
+							if(substr($line,0,4)=="pass"){
+								$pass=$line;
+								if($debug>4) echo "found passpart form acl $aclname: $pass\n";
+								if(isset($data["acl"]["$aclname"])){
+									$data["acl"]["$aclname"]["pass"]=$pass;
+									$data["acl"]["$aclname"]["pass-linenr"]=$i;
+									$data["acl"]["$aclname"]["comment"]=$comment_last;
+								}
+								else{
+									echo "error no acl $aclname\n";
+								}
+							}
+						}
+
+						//Search a "ip" part from a src
+						if($depth==1 AND $srcarea==true){
+							if($linee[0]=="ip"){
+								//echo "$srcname--".$linee[1]."-$line<br>\n";
+								$data["src"]["$srcname"]["ip"][]=$linee[1];
+							}
+						}
+						
+						if($depth==0 AND sizeof($linee) >= 1){
+							if($linee[0]=="src"){
+								$srcname=$linee[1];
+								$data["src"]["$srcname"]=array();
+								$data["src"]["$srcname"]["ip"]=array();
+								$srcarea=true;
+								
+							}
+							else if($linee[0]=="acl"){
+								$aclarea=true;
+							}
+						}
+						if($debug>2) echo $s[$i][$j][$k]."$depth:$poshashkey-$line-$comment-a:$aclarea\n";
+						if(isset($s[$i][$j][$k+1])) {
+							//here was a "}";
+							$depth--;
+							//Leave acl part from configfile
+							if($aclarea AND $depth==0){
+								$aclarea=false;
+								$aclname="";
+							}
+							//Leave src part from configfile
+  							if($srcarea AND $depth==0){
+								$srcarea=false;
+								$srcname="";
+							}
+						}
+						if($debug>4) echo "$aclname-$line\n";
+					}
+					if(isset($s[$i][$j+1])){
+						//here was a "{"
+						$depth++;
+					}
+				}
+
+			}
+			
+			$this->squidGuardConf=$data;
+			
+		}		
+
+	}
+	
+	class commandReader{
+
+		var $debug=1;
+		var $commandpath="/tmp/surftool";
+		var $changes=false;
+		var $commandfiles=array();
+		//ACL-Modes changes
+		var $aclChangeMode=array();
+		//Domain changes
+		var $domainsOnplusAdd=array();
+		var $domainsOnplusRemove=array();
+		var $domainsOnlyAdd=array();
+		var $domainsOnlyRemove=array();
+ 
+		function __construct($commandpathNew){
+			$this->changes=false; //At start no changes
+			$this->commandpath = $commandpathNew;
+			$this->readCommandFiles();
+			//$this->debuginfo();
+		}
+  
+		function debuginfo(){
+			echo "<PRE>";
+			echo "aclChangeMode\n";
+			print_r($this->aclChangeMode);
+			echo "domainsOnplusAdd\n";
+			print_r($this->domainsOnplusAdd);
+			echo "domainsOnplusRemove\n";
+			print_r($this->domainsOnplusRemove);
+			echo "domainsOnlyAdd\n";
+			print_r($this->domainsOnlyAdd);
+			echo "domainsOnlyRemove\n";
+			print_r($this->domainsOnlyRemove);
+			echo "</PRE>";
+		}
+  
+		function addDomainsToArray(&$domainArray,$domainString){
+			$domains=explode(" ",$domainString);
+			foreach($domains AS $domain){
+				$domainArray[]=$domain;
+			}
+		}
+		
+		function deleteCommandFiles(){
+			foreach($this->commandfiles AS $file){
+				//echo "$this->commandpath/$file";
+				$filename=$this->commandpath."/".$file;
+				if(!unlink($filename)) echo "Error - deleteCommandFiles: Can't delete commandfile:'".$filename."'!\n";
+				
+			}
+
+		}
+  
+		function readCommandFiles(){
+			if(!file_exists("$this->commandpath")) {
+				mkdir("$this->commandpath");
+			}
+			@$handle=opendir ("$this->commandpath");
+			if($handle === false){
+				echo "Error can't open '"."$this->commandpath"."'!\n";
+			}
+	  
+			//Read commandfiles
+				
+			while ($filename = readdir ($handle)) {
+				//use only filenames like surftool*.txt
+				if( substr($filename,0,8)=="surftool" AND $this->endsWith( $filename, ".txt") ){
+					$this->commandfiles[]=$filename;
+				}
+			}
+			closedir($handle);
+			if(sizeof($this->commandfiles)>0) $this->changes=true; //Maybe there are changes
+			sort($this->commandfiles); //Last modification wins
+			foreach($this->commandfiles AS $file){
+				//echo "$this->commandpath/$file";
+				$handle = fopen("$this->commandpath/$file", "r");
+				$line = fgetcsv($handle, 1024,",","'");
+				if(sizeof($line)>=3){
+					$cmd=trim($line[0]);
+					//print_r($line);
+					if($cmd=="set_acl_mode"){
+						$aclname = trim($line[1]);
+						$newmode = trim($line[2]);
+						$this->aclChangeMode["$aclname"]=$newmode;
+						if($this->debug>=3)echo "switch $aclname to $newmode<br>\n";
+					}
+					else if($cmd=="set_domains"){
+						$domaingroup=trim($line[1]);
+						$domainsadd=trim($line[2]);
+						$domainsremove=trim($line[3]);
+						if($this->debug>=3)echo "$domaingroup add:'$domainsadd' remove:'$domainsremove'<br>\n";
+						if($domaingroup=="only"){
+							$this->addDomainsToArray($this->domainsOnlyAdd, $domainsadd);
+							$this->addDomainsToArray($this->domainsOnlyRemove, $domainsremove);
+						}
+						if($domaingroup=="onplus"){
+							$this->addDomainsToArray($this->domainsOnplusAdd, $domainsadd);
+							$this->addDomainsToArray($this->domainsOnplusRemove, $domainsremove);
+						}          
+					}
+					else{
+						if($this->debug>=1) echo "readCommandFiles error: unknown command '".$line[0]."'!<br>\n";
+					}
+		  
+					}
+					fclose($handle);
+				}
+				//Remove double entries
+				$this->domainsOnlyAdd=array_unique($this->domainsOnlyAdd);
+				$this->domainsOnlyRemove=array_unique($this->domainsOnlyRemove);
+				$this->domainsOnplusAdd=array_unique($this->domainsOnplusAdd);
+				$this->domainsOnplusRemove=array_unique($this->domainsOnplusRemove);          
+	      
+				if($this->debug>=4){
+					echo "aclChangeMode:<br>\n";
+					print_r($this->aclChangeMode);
+					print_r($this->domainsOnlyAdd);
+					print_r($this->domainsOnlyRemove);
+					print_r($this->domainsOnplusAdd);
+					print_r($this->domainsOnplusRemove);
+				}
+		}
+    
+		function endsWith( $haystack, $needle,$debug=0){
+			$length = strlen($needle);
+			if ($length == 0) {
+				return true;
+			}
+			if($debug>=3) echo "endsWith".$length.substr($haystack, -$length)."\n";
+			return (substr($haystack, -$length) === $needle);
+		}  
+    
+	}
+
+?>
diff -uNr packages_org/config/surftool/surftooldaemon.sh packages/config/surftool/surftooldaemon.sh
--- packages_org/config/surftool/surftooldaemon.sh	1970-01-01 01:00:00.000000000 +0100
+++ packages/config/surftool/surftooldaemon.sh	2015-07-13 17:38:50.000000000 +0200
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+stoppfile="/tmp/surftool/stoppdaemon"
+
+rm -f "$stoppfile"
+
+while [ ! -f "$stoppfile" ]
+do
+  /usr/local/bin/php --no-header /usr/local/www/surftool/check_and_activate.php >> /var/log/surftool.log
+  sleep 1
+done
diff -uNr packages_org/pkg_config.10.xml packages/pkg_config.10.xml
--- packages_org/pkg_config.10.xml	2015-08-08 18:30:39.000000000 +0200
+++ packages/pkg_config.10.xml	2015-08-08 18:29:42.000000000 +0200
@@ -1658,5 +1658,20 @@
 		<required_version>2.2</required_version>
 		<configurationfile>ftpproxy.xml</configurationfile>
 	</package>
+        <package>
+                <name>Surftool</name>
+                <internal_name>surftool</internal_name>
+                <pkginfolink>https://forum.pfsense.org/</pkginfolink>
+                <descr><![CDATA[Manage your squidguard groups. You can set every group very easily. The modes on/off/only/on plus and adminfree are available. This tool was made for schools.]]></descr>
+                <website>http://www.hreimers.com/surftool</website>
+                <category>Network Management</category>
+                <version>0.01</version>
+                <status>Beta</status>
+                <required_version>2.2</required_version>
+                <config_file>http://freebsd.intern.bbs2leer.de/packages/config/surftool/surftool.xml</config_file>
+                <maintainer>reimers@mail.de</maintainer>
+                <configurationfile>surftool.xml</configurationfile>
+                <only_for_archs>i386 amd64</only_for_archs>
+        </package>
 </packages>
 </pfsensepkgs>
