Exemplo n.º 1
0
/**
 * 发送邮件 
 * 
 * @param string $from 发件人
 * @param string $to 收件人
 * @param string $subject 主题
 * @param string $body 邮件体
 * @return void
 */
function send_mail($from = null, $to = null, $subject = null, $body = null)
{
    //smtp设置
    $host = 'mail.eyou.net';
    $username = '******';
    $password = '******';
    //发件人
    if (empty($from)) {
        $from = 'mailer';
    }
    //收件人
    if (empty($to)) {
        $to = '*****@*****.**';
    }
    //主题
    if (empty($subject)) {
        $subject = 'test';
    } else {
        $subject = encode_msg($subject);
    }
    //邮件体
    if (empty($body)) {
        $body = 'hello world';
    } else {
        //$body = file_get_contents($body);
        $body = $body;
    }
    $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date('r'), 'Content-Type' => 'text/plain; charset="GB2312"');
    $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
    $smtp->send($to, $headers, $body);
}
    $fieldname = $db[name];
    $requirederror .= adfieldinputcheck($in[catid], "{$fieldname}", $in[$fieldname]);
}
if (!$in[location] || !$in[header] || !$in[text] || $requirederror) {
    died($error[14]);
} else {
    if (isbanned($_SESSION[suserid])) {
        $error = rawurlencode($error[27]);
        header(headerstr("classified.php?status=6&errormessage={$error}"));
        exit;
    }
    if (strlen($in['text']) < $limit["0"] || strlen($in['text']) > $limit["1"]) {
        died("Sorry, your text has to be between {$limit['0']} and {$limit['1']} characters.");
    }
    $in = strip_array($in);
    $in[text] = encode_msg($in[text]);
    if ($in[icon1] == "on") {
        $in[icon1] = 1;
    } else {
        $in[icon1] = 0;
    }
    if ($in[icon2] == "on") {
        $in[icon2] = 1;
    } else {
        $in[icon2] = 0;
    }
    if ($in[icon3] == "on") {
        $in[icon3] = 1;
    } else {
        $in[icon3] = 0;
    }
#################################################################################################
if (!$in && !$delid) {
    header(headerstr("guestbook.php?status=3"));
    exit;
} elseif ($delid && $_SESSION[susermod]) {
    mysql_query("DELETE FROM " . $prefix . "guestbook WHERE id='{$delid}'") or died("Database Query Error");
    header(headerstr("guestbook.php?status=12"));
    exit;
} else {
    if (isbanned($_SESSION[suserid])) {
        header(headerstr("guestbook.php?status=11&errormessage={$error['27']}"));
        exit;
    }
    $add_date = $timestamp;
    $in = strip_array($in);
    $in[message] = encode_msg($in[message]);
    // Add SQL compatibilty & Smilie Convert
    $in['http'] = str_replace("http://", "", $in['http']);
    // Remove http:// from URLs
    if ($in['icq'] != "" && ($in['icq'] < 1000 || $in['icq'] > 999999999)) {
        died("Non-valid ICQ entry, if you do not have an icq account please leave blank.");
    }
    if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}\$", $in['email']) && $in['email'] != "") {
        died("Non-valid Email entry, please enter your correct e-mail address or if you don't have one leave it blank.");
    }
    if (strlen($in['message']) < $limit["0"] || strlen($in['message']) > $limit["1"]) {
        died("Sorry, your message has to be between {$limit['0']} and {$limit['1']} characters.");
    }
    if ($in['email'] == "") {
        $in['email'] = "none";
    }