/** * Make a URL (global link) to an entry. * * @uses make_filelink makes the link (without protocol and host). * * @param string $code * @param string $weblog * @param string $anchor * @param string $parameter */ function make_fileurl($code = "", $weblog = "", $anchor = "comm", $parameter = "") { global $Paths; $link = make_filelink($code, $weblog, $anchor, $parameter); return gethost() . $link; }
} else { $override_weblog = find_current_weblog_referer(); } } // If non-crufty URLs (mod_rewrite) is enabled and someone tries to // access the crufty URL, redirect (if not in preview mode). // This is search engine friendly. list($request_script) = explode("?", $_SERVER['REQUEST_URI']); if (!isset($Pivot_Vars['f_title']) && $Cfg['mod_rewrite'] && basename($request_script) == "entry.php") { if ($override_weblog == "") { reset($Weblogs); $Current_weblog = key($Weblogs); } else { $Current_weblog = $override_weblog; } $filelink = make_filelink($_GET['id'], '', ''); // Handle addition query parameters $query = '?'; unset($_GET['id']); foreach ($_GET as $key => $value) { $query .= $key . '=' . urlencode($value) . '&'; } if ($query != '?') { $filelink .= substr($query, 0, -1); } // Redirect header("HTTP/1.1 301 Moved Permanently"); header("Location: {$filelink}"); exit; } // load an entry
/** * Needs cleanup!! * * @param unknown_type $p_sTag * @param unknown_type $p_nSkip * @return unknown */ function get_entries_with_tag($p_sTag, $p_nSkip = 0) { global $db, $Paths; $p_sTag = strtolower($p_sTag); $p_sTag = str_replace(" ", "+", $p_sTag); if (file_exists($Paths['pivot_path'] . "db/tagdata/{$p_sTag}.tag")) { $fpTagFile = fopen($Paths['pivot_path'] . "db/tagdata/{$p_sTag}.tag", "r"); } else { return ""; } $sEntriesString = ""; while (!feof($fpTagFile)) { $sEntriesString .= fread($fpTagFile, 4096); } fclose($fpTagFile); $aEntries = explode(",", $sEntriesString); rsort($aEntries); $aLinks = array(); foreach ($aEntries as $nThisEntry) { $myDB = new db(); global $Paths; $myDB->read_entry($nThisEntry); $sTitle = $myDB->entry["title"]; if ($myDB->entry["code"] != $p_nSkip) { $aLinks[] = "<li><a href=\"" . make_filelink($myDB->entry["code"], '', '') . "\">" . $sTitle . "</a></li>"; } } if (count($aLinks) > 0) { $sLinkList = "<ul style=\"padding-left:10px;\">\n"; $sLinkList .= implode("\n", $aLinks); $sLinkList .= "</ul>\n"; return $sLinkList; } else { return ""; } }
function make_default() { global $Weblogs, $Current_weblog, $db, $entry; $db = new db(); $arc_list = ""; if (file_exists($pivot_dir . "db/ser-archive_overview_cat.php") && file_exists($pivot_dir . "db/ser-archive_overview_cat.php")) { $arc_array_cat = load_serialize($pivot_dir . "db/ser-archive_overview_cat.php", TRUE); $arc_array_mon = load_serialize($pivot_dir . "db/ser-archive_overview_mon.php", TRUE); // if over three three days old. if (mktime() - filemtime($pivot_dir . "db/ser-archive_overview_cat.php") > 259200) { unlink($pivot_dir . "db/ser-archive_overview_cat.php"); unlink($pivot_dir . "db/ser-archive_overview_mon.php"); } } else { $list_entries = $db->getlist_range("1970-01-01-00-00", "2020-12-31-23-59", "", "", FALSE); // iterate through all of the entries, building the arrays for both the // per-month and per-category lists.. foreach ($list_entries as $list_entry) { $date = format_date($list_entry['date'], $Weblogs[$Current_weblog]['fulldate_format']); $link = make_filelink($list_entry['code']); list($ye, $mo) = explode("-", $list_entry['date']); if (isset($list_entry['category'])) { foreach ($list_entry['category'] as $cat) { $arc_array_cat[$cat][$ye] = 1; } } $arc_array_mon[$ye][$mo] = 1; } save_serialize($pivot_dir . "db/ser-archive_overview_cat.php", $arc_array_cat, FALSE); save_serialize($pivot_dir . "db/ser-archive_overview_mon.php", $arc_array_mon, FALSE); } $current_cats = find_cats_in_weblog($Current_weblog); // build the per-month list foreach ($arc_array_mon as $ye => $months) { $arc_list .= "<p><b>{$ye}:</b><br />\n"; ksort($months); $temp_arr = array(); foreach ($months as $mo => $dummy) { $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $ye, $mo, lang('months', -1 + $mo)); } $arc_list .= implode(", ", $temp_arr) . "<br /></p>\n"; } // build the per-category list ksort($arc_array_cat); if (count($arc_array_cat) > 1) { foreach ($arc_array_cat as $cat => $year) { if (in_array($cat, $current_cats)) { $arc_list .= "<p><b>{$cat}:</b>\n"; ksort($year); $temp_arr = array(); foreach ($year as $ye => $dummy) { $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $cat, $ye, $ye); } $arc_list .= implode(", ", $temp_arr) . "</p>\n"; } } } // the search template for the current weblog if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") { $template_html = load_template($Weblogs[$Current_weblog]['extra_template']); } else { $template_html = load_template($Weblogs[$Current_weblog]['archive_template']); } $template_html = replace_subweblogs_templates($template_html, $arc_list); $filename = $Weblogs[$Current_weblog]['archive_path'] . make_archive_name(); if (!$template_html) { ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]"); } else { $output = $template_html; $output = parse_step4($output); } echo $output; flush(); }
/** * Searches the index for words. * * @param array $str_a Contains the display text (index 0) and the search text (index 1). * @return string The search results as a list (in HTML code). */ function search_index($str_a) { global $Current_weblog, $Weblogs, $index_file, $matches, $db, $allowed_chars; $str_a[1] = trim($str_a[1]); $words = explode(" ", $str_a[1]); $orig_words = explode(" ", trim($str_a[0])); // Ignoring empty strings and removing non-allowed chars from words foreach ($words as $key => $val) { if (trim($val) == "") { unset($words[$key]); } else { $words[$key] = preg_replace('/[^' . preg_quote($allowed_chars) . ']/i', '', trim($val)); } } if (count($words) > 0) { foreach ($words as $word) { if (file_exists("db/search/" . $word[0] . ".php")) { $index_file[$word[0]] = load_serialize("db/search/" . $word[0] . ".php"); } } } $n = count($words); for ($i = 0; $i < $n; $i++) { // getword sets $matches used below. $res = getword($words[$i]); if ($res) { $found_words[] = $orig_words[$i]; } } // mix 'n match.. If the result set for 'AND' is empty, just lump // them together, so we have an 'OR'.. if (count($matches) == 1) { $result = $matches[0]; } else { if (count($matches) == 2) { list($word1, $word2) = $matches; $result = array_intersect($word1, $word2); if (count($result) == 0) { $result = array_merge($word1, $word2); } } else { if (count($matches) == 3) { list($word1, $word2, $word3) = $matches; $result = array_intersect($word1, $word2, $word3); if (count($result) == 0) { $result = array_merge($word1, $word2, $word3); } } else { if (count($matches) > 3) { list($word1, $word2, $word3, $word4) = $matches; $result = array_intersect($word1, $word2, $word3, $word4); if (count($result) == 0) { $result = array_merge($word1, $word2, $word3, $word4); } } } } } $title = lang('weblog_text', 'search_title'); if (strlen($Weblogs[$Current_weblog]['search_format']) > 1) { list($format_top, $format_summary, $format_start, $format_entry, $format_end) = explode("----", $Weblogs[$Current_weblog]['search_format']); } else { $format_top = "<h2>%search_title%</h2>\n%search_form%\n"; $format_summary = "<p>%search_summary%</p>\n"; $format_start = "<ul>\n"; $format_entry = "<li><!-- %code% --><a href='%link%'>%title%</a></li>\n"; $format_end = "</ul>\n"; } $output = $format_top . $format_summary; if (isset($found_words) && count($found_words) > 0) { rsort($result); $result = array_unique($result); $count = count($result); $name = implode(', ', $found_words); $summary = str_replace('%name%', $name, lang('weblog_text', 'matches')); $output .= $format_start; $db = new db(); foreach ($result as $hit) { if ($db->entry_exists($hit)) { $entry = $db->read_entry($hit); $entry['link'] = make_filelink($entry['code'], "", ""); $entry['categories'] = implode(', ', $entry['category']); $weblogs = find_weblogs_with_cat($entry['category']); foreach ($weblogs as $key => $value) { $weblogs[$key] = $Weblogs[$value]['name']; } $entry['weblogs'] = implode(', ', $weblogs); if ($entry['title'] == "") { $entry['title'] = substr(strip_tags($entry['introduction']), 0, 50); } $output .= format_entry($entry, $format_entry); } } $output .= "{$format_end}\n"; } else { if ($str_a[1] != "") { $count = 0; $name = $str_a[0]; $summary = str_replace('%name%', $name, lang('weblog_text', 'nomatches')); } } $output = str_replace("%search_term%", $name, $output); $output = str_replace("%search_count%", $count, $output); $output = str_replace("%search_summary%", $summary, $output); $output = str_replace("%search_title%", $title, $output); return $output; }
/** * The screen you'll see after submitting an entry. It stores the entry, updates the indices (pivot's * content indices, and the search index), rebuilds the frontpage and XML & Atom feeds, and then it * displays a list of the latest entries. * */ function entrysubmit_screen() { global $db, $config_array, $Pivot_Vars, $entry, $Cfg, $Users, $Paths, $Weblogs, $filtered_words; // check against unauthorised direct access. check_csrf(); $db = new db(); $entry = get_entry_from_post(); if (!$entry['title'] == "" || !$entry['introduction'] == "" || !$entry['user'] == "") { // in this part, we remove the entry from the categories in which // the current user is not allowed to post entries foreach ($entry['category'] as $my_cat) { $allowed = explode("|", $Cfg['cat-' . $my_cat]); if (in_array($Pivot_Vars['user'], $allowed)) { $allowed_cats[] = $my_cat; } else { $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_catnopost'), $m_cat); debug("not in category: " . $my_cat); } } $entry['category'] = $allowed_cats; $db->set_entry($entry); if ($db->save_entry(TRUE)) { $message = sprintf(lang('entries', 'entry_saved_ok') . $message, '<i>' . trimtext($entry['title'], 25) . '</i>'); } else { $message = sprintf(lang('entries', 'entry_saved_ok'), '<i>' . trimtext($entry['title'], 25) . '</i>'); } // only trigger the ping if it's a new entry.. if ($entry['code'] == ">" && $entry['status'] == "publish") { $ping = TRUE; } else { $ping = FALSE; } // only notify if entry is published, and is either new or status changed to publish. if ($entry['status'] == "publish") { if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") { $notified = notify_new('entry', $db->entry); $notified = "<br /><br />" . $notified; } } // if the global index as they are made var is set - can continue if ('1' == $Cfg['search_index']) { /* 2004/10/16 =*=*= JM an entry should only be indexed if both are true: - 'publish'==$entry['status'] - current date is at least equal to $entry['publish_date'] I lie, there is another case... it is conceivable that this is a timed publish AND the time has come I will leave this to timed publish routines - if I can find them... -> pvLib ... it's flagged and of course, providing that there is at least one category where it would be indexed... something else that can't be tested... if the user changes a normal publish to a timed-publish, or puts on hold when it was previously normal. user should reindex in this case */ // check status and date if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= date('Y-m-d-H-i')) { // categories... if (can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) { include_once 'modules/module_search.php'; update_index($db->entry); debug('update search index: ' . $db->entry['code']); } } } // perhaps send a trackback ping. if ($Pivot_Vars['tb_url'] != "" && $entry['status'] == "publish") { debug("tburl: " . $Pivot_Vars['tb_url']); require_once 'includes/send_trackback.php'; $weblogs = find_weblogs_with_cat($db->entry['category']); if (isset($Weblogs[$weblogs[0]])) { $my_url = $Paths['host'] . make_filelink($db->entry['code'], $weblogs[0], ''); $weblog_title = $Weblogs[$weblogs[0]]['name']; debug("TRACKBACK ping: {$my_url}"); $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_ping_sent'), $Pivot_Vars['tb_url']); $tb_urls = explode("\n", $Pivot_Vars['tb_url']); // make the contents of what to send with the trackback.. $tb_contents = parse_step4($entry['introduction']); if ($Pivot_Vars['convert_lb'] == 2) { $tb_contents = pivot_textile($tb_contents); } else { if ($Pivot_Vars['convert_lb'] == 3 || $Pivot_Vars['convert_lb'] == 4) { $tb_contents = pivot_markdown($tb_contents, $Pivot_Vars['convert_lb']); } } $tb_contents = trimtext(strip_tags($tb_contents), 255); foreach ($tb_urls as $tb_url) { $tb_url = trim($tb_url); if (isurl($tb_url)) { trackback_send($Pivot_Vars['tb_url'], $my_url, $entry['title'], $weblog_title, $tb_contents); } } } } // Update the tags for this entry if it's published and remove the old tags if not if ($db->entry['status'] == 'publish') { writeTags($db->entry['keywords'], $_POST['f_keywords_old'], $db->entry['code']); } else { deleteTags($_POST['f_keywords_old'], $db->entry['code']); } } generate_pages($db->entry['code'], TRUE, TRUE, TRUE, $ping); entries_screen($message . $notified); }
function send_mail_comm() { global $Cfg, $db, $my_comment, $ip, $date, $Weblogs, $Current_weblog, $Paths, $Users, $i18n_use; $cat_weblogs = find_weblogs_with_cat($db->entry['category']); $addr_arr = array(); foreach ($cat_weblogs as $this_weblog) { if ($Weblogs[$this_weblog]['comment_sendmail'] == 1) { $addr_arr = array_merge($addr_arr, explode(",", $Weblogs[$this_weblog]['comment_emailto'])); } } // make a nice title for the mail.. if (strlen($db->entry['title']) > 2) { $title = $db->entry['title']; $title = strip_tags($title); } else { $title = substr($db->entry['introduction'], 0, 300); $title = strip_tags($title); $title = str_replace("\n", "", $title); $title = str_replace("\r", "", $title); $title = substr($title, 0, 60); } if (!$i18n_use) { $title = utf8_encode($title); } // maybe send some mail to authors.. if (count($addr_arr) > 0) { $adminurl = $Paths['host'] . $Paths['pivot_url'] . "index.php?"; $id = safe_string($my_comment["name"], TRUE) . "-" . format_date($my_comment["date"], "%ye%%month%%day%%hour24%%minute%"); $editlink = $adminurl . "menu=entries&func=editcomments&id=" . $db->entry['code']; $approvelink = $adminurl . "menu=moderate_comments&" . urlencode($id) . "=1"; $deletelink = $adminurl . "menu=moderate_comments&" . urlencode($id) . "=2"; $blocklink = $adminurl . "menu=entries&func=editcomments&id=" . $db->entry['code'] . "&blocksingle=" . $my_comment['ip']; $comment = $my_comment['comment']; // $comment = unentify($comment); $body = sprintf(lang('comment', 'email_posted_comm') . ":\n\n", unentify($my_comment['name'])); $body .= sprintf("%s", $comment); $body .= sprintf("\n\n-------------\n"); $body .= sprintf(lang('weblog_text', 'name') . ": %s\n", unentify($my_comment['name'])); $body .= sprintf(lang('weblog_text', 'ip') . ": %s\n", $my_comment['ip']); $body .= sprintf(lang('weblog_text', 'date') . ": %s\n", $my_comment['date']); $body .= trim(sprintf(lang('weblog_text', 'email') . ": %s", $my_comment['email'])) . "\n"; $body .= trim(sprintf(lang('weblog_text', 'url') . ": %s\n", $my_comment['url'])) . "\n"; $body .= sprintf("\n" . lang('comment', 'email_comm_on') . "\n", $title); if (count($notify_arr) > 0) { $body .= sprintf(lang('comment', 'notifications') . ": %s\n", implode(", ", array_keys($notify_arr))); } $body .= sprintf("-------------\n"); if ($Cfg['moderate_comments'] == 1) { $body .= sprintf(lang('comment', 'email_allow_comm') . ":\n%s\n", $approvelink); $body .= sprintf("\n" . lang('comment', 'email_delete_comm') . ":\n%s\n", $deletelink); } $body .= sprintf("\n%s:\n%s%s\n", lang('comment', 'email_view_entry'), $Paths['host'], make_filelink("", "", "")); $body .= sprintf("\n%s:\n%s%s\n", lang('comment', 'email_view_comm'), $Paths['host'], make_filelink("", "", $id)); $body .= sprintf("\n%s:\n%s\n", lang('comment', 'email_edit_comm'), $editlink); $body .= sprintf("\n%s:\n%s\n", lang('comment', 'email_block_ip'), $blocklink); if (!$i18n_use) { $body = utf8_encode($body); } $name = $my_comment['name']; if (!$i18n_use) { $name = utf8_encode($name); } $comment_name = '=?UTF-8?B?' . base64_encode($name) . '?='; if (isemail($my_comment['email'])) { $add_header = sprintf("From: \"%s\" <%s>\n", $comment_name, $my_comment['email']); } else { $add_header = sprintf("From: \"'%s'\" <%s>\n", $comment_name, $addr_arr[0]); } $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_comm') . " Re: {$title}"; $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; $addr_arr = array_unique($addr_arr); foreach ($addr_arr as $addr) { $addr = trim($addr); @mail($addr, $subject, $body, $add_header); debug("Send Mail to {$addr} for '" . $my_comment['name'] . "'"); } } // Handle the users that want to be notified via email.. notify_new('comment', array($db->entry, $my_comment, $Cfg['moderate_comments'])); }
/** * Inserts RDF-code on entrypages (in the entrypage template) for trackback * autodiscovery. * * Several blog authoring tools can use the RDF to detect the trackback URL for the entry. */ function snippet_trackautodiscovery() { global $db; $rdf = "<!-- <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\r\nxmlns:dc=\"http://purl.org/dc/elements/1.1/\"\r\nxmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\"><rdf:Description\r\nrdf:about=\"%url%\"\r\ndc:identifier=\"%url%\"\r\ndc:title=\"%title%\"\r\ntrackback:ping=\"%tb-url%\"/></rdf:RDF> -->"; $url = gethost() . make_filelink($db->entry['code'], "", "", ""); $tb_url = snippet_pivot_url() . 'tb.php?tb_id=' . $db->entry['code']; $rdf = str_replace("%url%", $url, $rdf); $rdf = str_replace("%title%", $db->entry['title'], $rdf); $rdf = str_replace("%tb-url%", $tb_url, $rdf); return $rdf; }
/** * 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}'"); } } } }
function send_mail_tb() { global $Cfg, $entry, $PIV_PARA, $my_trackback, $Weblogs, $Current_weblog, $Paths, $Users, $i18n_use; $cat_weblogs = find_weblogs_with_cat($entry['category']); $addr_arr = array(); foreach ($cat_weblogs as $this_weblog) { $Current_weblog = $this_weblog; // Using the same settings as for comments if ($Weblogs[$this_weblog]['comment_sendmail'] == 1) { $addr_arr = array_merge($addr_arr, explode(",", $Weblogs[$this_weblog]['comment_emailto'])); } } // Make the array of user that want to be notified.. $notify_arr = array(); $title = $entry['title']; if (!$i18n_use) { $title = utf8_encode($title); } // maybe send some mail to authors.. if (count($addr_arr) > 0 && !isset($PIV_PARA['f_comm_ip'])) { $adminurl = $Paths['host'] . $Paths['pivot_url'] . "index.php?"; $id = format_date($my_trackback["date"], "%ye%%month%%day%%hour24%%minute%"); $editlink = $adminurl . "menu=entries&func=edittrackbacks&id=" . $entry['code']; $blocklink = $adminurl . "menu=entries&func=edittrackbacks&id=" . $entry['code'] . "&blocksingle=" . $my_trackback['ip']; $body = sprintf(lang('comment', 'email_posted_tb') . ":", unentify($my_trackback['name'])); $body .= sprintf("\n\n-------------\n"); $body .= sprintf(lang('weblog_text', 'title') . ": %s\n", $my_trackback['title']); $body .= sprintf("%s", unentify($my_trackback['excerpt'])); $body .= sprintf("\n-------------\n"); $body .= sprintf(lang('weblog_text', 'ip') . ": %s\n", $my_trackback['ip']); $body .= sprintf(lang('weblog_text', 'date') . ": %s\n", $my_trackback['date']); $body .= sprintf(lang('weblog_text', 'url') . ": %s\n", $my_trackback['url']); $body .= sprintf("\n" . lang('comment', 'email_tb_on') . "\n", $title); if (count($notify_arr) > 0) { $body .= sprintf(lang('comment', 'notifications') . ": %s\n", implode(", ", $notify_arr)); } $body .= sprintf("-------------\n"); $body .= sprintf("%s:\n%s%s\n", lang('comment', 'email_view_entry'), $Paths['host'], make_filelink($PIV_PARA['f_comm_code'], "", $id)); $body .= sprintf("\n%s:\n%s\n", lang('comment', 'email_edit_tb'), $editlink); $body .= sprintf("\n%s:\n%s\n", lang('comment', 'email_block_ip'), $blocklink); if (!$i18n_use) { $body = utf8_encode($body); } $contact_addr = $Users[$entry['user']]['email']; $user = $Users[$entry['user']]['nick']; if (empty($user)) { $user = $entry['user']; } $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('trackback', 'email_subject') . " " . $title; $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; foreach ($addr_arr as $addr) { $addr = trim($addr); @mail($addr, $subject, $body, $add_header); debug("Sent Mail to {$addr} for '" . $my_trackback['name'] . "'"); } } }