示例#1
0
文件: email.php 项目: horrabin/opendb
/**
* Email to be sent from one OpenDb user to another
* 
* @from_userid can be null, and in this case, the from address will be the configured no-reply address for
* the psuedo administrator.
*/
function opendb_user_email($to_userid, $from_userid, $subject, $message, &$errors, $append_site_to_subject = TRUE)
{
    $to_userid = trim($to_userid);
    if (is_user_permitted_to_receive_email($to_userid)) {
        $to_user_r = fetch_user_r($to_userid);
        $to_email_addr = trim($to_user_r['email_addr']);
        $to_name = trim($to_user_r['fullname']);
        $from_userid = trim($from_userid);
        if (is_user_valid($from_userid)) {
            $from_user_r = fetch_user_r($from_userid);
            $from_email_addr = trim($from_user_r['email_addr']);
            $from_name = trim($from_user_r['fullname']);
        } else {
            if (strlen($from_userid) == 0) {
                $from_email_addr = trim(get_opendb_config_var('email', 'noreply_address'));
                $from_name = trim(get_opendb_lang_var('noreply'));
            } else {
                //if(is_valid_email_addr($from_userid))
                $from_email_addr = $from_userid;
            }
        }
        if (!is_valid_email_addr($to_email_addr)) {
            $errors[] = get_opendb_lang_var('invalid_to_address');
            return FALSE;
        }
        if (!is_valid_email_addr($from_email_addr)) {
            $errors[] = get_opendb_lang_var('invalid_from_address');
            return FALSE;
        }
        $subject = trim(stripslashes($subject));
        if (strlen($subject) == 0) {
            $errors[] = get_opendb_lang_var('invalid_subject');
            return FALSE;
        }
        if ($append_site_to_subject) {
            $subject .= " [" . get_opendb_config_var('site', 'title') . "]";
        }
        $message = trim(stripslashes($message));
        $message .= get_email_footer();
        if (sendEmail($to_email_addr, $to_name, $from_email_addr, $from_name, $subject, $message, $errors)) {
            // insert email function will set this to NULL if from user provided!
            insert_email($to_userid, $from_userid != $from_email_addr ? $from_userid : NULL, $from_email_addr, $subject, $message);
            return TRUE;
        }
    }
    //else
    return FALSE;
}
示例#2
0
        continue;
    }
    if (!check_email($_POST['mail'][$i])) {
        die($_POST['mail'][$i] . " 格式不正确");
    }
    $news_share->id = 0;
    $news_share->user = $user->name;
    $news_share->nick_name = htmlspecialchars($_POST['name'][$i]);
    $news_share->email = htmlspecialchars($_POST['mail'][$i]);
    $news_share->created_at = now();
    $news_share->news_id = $news_id;
    $news_share->share_type = 'assitant';
    $news_share->save();
    $content = addslashes($_POST['name'][$i] . ",你好:<br/><br/>  您的好友" . $user->name . "想与您分享网趣宝贝的文章《" . $news->name . "》,您可以点击以下连接阅读<br/><br/><a href='{$site_domain}" . get_news_url($news, 'static') . "'>http://www.localhost.com" . get_news_url($news, 'static') . "</a><br/>  如果点击以上链接不起作用,请将此网址复制并粘贴到新的浏览器窗口中。");
    $title = $news->title;
    insert_email($news_share->email, $email_from, $title, $content);
}
function insert_email($email_to, $email_from, $email_subject, $email_content)
{
    $db = get_db();
    $db->execute("insert into `eachbb_email`.eb_email (email_to,email_from,email_subject,email_content,created_at) values('{$email_to}','{$email_from}','{$email_subject}','{$email_content}',now())");
}
#send_mail('smtp.qiye.163.com','*****@*****.**','userservice','*****@*****.**',$_GET['mail'][$i],$title,$content);
?>
<script>
	alert("已成功分享!");
	window.location.href = "<?php 
echo get_news_url($news, 'static');
?>
";
</script>
示例#3
0
 $phones = isset($_POST['phones']) ? $_POST['phones'] : 0;
 $phonetypes = isset($_POST['phonetypes']) ? $_POST['phonetypes'] : 0;
 $row = 0;
 foreach ($phonecountries as $country) {
     //$countryid = insert_country( $country , $code[$row] );
     $phoneid = insert_phone_for_user($phones[$row], $phonetypes[$row], $userid);
     if ($phoneid) {
         insert_relation("persons", "phones", $personid, $phoneid);
     }
     $row++;
 }
 $emails = isset($_POST['emails']) ? $_POST['emails'] : 0;
 $emailtypes = isset($_POST['emailtypes']) ? $_POST['emailtypes'] : 0;
 $row = 0;
 foreach ($emails as $email) {
     $emailid = insert_email($emails[$row], $emailtypes[$row]);
     //dimiourgia....
     if ($emailid) {
         insert_relation("persons", "emails", $personid, $emailid);
     }
     $row++;
 }
 $websites = isset($_POST['websites']) ? $_POST['websites'] : 0;
 $websitetypes = isset($_POST['websitetypes']) ? $_POST['websitetypes'] : 0;
 $row = 0;
 foreach ($websites as $website) {
     $websiteid = insert_website($websites[$row], $websitetypes[$row]);
     if ($websiteid) {
         insert_relation("persons", "websites", $personid, $websiteid);
     }
     $row++;