当前位置: 首页>>代码示例>>PHP>>正文


PHP send_email函数代码示例

本文整理汇总了PHP中send_email函数的典型用法代码示例。如果您正苦于以下问题:PHP send_email函数的具体用法?PHP send_email怎么用?PHP send_email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了send_email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DoTask

function DoTask()
{
    global $GAME, $unexpectederrormessage;
    if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot abort this game');
        $mypage->leaf('p', 'This game cannot be aborted just now, perhaps because it has finished. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['MyColour'] == 50) {
        $mypage = page::standard();
        $mypage->title_body('Not playing in this game');
        $mypage->leaf('p', 'You are not currently playing in this game, so you cannot vote to abort it. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['AbortVoteActive']) {
        myerror($unexpectederrormessage, 'Unexpected vote page "gae.php" reached');
    }
    if ($GAME['CurrentPlayers'] - $GAME['PlayersMissing'] == 1) {
        abortgame(0);
        dbformatgamedata();
        page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted and aborted game.');
    }
    $GAME['AbortVote'][$GAME['MyColour']] = 1;
    dbformatgamedata();
    for ($i = 0; $i < MAX_PLAYERS; $i++) {
        if ($GAME['PlayerExists'][$i] == 1 and !$GAME['PlayerMissing'][$i] and $i != $GAME['MyColour'] and $GAME['EmailPrompt'][$i] and $GAME['Email'][$i] != '') {
            $subject = 'There is a vote to abort game number ' . $GAME['GameID'];
            $body = '<p>This is an automated message. One of your fellow players in game number ' . $GAME['GameID'] . ' has initiated a vote to abort the game. In order for the game to be aborted, all of the players must agree; this means that a unanimous vote is required. Please visit the game\'s page and either vote in favour of aborting it, or shut the vote down by voting not to abort. Here is the URL of the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER;
            send_email($subject, $body, $GAME['Email'][$i], null);
        }
    }
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted.');
}
开发者ID:hdp,项目名称:brass,代码行数:34,代码来源:gae.php

示例2: register_email

function register_email($account)
{
    global $_url, $MMORPG_Name, $MMORPG_Description;
    //-----------------------------------------------
    //DECLARE LES VARIABLES
    //-----------------------------------------------
    $sujet = "{$MMORPG_Name} - Validation inscription";
    $destinataire = $account['Account_Email'];
    //'mail_destinataire@fai.fr';
    $url_valid = get_link('Register', 'User', array('Valid' => 'Activer', 'Account_Key' => $account['Account_Key'], 'Account_Email' => $account['Account_Email']));
    $message_texte = 'Bonjour,' . "\n\n" . 'utilisier ce lien dans votre navigateur pour valider votre inscription' . "\n\n" . $url_valid;
    $message_html = '<html> 
     <head> 
     <title>' . $MMORPG_Name . ' - valider votre inscription</title> 
     </head> 
     <body>
		' . $MMORPG_Description . '<hr/>
		Vous venez d\'effectuer l\'inscription sur le site <a href="' . $_url . '">' . $MMORPG_Name . '</a> .<br/><br/>
        Pour valider votre inscription, cliquez sur ce bouton :
        <form method="post" action="' . get_link('Register', 'User') . '">
            <input type="hidden" name="Account_Key" value="' . $account['Account_Key'] . '"/>
            <input type="hidden" name="Account_Email" value="' . $account['Account_Email'] . '"/>
            <input type="submit" name="Valid" value="Activer"/>
        </form>
        
        Ou sur <a href="' . $url_valid . '">ce lien</a>
     </body> 
     </html>';
    debug_log($message_html, false);
    send_email($account['Account_Email'], $sujet, $message_texte, $message_html);
}
开发者ID:galadie,项目名称:Caranille-RPG,代码行数:31,代码来源:Register.php

示例3: broadcast_email_notice

function broadcast_email_notice(&$model, &$rec)
{
    if (!isset($rec->title)) {
        return;
    }
    global $request, $db;
    $i = owner_of($rec);
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
    $where = array('subscriptions.subscribed' => $i->id);
    $Subscription->set_param('find_by', $where);
    $Subscription->find();
    while ($sub = $Subscription->MoveNext()) {
        $sid = $sub->FirstChild('identities');
        if (!in_array($sid->id, $sent_to) && $sub->email) {
            $html = false;
            // this is the body of the e-mail if ($html == false)
            $text = $rec->title;
            $subject = $i->nickname . " posted a notice";
            send_email($sid->email_value, $subject, $text, environment('email_from'), environment('email_name'), $html);
            $sent_to[] = $sid->id;
        }
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:25,代码来源:email_notice.php

示例4: register_processAction

 /** Attempts to register a new user and send an email
  * Method: POST 
  */
 public function register_processAction(Request $req)
 {
     $result = array("result" => "", "error" => "");
     $user_register_details = array("user" => array("first_name" => filter_var($req->request->get("uFirstName"), FILTER_SANITIZE_SPECIAL_CHARS), "last_name" => filter_var($req->request->get("uLastName"), FILTER_SANITIZE_SPECIAL_CHARS), "email" => filter_var($req->request->get("uEmail"), FILTER_SANITIZE_EMAIL), "password_dec" => filter_var($req->request->get("uPassword"), FILTER_SANITIZE_SPECIAL_CHARS), "group_name" => "regular", "active" => 1, "created_date" => date("Y-m-d"), "updated_date" => "", "facebook_id" => "", "twitter_id" => ""));
     $false_check_arr = array("first_name", "last_name", "email", "password_dec");
     $user_check = $user_register_details["user"];
     foreach ($false_check_arr as $false_check) {
         if (!$user_check[$false_check]) {
             $result["error"] .= "Please enter a valid value for " . $false_check . ". ";
         }
     }
     if (strlen($result["error"]) == 0) {
         $db_params = get_db_params_from_config();
         $db_conn = new DBConnection($db_params);
         $db_conn->connect();
         $r_user = new RegularUser($db_conn);
         $reg_results = $r_user->register_new(json_encode($user_register_details));
         $result["result"] .= $reg_results["result"];
         $result["error"] .= $reg_results["error"];
     }
     if (strlen($result["error"]) == 0) {
         // Send confirmation email
         $em_result = send_email("cms@scottdnz.net", "cms_replies@scottdnz.net", $user_register_details["email"]);
         // Deal with email errors ...
         return $this->render("TestCMSCMSBundle:Default:create_content.html.twig", array("result" => $result));
     }
     return $this->render("TestCMSCMSBundle:User:register.html.twig", array("result" => $result));
 }
开发者ID:akrazalive,项目名称:cms,代码行数:31,代码来源:UserController.php

示例5: friend_add

function friend_add($username)
{
    if (isset($_SESSION["user_id"])) {
        $mysqli = db_connect();
        // fetch the ID of the friend
        $sql = "SELECT * FROM Users WHERE Username='" . $mysqli->real_escape_string($username) . "'";
        $result = $mysqli->query($sql);
        if ($result->num_rows > 0) {
            $user_row = $result->fetch_assoc();
            $user_id = $user_row["Id"];
            // delete the friendship if it exists
            $sql = "DELETE FROM Friends WHERE UserId=" . $mysqli->real_escape_string($_SESSION["user_id"]) . " AND FriendId=" . $mysqli->real_escape_string($user_id);
            $result = $mysqli->query($sql);
            // insert a new record
            $sql = "INSERT INTO Friends (UserId,FriendId,Created,IPCreated) VALUES (" . $mysqli->real_escape_string($_SESSION["user_id"]) . "," . $mysqli->real_escape_string($user_id) . ",NOW(),'" . $mysqli->real_escape_string($_SERVER["REMOTE_ADDR"]) . "')";
            $result = $mysqli->query($sql);
            // next find out if the user we are adding as a friend wishes to be informed
            if ($user_row["NotifyNewFriends"] == 1 and $user_row["Status"] == USER_STATUS_VALIDATED) {
                $mail_to = $user_row["Email"];
                $mail_subject = SITE_NAME . " - " . $_SESSION["user_name"] . " added you as a friend!";
                $mail_message = $_SESSION["user_name"] . " added you as a friend!\n\n" . "http://wetheusers.net/" . $_SESSION["user_name"] . "\n\n";
                send_email($mail_to, $mail_subject, $mail_message);
            }
            SendSystemMessage($mysqli, $user_id, $_SESSION["user_name"] . " added you as a friend!", "[" . $_SESSION["user_name"] . "](http://wetheusers.net/" . $_SESSION["user_name"] . ") has added you as a friend", 4);
            return true;
        } else {
            return false;
        }
    } else {
        header("Location: /401");
    }
}
开发者ID:jonbeckett,项目名称:wetheusers,代码行数:32,代码来源:friends.php

示例6: forget_pass

 public function forget_pass()
 {
     $this->load->helper('email');
     $this->load->helper('string');
     $this->load->model('Users_Model');
     $email = $this->input->post('email');
     if (!valid_email($email)) {
         $this->session->set_flashdata('log_error', 'Please Enter a Valid Email id.');
     } else {
         if ($this->Users_Model->mailexist($email)) {
             $userdetails = $this->Users_Model->getDetailByMailId($email);
             $username = $userdetails->fld_username;
             $fld_id = $userdetails->fld_id;
             $random_Pass = strtolower(random_string());
             $md_pass = md5($random_Pass);
             $data = array('fld_password' => $md_pass);
             $chang_pass = $this->Users_Model->updateUser($fld_id, $data);
             if ($chang_pass) {
                 $url = site_url('administrator');
                 $msg = "<b>New login details</b> <br /> Username : " . $username . " <br /> Password : " . $random_Pass . " <br /> Url : <a href='" . $url . "' title='Click Here'>" . $url . "</a>";
                 $sendmail = send_email($email, $subject = 'Password Change', $message = $msg);
                 if ($sendmail) {
                     $this->session->set_flashdata('log_succ', 'Please check your email id, We have sent your login details on your mail Id.');
                 } else {
                     $this->session->set_flashdata('log_error', 'There is some error accoured, Please try again');
                 }
             }
         } else {
             $this->session->set_flashdata('log_error', 'Your email Id is not registered.');
         }
     }
     redirect('administrator/?forget=true');
 }
开发者ID:vishwakarma09,项目名称:bimpra.tk,代码行数:33,代码来源:Login.php

示例7: contact

 public function contact()
 {
     $this->form_validation->set_rules('name', 'Name', 'required|trim');
     $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
     $this->form_validation->set_rules('message', 'Message', 'required|trim');
     $this->form_validation->set_rules('phone', 'phone', '');
     $this->form_validation->set_rules('subject', 'subject', '');
     $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
     if ($this->form_validation->run() == FALSE) {
         $article = $this->mArticle->get(194195);
         $data = array('main_content' => 'pages/contact');
         $data = array_merge($data, (array) $article);
         $data['form_errors'] = $this->form_validation->error_array();
         $subjects = $this->mUtil->getCodes('Contact Us Subject');
         foreach ($subjects as $s) {
             $data['subjects'][$s] = $s;
         }
         $this->load->view('template', $data);
     } else {
         /*$body = "Name: " . set_value('name') . "<br>";
         		$body .= "Email: " . set_value('email') . "<br>";
         		$body .= "Phone: " . set_value('phone') . "<br>";
         		$body .= "Subject: " . set_value('subject') . "<br>";
         		$body .= "Message: <br><br>" . set_value('message') . "<br>";*/
         $message = $this->load->view('emails/contact', $data, TRUE);
         send_email('info@soundbooka.com', 'Soundbooka - Contact Us', $message);
         $message = $this->load->view('emails/contact-thank-you', $data, TRUE);
         send_email(set_value('email'), 'Soundbooka - Contact Us', $message);
         $this->session->set_flashdata('message', 'Your message was sent.');
         redirect('/contact');
     }
 }
开发者ID:nukem,项目名称:Twist,代码行数:32,代码来源:home+-+06-12-2011.php

示例8: support

    public function support()
    {
        $data = $this->input->post();
        if (count($data)) {
            echo '<script language="javascript" type="text/javascript">
						alert(\'Empty inputs.\');
						window.location = "/";
    				</script>';
            exit;
        }
        // Enter the email where you want to receive the notification when someone submit form
        $recipient = "chi.lieu@cloudberrysoft.com, quan.luu@cloudberrysoft.com, binlieu777@yahoo.com";
        $subject = "Support Form";
        $formcontent = print_r($data, true);
        $this->load->helper('email');
        $success = send_email($recipient, $subject, $formcontent);
        if ($success == true) {
            echo '<script language="javascript" type="text/javascript">
						alert(\'Thank you for you e-mail. We will contact you shortly.\');
						window.location = "/";
					</script>';
        } else {
            echo '<script language="javascript" type="text/javascript">
						alert(\'Email cannot send.\');
						window.location = "/";
    				</script>';
        }
        exit;
    }
开发者ID:chilieu,项目名称:cbsh,代码行数:29,代码来源:Index.php

示例9: recover

 function recover()
 {
     $return = array("rpta" => false, "message" => "Ingrese correo electronico.");
     $dataPost = $this->input->post();
     $notfind = false;
     if (isset($dataPost['data'])) {
         $rptaTmp = $this->recoverpass->checkmail($dataPost['data']);
         //var_dump("<pre>",$rptaTmp);exit;
         if ($rptaTmp['rpta'] == true) {
             while ($notfind == false) {
                 $string = generateRandomString();
                 $tmp = $this->recoverpass->Find($string);
                 // se comprueba que este codigo no exista en la bd
                 $notfind = $tmp['rpta'];
             }
             $arr = array("email" => $dataPost['data'], "generatecode" => $string);
             $message = "<p>Hemos recibido la solicitud de restaurar su contraseña.</p>" . "<p>Si usted ha solicitado este cambio de contraseña por favor de click <a href='" . site_url('Recoverpass/changePassMail') . "/" . $string . "'>AQUI</a> </p>" . "<p>Caso contrario, por favor ingrese a <a href='http://www.lifeleg.com/'>www.lifeleg.com</a>, y cambie su contraseña.</p>" . "<p>GRACIAS, por pertenecer a nuestra familia, seguiremos trabajando para ofrecerle lo mejor.</p>";
             $rptamail = send_email("Restaurar contraseña", $message, $dataPost['data'], false);
             if ($rptamail == true) {
                 $arr = array("email" => $dataPost['data'], "generatecode" => $string);
                 $this->recoverpass->insertRecover($arr);
                 $return['rpta'] = true;
                 $return['message'] = "Correo enviado correctamente, por favor ingresa a tu bandeja y sigue las instrucciones, Gracias!";
             }
         } else {
             $return['message'] = "E-mail no registrado, verifique y vuelva a intentarlo por favor.";
         }
     }
     echo json_encode($return);
 }
开发者ID:carloz192,项目名称:lifeleg,代码行数:30,代码来源:Recoverpass.php

示例10: form_ajaxed

function form_ajaxed()
{
    $data = $_REQUEST['data'];
    parse_str($data);
    $info = array();
    if (wp_verify_nonce($_wpnonce)) {
        if (empty($fname)) {
            echo 'Please enter your first name';
            die;
        } elseif (empty($sname)) {
            echo 'Please enter your last name';
            die;
        } elseif (empty($email)) {
            echo 'Please enter your email address';
            die;
        } elseif (empty($message)) {
            echo 'Please enter a brief description of your query';
            die;
        } else {
            $info = array("fname" => $fname, "sname" => $sname, "email" => $email);
            if (send_email('daniel@ecomstudio.co.uk', 'Website Enquiry', $message, $info)) {
                echo 'Email Sent';
            } else {
                echo 'Email Failed';
            }
        }
    } else {
        echo 'There seems to be an issue, please refresh the page and try again.';
        die;
    }
    die;
}
开发者ID:thurrockdan,项目名称:ecom-contact,代码行数:32,代码来源:functions.php

示例11: send_problem_email

function send_problem_email($user, $host)
{
    global $master_url;
    $body = "";
    $host_content = "ID: " . $host->id . "\n    Created: " . time_str($host->create_time) . "\n    Venue: " . $host->venue . "\n    Total credit: " . $host->total_credit . "\n    Average credit: " . $host->expavg_credit . "\n    Average update time: " . time_str($host->expavg_time) . "\n    IP address: {$host->last_ip_addr} (same the last {$host->nsame_ip_addr} times)\n    Domain name: " . $host->domain_name;
    $x = $host->timezone / 3600;
    if ($x >= 0) {
        $x = "+{$x}";
    }
    $host_content .= "\n    Local Time = UTC {$x} hours\n    Number of CPUs: " . $host->p_ncpus . "\n    CPU: {$host->p_vendor} {$host->p_model}\n    FP ops/sec: " . $host->p_fpops . "\n    Int ops/sec: " . $host->p_iops . "\n    memory bandwidth: " . $host->p_membw . "\n    Operating System: {$host->os_name} {$host->os_version}";
    $x = $host->m_nbytes / (1024 * 1024);
    $y = round($x, 2);
    $host_content .= "\n    Memory: {$y} MB";
    $x = $host->m_cache / 1024;
    $y = round($x, 2);
    $host_content .= "\n    Cache: {$y} KB";
    $x = $host->m_swap / (1024 * 1024);
    $y = round($x, 2);
    $host_content .= "\n    Swap Space: {$y} MB";
    $x = $host->d_total / (1024 * 1024 * 1024);
    $y = round($x, 2);
    $host_content .= "\n    Total Disk Space: {$y} GB";
    $x = $host->d_free / (1024 * 1024 * 1024);
    $y = round($x, 2);
    $host_content .= "\n    Free Disk Space: {$y} GB\n    Avg network bandwidth (upstream): {$host->n_bwup} bytes/sec\n    Avg network bandwidth (downstream): {$host->n_bwdown} bytes/sec";
    $x = $host->avg_turnaround / 86400;
    $host_content .= "\n    Average turnaround: " . round($x, 2) . " days\n    Number of RPCs: {$host->rpc_seqno}\n    Last RPC: " . time_str($host->rpc_time) . "\n    % of time client on: " . 100 * $host->on_frac . " %\n    % of time host connected: " . 100 * $host->connected_frac . " %\n    % of time user active: " . 100 * $host->active_frac . " %\n    # of results today: " . $host->nresults_today;
    $subject = PROJECT . " notice for {$user->name}";
    $body = PROJECT . " notification:\n\nDear {$user->name}\nYour machine (host # {$host->id}) described below appears to have a misconfigured BOINC\ninstallation.  Could you please have a look at it?\n\nSincerely,\n        The " . PROJECT . " team\n";
    $body .= "\n\nThis is the content of our database:\n" . $host_content . "\n\nFor further information and assistance with " . PROJECT . " go to {$master_url}";
    echo nl2br($body) . "<br><br>";
    return send_email($user, $subject, $body);
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:33,代码来源:problem_host.php

示例12: add_user

 public function add_user()
 {
     $this->form_validation->set_rules('name', 'Name', 'trim|required');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
     $this->form_validation->set_rules('phone', 'Phone', 'trim|required|numeric');
     $this->form_validation->set_rules('password', 'Password', 'trim|required');
     $this->form_validation->set_rules('repassword', 'Confirm Password', 'trim|required');
     $this->form_validation->set_rules('terms', 'Terms', 'trim|required');
     $this->form_validation->set_rules('user', 'User Type', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         $this->index();
     } else {
         $email = $this->input->post('email');
         $name = $this->input->post('name');
         if ($this->Registermodel->add_user() == true) {
             $sub = "GiveRooms Verification Mail";
             $msg = "<html><p>Dear " . $name . ",</p><p>Thank you for registration on GiveRooms.com,<br/>You need to activate by clicking link below.</p><p>Active Link:<br/><a href='http://www.giverooms.com/register.php?passkey='>http://www.giverooms.com/register.php?passkey=</a></p></html>";
             $this->session->set_flashdata('register', array('messages' => 'successfully !We send verification link to you email.See in your email', 'class' => 'alert-success'));
             send_email('', $email, '', $sub, $msg);
             redirect(site_url('register.html'));
         } else {
             //redirect(site_url('login.html'));
         }
     }
 }
开发者ID:giverooms,项目名称:giverooms,代码行数:25,代码来源:Register.php

示例13: send_reminder

 private function send_reminder($questionnaire)
 {
     $client_name = $questionnaire->client_name;
     $client_email = $questionnaire->client_email;
     $personalized_slug = $questionnaire->personalized_slug;
     $issued_date = $questionnaire->issued_date;
     $progress = $questionnaire->progress;
     // Generate the personalized url
     $personalized_url = site_url("go/{$personalized_slug}");
     $to = $client_email;
     $subject = 'Questionnaire Reminder - ' . $this->config->item('site_name');
     $message = '';
     // Compose the message
     $message .= "Dear {$client_name}," . PHP_EOL;
     $message .= PHP_EOL;
     $message .= "This is a reminder e-mail." . PHP_EOL;
     $message .= "Your questionnaire was issued on {$issued_date} and is {$progress}% complete." . PHP_EOL;
     $message .= PHP_EOL;
     $message .= "Please follow the link below and fill out the Website Design Questionnaire." . PHP_EOL;
     $message .= "{$personalized_url}" . PHP_EOL;
     $message .= PHP_EOL;
     $message .= "Thanks," . PHP_EOL;
     $message .= $this->config->item('site_name');
     // Send the email
     $this->load->helper('email');
     $result = send_email($to, $subject, $message);
     return $result;
 }
开发者ID:AdrianBav,项目名称:ee-questionnaire,代码行数:28,代码来源:questionnaire.php

示例14: test_email

function test_email(){
	$mail_to = "jonathan.beckett@gmail.com";
	$mail_subject = "Test Email";
	$mail_message = "This is a test";
	
	send_email($mail_to, $mail_subject, $mail_message, true);
}
开发者ID:jonbeckett,项目名称:wetheusers,代码行数:7,代码来源:test.php

示例15: comment_add

function comment_add()
{
    if (isset($_SESSION["user_id"])) {
        $post_id = isset($_POST["post_id"]) ? $_POST["post_id"] : "";
        $body = isset($_POST["body"]) ? $_POST["body"] : "";
        if ($post_id != "" && $body != "") {
            $mysqli = db_connect();
            $sql = "SELECT Posts.Id,Posts.Title,Users.NotifyComments,Users.Username,Users.Email,Posts.UserId FROM Posts" . " INNER JOIN Users ON Users.Id=Posts.UserId" . " WHERE Posts.Id=" . $mysqli->real_escape_string($post_id);
            $post_result = $mysqli->query($sql);
            if ($post_result->num_rows > 0) {
                $post_row = $post_result->fetch_assoc();
                $link_title = $post_row["Title"] != "" ? $post_row["Title"] : "Untitled";
                // Add the comment to the comments table
                $sql = "INSERT INTO Comments (" . "PostId,UserId,Body,Created,IPCreated" . ") VALUES (" . $mysqli->real_escape_string($post_id) . "," . $mysqli->real_escape_string($_SESSION["user_id"]) . ",'" . $mysqli->real_escape_string($body) . "'" . ",Now()" . ",'" . $mysqli->real_escape_string($_SERVER["REMOTE_ADDR"]) . "'" . ")";
                $mysqli->query($sql);
                $new_comment_id = $mysqli->insert_id;
                // Update the number of comments on the post
                $count_sql = "SELECT COUNT(*) AS NumComments FROM Comments WHERE PostId=" . $mysqli->real_escape_string($post_id);
                $count_result = $mysqli->query($count_sql);
                $count_row = $count_result->fetch_assoc();
                $update_sql = "UPDATE Posts SET Comments=" . $mysqli->real_escape_string($count_row["NumComments"]) . " WHERE Id=" . $mysqli->real_escape_string($post_id);
                $update_result = $mysqli->query($update_sql);
                // do an email notification if required
                if ($post_row["UserId"] != $_SESSION["user_id"]) {
                    if ($post_row["NotifyComments"] == 1) {
                        $mail_to = $post_row["Email"];
                        $mail_subject = SITE_NAME . " - " . $_SESSION["user_name"] . " commented on '" . $post_row["Title"] . "'";
                        $mail_message = "You have received a new comment on your post '" . $link_title . "' by " . $_SESSION["user_name"] . "...\n---\n" . $body . "\n - " . $_SESSION["user_name"] . " (http://wetheusers.net/" . $_SESSION["user_name"] . ")\n---\n" . "http://wetheusers.net/post/" . $post_row["Id"] . "/" . toAscii($link_title) . "\n\n";
                        send_email($mail_to, $mail_subject, $mail_message);
                    }
                    SendSystemMessage($mysqli, $post_row["UserId"], $_SESSION["user_name"] . " commented on your post '" . $link_title . "'", "[" . $_SESSION["user_name"] . "](http://wetheusers.net/" . $_SESSION["user_name"] . ") commented on your post [" . $link_title . "](http://wetheusers.net/post/" . $post_row["Id"] . "/" . toAscii($link_title) . ")\n\n" . $body, 1);
                }
                // find out people who have commented previously that have NotifyOtherComments switched on
                $sql = "SELECT DISTINCT Users.Id AS UserId, Users.Email AS Email,Users.NotifyOtherComments" . " FROM Users" . " INNER JOIN Comments ON Comments.UserId=Users.Id AND Comments.PostId=" . $post_row["Id"] . " INNER JOIN Posts ON Posts.Id=" . $post_row["Id"] . " WHERE Comments.UserId<>" . $mysqli->real_escape_string($_SESSION["user_id"]) . " AND Posts.UserId<>Comments.UserId";
                // not if you wrote the comment
                // not if you wrote the post
                $result = $mysqli->query($sql);
                if ($result->num_rows > 0) {
                    while ($comment_row = @$result->fetch_assoc()) {
                        if ($comment_row["NotifyOtherComments"] == 1 && $post_row["UserId"] != $_SESSION["user_id"]) {
                            $mail_to = $comment_row["Email"];
                            $mail_subject = $_SESSION["user_name"] . " commented on '" . $post_row["Title"] . "' too";
                            $mail_message = "A new comment has been posted by " . $_SESSION["user_name"] . " on '" . $link_title . "' by " . $post_row["Username"] . ".\n---\n" . $body . "\n - " . $_SESSION["user_name"] . " (http://wetheusers.net/" . $_SESSION["user_name"] . ")\n---\n" . "http://wetheusers.net/post/" . $post_row["Id"] . "/" . toAscii($post_row["Title"]) . "\n\n";
                            send_email($mail_to, $mail_subject, $mail_message);
                        }
                        SendSystemMessage($mysqli, $comment_row["UserId"], "'" . $_SESSION["user_name"] . "' posted a new comment on '" . $link_title . "' by " . $post_row["Username"], "A new comment has been posted by [" . $_SESSION["user_name"] . "](http://wetheusers.net/" . $_SESSION["user_name"] . ") on [" . $link_title . "](http://wetheusers.net/post/" . $post_row["Id"] . "/" . toAscii($link_title) . ") by [" . $post_row["Username"] . "](http://wetheusers.net/" . $post_row["Username"] . ") (you have also commented on this post)\n\n" . $body, 2);
                    }
                }
                return "success";
            } else {
                header("Location: /404");
            }
        } else {
            header("Location: " . $_SERVER["HTTP_REFERER"] . "/failure");
        }
    } else {
        header("Location: /401");
    }
}
开发者ID:jonbeckett,项目名称:wetheusers,代码行数:59,代码来源:comments.php


注:本文中的send_email函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。