简体   繁体   中英

Mailto subject referencing

I have modified an internal error page that is displayed to the user once a URL is blocked by SquidGuard. Following is the part of the script that I need some assistance with:

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
    $str[] = '<html>';
    $str[] = '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title></head>';
    $str[] = '<body style="background-color:#FFFFFF; font-family:verdana, arial, sans serif;">';

    $str[] = '<div style="padding:5px; background-color:#FFFFFF; text-align:center; font-weight:bold; font-family:verdana,arial,sans serif; color:#2F93D1; font-size:70%;"> <p>';
      if ($cl['n'])        $str[] = "Your Node Name: {$cl['n']} </p><p> ";
      if ($cl['a'])        $str[] = "Your Node IP: {$cl['a']} </p><p> ";
      if ($cl['i'])        $str[] = "Node User: {$cl['i']} </p><p> ";
      if ($cl['s'])        $str[] = "Group: {$cl['s']} </p><p> ";
      if ($cl['t'])        $str[] = "Blacklist Category: {$cl['t']} ";
    $str[] = '</p></div><div style="background-color:#FFFFFF; text-align:center; padding:20px;">';
    $str[] = '<p><img style="padding-top:20px;display: block;margin: 0px auto" src="https://lh4.googleusercontent.com/_aRy3rhrUl64/TaOzVHF01fI/AAAAAAAACVw/H__Us1P5ghc/s800/Untitled.jpg" alt="geblockt"></p></div></div>';
    $str[] = '<div style="padding:20px; margin-top:20px; background-color:#FFFFFF; text-align:center; color:#000000; font-family:verdana, arial, sans serif; font-size:80%;">';
            if ($err_msg) $str[] = '<p style="font-weight:bold; font-size:150%;"> '. $err_msg.' </p>';
            if ($cl['u']) $str[] = "<p><strong>URL: {$cl['u']}</strong></p>";
    $str[] = '<p>Because of access restrictions, your request to the above address is not allowed. </p>
    <p>Please contact <a href="mailto:firewall_support@iuass.org?subject=[HELP IS NEEDED HERE]&body=Please unblock this URL, thanks">IUASS firewall support</a> if you are of the opinion that this is not correct.</p><p>';
    $str[] = '</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><img src="http://iuass.org/system/cms/themes/default/img/logo.gif" alt="geblockt" width="315" height="44" style="padding-top:20px;display: block;margin: 0px auto"></p></div></div>';
    $str[] = '<div style="width:70%; margin:20px auto; background-color:#FFFFFF; text-align:center; color:#000000; font-size:60%; font-family:verdana,arial,sans serif;">Web Filtering by <a style="color:#000000;">IUASS Firewall implementing pfSense with Squid and SquidGuard</div></div>';
    $str[] = "</body>";
    $str[] = "</html>";

    return implode("\n", $str);
}

What I need to do is to add the blocked url to the mailto subject in

<a href="mailto:firewall_support@iuass.org?subject=[HELP IS NEEDED HERE]&body=Please unblock this URL, thanks">

As far as I understand, the url is referred to by {$cl['u']} pointer. If I add it above after "?subject=" it does not work due to syntax error. Therefore, is there a way or another through html or php or any other scripting that will enable the user once clicking on the firewall_support@iuass.org link to open a new email message where the subject field is already filled out with the url in quest?

Any assistance in this regard is highly appreciated.

Thanks in advance.

How about:

<?php echo "<a href='mailto:firewall_support@iuass.org?subject=" . $cl['u'] . "&body=Please unblock this URL, thanks'" ?>

This will create a hyperlink with the mailto URI you mentioned inserting the contents of $cl['u'].

Have you tried something like:

if ($cl['u']) $str[] = "<p>Because of access restrictions, your request to the above address is not allowed. </p><p>Please contact <a href=\"mailto:firewall_support@iuass.org?subject={$cl['u']}&body=Please unblock this URL, thanks\">IUASS firewall support</a> if you are of the opinion that this is not correct.</p>";

And its always useful to paste your code, for example on pastebin, so that we can have a look over it, especially in the case of syntax errors.

Moreover note that you will run into trouble if you do it the simple way I suggested, since urls will contain characters like &. You will have to replace all occurences of & by their htmlentities first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM