#----------------------------------------------------------------
#   DO NOT MODIFY THIS FILE AS IT IS MODIFIED BY THE TEMPLATE
#----------------------------------------------------------------
#   SquidGuard CONFIGURATION FILE
#----------------------------------------------------------------

# CONFIGURATION DIRECTORIES
dbhome {"$SquidGuardDb"}
logdir {"$SquidGuardLogDir"}

# TIME RULES:
# abbrev for weekdays: 
# s = sun, m = mon, t =tue, w = wed, h = thu, f = fri, a = sat

{ 
	if ($SquidGuardTimeRestriction =~ /Y/i) {
		$OUT .= "time workhours \{\n";
		$OUT .= "\tweekly s ".$SquidGuardWorkHoursSunAM." ".$SquidGuardWorkHoursSunPM."\n";
		$OUT .= "\tweekly m ".$SquidGuardWorkHoursMonAM." ".$SquidGuardWorkHoursMonPM."\n";
		$OUT .= "\tweekly t ".$SquidGuardWorkHoursTueAM." ".$SquidGuardWorkHoursTuePM."\n";
		$OUT .= "\tweekly w ".$SquidGuardWorkHoursWedAM." ".$SquidGuardWorkHoursWedPM."\n";
		$OUT .= "\tweekly h ".$SquidGuardWorkHoursThuAM." ".$SquidGuardWorkHoursThuPM."\n";
		$OUT .= "\tweekly f ".$SquidGuardWorkHoursFriAM." ".$SquidGuardWorkHoursFriPM."\n";
		$OUT .= "\tweekly a ".$SquidGuardWorkHoursSatAM." ".$SquidGuardWorkHoursSatPM."\n";
		$OUT .= "\}\n";
	};
}

# SOURCE ADDRESSES:
src privilegedsource \{
	iplist	privilegedsource/ips
\}

src bannedsource \{
	iplist	bannedsource/ips
\}

{
    if ($SquidGuardTimeRestriction =~ /Y/i) {
		$OUT .= "src timerestriction \{\n";
		$OUT .= "\tiplist	lansource/lan\n";
		$OUT .= "\}\n";
	};
}

src lansource \{
	iplist lansource/lan
\}

# DESTINATION CLASSES:
dest adult \{
    domainlist adult/domains
    urllist adult/urls
    expressionlist  adult/expressions
\}

dest audio-video \{
    domainlist audio-video/domains
    urllist audio-video/urls
\}

dest forums \{
    domainlist forums/domains
    urllist forums/urls
    expressionlist  forums/expressions
\}

dest hacking \{
    domainlist hacking/domains
    urllist hacking/urls
\}

dest redirector \{
    domainlist redirector/domains
    urllist redirector/urls
    expressionlist  redirector/expressions
\}

dest warez \{
    domainlist warez/domains
    urllist warez/urls
\}

dest ads \{
    domainlist ads/domains
    urllist ads/urls
\}

dest aggressive \{
    domainlist aggressive/domains
    urllist aggressive/urls
\}

dest drugs \{
    domainlist drugs/domains
    urllist drugs/urls
\}

dest gambling \{
    domainlist gambling/domains
    urllist gambling/urls
\}

dest publicite \{
    domainlist publicite/domains
    urllist publicite/urls
    expressionlist  publicite/expressions
\}

dest violence \{
    domainlist violence/domains
    urllist violence/urls
    expressionlist  violence/expressions
\}


dest banneddestination \{
	domainlist banneddestination/domains
	urllist banneddestination/urls
	expressionlist 	banneddestination/expressions
\}

dest advertising \{
	domainlist 		advertising/domains
	urllist 		advertising/urls
{
	$OUT .= "\tredirect http://127.0.0.1:8444/$SquidGuardAdvertisingRedirectUrl\n";
	$OUT .= "\tlog\t$SquidGuardAdvertisingLog\n";
} 

\}

# ACLs
acl \{
	privilegedsource \{
		pass !advertising all
{
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardPrivilegedSourceRedirectUrl\n";
}
	\}
	
	bannedsource \{
		pass none
{
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardBannedSourceRedirectUrl\n";
}
	\}

{
	if ($SquidGuardTimeRestriction =~ /Y/i) {
		$OUT .= "\ttimerestriction outside workhours \{\n";
		$OUT .= "\t\tpass none\n";
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardTimeRestrictionRedirectUrl\n";
		$OUT .= "\t\} else \{\n";
		$OUT .= "\t\tpass !adult !audio-video !forums !hacking !redirector !warez !ads !aggressive !drugs !gambling !publicite !violence !banneddestination !advertising all\n";
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardTimeRestrictionRedirectUrl\n";
		$OUT .= "\t\}\n";

	} else {
		$OUT .= "\tlansource \{\n";
		$OUT .= "\t\tpass !adult !audio-video !forums !hacking !redirector !warez !ads !aggressive !drugs !gambling !publicite !violence !banneddestination !advertising all\n";
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardLanSourceRedirectUrl\n";
		$OUT .= "\t\}\n";
	};
}
	
	default \{
		pass none
{
		$OUT .= "\t\tredirect http://127.0.0.1:8444/$SquidGuardDefaultRedirectUrl\n";
}
	\}
\}
