function writeDB_private_message($to_userid, $image, $subject, $from_userid, $message, $copie) { global $NPDS_Prefix; $res = sql_query("SELECT uid, user_langue FROM " . $NPDS_Prefix . "users WHERE uname='{$to_userid}'"); list($to_useridx, $user_languex) = sql_fetch_row($res); if ($to_useridx == "") { forumerror('0016'); } else { global $gmt; $time = date(translate("dateinternal"), time() + $gmt * 3600); include_once "language/lang-multi.php"; $subject = removeHack($subject); $message = str_replace("\n", "<br />", $message); $message = addslashes(removeHack($message)); $sql = "INSERT INTO " . $NPDS_Prefix . "priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text) "; $sql .= "VALUES ('{$image}', '{$subject}', '{$from_userid}', '{$to_useridx}', '{$time}', '{$message}')"; if (!($result = sql_query($sql))) { forumerror('0020'); } if ($copie) { $sql = "INSERT INTO " . $NPDS_Prefix . "priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text, type_msg, read_msg) "; $sql .= "VALUES ('{$image}', '{$subject}', '{$from_userid}', '{$to_useridx}', '{$time}', '{$message}', '1', '1')"; if (!($result = sql_query($sql))) { forumerror('0020'); } } global $subscribe, $nuke_url; if ($subscribe) { $sujet = translate_ml($user_languex, "Vous avez un nouveau message."); $message = translate_ml($user_languex, "Bonjour") . ",<br /><br /><a href=\"{$nuke_url}/viewpmsg.php\">" . translate_ml($user_languex, "Cliquez ici pour lire votre nouveau message.") . "</a><br /><br />"; include "signat.php"; copy_to_email($to_useridx, $sujet, $message); } } }
function subscribe_mail($Xtype, $Xtopic, $Xforum, $Xresume, $Xsauf) { // $Xtype : topic, forum ... / $Xtopic clause WHERE / $Xforum id of forum / $Xresume Text passed / $Xsauf not this userid global $NPDS_Prefix; global $sitename, $nuke_url; if ($Xtype == "topic") { $result = sql_query("SELECT topictext FROM " . $NPDS_Prefix . "topics WHERE topicid='{$Xtopic}'"); list($abo) = sql_fetch_row($result); $result = sql_query("SELECT uid FROM " . $NPDS_Prefix . "subscribe WHERE topicid='{$Xtopic}'"); } if ($Xtype == "forum") { $result = sql_query("SELECT forum_name, arbre FROM " . $NPDS_Prefix . "forums WHERE forum_id='{$Xforum}'"); list($abo, $arbre) = sql_fetch_row($result); if ($arbre) { $hrefX = "viewtopicH.php"; } else { $hrefX = "viewtopic.php"; } $resultZ = sql_query("SELECT topic_title FROM " . $NPDS_Prefix . "forumtopics WHERE topic_id='{$Xtopic}'"); list($title_topic) = sql_fetch_row($resultZ); $result = sql_query("SELECT uid FROM " . $NPDS_Prefix . "subscribe WHERE forumid='{$Xforum}'"); } include_once "language/lang-multi.php"; while (list($uid) = sql_fetch_row($result)) { if ($uid != $Xsauf) { $resultX = sql_query("SELECT email, user_langue FROM " . $NPDS_Prefix . "users WHERE uid='{$uid}'"); list($email, $user_langue) = sql_fetch_row($resultX); if ($Xtype == "topic") { $entete = translate_ml($user_langue, "Vous recevez ce Mail car vous vous êtes abonné à : ") . translate_ml($user_langue, "Sujet") . " => " . strip_tags($abo) . "\n\n"; $resume = translate_ml($user_langue, "Le titre de la dernière publication est") . " => {$Xresume}\n\n"; $url = translate_ml($user_langue, "L'URL pour cet article est : ") . "<a href=\"{$nuke_url}/search.php?query=&topic={$Xtopic}\">{$nuke_url}/search.php?query=&topic={$Xtopic}</a>\n\n"; } if ($Xtype == "forum") { $entete = translate_ml($user_langue, "Vous recevez ce Mail car vous vous êtes abonné à : ") . translate_ml($user_langue, "Forum") . " => " . strip_tags($abo) . "\n\n"; $url = translate_ml($user_langue, "L'URL pour cet article est : ") . "<a href=\"{$nuke_url}/{$hrefX}?topic={$Xtopic}&forum={$Xforum}&start=9999#last-post\">{$nuke_url}/{$hrefX}?topic={$Xtopic}&forum={$Xforum}&start=9999</a>\n\n"; $resume = translate_ml($user_langue, "Le titre de la dernière publication est") . " => "; if ($Xresume != "") { $resume .= $Xresume . "\n\n"; } else { $resume .= $title_topic . "\n\n"; } } $subject = translate_ml($user_langue, "Abonnement") . " / {$sitename}"; $message = $entete; $message .= $resume; $message .= $url; include "signat.php"; send_email($email, $subject, $message, '', true, 'html'); } } }
function send_email_to_user($username, $subject, $message, $all, $groupe, $expediteur) { global $NPDS_Prefix, $f_meta_nom, $f_titre, $adminimg; if ($subject != '') { if ($expediteur == 1) { $emetteur = 1; } else { global $user; if ($user) { $userX = base64_decode($user); $userdata = explode(':', $userX); $emetteur = $userdata[0]; } else { $emetteur = 1; } } if ($all) { $result = sql_query("SELECT uid, user_langue FROM " . $NPDS_Prefix . "users"); while (list($to_userid, $user_langue) = sql_fetch_row($result)) { $tab_to_userid[] = $to_userid . ':' . $user_langue; } } else { if ($groupe) { $result = sql_query("SELECT s.uid, s.groupe, u.user_langue FROM " . $NPDS_Prefix . "users_status s, " . $NPDS_Prefix . "users u WHERE s.uid=u.uid AND s.groupe!='' ORDER BY s.uid ASC"); while (list($to_userid, $groupeX, $user_langue) = sql_fetch_row($result)) { $tab_groupe = explode(',', $groupeX); if ($tab_groupe) { foreach ($tab_groupe as $groupevalue) { if ($groupevalue == $groupe) { $tab_to_userid[] = $to_userid . ':' . $user_langue; } } } } } else { $result = sql_query("SELECT uid, user_langue FROM " . $NPDS_Prefix . "users WHERE uname='{$username}'"); while (list($to_userid, $user_langue) = sql_fetch_row($result)) { $tab_to_userid[] = $to_userid . ':' . $user_langue; } } } if ($subject == '' or $message == '') { header("location: admin.php"); } $message = str_replace('\\n', '<br />', $message); global $gmt; $time = date(translate("dateinternal"), time() + $gmt * 3600); $pasfin = false; $count = 0; include_once "language/lang-multi.php"; while ($count < sizeof($tab_to_userid)) { $to_tmp = explode(':', $tab_to_userid[$count]); $to_userid = $to_tmp[0]; if ($to_userid != '' and $to_userid != 1) { $sql = "INSERT INTO " . $NPDS_Prefix . "priv_msgs (msg_image, subject, FROM_userid, to_userid, msg_time, msg_text) "; $sql .= "VALUES ('{$image}', '{$subject}', '{$emetteur}', '{$to_userid}', '{$time}', '{$message}')"; if ($resultX = sql_query($sql)) { $pasfin = true; } // A copy in email if necessary global $nuke_url, $subscribe; if ($subscribe) { $old_message = $message; $sujet = translate_ml($to_tmp[1], 'Vous avez un nouveau message.'); $message = translate_ml($to_tmp[1], 'Bonjour') . ",<br /><br /><a href=\"{$nuke_url}/viewpmsg.php\">" . translate_ml($to_tmp[1], "Cliquez ici pour lire votre nouveau message.") . "</a><br /><br />"; include "signat.php"; copy_to_email($to_userid, $sujet, $message); $message = $old_message; } } $count++; } } global $aid; Ecr_Log('security', "SendEmailToUser({$subject}) by AID : {$aid}", ''); global $hlpfile; include 'header.php'; GraphicAdmin($hlpfile); adminhead($f_meta_nom, $f_titre, $adminimg); echo ' <hr />'; if ($pasfin) { echo ' <div class="alert alert-success"><strong>"' . stripslashes($subject) . '"</strong> ' . adm_translate("a été envoyée") . '.</div>'; } else { echo ' <div class="alert alert-danger"><strong>"' . stripslashes($subject) . '"</strong>' . adm_translate("n'a pas été envoyée") . '.</div>'; } adminfoot('', '', '', ''); }
forumerror('0029'); } $sql = "SELECT t.topic_notify, u.email, u.uname, u.uid, u.user_langue FROM " . $NPDS_Prefix . "forumtopics t, " . $NPDS_Prefix . "users u WHERE t.topic_id = '{$topic}' AND t.topic_poster = u.uid"; if (!($result = sql_query($sql))) { forumerror('0022'); } $m = sql_fetch_assoc($result); $sauf = ""; if ($m['topic_notify'] == 1 && $m['uname'] != $userdata['uname']) { include_once "language/lang-multi.php"; $resultZ = sql_query("SELECT topic_title FROM " . $NPDS_Prefix . "forumtopics WHERE topic_id='{$topic}'"); list($title_topic) = sql_fetch_row($resultZ); $subject = strip_tags($forum_name) . "/" . $title_topic . " : " . translate_ml($m['user_langue'], "Une réponse à votre dernier Commentaire a été posté."); $message = $m['uname'] . "\n\n"; $message .= translate_ml($m['user_langue'], "Vous recevez ce Mail car vous avez demandé à être informé lors de la publication d'une réponse.") . "\n"; $message .= translate_ml($m['user_langue'], "Pour lire la réponse") . " : "; $message .= "<a href=\"{$nuke_url}/viewtopic.php?topic={$topic}&forum={$forum}&start=9999#last-post\">{$nuke_url}/viewtopic.php?topic={$topic}&forum={$forum}&start=9999</a>\n\n"; include "signat.php"; if (!$system) { send_email($m['email'], $subject, $message, "", true, "html"); $sauf = $m['uid']; } } global $subscribe; if ($subscribe) { if (subscribe_query($userdata['uid'], "forum", $forum)) { $sauf = $userdata['uid']; } subscribe_mail("forum", $topic, $forum, "", $sauf); } if (isset($upload)) {
$sql = "INSERT INTO " . $NPDS_Prefix . "priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text) "; $sql .= "VALUES ('{$image}', '{$subject}', '" . $userdata['uid'] . "', '{$to_userid}', '{$time}', '{$message}')"; if (!($result = sql_query($sql))) { forumerror('0020'); } if ($copie) { $sql = "INSERT INTO " . $NPDS_Prefix . "priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text, type_msg, read_msg) "; $sql .= "VALUES ('{$image}', '{$subject}', '" . $userdata['uid'] . "', '{$to_userid}', '{$time}', '{$message}', '1', '1')"; if (!($result = sql_query($sql))) { forumerror('0020'); } } global $nuke_url, $subscribe; if ($subscribe) { $sujet = translate_ml($user_langue, 'Vous avez un nouveau message.'); $message = translate_ml($user_langue, "Bonjour") . ",<br /><br /><a href=\"{$nuke_url}/viewpmsg.php\">" . translate_ml($user_langue, "Cliquez ici pour lire votre nouveau message.") . "</a><br /><br />"; include "signat.php"; copy_to_email($to_userid, $sujet, $message); } } } unset($message); unset($sujet); if ($full_interface != 'short') { header("Location: viewpmsg.php"); } else { header("Location: readpmsg_imm.php?op=new_msg"); } } if ($delete_messages . x && $delete_messages . y) { for ($i = 0; $i < $total_messages; $i++) {