<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Custom SquidGuard error [How-To]]]></title><description><![CDATA[<p dir="auto">Hey there,</p>
<p dir="auto">Well, its pointless making a new thread just to put an existing code which is already available <a href="https://forum.pfsense.org/index.php?topic=26057.0" target="_blank" rel="noopener noreferrer nofollow ugc"><strong>in this post here</strong></a>. That post really helped me to design within the <strong>sgerror.php</strong> file itself rather than redirecting to another file which didn't work for me through. Below is what I've edited to fit my needs and I just thought may this would help someone who needs another pre-edited code itself. If admins can merge this post with original thread, that would be great.</p>
<p dir="auto"><strong>File Location</strong></p>
<pre><code>/usr/local/www/sgerror.php
</code></pre>
<pre><code>
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# IE displayed self-page, if them size &gt; 1024
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function get_error_page($er_code_id, $err_msg='') {
        global $err_code;
        global $cl;
        global $g;
        global $config;
        $str = Array();

        header("HTTP/1.1 " . $err_code[$er_code_id]);
		$str[] = '';
        $str[] = '';
			$str[] = '&lt;title&gt;Access Denied by EoN Gateway&lt;/title&gt;';
        $str[] = '';
/*	if ($config['installedpackages']['squidguarddefault']['config'][0]['deniedmessage']) {
		$str[] = "

### {$config['installedpackages']['squidguarddefault']['config'][0]['deniedmessage']}: {$err_code[$er_code_id]}

";
	} else {
		$str[] = "

### Request denied by {$g['product_name']} proxy: {$err_code[$er_code_id]}

";
	}
*/
        $str[] = '';
		$str[] = '';
                if ($cl['n'])        $str[] = "Client Name: {$cl['n']} | ";
                if ($cl['a'])        $str[] = "IP: {$cl['a']} | ";
                if ($cl['i'])        $str[] = "User: {$cl['i']} | ";
                if ($cl['s'])        $str[] = "Group: {$cl['s']} | ";
                if ($cl['t'])        $str[] = "Blocked Category: {$cl['t']} ";
		$str[] = '';
		$str[] = 'Request Denied by Gateway!';
		$str[] = '';
				if ($cl['u'])        $str[] = "

**URL:** {$cl['u']}

";
		$str[] = '

Access to above site is restricted during office hours (Sunday to Thursday, 9.30am - 6.30pm / Saturday, 10.30am - 3.00pm).
 Please try again outside of these hours, or if you need urgent access, discuss with the [System Administrator](mailto:user@domain.com).

';
		$str[] = '

![geblockt](http://gateway2.domain.local/logo.png)

';
        $str[] = 'Web Filtering by [**PfSense**](https://pfsense.org) and [**SquidGuard**](http://squidguard.org) | Copyrights © 2014\. Company Name';
        $str[] = "";
        $str[] = "";

        return implode("\n", $str);
}
</code></pre>
<p dir="auto"><strong>Points to consider in this code:</strong></p>
<ul>
<li>
<p dir="auto">I've commented a code, its the default proxy error notification generates which I didn't want to appear as I was making it to fit my needs. comments are within "/*  */". If you need, you can allow it to appear.</p>
</li>
<li>
<p dir="auto">At first image didn't appear to me, so I've called the complete URL of where the image located</p>
</li>
</ul>
<p dir="auto"><img src="/public/_imported_attachments_/1/access-denied.PNG" alt="access-denied.PNG" class="img-markdown  img-fluid" /><br />
<img src="/public/_imported_attachments_/1/access-denied.PNG_thumb" alt="access-denied.PNG_thumb" class="img-markdown  img-fluid" /></p>
]]></description><link>https://forum.netgate.com/topic/69306/custom-squidguard-error-how-to</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 03:42:50 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/69306.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 May 2014 07:01:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Custom SquidGuard error [How-To] on Thu, 17 Jul 2014 20:58:37 GMT]]></title><description><![CDATA[<p dir="auto">Nevermind, i'm dumb heh. got it working.</p>
]]></description><link>https://forum.netgate.com/post/473073</link><guid isPermaLink="true">https://forum.netgate.com/post/473073</guid><dc:creator><![CDATA[PokerMunkee]]></dc:creator><pubDate>Thu, 17 Jul 2014 20:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to Custom SquidGuard error [How-To] on Wed, 18 Jun 2014 11:48:42 GMT]]></title><description><![CDATA[<p dir="auto">when you upgrade to a new release of pfsense, the changes to the file <strong>"/usr/local/www/sgerror.php"</strong> are lost.<br />
I do it this way:</p>
<ol>
<li>in my home, I created the file "personalSgerror.php" which contains my function "get_error_page (….."</li>
<li>in the file "/usr/local/www/sgerror.php" I added <strong>include "/home/&lt;your home=""&gt;/personalSgerror.php";&lt;/your&gt;</strong>  and I renamed the function "get_error_page (….." to "Xget_error_page (....."</li>
</ol>
<p dir="auto">file "/usr/local/www/sgerror.php"```</p>
<p dir="auto">include "globals.inc";<br />
include "config.inc";<br />
include "/home/&lt;your home=""&gt;/personalSgerror.php";<br />
$page_info = &lt;&lt;&lt;eod&lt;br&gt;# ----------------------------------------------------------------------------------------------------------------------</p>
<h1><a class="anchor-offset" name="squidguard-error-page-generator"></a>SquidGuard error page generator</h1>
<h1><a class="anchor-offset" name="c-2006-2007-serg-dvoriancev"></a>(C)2006-2007 Serg Dvoriancev</h1>
<p dir="auto">...............<br />
...............&lt;/eod&lt;br&gt;&lt;/your&gt;</p>
<pre><code>
my function "get_error_page (….."  in the file  **personalSgerror.php**```
/*
 https://forum.pfsense.org/index.php?topic=26057.0

  This file replaces the function get_error_page (.....
  save this file in your home dir, end rename to personalSgerror.php

  In the file /usr/local/www/sgerror.php
  i put the directive below
  include "/home/&lt;your home=""&gt;/personalSgerror.php";
  and rename the original function
  get_error_page (.....
  Xget_error_page function (.....
*/
function get_error_page($er_code_id, $err_msg='') {
	global $err_code;
	global $cl;
	global $g;
	global $config;
	$str = Array();

	header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
	header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
	header( 'Cache-Control: no-store, no-cache, must-revalidate' );
	header( 'Cache-Control: post-check=0, pre-check=0', false );
	header( 'Pragma: no-cache' );
	header("HTTP/1.1 " . $err_code[$er_code_id]);
	$str[] = '';
	$str[] = '';
	$str[] = '&lt;title&gt;'.$err_code[$er_code_id].'&lt;/title&gt;';
	$str[] = '';
	$str[] = '';

	$str[] = '';
	$str[] = 'ACCESS DENIED';
	$str[] = '';

	$str[] = '';
	$str[] = ''.date('D, d M Y H:i:s').'';
	if ($cl['s']) $str[] = "Group: {$cl['s']} | ";
	if ($cl['t']) $str[] = "Category: {$cl['t']}";
	$str[] = '';
	$str[] = '';
	$str[] = '';
	$str[] = 'NETWORK '.$config['system']['domain'].'';
	$str[] = 'ACCESSO NEGATO!';
	$str[] = ''. $err_code[$er_code_id].'';
	$str[] = '';
	$str[] = '';

	if($config['installedpackages']['squidguarddefault']['config'][0]['deniedmessage']) {
		$str[] = '

'.$config['installedpackages']['squidguarddefault']['config'][0]['deniedmessage'].'

';
	}else{
		$str[] = '

Access to the request page or domain
has been denied by '.$g['product_name'].'

';
	}

	$str[] = '&lt;hr  size="1" width="70%" noshade=""&gt;';
	if ($cl['u']) $str[] = 'URL: '.$cl['u'].'';
	if ($cl['s']) $str[] = '
Gruppo: **'.$cl['s'].'** - ';
	if ($cl['t']) $str[] = 'Categoria: **'.$cl['t'].'**';
	$str[] = '&lt;hr  size="1" width="70%" noshade=""&gt;';
	if ($cl['n']) $str[] = 'Client Name: '.$cl['n'].'
';
	if ($cl['a']) $str[] = 'Client IP: '.$cl['a'].'
';
	if ($cl['i']) $str[] = 'Client User: '.$cl['i'].'
';
	$str[] = '&lt;hr  size="1" width="70%" noshade=""&gt;';

	if(strlen($err_msg)&gt;1 ){
		 $str[] = ''.$err_msg.'';
	}else{
		$str[] = 'Contact the Network Administrator if you think there has been an error';
	}

	$str[] = '&lt;/hr &gt;&lt;/hr &gt;&lt;/hr &gt;';
	$str[] = '';
	$str[] = 'Pagine web controllate e filtrate da  [**SquidGuard**](http://www.squidguard.org "http://www.squidguard.org") su firewall  [**'.$g['product_name'].'**](http://'.$g['product_website'].' "http://'.$g['product_website'].'")';
	$str[] = '';
	$str[] = '';
	$str[] = "";

	return implode("\n", $str);
}
?&gt;&lt;/your&gt;
</code></pre>
<p dir="auto">in the attached file "personalSgerror.php.txt" my function "get_error_page (….."<br />
put this file in your home and rename it to "personalSgerror.php"</p>
<p dir="auto"><img src="https://copy.com/RNNED3B8raE3/ACEESS_DENIED.png" alt="" class="img-markdown  img-fluid" /></p>
<p dir="auto">in the attached file "ACCESS_DENIED.png" a screenshot for the access denied page.</p>
<p dir="auto">I hope that in future versions of pfsense, developers can add in the web gui the ability to customize the function "get_error_page (….."</p>
<p dir="auto">sorry for my bad English.<br />
greetings<br />
Mario</p>
<p dir="auto"><img src="/public/_imported_attachments_/1/ACEESS_DENIED.png" alt="ACEESS_DENIED.png" class="img-markdown  img-fluid" /><br />
<img src="/public/_imported_attachments_/1/ACEESS_DENIED.png_thumb" alt="ACEESS_DENIED.png_thumb" class="img-markdown  img-fluid" /><br />
<a href="/public/_imported_attachments_/1/personalSgerror.php.txt">personalSgerror.php.txt</a></p>
]]></description><link>https://forum.netgate.com/post/467947</link><guid isPermaLink="true">https://forum.netgate.com/post/467947</guid><dc:creator><![CDATA[mario.q]]></dc:creator><pubDate>Wed, 18 Jun 2014 11:48:42 GMT</pubDate></item></channel></rss>