From f7cdc1edbf14721a73ca73b944902b6d03dca43e Mon Sep 17 00:00:00 2001 From: "D. V. Serg" Date: Mon, 14 Jan 2008 14:15:39 +0000 Subject: - sources page moved to ACL - fix blacklist - add non-80 port support - changes in error report generator page --- packages/squidGuard/sgerror.php | 241 +++++++++++++++++++++--- packages/squidGuard/squidguard.inc | 150 ++++++++++++++- packages/squidGuard/squidguard.xml | 12 +- packages/squidGuard/squidguard_acl.xml | 157 ++++++++++----- packages/squidGuard/squidguard_configurator.inc | 95 ++++++---- packages/squidGuard/squidguard_default.xml | 29 ++- packages/squidGuard/squidguard_dest.xml | 16 +- packages/squidGuard/squidguard_log.xml | 6 +- packages/squidGuard/squidguard_rewr.xml | 6 +- packages/squidGuard/squidguard_time.xml | 6 +- 10 files changed, 551 insertions(+), 167 deletions(-) diff --git a/packages/squidGuard/sgerror.php b/packages/squidGuard/sgerror.php index 302126fb..7e3b5c6c 100644 --- a/packages/squidGuard/sgerror.php +++ b/packages/squidGuard/sgerror.php @@ -1,51 +1,240 @@ $val) { + if (strpos(strtolower($url), strval($key)) === 0) { + $err_id = $key; + break; + } + } + + # blank page + if ($url === 'blank') { + echo get_page(''); + } + # blank image + elseif ($url === TAG_BLANK_IMG) { + # -------------------------------------------------------------- + # 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", '', 301); + header("Location: $url", '', 302); } - exit(); -} else { - header("HTTP/1.0 410"); - exit(); + // 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); } ?> \ No newline at end of file diff --git a/packages/squidGuard/squidguard.inc b/packages/squidGuard/squidguard.inc index a5b61644..e3918042 100644 --- a/packages/squidGuard/squidguard.inc +++ b/packages/squidGuard/squidguard.inc @@ -1,4 +1,5 @@ $val) { if (substr_count($key, PREFLD_UPTIME) != 0) { @@ -166,7 +179,7 @@ function squidguard_validate_acl($post, $input_errors) { else $pass_over_val .= " $key"; } - // !ATTENTION! on pfSense XML config must be must(shall) be '!all' instead of 'none' - it is a must for correct work GUI + // !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)) { @@ -310,6 +323,57 @@ function squidguard_resync() { if ($_POST['submit'] == APPLY_BTN) sg_reconfigure(); } +// ----------------------------------------------------------------------------- +// squidguard_resync_acl +// ----------------------------------------------------------------------------- +function squidguard_resync_acl() { + global $config; + $conf = $config['installedpackages'][MODULE_ACL]['config']; + $id = $_GET['id']; + if (!$id) + $id = $_POST['id']; + + // --- sources --- + // move current id by order + if (($id != '') and is_array($conf) and ($id !== intval($conf[$id]['order']))) { + // copy current item to temp and remove it's from list + $src_new = array(); + $src_cur = $conf[$id]; + unset ($conf[$id]); + + // rebuild list and insert current item by order + $i=0; + foreach($conf as $src) { + if (intval($src_cur['order']) === $i) { + $src_new[] = $src_cur; + unset($src_cur); + $i++; + } + $src_new[] = $src; + $i++; + } + // if current item not inserted - insert him to the end + if (isset($src_cur)) { + $src_new[] = $src_cur; + unset($src_cur); + } + + // renew order values + foreach($src_new as $key => $src) { + $src_new[$key]['order'] = $key; + } + + unset ($config['installedpackages'][MODULE_ACL]['config']); + $config['installedpackages'][MODULE_ACL]['config'] = $src_new; + write_config('Update squidguardacl config'); + } else if (($_GET['act'] === 'del') or ($_POST['act'] === 'del')) { + // update order on delete item + foreach($config['installedpackages'][MODULE_ACL]['config'] as $key => $src) + $config['installedpackages'][MODULE_ACL]['config'][$key]['order'] = $key; + write_config('Update squidguardsrc config'); + } +} + // ----------------------------------------------------------------------------- // squidguard_resync_src // ----------------------------------------------------------------------------- @@ -381,7 +445,7 @@ function get_pkg_items_list($pkg_gui_name, $fieldname) { # ============================================================================== // ----------------------------------------------------------------------------- -// squidguard_before_form_src +// squidguard_before_form_src -- ### will deleted ### // ----------------------------------------------------------------------------- function squidguard_before_form_src($pkg) { global $config; @@ -394,7 +458,7 @@ function squidguard_before_form_src($pkg) { title='move up' width='17' height='17' border='0' onclick='on_moveup()'>"; $img_down = ""; - $s = "Move to: $img_up $img_down
" . $fld['description']; + $s = "$img_up $img_down
Move to: " . $fld['description']; $fld['description'] = $s; } $i++; @@ -461,6 +525,7 @@ function squidguard_before_form($pkg) { // ----------------------------------------------------------------------------- function squidguard_before_form_acl($pkg) { global $config; + global $g; $current_id = ''; $sources = ''; @@ -480,6 +545,22 @@ function squidguard_before_form_acl($pkg) { if ($current_id == '') $current_id = 0; + // 'source' part of 'acl' page + $i=0; + foreach($pkg['fields']['field'] as $field) { + if ($field['fieldname'] == 'order') { + $fld = &$pkg['fields']['field'][$i]; + $img_up = ""; + $img_down = ""; + $s = "Move to: $img_up $img_down
" . $fld['description']; + $fld['description'] = $s; + } + $i++; + } + unset ($i); + // sources $sources = $config['installedpackages']['squidguardsrc']['config']; if (is_array($sources)) { @@ -615,7 +696,7 @@ function squidguard_before_form_log($pkg) { $i=0; $move_pos = 0; $move_step = 50; - +return; foreach($pkg['fields']['field'] as $field) { if ($field['fieldname'] == 'logtype') { $slog = ''; @@ -748,7 +829,7 @@ function make_grid_general_items($id = '') if ($config['installedpackages']['squidguardgeneral']['config'][0]['view_gui_log'] == 'on') { $log_content = sg_getlog(50); $log_content = str_replace("\n","
", $log_content); - $res .= "Web GUI log (Last 50)"; + $res .= "Web GUI log (Latest 50)"; $res .= "$log_content"; } } @@ -999,6 +1080,31 @@ function squidGuard_print_javascript() { $javascript .= "\n"; @@ -1029,7 +1135,7 @@ function squidGuard_print_javascript() { $javascript .= "\n"; } - if ($xml == "squidguard_src.xml") { + if ($xml == "squidguard_src.xml") { ### will deleted ### $javascript .= "\n"; } - print($javascript); + print($javascript); } # ============================================================================== @@ -1092,11 +1198,18 @@ function convert_pfxml_to_sgxml() { $squidxml = $config['installedpackages']['squid']['config'][0]; if(isset($squidxml['transparent_proxy'])) { $lanip = $config['interfaces']['lan']['ipaddr']; + $guiport = $config['system']['webgui']['port']; + $guiprotocol = $config['system']['webgui']['protocol']; + $sgxml[FLD_SQUID_TRANSPARENT_MODE] = 'on'; $sgxml[FLD_CURRENT_LAN_IP] = $lanip; + $sgxml[FLD_CURRENT_GUI_PORT] = $guiport; + $sgxml[FLD_CURRENT_GUI_PROTO] = $guiprotocol; } else { unset($sgxml[FLD_SQUID_TRANSPARENT_MODE]); unset($sgxml[FLD_CURRENT_LAN_IP]); + unset($sgxml[FLD_CURRENT_GUI_PORT]); + unset($sgxml[FLD_CURRENT_GUI_PROTO]); } // store cfg cache @@ -1110,9 +1223,14 @@ function convert_pfxml_to_sgxml() { // convert_pfxml_to_sgxml_source // sgxml_source: [name][ip][desc][log] // ----------------------------------------------------------------- +# Changes 04-01-2008 : +# Source fields moved to ACL page. Source page - will remove +# But in XML internal config nothing to change +# function convert_pfxml_to_sgxml_source($pfconfig) { $sgxml = array(); - +/* +# --- previous ver --- $pfxml = $pfconfig['installedpackages']['squidguardsrc']['config']; if (is_array($pfxml)) { foreach($pfxml as $pfx) { @@ -1125,6 +1243,19 @@ function convert_pfxml_to_sgxml_source($pfconfig) { $sgxml[FLD_ITEM][] = $sgx; } } +*/ + $pfxml = $pfconfig['installedpackages']['squidguardacl']['config']; + if (is_array($pfxml)) { + foreach($pfxml as $pfx) { + $sgx = array(); + $sgx[FLD_NAME] = $pfx['name']; + $sgx[FLD_IP] = $pfx['iplist']; + $sgx[FLD_DOMAINS] = $pfx[FLD_DOMAINS]; + $sgx[FLD_LOG] = $pfx['enablelog']; + $sgx[FLD_DESCRIPTION] = $pfx['description']; + $sgxml[FLD_ITEM][] = $sgx; + } + } return $sgxml; } @@ -1221,7 +1352,8 @@ function convert_pfxml_to_sgxml_acl($pfconfig) { if (is_array($pfxml)) { foreach($pfxml as $pfx) { $sgx = array(); - $sgx[FLD_NAME] = $pfx[FLD_SOURCE]; +# $sgx[FLD_NAME] = $pfx[FLD_SOURCE]; // [04-01-2008] previous ver - this field will removed + $sgx[FLD_NAME] = $pfx[FLD_NAME]; // [04-01-2008] new ver $sgx[FLD_DESCRIPTION] = $pfx[FLD_DESCRIPTION]; $sgx[FLD_DISABLED] = $pfx[FLD_DISABLED]; $sgx[FLD_TIMENAME] = $pfx[FLD_TIME]; diff --git a/packages/squidGuard/squidguard.xml b/packages/squidGuard/squidguard.xml index 895b4fdf..26644e0c 100644 --- a/packages/squidGuard/squidguard.xml +++ b/packages/squidGuard/squidguard.xml @@ -33,10 +33,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -67,12 +63,6 @@ http://www.pfsense.org/packages/config/squidGuard/squidguard_configurator.inc - - http://www.pfsense.org/packages/config/squidGuard/squidguard_acl.xml @@ -85,9 +75,11 @@ http://www.pfsense.org/packages/config/squidGuard/squidguard_rewr.xml + http://www.pfsense.org/packages/config/squidGuard/squidguard_time.xml diff --git a/packages/squidGuard/squidguard_acl.xml b/packages/squidGuard/squidguard_acl.xml index aa3349cd..d9ba4981 100644 --- a/packages/squidGuard/squidguard_acl.xml +++ b/packages/squidGuard/squidguard_acl.xml @@ -14,51 +14,49 @@ A proxy server user has been deleted. A proxy server user has been created/modified. - - - General settings - /pkg_edit.php?xml=squidguard.xml&id=0 - - - Default - /pkg_edit.php?xml=squidguard_default.xml&id=0 - - - ACL - /pkg.php?xml=squidguard_acl.xml - - - - Sources - /pkg.php?xml=squidguard_src.xml - - - Destinations - /pkg.php?xml=squidguard_dest.xml - - - Times - /pkg.php?xml=squidguard_time.xml - - - Rewrites - /pkg.php?xml=squidguard_rewr.xml - - - Log - /pkg_edit.php?xml=squidguard_log.xml - - + + + General settings + /pkg_edit.php?xml=squidguard.xml&id=0 + + + Default + /pkg_edit.php?xml=squidguard_default.xml&id=0 + + + ACL + /pkg.php?xml=squidguard_acl.xml + + + + Destinations + /pkg.php?xml=squidguard_dest.xml + + + Times + /pkg.php?xml=squidguard_time.xml + + + Rewrites + /pkg.php?xml=squidguard_rewr.xml + + + Log + /pkg_edit.php?xml=squidguard_log.xml + + Disable disabled + Destinations dest @@ -88,6 +86,7 @@ Check this for disable this ACL rule. checkbox + + + Name + name + + You can enter name here. Name consist minimum 2 symbols, first from which letter. <br> + All other symbols is [a-Z_0-9]. Source name must be <b>unique</b> . + + input + + 100 + + + Order + order + + Order source in list. <br> + <b>Note:</b> <br> + Sources order have very high importance. Sources are evaluated on a first-match basis. <br> + If your sources have an overlaying ranges, then act will be first in list. <br> + <b>For example:</b> <br> + Wrong order: + First source entry is the range 10.0.0.0/24 and second entry is 10.0.0.15 (or 10.0.0.15/32 ) <br> + Right order: + First source entry is the single ip 10.0.0.15 (or 10.0.0.15/32 ) then the overlaying range 10.0.0.0/24 <br> + + input + 5 + + + Source IP addresses + iplist + + Enter source IP addresses here with space(' ') divider. + IP addresses must have format:<br> + single example: '192.168.0.1' <br> + range examples: '192.168.0.0/24', '192.168.1.0/255.255.255.0', '192.168.1.1-192.168.1.10' + + textarea + 65 + 3 + + + Source Domains + domains + + Enter source domains names here with space(' ') divider. + Example: <b>'foo.bar'</b> match <b>'foo.bar'</b> or <b>'*.foo.bar'</b>. + + textarea + 65 + 3 + Time time @@ -106,29 +158,33 @@ dest input - 114 + 100 Redirect redirect - Enter redirection URL or Error page code for this rule, or leave blank. - Supported error page codes: 403, 404, 410. - + Enter redirection URL, Tag or Error page code for this rule, or leave blank. <br> + Supported URL's: 'http://myurl', 'https://myurl'. <br> + Supported tags: 'blank', 'blank_img'. <br> + Supported error page codes: 3xx, 4xx, 5xx. Format: 'code' or 'code[space]reason message'. + textarea - 70 - 5 + 65 + 2 Overtime redirect overredirect - Enter redirection URL or Error page code for this rule, or leave blank. - Supported error page codes: 403, 404, 410. - + Enter redirection URL, Tag or Error page code for this rule, or leave blank. <br> + Supported URL's: 'http://myurl', 'https://myurl'. <br> + Supported tags: 'blank', 'blank_img'. <br> + Supported error page codes: 3xx, 4xx, 5xx. Format: 'code' or 'code[space]reason message'. + textarea - 70 - 5 + 65 + 2 Rewrite @@ -147,7 +203,7 @@ description You may enter a description here for your reference (not parsed). input - 114 + 100 @@ -158,11 +214,14 @@ squidguard_before_form_acl(&$pkg); - squidGuard_print_javascript(); + squidGuard_print_javascript(); -// squidguard_resync_time(); + squidguard_resync_acl(); + + squidguard_resync_acl(); + diff --git a/packages/squidGuard/squidguard_configurator.inc b/packages/squidGuard/squidguard_configurator.inc index e32169a1..db751a95 100644 --- a/packages/squidGuard/squidguard_configurator.inc +++ b/packages/squidGuard/squidguard_configurator.inc @@ -196,10 +196,9 @@ define('REDIRECTOR_PROCESS_COUNT', '3'); # define default redirection url (redirector get this url for all blocked url's) # * !ATTENTION! this url must be exists; IF url not exist, redirector will't block # (returned to squid some url, what blocked) -# this may use '301:' or '302:' value (only) -#define('REDIRECT_BASE_URL', '302:'); -define('REDIRECT_BASE_URL', 'http://127.0.0.1/sgerror.php'); -define('REDIRECT_TRANSPARENT_BASE_URL', '/sgerror.php'); +# ------------------------------------------------------------------------------ +define('REDIRECT_BASE_URL', '/sgerror.php'); +define('REDIRECT_URL_ARGS', '&a=%a&n=%n&i=%i&s=%s&t=%t&u=%u'); # ------------------------------------------------------------------------------ # squidguard system defines @@ -338,6 +337,8 @@ define('FLD_TIMERANGE', 'sg_timerange'); // transparent mode define('FLD_SQUID_TRANSPARENT_MODE', 'squid_transparent_mode'); define('FLD_CURRENT_LAN_IP', 'current_lan_ip'); +define('FLD_CURRENT_GUI_PORT', 'current_gui_port'); +define('FLD_CURRENT_GUI_PROTO', 'current_gui_protocol'); # ------------------------------------------------------------------------------ # sg_init @@ -553,12 +554,13 @@ function sg_reconfigure_user_db() { $path = "$dbhome/" . $dst[FLD_NAME]; $dst_names[] = $path; - // 1. check destination catalog + // 1. check destination catalog and create them, if need if (!file_exists($path)) { if (!mkdir ($path, 0755)) { sg_addlog("sg_reconfigure_user_db: error create dir $path"); return; - } else sg_addlog("Create dir $path"); + } + else sg_addlog("Create dir $path"); } // 2. build domains file @@ -780,9 +782,7 @@ function sg_getlog($last_entries_count) { function sg_build_default_config() { global $squidguard_config; $sgconf = array(); - $redirect_base_url = REDIRECT_BASE_URL; - -// TODO: need fix for transparentproxy +# $redirect_base_url = sg_redirector_base_url(); // header $sgconf[] = CONFIG_SG_HEADER; @@ -795,7 +795,7 @@ function sg_build_default_config() { $sgconf[] = "acl {"; $sgconf[] = "\t default {"; $sgconf[] = "\t\t pass none"; - $sgconf[] = "\t\t redirect " . $redirect_base_url; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url('404 Check proxy filter settings on errors.'); # $redirect_base_url $sgconf[] = "\t }"; $sgconf[] = "}"; @@ -803,13 +803,43 @@ function sg_build_default_config() { return $sgconf; } +// ------------------------------------------------------------ +// sg_redirector_base_url +// ------------------------------------------------------------ +function sg_redirector_base_url($url) { + global $squidguard_config; + $rdr_path = REDIRECT_BASE_URL; + + // check GUI port settings + if (isset($squidguard_config[FLD_CURRENT_GUI_PORT]) and !empty($squidguard_config[FLD_CURRENT_GUI_PORT])) { + $rdr_path = ":" . $squidguard_config[FLD_CURRENT_GUI_PORT] . $rdr_path; + } + + // check Lan IP port settings + $rdr_path = $squidguard_config[FLD_CURRENT_LAN_IP] . $rdr_path; + + // check GUI protocol settings + if ($squidguard_config[FLD_CURRENT_GUI_PROTO] === "https") + $rdr_path = "https://" . $rdr_path; + else $rdr_path = "http://" . $rdr_path; + + // arguments + // Attention: + // order arg's must be: first-URL, last-SG variables + // SG have bug, what broke data after his var's + $rdr_path = $rdr_path . "?url=" . rawurlencode($url) . REDIRECT_URL_ARGS; + + sg_addlog("sg_redirector_base_url: select redirector base url ($rdr_path)"); + return $rdr_path; +} + // ------------------------------------------------------------ // sg_build_config // ------------------------------------------------------------ function sg_build_config() { global $squidguard_config; $sgconf = array(); - $redirect_base_url = REDIRECT_BASE_URL; +# $redirect_base_url = REDIRECT_BASE_URL; sg_addlog("sg_build_config: create squidGuard config"); if(!is_array($squidguard_config)) { @@ -830,13 +860,8 @@ function sg_build_config() { // --- Header --- $sgconf[] = CONFIG_SG_HEADER; - // Transparent redirector base url - if (isset($squidguard_config[FLD_SQUID_TRANSPARENT_MODE]) and - isset($squidguard_config[FLD_CURRENT_LAN_IP])) { - $redirect_base_url = "http://" . $squidguard_config[FLD_CURRENT_LAN_IP] . REDIRECT_TRANSPARENT_BASE_URL; - sg_addlog("sg_build_config: select LAN redirector base url ($redirect_base_url)"); - } else - sg_addlog("sg_build_config: select localhost redirector base url ($redirect_base_url)"); + // redirector base url +# $redirect_base_url = sg_redirector_base_url(); // init $sgconf[] = "logdir " . $squidguard_config[FLD_LOGDIR]; @@ -955,7 +980,7 @@ function sg_build_config() { if ($dst[FLD_URLS]) $sgconf[] = "\t urllist $dstname/urls"; if ($dst[FLD_REDIRECT] && is_url($dst[FLD_REDIRECT])) - $sgconf[] = "\t redirect " . $redirect_base_url . "?url={$dst[FLD_REDIRECT]}"; + $sgconf[] = "\t redirect " . sg_redirector_base_url($dst[FLD_REDIRECT]); # $redirect_base_url . rawurlencode($dst[FLD_REDIRECT]); if ($dst[FLD_LOG]) $sgconf[] = "\t log " . SQUIDGUARD_ACCESSBLOCK_FILE; $sgconf[] = "}"; @@ -969,7 +994,7 @@ function sg_build_config() { $sgconf[] = ""; $sgconf[] = "rew " . $rew[FLD_NAME] . " {"; foreach ($rew[FLD_ITEM] as $rw) - $sgconf[] = "\t s@." . $rw[FLD_TARGETURL] . "@" . $rw[FLD_REPLACETO]."@"; + $sgconf[] = "\t s@." . $rw[FLD_TARGETURL] . "@" . $rw[FLD_REPLACETO]."@r"; if ($rew[FLD_LOG]) $sgconf[] = "\t log " . SQUIDGUARD_ACCESSBLOCK_FILE; $sgconf[] = "}"; @@ -1017,7 +1042,7 @@ function sg_build_config() { $sgconf[] = "\t\t pass " . $acl[FLD_DESTINATIONNAME]; if ($acl[FLD_REDIRECT]) { if (is_url($acl[FLD_REDIRECT])) - $sgconf[] = "\t\t redirect " . $redirect_user_url . "?url={$acl[FLD_REDIRECT]}"; + $sgconf[] = "\t\t redirect " . $redirect_user_url . rawurlencode($acl[FLD_REDIRECT]); else $sgconf[] = "\t\t redirect " . $redirect_user_url . "?msg=" . htmlspecialchars($acl[FLD_REDIRECT]); } if ($acl[FLD_REWRITENAME]) @@ -1027,7 +1052,7 @@ function sg_build_config() { $sgconf[] = "\t } else {"; $sgconf[] = "\t\t pass " . $acl[FLD_OVERDESTINATIONNAME]; if ($acl[FLD_OVERREDIRECT] && is_url($acl[FLD_OVERREDIRECT])) - $sgconf[] = "\t\t redirect " . $redirect_base_url . "?url={$acl[FLD_OVERREDIRECT]}"; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url($acl[FLD_OVERREDIRECT]); # $redirect_base_url . rawurlencode($acl[FLD_OVERREDIRECT]); if ($acl[FLD_OVERREWRITENAME]) $sgconf[] = "\t\t rewrite " . $acl[FLD_OVERREWRITENAME]; @@ -1038,7 +1063,7 @@ function sg_build_config() { $sgconf[] = "\t\t pass " . $acl[FLD_DESTINATIONNAME]; if ($acl[FLD_REDIRECT] && is_url($acl[FLD_REDIRECT])) - $sgconf[] = "\t\t redirect " . $redirect_base_url . "?url={$acl[FLD_REDIRECT]}"; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url($acl[FLD_REDIRECT]); # $redirect_base_url . rawurlencode($acl[FLD_REDIRECT]); if ($acl[FLD_REWRITENAME]) $sgconf[] = "\t\t rewrite " . $acl[FLD_REWRITENAME]; @@ -1079,24 +1104,24 @@ function sg_build_config() { $sgconf[] = "\t default within " . $def[FLD_TIMENAME] . " { "; $sgconf[] = "\t\t pass " . $def[FLD_DESTINATIONNAME]; if ($def[FLD_REDIRECT] && is_url($def[FLD_REDIRECT])) - $sgconf[] = "\t\t redirect " . $redirect_base_url . "?url={$def[FLD_REDIRECT]}"; - else $sgconf[] = "\t\t redirect " . $redirect_base_url; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url($def[FLD_REDIRECT]); # $redirect_base_url . rawurlencode($def[FLD_REDIRECT]); + else $sgconf[] = "\t\t redirect " . sg_redirector_base_url(''); # $redirect_base_url; // overtime $sgconf[] = "\t } else {"; $sgconf[] = "\t\t pass " . $def[FLD_OVERDESTINATIONNAME]; if ($def[FLD_OVERREDIRECT] && is_url($def[FLD_OVERREDIRECT])) { - $sgconf[] = "\t\t redirect " . $redirect_base_url . "?url={$def[FLD_OVERREDIRECT]}"; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url($def[FLD_OVERREDIRECT]); # $redirect_base_url . rawurlencode($def[FLD_OVERREDIRECT]); } - else $sgconf[] = "\t\t redirect " . $redirect_base_url; + else $sgconf[] = "\t\t redirect " . sg_redirector_base_url(''); # $redirect_base_url; $sgconf[] = "\t }"; } else { // without time $sgconf[] = "\t default { "; $sgconf[] = "\t\t pass " . $def[FLD_DESTINATIONNAME]; if ($def[FLD_REDIRECT] && is_url($def[FLD_REDIRECT])) { - $sgconf[] = "\t\t redirect " . $redirect_base_url . "?url={$def[FLD_REDIRECT]}"; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url($def[FLD_REDIRECT]); # $redirect_base_url . rawurlencode($def[FLD_REDIRECT]); } - else $sgconf[] = "\t\t redirect " . $redirect_base_url; + else $sgconf[] = "\t\t redirect " . sg_redirector_base_url(''); # $redirect_base_url; $sgconf[] = "\t }"; } } // if def @@ -1104,7 +1129,7 @@ function sg_build_config() { sg_addlog("sg_build_config: error - ACL 'default' is empty, use as default 'block all'."); $sgconf[] = "\t default { "; $sgconf[] = "\t\t pass none"; - $sgconf[] = "\t\t redirect " . $redirect_base_url; + $sgconf[] = "\t\t redirect " . sg_redirector_base_url(''); # $redirect_base_url; $sgconf[] = "\t }"; } @@ -1561,10 +1586,12 @@ function scan_dir($dir) { # is_url - build files listing for $dir # ------------------------------------------------------------------------------ function is_url($url) { - if (empty($url)) return false; - if (eregi("^http://", $url)) return true; - if (eregi("^https://", $url)) return true; - if (eregi("^([0-9]{3})", $url)) return true; // http error code 403, 404, 410, 500, + if (empty($url)) return false; + if (eregi("^http://", $url)) return true; + if (eregi("^https://", $url)) return true; + if (strstr("blank", $url)) return true; + if (strstr("blank_img", $url)) return true; + if (eregi("^([0-9]{3})", $url)) return true; // http error code 403, 404, 410, etc. return false; } # ------------------------------------------------------------------------------ diff --git a/packages/squidGuard/squidguard_default.xml b/packages/squidGuard/squidguard_default.xml index 122206ab..b6209c76 100644 --- a/packages/squidGuard/squidguard_default.xml +++ b/packages/squidGuard/squidguard_default.xml @@ -25,10 +25,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -59,29 +55,32 @@ dest input - 115 + 100 Default Redirect redirect - Enter redirection URL or Error page code for this rule, or leave blank. - Supported error page codes: 403, 404, 410. - + Enter redirection URL, Tag or Error page code for this rule, or leave blank. <br> + Supported URL's: 'http://myurl', 'https://myurl'. <br> + Supported tags: 'blank', 'blank_img'. <br> + Supported error page codes: 3xx, 4xx, 5xx. Format: 'code' or 'code[space]reason message'. textarea - 70 - 5 + 65 + 2 Default overtime redirect overredirect - Enter redirection URL or Error page code for this rule, or leave blank. - Supported error page codes: 403, 404, 410. - + Enter redirection URL, Tag or Error page code for this rule, or leave blank. <br> + Supported URL's: 'http://myurl', 'https://myurl'. <br> + Supported tags: 'blank', 'blank_img'. <br> + Supported error page codes: 3xx, 4xx, 5xx. Format: 'code' or 'code[space]reason message'. + textarea - 70 - 5 + 65 + 2 Default Rewrite diff --git a/packages/squidGuard/squidguard_dest.xml b/packages/squidGuard/squidguard_dest.xml index 0643c08f..ab705ae2 100644 --- a/packages/squidGuard/squidguard_dest.xml +++ b/packages/squidGuard/squidguard_dest.xml @@ -27,10 +27,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -128,12 +124,14 @@ Redirect redirect - Enter redirection URL or Error page code for this rule, or leave blank. - Supported error page codes: 403, 404, 410. - + Enter redirection URL, Tag or Error page code for this rule, or leave blank. <br> + Supported URL's: 'http://myurl', 'https://myurl'. <br> + Supported tags: 'blank', 'blank_img'. <br> + Supported error page codes: 3xx, 4xx, 5xx. Format: 'code' or 'code[space]reason message'. + textarea 60 - 5 + 2 Enable log @@ -158,6 +156,6 @@ // squidguard_resync_time(); - squidGuard_print_javascript(); + squidGuard_print_javascript(); diff --git a/packages/squidGuard/squidguard_log.xml b/packages/squidGuard/squidguard_log.xml index c201e9f3..ae781562 100644 --- a/packages/squidGuard/squidguard_log.xml +++ b/packages/squidGuard/squidguard_log.xml @@ -27,10 +27,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -58,7 +54,7 @@ select access_log - + diff --git a/packages/squidGuard/squidguard_rewr.xml b/packages/squidGuard/squidguard_rewr.xml index 0de007ac..5d2e6ac3 100644 --- a/packages/squidGuard/squidguard_rewr.xml +++ b/packages/squidGuard/squidguard_rewr.xml @@ -24,10 +24,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -128,7 +124,7 @@ - squidGuard_print_javascript(); + squidGuard_print_javascript(); squidguard_validate_rewrite($_POST, &$input_errors); diff --git a/packages/squidGuard/squidguard_time.xml b/packages/squidGuard/squidguard_time.xml index 360a2930..76b781ab 100644 --- a/packages/squidGuard/squidguard_time.xml +++ b/packages/squidGuard/squidguard_time.xml @@ -27,10 +27,6 @@ ACL /pkg.php?xml=squidguard_acl.xml - - Sources - /pkg.php?xml=squidguard_src.xml - Destinations /pkg.php?xml=squidguard_dest.xml @@ -131,7 +127,7 @@ - squidGuard_print_javascript(); + squidGuard_print_javascript(); squidguard_validate_times(&$_POST, &$input_errors); -- cgit v1.2.3