Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Nicolas_Daems
Explorer

How-To - Customize UserCheck Page to send email and report issue

Hi,

Few months ago we developped a small hack in UserCheck in order to send an email and report wrongly categorized website to Helpdesk team.

Please find the way if you're looking for such feature (Compatible in R77.30 & R80.x)

  • UserCheck portal relies on a javascript library stored on the Gateway.
  • Edit this files on the Gateways 
    • vi /opt/CPUserCheckPortal/htdocs/UserCheck/js/UCTools
  • Add your javascript fonction which will collect info and send email from User Application

 

function submitform()
{
// Possible Values
// [user_name] => UserName ()
// [orig_url] => http://www.facebook.com/
// [resource_hmac] => 64f1ca1aebff4e9d58c40b8e5db920450777c5f08660ebace3fd0d31d9dde7a8
// [resource] => http://www.facebook.com/
// [application_name] => Facebook
// [application_id] => 10080872
// [category] => Social Networking
// [product] => apcl
// [version] => r7520
// [src_ip] => 172.16.1.200
// [incident_id] => 8A1F15DF-6D72-6F67-6F76-696E97150744
// [application_name_orig] => Facebook

var Variables = window.oUserAction.incidentObject.Variables;
var user_name = Variables['user_name'];
var category = Variables['category'];
var origUrl = Variables['resource'];

//Get the application name. If this variable has been modified (added application icon for example), take the original.
var appname = Variables['application_name_orig'];
if(appname === undefined)
appname = Variables['application_name'];

var link = "mailto:helpdesk@mydomain.com"
+ "&subject=" + escape("Page Blocked")
+ "&body=" + escape("Username: " + user_name + "\r\n" + "URL: " + origUrl + "\r\n" + "Application : " + appname + "\r\n" + "Category : " + category + "\r\n");

window.location.href = link;
}

  • Save the file. In case of Upgrade this file will be overwrited
  • Last modification has to be done in the UserCheck Page via the SmartConsole.
  • Edit the UserCheck Page and and the following code to call the Javascript function
    • <a href="javascript: submitform();">Request</a>
2 Replies
Braden_Bersik
Participant

Hi Nicolas,

I've been using this code in my environment for a few years and it has worked brilliantly! Thank you very much for developing and posting it.

Unfortunately, sometime in the last few weeks, something broke (I'm guessing it was caused by a Microsoft update because we haven't changed the script) and now the code is dumped in the To field of the email, instead of distributing the collected information to the respective fields of the email. I'm attaching a screenshot to illustrate.

Just wondering if you've run into this as well or if this is unique to our implementation. We're running R80.40 JHF 91.

Thanks,

Braden Bersik

UserCheck-email_script_error.png

Braden_Bersik
Participant

I eventually figured out the issue after playing with the code. There were actually two separate problems, both equating to syntax issues.

Issue #1

In the original script the subject is called via “&subject”.

I don’t know why, I still have no idea, and I’m ignorant when it comes to programming, BUT, based on scripting examples I saw on some forums, I changed the ampersand to a question mark ( “?subject” ) and it started working again – distributing the field structure of the email correctly.

I saw "&subject" in scripting examples on forums, as well - not implying that this syntax is incorrect. But it no longer works for our implementation. Weird!

Issue #2

We upgraded several gateways over the course of a week or two, to R80.40 JHF 91. Most of these gateways were on R80.40, though not all. Subsequent to the upgrades, some of the syntax in the scripts was corrupted with what I am assuming were incorrectly translated/interpreted ascii characters. In other words, some of the characters of the original script were replaced with ascii characters that had no function or use in the script. I corrected these errors and everything has been solid since. I didn’t upgrade the gateways, and the guy who did doesn’t remember exactly which were R80.40 already, so I couldn’t correlate whether the corruption occurred from upgrading a specific version.

Here is my code as it is running today (minus company-specific info):

--------------------------------

function submitform()

{

var Variables = window.oUserAction.incidentObject.Variables;

var user_name = Variables['user_name'];

var category = Variables['category'];

var origUrl = Variables['resource'];

var src_ip = Variables['src_ip'];

 

//Get the application name. If this variable has been modified (added application icon for example), take the original.

var appname = Variables['application_name_orig'];

if(appname === undefined)

appname = Variables['application_name'];

 

var link = "mailto:REDACTED"

+ "?subject=" + escape("Blocked Web Page")

+ "&body=" + escape("****Please assign to REDACTED****" + "\r\n" + "Please provide a brief explanation/justification for access to this website: " + "\r\n" + "\r\n" + "\r\n" + "Username: " + user_name + "\r\n" + "URL: " + origUrl + "\r\n" + "Application: " + appname + "\r\n" + "Category: " + category + "\r\n" + "Client IP: " + src_ip + "\r\n");

window.location.href = link;

};

---------------------------------

I still applaud this excellent customization! It is quite useful. Thank you!

0 Kudos