/** * Display all comment users */ function see_comm_users() { global $Pivot_Vars, $Users, $Paths; PageHeader(lang('adminbar', 'seecommusers_title'), 1); PageAnkeiler(lang('userbar', 'admin') . ' » ' . lang('adminbar', 'seecommusers_title')); StartTable('', 7); GenSetting('', lang('userinfo', 'commusers'), '', 8, '', 7); // In the comment user info table below, the keys pass, notify_entries, // notify_default and show_address are ignored. Activate the commented // out HTML code (in $table_body and $table_row) to display everything. $table_body = ' <tr class="tabular_header"> <td class="tabular">' . lang('userinfo', 'username') . ': </td> <td class="tabular">' . lang('userinfo', 'email') . ': </td> <td class="tabular">' . lang('userinfo', 'url') . ': </td> <td class="tabular">' . lang('userinfo', 'lastlogin') . ': </td> <!-- td class="tabular">' . lang('userinfo', 'show_address') . ': </td --> <!-- td class="tabular">' . lang('userinfo', 'notify_entries') . ': </td --> <!-- td class="tabular">' . lang('userinfo', 'notify_default') . ': </td --> <td class="tabular">' . lang('userinfo', 'verified') . ': </td> <td class="tabular">' . lang('userinfo', 'disabled') . ': </td> <td></td> </tr>'; $table_row = ' <tr> <td class="tabular">%name%</td> <td class="tabular">%email%</td> <td class="tabular">%url%</td> <td class="tabular">%last_login%</td> <!-- td class="tabular">%show_address%</td --> <!-- td class="tabular">%notify_entries%</td --> <!-- td class="tabular">%notify_default%</td --> <td class="tabular">%verified%</td> <td class="tabular">%disabled%</td> <td nowrap="nowrap">%editlink%</td> </tr>'; $comment_users = get_registered_visitors(); foreach ($comment_users as $name_md5 => $commuserdata) { $thisrow = $table_row; $commuserdata['verified'] = $commuserdata['verified'] == 1 ? "%Yes%" : "%No%"; if (!isset($commuserdata['disabled']) || $commuserdata['disabled'] == 0) { $commuserdata['disabled'] = "%No%"; } else { $commuserdata['disabled'] = "%Yes%"; } if (!isset($commuserdata['last_login'])) { $commuserdata['last_login'] = ""; } foreach ($commuserdata as $key => $value) { if (empty($value)) { $value = "-"; } $thisrow = str_replace("%{$key}%", trimtext($value, 30), $thisrow); } if ($Users[$Pivot_Vars['user']]['userlevel'] >= 3) { $thisrow = str_replace("%editlink%", MakeLink(array('func' => 'admin', 'do' => 'editcommuser', 'edituser' => $name_md5)) . lang('userinfo', 'editcommuser') . '</a>', $thisrow); } else { $thisrow = str_replace("%editlink%", "", $thisrow); } $table_body .= $thisrow; } $table_body = str_replace("%Yes%", lang('general', 'yes'), $table_body); $table_body = str_replace("%No%", lang('general', 'no'), $table_body); echo $table_body . '</table><br />'; PageFooter(); }
/** * Sends notification for any type - currently only entries/comments. * * @param string $type * @param array $data * @return void */ function notify_new($type, $data) { global $Paths, $Current_weblog, $Users, $Weblogs, $i18n_use; // FIXME: // $contact_addr used below is not set because there is really no // good setting for that - the comment_emailto setting for each e-mail // isn't meant for the from header... if ($type == 'comment') { // splitting up input data $entry = $data[0]; $comment = $data[1]; if (isset($data[2]) && $data[2]) { debug("Notification of new comment surpressed."); return; } // make a nice title for the mail.. if (strlen($entry['title']) > 2) { $title = $entry['title']; $title = strip_tags($title); } else { $title = substr($entry['introduction'], 0, 300); $title = strip_tags($title); $title = str_replace("\n", "", $title); $title = str_replace("\r", "", $title); $title = substr($title, 0, 60); } $id = safe_string($comment["name"], TRUE) . "-" . format_date($comment["date"], "%ye%%month%%day%%hour24%%minute%"); // Make the array of users that want to be notified via email.. $notify_arr = array(); foreach ($entry['comments'] as $temp_comm) { if ($temp_comm['notify'] == 1 && isemail($temp_comm['email'])) { $notify_arr[$temp_comm['email']] = 1; } if ($temp_comm['notify'] == 0 && isemail($temp_comm['email'])) { unset($notify_arr[$temp_comm['email']]); } } // don't send to the user that did the comment... if (isset($notify_arr[$comment['email']])) { unset($notify_arr[$comment['email']]); } // send mail to those on the 'notify me' list.. if (count($notify_arr) > 0) { $contact_addr = $Users[$entry['user']]['email']; $user = $Users[$entry['user']]['nick']; if (empty($user)) { $user = $entry['user']; } if (!$i18n_use) { $user = utf8_encode($user); } $body = sprintf(lang('comment', 'email_posted_comm') . ":\n\n", unentify($comment['name'])); $body .= sprintf("%s", unentify($comment['comment'])); $body .= sprintf("\n\n-------------\n"); $body .= sprintf(lang('weblog_text', 'name') . ": %s\n", unentify($comment['name'])); $body .= sprintf(lang('comment', 'email_comm_on') . "\n", $title); $body .= sprintf("\n%s:\n%s%s\n", lang('comment', 'email_view_entry'), $Paths['host'], make_filelink($entry['code'], "", "")); $body .= sprintf("%s:\n%s%s\n", lang('comment', 'email_view_comm'), $Paths['host'], make_filelink($entry['code'], "", $id)); if (!$i18n_use) { $body = utf8_encode($body); } $body = decode_text($body, 'special'); $contact_name = '=?UTF-8?B?' . base64_encode($user) . '?='; $add_header = sprintf("From: \"'%s'\" <%s>\n", $contact_name, $contact_addr); $add_header .= "MIME-Version: 1.0\n"; $add_header .= "Content-Type: text/plain; charset=UTF-8; format=flowed\n"; $add_header .= "Content-Transfer-Encoding: 8bit\n"; $subject = lang('comment', 'email_subject_notify') . " Re: {$title}"; if (!$i18n_use) { $subject = utf8_encode($subject); } $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; foreach ($notify_arr as $addr => $val) { $addr = trim($addr); @mail($addr, $subject, $body, $add_header); debug("Sent Notify to {$addr} from '" . $comment['name'] . "'"); } } } else { if ($type == 'entry') { $entry = $data; // We need to determine the current weblog.. $weblogs = find_weblogs_with_cat($entry['category']); $Current_weblog = current($weblogs); // make a nice title for the mail.. if (strlen($entry['title']) > 2) { $title = $entry['title']; $title = strip_tags($title); } else { $title = substr($entry['introduction'], 0, 300); $title = strip_tags($title); $title = str_replace("\n", "", $title); $title = str_replace("\r", "", $title); $title = substr($title, 0, 60); } $title = unentify($title); // Make the array of users that want to be notified via email.. $comment_users = get_registered_visitors(); $notify_arr = array(); foreach ($comment_users as $commuserdata) { if ($commuserdata['verified'] && !$commuserdata['disabled'] && $commuserdata['notify_entries']) { $notify_arr[$commuserdata['email']] = $commuserdata['name']; } } // send mail to those on the 'notify me' list.. if (count($notify_arr) > 0) { $contact_addr = $Users[$entry['user']]['email']; // Get the user's nickname (or username if nickname // isn't set), and the weblog's name. $user = $Users[$entry['user']]['nick']; if (empty($user)) { $user = $entry['user']; } if (!$i18n_use) { $user = utf8_encode($user); } $weblog = find_weblogs_with_cat($entry['category']); $weblog = $Weblogs[$weblog[0]]['name']; $defaultbody = sprintf(lang('comment', 'email_posted_entry') . ":\n\n", $user); $defaultbody .= sprintf("%s\n\n%s\n", $title, unentify(strip_tags($entry['introduction']))); $defaultbody .= sprintf("\n\n-------------\n"); $defaultbody .= sprintf("\n%s:\n%s%s\n", lang('comment', 'email_view_fullentry'), $Paths['host'], make_filelink($entry, "", "")); $defaultbody .= sprintf("\n%s:\n%s%suser.php%s\n", lang('comment', 'email_view_settings'), $Paths['host'], $Paths['pivot_url'], "?w=" . para_weblog($Current_weblog)); $defaultbody .= sprintf("\n%s: %%name%% (%%addr%%)\n", lang('comment', 'email_sent_to'), $Paths['host'], $Paths['pivot_url']); $defaultbody = decode_text($defaultbody, 'special'); if (!$i18n_use) { $defaultbody = utf8_encode($defaultbody); } $contact_name = '=?UTF-8?B?' . base64_encode($user) . '?='; $add_header = sprintf("From: \"'%s'\" <%s>\n", $contact_name, $contact_addr); $add_header .= "MIME-Version: 1.0\n"; $add_header .= "Content-Type: text/plain; charset=UTF-8; format=flowed\n"; $add_header .= "Content-Transfer-Encoding: 8bit\n"; $subject = lang('comment', 'email_subject_notify') . " {$title} - {$weblog}"; if (!$i18n_use) { $subject = utf8_encode($subject); } $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; $notified = array(); foreach ($notify_arr as $addr => $name) { $addr = trim($addr); $body = $defaultbody; $body = str_replace("%name%", $name, $body); $body = str_replace("%addr%", $addr, $body); @mail($addr, $subject, $body, $add_header); debug("Sent Notify to {$addr} from '" . $entry['user'] . "'"); $notified[] = sprintf("%s (%s)", $name, $addr); } $notified = sprintf("%s: %s", lang('comment', 'email_notified'), implode(", ", $notified)); return $notified; } } else { if ($type == 'visitor_registration') { $type = $data[0]; $name = $data[1]; // Only sending notification to superadmin foreach ($Users as $key => $value) { if ($value['userlevel'] == 4) { $user = $key; break; } } $contact_addr = $Users[$user]['email']; $contact_name = $Users[$user]['nick']; if (empty($contact_name)) { $contact_name = $user; } if ($type == 'add') { $subject = "New visitor registration - {$name}"; } else { $subject = "New visitor confirmed - {$name}"; } $body = $subject; $body .= sprintf("\n\nView visitor information:\n%s%s?menu=admin&func=admin&do=seecommusers\n", $Paths['host'], $Paths['pivot_url']); if (!$i18n_use) { $contact_name = utf8_encode($contact_name); $subject = utf8_encode($subject); $body = utf8_encode($body); } $contact_name = '=?UTF-8?B?' . base64_encode($contact_name) . '?='; $add_header = sprintf("From: \"'%s'\" <%s>\n", $contact_name, $contact_addr); $add_header .= "MIME-Version: 1.0\n"; $add_header .= "Content-Type: text/plain; charset=UTF-8; format=flowed\n"; $add_header .= "Content-Transfer-Encoding: 8bit\n"; $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; @mail($contact_addr, $subject, $body, $add_header); debug("Sent registered visitor notification for {$name}"); return; } else { debug("Unknown notify type '{$type}'"); } } } }