Example #1
0
/**
 * Normalize the superglobals.
 *
 * @return void
 */
function normalize()
{
    if (ini_get('magic_quotes_gpc')) {
        $_GET = unescape($_GET);
        $_POST = unescape($_POST);
        $_REQUEST = unescape($_REQUEST);
        $_SERVER = unescape($_SERVER);
        $_COOKIE = unescape($_COOKIE);
    }
    $_GET = sanitize($_GET);
    $_POST = sanitize($_POST);
    $_REQUEST = sanitize($_REQUEST);
    $_SERVER = sanitize($_SERVER);
    $_COOKIE = sanitize($_COOKIE);
    $_GET = unify($_GET);
    $_POST = unify($_POST);
    $_REQUEST = unify($_REQUEST);
    $_SERVER = unify($_SERVER);
    $_COOKIE = unify($_COOKIE);
    if (is_file(MAIN_PATH . MAIN_APPLICATION_PATH . 'app/normalize.php')) {
        import('app/normalize.php');
    }
    return;
}
Example #2
0
/**
 * Returns a goal that succeeds if two terms unify in the received state.
 *
 * @param mixed $u a term
 * @param mixed $v a term
 */
function eq($u, $v)
{
    return function ($sC) use($u, $v) {
        $s = unify($u, $v, car($sC));
        if ($s) {
            return unit(cons($s, cdr($sC)));
        } else {
            return mzero();
        }
    };
}
Example #3
0
/**
 * Send encoded mail.
 *
 * @param string $to
 * @param string $subject
 * @param string $message
 * @param array  $headers
 * @param string $parameters
 * @param array  $files
 *
 * @return bool
 */
function mail_send($to, $subject, $message, $headers = array(), $parameters = null, $files = array())
{
    $subject = mb_convert_kana(unify($subject), 'KV', MAIN_INTERNAL_ENCODING);
    $message = mb_convert_kana(unify($message), 'KV', MAIN_INTERNAL_ENCODING);
    $subject = mb_convert_encoding($subject, 'JIS', MAIN_INTERNAL_ENCODING);
    $message = mb_convert_encoding($message, 'JIS', MAIN_INTERNAL_ENCODING);
    $subject = '=?iso-2022-jp?B?' . base64_encode($subject) . '?=';
    if (empty($files)) {
        $boundary = null;
    } else {
        $boundary = rand_string();
    }
    if (empty($files)) {
        $body = $message;
    } else {
        $body = "--{$boundary}\n";
        $body .= "Content-Type: text/plain; charset=\"iso-2022-jp\"\n";
        $body .= "Content-Transfer-Encoding: 7bit\n";
        $body .= "\n";
        $body .= "{$message}\n";
        foreach ($files as $file) {
            if (!is_file($file)) {
                continue;
            }
            $filename = basename($file);
            $body .= "\n";
            $body .= "--{$boundary}\n";
            $body .= "Content-Type: " . file_mimetype($file) . "; name=\"{$filename}\"\n";
            $body .= "Content-Disposition: attachment; filename=\"{$filename}\"\n";
            $body .= "Content-Transfer-Encoding: base64\n";
            $body .= "\n";
            $body .= chunk_split(base64_encode(file_get_contents($file))) . "\n";
        }
        $body .= '--' . $boundary . '--';
    }
    if (!isset($headers['X-Mailer'])) {
        $headers['X-Mailer'] = 'PHP';
    }
    if (!isset($headers['From'])) {
        $headers['From'] = '"From" <*****@*****.**>';
    }
    if (!isset($headers['MIME-Version'])) {
        $headers['MIME-Version'] = '1.0';
    }
    if (!isset($headers['Content-Type'])) {
        if (empty($files)) {
            $headers['Content-Type'] = 'text/plain; charset="iso-2022-jp"';
        } else {
            $headers['Content-Type'] = 'multipart/mixed; boundary="' . $boundary . '"';
        }
    }
    if (!isset($headers['Content-Transfer-Encoding'])) {
        $headers['Content-Transfer-Encoding'] = '7bit';
    }
    $header = null;
    foreach ($headers as $key => $value) {
        if ($header) {
            $header .= "\n";
        }
        $key = regexp_replace('(\\r|\\n)', '', $key);
        $value = regexp_replace('(\\r|\\n)', '', $value);
        $header .= $key . ': ' . $value;
    }
    return mail($to, $subject, $body, $header, $parameters);
}
Example #4
0
function normalize()
{
    $_GET = sanitize($_GET);
    $_POST = sanitize($_POST);
    $_REQUEST = sanitize($_REQUEST);
    $_SERVER = sanitize($_SERVER);
    $_COOKIE = sanitize($_COOKIE);
    $_GET = unify($_GET);
    $_POST = unify($_POST);
    $_REQUEST = unify($_REQUEST);
    $_SERVER = unify($_SERVER);
    $_COOKIE = unify($_COOKIE);
    return;
}