From 55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Fri, 6 Feb 2009 19:18:00 -0600 Subject: mv packages to config dir to match web layout --- config/squidGuard/.project | 11 + config/squidGuard/sgerror.php | 284 ++++ config/squidGuard/squidguard.inc | 1394 ++++++++++++++++ config/squidGuard/squidguard.xml | 164 ++ config/squidGuard/squidguard_acl.xml | 278 ++++ config/squidGuard/squidguard_configurator.inc | 2106 +++++++++++++++++++++++++ config/squidGuard/squidguard_default.xml | 142 ++ config/squidGuard/squidguard_dest.xml | 190 +++ config/squidGuard/squidguard_log.xml | 76 + config/squidGuard/squidguard_rewr.xml | 142 ++ config/squidGuard/squidguard_time.xml | 143 ++ 11 files changed, 4930 insertions(+) create mode 100644 config/squidGuard/.project create mode 100644 config/squidGuard/sgerror.php create mode 100644 config/squidGuard/squidguard.inc create mode 100644 config/squidGuard/squidguard.xml create mode 100644 config/squidGuard/squidguard_acl.xml create mode 100644 config/squidGuard/squidguard_configurator.inc create mode 100644 config/squidGuard/squidguard_default.xml create mode 100644 config/squidGuard/squidguard_dest.xml create mode 100644 config/squidGuard/squidguard_log.xml create mode 100644 config/squidGuard/squidguard_rewr.xml create mode 100644 config/squidGuard/squidguard_time.xml (limited to 'config/squidGuard') diff --git a/config/squidGuard/.project b/config/squidGuard/.project new file mode 100644 index 00000000..49cdc3c9 --- /dev/null +++ b/config/squidGuard/.project @@ -0,0 +1,11 @@ + + + squidGuard + + + + + + + + diff --git a/config/squidGuard/sgerror.php b/config/squidGuard/sgerror.php new file mode 100644 index 00000000..8084c5c3 --- /dev/null +++ b/config/squidGuard/sgerror.php @@ -0,0 +1,284 @@ + $val) { + if (strpos(strtolower($url), strval($key)) === 0) { + $err_id = $key; + break; + } + } + + # blank page + if ($url === TAG_BLANK) { + echo get_page(''); + } + # blank image + elseif ($url === TAG_BLANK_IMG) { + $msg = trim($msg); + if(strpos($msg, "maxlen_") !== false) { + $maxlen = intval(trim(str_replace("maxlen_", "", $url))); + filter_by_image_size($cl['u'], $maxlen); + exit(); + } + else { + # -------------------------------------------------------------- + # return blank image + # -------------------------------------------------------------- + header("Content-Type: image/gif;"); // charset=windows-1251"); + echo GIF_BODY; + } + } + # error code + elseif ($err_id !== 0) { + $er_msg = strstr($_GET['url'], ' '); + echo get_error_page($err_id, $er_msg); + } + # redirect url + elseif ((strpos(strtolower($url), "http://") === 0) or (strpos(strtolower($url), "https://") === 0)) { + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # redirect to specified url + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + header("HTTP/1.0"); + header("Location: $url", '', 302); + } + // error arguments + else { + echo get_page("sgerror: error arguments $url"); + } +} +else { + echo get_page($_SERVER['QUERY_STRING']); //$url . implode(" ", $_GET)); +# echo get_error_page(500); +} + +# ~~~~~~~~~~ +# Exit +# ~~~~~~~~~~ +exit(); + +# ---------------------------------------------------------------------------------------------------------------------- +# functions +# ---------------------------------------------------------------------------------------------------------------------- +function get_page($body) { + $str = Array(); + $str[] = ''; + $str[] = "\n$body\n"; + $str[] = ''; + return implode("\n", $str); +} + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IE displayed self-page, if them size > 1024 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +function get_error_page($er_code_id, $err_msg='') { + global $err_code; + global $cl; + $str = Array(); + + header("HTTP/1.1 " . $err_code[$er_code_id]); + + $str[] = ''; + $str[] = ''; + $str[] = '

Request denied by pfSense proxy: ' . $err_code[$er_code_id] . '

'; + if ($err_msg) $str[] = " Reason: $err_msg"; + $str[] = '
'; + if ($cl['a']) $str[] = " Client address: {$cl['a']}
"; + if ($cl['n']) $str[] = " Client name: {$cl['n']}
"; + if ($cl['i']) $str[] = " Client user: {$cl['i']}
"; + if ($cl['s']) $str[] = " Client group: {$cl['s']}
"; + if ($cl['t']) $str[] = " Target group: {$cl['t']}
"; + if ($cl['u']) $str[] = " URL: {$cl['u']}
"; + $str[] = '
'; + $str[] = ""; + $str[] = ""; + + return implode("\n", $str); +} + +function get_about() { + global $err_code; + global $page_info; + $str = Array(); + + // about info + $s = str_replace("\n", "
", $page_info); + $str[] = $s; + $str[] = "
"; + + $str[] = ''; + $str[] = ' HTTP error codes (ERROR_CODE):'; + foreach($err_code as $val) { + $str []= "
$val"; + } + $str[] = '
'; + + return implode("\n", $str); +} + +function filter_by_image_size($url, $val_size) { + + # load url header + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_NOBODY, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $hd = curl_exec($ch); + curl_close($ch); + + $size = 0; + $SKEY = "content-length:"; + $s_tmp = strtolower($hd); + $s_tmp = str_replace("\n", " ", $s_tmp); # replace all "\n" + if (strpos($s_tmp, $SKEY) !== false) { + $s_tmp = trim(substr($s_tmp, strpos($s_tmp, $SKEY) + strlen($SKEY))); + $s_tmp = trim(substr($s_tmp, 0, strpos($s_tmp, " "))); + if (is_numeric($s_tmp)) + $size = intval($s_tmp); + else $size = 0; + } + + # === check url type and content size === + # redirect to specified url + if (($size !== 0) && ($size < $val_size)) { + header("HTTP/1.0"); + header("Location: $url", '', 302); + } + # return blank image + else { + header("Content-Type: image/gif;"); + echo GIF_BODY; + } +} +?> \ No newline at end of file diff --git a/config/squidGuard/squidguard.inc b/config/squidGuard/squidguard.inc new file mode 100644 index 00000000..38ab4b7c --- /dev/null +++ b/config/squidGuard/squidguard.inc @@ -0,0 +1,1394 @@ + $val) { + if (substr_count($key, PREF_UPTIME) != 0) { + $name = str_replace(PREF_UPTIME, '', $key); + if ($name) { + switch($val) { + case "allow": $pass_up_val .= " $name"; break; + case "white": $pass_up_val .= " ^$name"; break; + case "deny" : $pass_up_val .= " !$name"; break; + } + } + } + elseif (substr_count($key, PREF_OVERTIME) != 0) { + $name = str_replace(PREF_OVERTIME, '', $key); + if ($name) { + switch($val) { + case "allow": $pass_over_val .= " $name"; break; + case "white": $pass_over_val .= " ^$name"; break; + case "deny" : $pass_over_val .= " !$name"; break; + } + } + } + } + + # !ATTENTION! on pfSense XML config must be must(shell) be '!all' instead of 'none' - it is a must for correct work GUI + + # if not exists key 'all', then add 'none' - default 'deny all' + if ((substr_count($pass_up_val, 'all') == 0)) { + $pass_up_val .= ' !all'; + } + + if (!empty($pass_over_val) && (substr_count($pass_over_val, 'all') == 0)) { + $pass_over_val .= ' !all'; + } + + if (empty($pass_over_val)) + $post[F_DEST] = "$pass_up_val"; + else $post[F_DEST] = "$pass_up_val [$pass_over_val]"; + + # check redirect + $errmsg = ''; + if (!sg_check_redirect($post[F_RMOD], $post[F_REDIRECT], &$errmsg)) { + $input_errors[] = "Redirect info error. $errmsg"; + } +} + +# ------------------------------------------------------------------------------ +# validate times +# Format: +# date: