예제 #1
0
function hesk_input($in, $error = 0, $redirect_to = '', $force_slashes = 0, $max_length = 0)
{
    // Strip whitespace
    $in = trim($in);
    // Is value length 0 chars?
    if (strlen($in) == 0) {
        // Do we need to throw an error?
        if ($error) {
            if ($redirect_to == 'NOREDIRECT') {
                hesk_process_messages($error, 'NOREDIRECT');
            } elseif ($redirect_to) {
                hesk_process_messages($error, $redirect_to);
            } else {
                hesk_error($error);
            }
        } else {
            return $in;
        }
    }
    // Sanitize input
    $in = hesk_clean_utf8($in);
    $in = hesk_htmlspecialchars($in);
    $in = preg_replace('/&(\\#[0-9]+;)/', '&$1', $in);
    // Add slashes
    if (HESK_SLASH || $force_slashes) {
        $in = addslashes($in);
    }
    // Check length
    if ($max_length) {
        $in = substr($in, 0, $max_length);
    }
    // Return processed value
    return $in;
}
예제 #2
0
$set['email_providers'] = count($set['email_providers']) ? "'" . implode("','", $set['email_providers']) . "'" : '';
/* --> Notify customer when */
$set['notify_new'] = empty($_POST['s_notify_new']) ? 0 : 1;
$set['notify_closed'] = empty($_POST['s_notify_closed']) ? 0 : 1;
// SPAM tags
$set['notify_skip_spam'] = empty($_POST['s_notify_skip_spam']) ? 0 : 1;
$set['notify_spam_tags'] = array();
if (!empty($_POST['s_notify_spam_tags']) && !is_array($_POST['s_notify_spam_tags'])) {
    $lines = preg_split('/$\\R?^/m', $_POST['s_notify_spam_tags']);
    foreach ($lines as $tag) {
        // Remove dangerous tags just as an extra precaution
        $tag = str_replace(array('<?php', '<?', '<%', '<script'), '', $tag);
        // Remove excess spaces
        $tag = trim($tag);
        // Remove anything not utf-8
        $tag = hesk_clean_utf8($tag);
        // Limit tag length
        if (strlen($tag) < 1 || strlen($tag) > 50) {
            continue;
        }
        // Escape single quotes and backslashes
        $set['notify_spam_tags'][] = str_replace(array("\\", "'"), array("\\\\", "\\'"), $tag);
        // '
    }
}
if (count($set['notify_spam_tags']) < 1) {
    $set['notify_skip_spam'] = 0;
    $set['notify_spam_tags'] = array('Spam?}', '***SPAM***', '[SPAM]', 'SPAM-LOW:', 'SPAM-MED:');
}
$set['notify_spam_tags'] = count($set['notify_spam_tags']) ? "'" . implode("','", $set['notify_spam_tags']) . "'" : '';
/* --> Other */