Beispiel #1
0
function add_comment_feeditem($item)
{
    global $db, $rss_items, $atom_items, $Cfg, $Weblogs, $Current_weblog, $Allow_RSS, $Paths;
    if (!siteurl_isset()) {
        $weblog = $Paths['host'] . $Paths['pivot_url'];
    } else {
        $weblog = $Weblogs[$Current_weblog]['siteurl'];
    }
    $entry = $db->read_entry($item['code']);
    $link = make_fileurl($item['uid'], "", "");
    $title = $db->entry['title'];
    $date = format_date($item['date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . rss_offset();
    $description = htmlspecialchars(strip_tags($item['comment']));
    $description = str_replace(" ", " ", $description);
    $id = safe_string($item["name"], TRUE) . "-" . format_date($item["date"], "%ye%%month%%day%%hour24%%minute%");
    $tag = str_replace("_", "", strtolower(safe_string($Cfg['sitename'], TRUE))) . "," . date("Y") . ":" . $id;
    // make sure description is not too long..
    if (isset($Weblogs[$Current_weblog]['rss_full']) && $Weblogs[$Current_weblog]['rss_full'] == 0) {
        // don't put anything in the content.
        $content = "";
    } else {
        // put the introduction and body in the content..
        $content = str_replace(" ", " ", $introduction . $body);
    }
    if (isemail($item['email'])) {
        $email = "\n<email>" . $item['email'] . "</email>";
    } else {
        $email = "";
    }
    if (isurl($item['url'])) {
        if (strpos($item["url"], "ttp://") < 1) {
            $item["url"] = "http://" . $item["url"];
        }
        $url = "\n<uri>" . $item['url'] . "</uri>";
    } else {
        $url = "";
    }
    $atom_item = '
	<entry>
	    <title>%author% on %title%</title>
	    <link rel="alternate" type="text/html" href="%link%#%id%"/>
	    <updated>%date%</updated>
	    <published>%date%</published>
	    <id>tag:%tag%</id>
	    <summary type="text">%description%</summary>
	    <content type="html" xml:lang="%lang%" xml:base="%link%">
		<![CDATA[ 
			%content%
		]]>
	    </content>
	    <author>
		<name>%author%</name>%url%%email%
	    </author>
	</entry>
';
    $from = array("%title%", "%link%", "%id%", "%description%", "%content%", "%author%", "%guid%", "%date%", "%tag%", "%lang%", "%url%", "%email%");
    $to = array(htmlspecialchars(strip_tags($entry['title'])), $link, $id, RelativeToAbsoluteURLS($description), trim(comment_format($item['comment'])), htmlspecialchars(unentify($item['name'])), $item['uid'] . "@" . $weblog, $date, $tag, snippet_lang(), $url, $email);
    $atom_item = str_replace($from, $to, $atom_item);
    $atom_items[$date] = $atom_item;
}
/**
 * Adds an item to the XML feeds for the given entry ID.
 *
 * The function uses the global array $items_added to avoid
 * adding the same entry twice.
 *
 * @uses feedtemplate loads the item template for XML feeds.
 *
 * @param int $uid
 * @param string $orgdate
 * @param string $title
 * @param string $introduction
 * @param string $body
 * @param string $user
 * @param string $category
 */
function add_rss($uid, $orgdate, $title, $introduction, $body, $user, $category)
{
    global $db, $rss_items, $atom_items, $items_added, $Cfg, $Weblogs, $Current_weblog, $Allow_RSS, $Paths, $Users;
    if (!$Allow_RSS) {
        return;
    }
    // Checking if the item is already added to avoid duplication
    if (in_array($uid, $items_added)) {
        return;
    } else {
        $items_added[] = $uid;
    }
    $link = make_fileurl($uid, "", "");
    if (!siteurl_isset()) {
        $weblog = gethost() . $Paths['pivot_url'];
        // we strip off the 'www.' part. It may not always result in a valid URL, but the
        // guid isn't supposed to be one anyhow. This prevents problems in readers, when
        // the feed is sometimes generated from www.example.org, and sometimes from example.org.
        $weblog = str_replace("www.", "", $weblog);
    } else {
        $weblog = $Weblogs[$Current_weblog]['siteurl'];
    }
    $title = trim(unentify($db->entry['title']));
    $subtitle = trim(unentify($db->entry['subtitle']));
    // parse fields and remove scripting from the feed. Script in feed is bad..
    $introduction = parse_intro_or_body($db->entry['introduction']);
    $introduction = clean_rss_text($introduction);
    $body = parse_intro_or_body($db->entry['body']);
    $body = clean_rss_text($body);
    $tag = str_replace("_", "", strtolower(safe_string($Cfg['sitename'], TRUE))) . "," . date("Y") . ":" . str_replace("_", "", safe_string($Weblogs[$Current_weblog]['name'], TRUE)) . "." . $uid;
    $lang = str_replace("_utf8", "", snippet_lang());
    $date = format_date($orgdate, "%year%-%month%-%day%T%hour24%:%minute%:00") . rss_offset();
    $date_rfc = format_date($orgdate, "%english_dname%, %day% %english_monname% %year% %hour24%:%minute%:00 ") . rss_offset("rfc822");
    if ($db->entry['edit_date'] != "") {
        $edit_date = format_date($db->entry['edit_date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . rss_offset();
    } else {
        // if the entry was never edited, use the entrydate
        $edit_date = $date;
    }
    $summary = unentify(strip_tags($introduction));
    $summary = trim(str_replace("&", "&amp;", str_replace("&nbsp;", " ", $summary)));
    // Set content (Atom 1.0) and description (RSS 2.0) according to completeness settings
    if (isset($Weblogs[$Current_weblog]['rss_full']) && $Weblogs[$Current_weblog]['rss_full'] == 0) {
        // don't put anything in the content.
        $content = "";
        $description = trim($introduction);
        if (strlen($body) > 5) {
            $description .= snippet_more();
            $summary .= ' ...';
        }
    } else {
        // put the introduction and body in the content..
        $content = trim(str_replace("&nbsp;", " ", $introduction . $body));
        $description = trim($introduction . $body);
    }
    $rss_item = feedtemplate('feed_rss_template.xml', 'item');
    $atom_item = feedtemplate('feed_atom_template.xml', 'item');
    // Handling viatitle special to avoid validation errors
    if (!empty($db->entry['viatitle'])) {
        $viatitle = 'title="' . $db->entry['viatitle'] . '"';
    } else {
        $viatitle = "";
    }
    $from = array("%title%", "%subtitle%", "%link%", "%description%", "%summary%", "%author%", "%author-email%", "%author-nick%", "%guid%", "%date%", "%edit_date%", "%date_rfc%", "%category%", "%content%", "%tag%", "%lang%", "%vialink%", "%viatitle%");
    $to = array(htmlspecialchars(strip_tags($title)), htmlspecialchars(strip_tags($subtitle)), $link, RelativeToAbsoluteURLS($description), RelativeToAbsoluteURLS($summary), $user, $Users[$user]['email'], $Users[$user]['nick'], $uid . "@" . $weblog, $date, $edit_date, $date_rfc, htmlspecialchars(implode(", ", $category)), RelativeToAbsoluteURLS($content), $tag, $lang, $db->entry['vialink'], $viatitle);
    $rss_item = str_replace($from, $to, $rss_item);
    $atom_item = str_replace($from, $to, $atom_item);
    // We add the count($rss_items), because otherwise we can't have two items
    // that are posted at the same minute.
    $rss_items[$orgdate . "." . count($rss_items)] = $rss_item;
    $atom_items[$orgdate . "." . count($rss_items)] = $atom_item;
}
Beispiel #3
0
/**
 * Returns the value as a string
 * @param mixed $val
 * @return string
 * @throws CastException if the value cannot be safely cast to a string
 */
function to_string($val)
{
    if (!safe_string($val)) {
        throw new CastException("Value could not be converted to string");
    } else {
        return (string) $val;
    }
}
Beispiel #4
0
        //@$thumb->save($filename_with_dir, 'jpg');
        //cropImage(887, 174, $dir.$filename, 'png', $dir.$filename);
        cropImage(340, 250, $dir . $filename, 'jpg', $dir . $filename_small);
        $sql = "INSERT INTO " . $tblprefix . "albums SET title = '" . $title . "',image='" . $filename . "'";
        $res = $db->Execute($sql);
        if ($res) {
            //updatesliderXML();
            $okmsg = base64_encode("Album Information Added successfully. !");
            @header("Location: admin.php?okmsg={$okmsg}&act=managealbums");
            exit;
        }
    }
}
//-------------Update Album Image ----------
if ($_POST['mode'] == 'send' && $_POST['act'] == 'managealbums' && isset($_POST['UpdateAlbumSbt'])) {
    $title = safe_string($_POST['title']);
    $aid = $_POST['aid'];
    if ($_FILES['album_image']['name'] != '') {
        $upd_qry = "SELECT * FROM " . $tblprefix . "albums WHERE id = '" . $aid . "'";
        $rs_upd = $db->Execute($upd_qry);
        if ($rs_upd->fields['image'] != "") {
            $a_img_del = ROOT . ALBUM_FOLDER . $rs_upd->fields['image'];
            @unlink($a_img_del);
            @unlink(ROOT . ALBUM_FOLDER . 'tmb-' . $rs_upd->fields['image']);
        }
        $file_temp = $_FILES['album_image']['tmp_name'];
        $filename = date('ymdghs') . $_FILES['album_image']['name'];
        $filename_small = 'tmb-' . $filename;
        $dir = ROOT . ALBUM_FOLDER;
        $filename_with_dir = $dir . $filename;
        @copy($file_temp, $filename_with_dir);
Beispiel #5
0
$content->setVariable("VALUE_WANTS", safe_string($user_profile["USER_PROFILE_WANTS"]));
$content->setVariable("VALUE_HAVES", safe_string($user_profile["USER_PROFILE_HAVES"]));
$content->setVariable("VALUE_OTHER_INTERESTS", safe_string($user_profile["USER_PROFILE_OTHER_INTERESTS"]));
$content->setVariable("VALUE_ORGANIZATIONS", safe_string($user_profile["USER_PROFILE_ORGANIZATIONS"]));
$content->setVariable("VALUE_USER_PROFILE_DSC", safe_string($user_profile["USER_PROFILE_DSC"]));
$content->setVariable("VALUE_EMAIL", safe_string($user_profile["USER_EMAIL"]));
$content->setVariable("VALUE_ADDRESS", safe_string($user_profile["USER_PROFILE_ADDRESS"]));
$content->setVariable("VALUE_TELEPHONE", safe_string($user_profile["USER_PROFILE_TELEPHONE"]));
$content->setVariable("VALUE_PHONE_MOBILE", safe_string($user_profile["USER_PROFILE_PHONE_MOBILE"]));
$content->setVariable("VALUE_WEBSITE", safe_string($user_profile["USER_PROFILE_WEBSITE_URI"]));
$content->setVariable("VALUE_WEBSITE_NAME", safe_string($user_profile["USER_PROFILE_WEBSITE_NAME"]));
$content->setVariable("VALUE_IM_ICQ", safe_string($user_profile["USER_PROFILE_IM_ICQ"]));
$content->setVariable("VALUE_IM_SKYPE", safe_string($user_profile["USER_PROFILE_IM_SKYPE"]));
$content->setVariable("VALUE_IM_AIM", safe_string($user_profile["USER_PROFILE_IM_AIM"]));
$content->setVariable("VALUE_IM_MSN", safe_string($user_profile["USER_PROFILE_IM_MSN"]));
$content->setVariable("VALUE_IM_YAHOO", safe_string($user_profile["USER_PROFILE_IM_YAHOO"]));
// LANGUAGE
if (TRUE) {
    // && !empty($user_profile["USER_LANGUAGE"]) ) {
    $ulang = $user_profile["USER_LANGUAGE"];
    if (!is_string($ulang) || $ulang === "0") {
        $ulang = LANGUAGE_DEFAULT_STEAM;
    }
    $languages = array("english" => array("name" => gettext("English"), "icon" => "flag_gb.gif", "lang_key" => "en_US"), "german" => array("name" => gettext("German"), "icon" => "flag_de.gif", "lang_key" => "de_DE"));
    if (!array_key_exists($ulang, $languages)) {
        $ulang = LANGUAGE_DEFAULT_STEAM;
    }
    $content->setCurrentBlock("USER_LANGUAGE");
    $content->setVariable("LABEL_LANGUAGES", gettext("Language"));
    foreach ($languages as $key => $language) {
        $content->setCurrentBlock("LANGUAGE");
Beispiel #6
0
/**
 * Override or insert variables into page templates.
 *
 * @param $vars
 *   A sequential array of variables to pass to the theme template.
 * @param $hook
 *   The name of the theme function being called.
 */
function genesis_preprocess_page(&$vars, $hook)
{
    global $theme;
    // Don't display empty help from node_help().
    if ($vars['help'] == "<div class=\"help\"> \n</div>") {
        $vars['help'] = '';
    }
    // Add conditional stylesheets.
    if (!module_exists('conditional_styles')) {
        $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], '');
    }
    // Set variables for the logo and site_name.
    if (!empty($vars['logo'])) {
        // Return the site_name even when site_name is disabled in theme settings.
        $vars['logo_alt_text'] = variable_get('site_name', '');
        $vars['site_logo'] = '<a href="' . $vars['front_page'] . '" title="' . t('Home page') . '" rel="home"><img src="' . $vars['logo'] . '" alt="' . $vars['logo_alt_text'] . ' ' . t('logo') . '" /></a>';
    }
    if (!empty($vars['site_name'])) {
        $vars['site_name'] = '<a href="' . $vars['front_page'] . '" title="' . t('Home page') . '" rel="home">' . $vars['site_name'] . '</a>';
    }
    // Set variables for the primary and secondary links.
    if (!empty($vars['primary_links'])) {
        $vars['primary_menu'] = theme('links', $vars['primary_links'], array('class' => 'primary-links clear-block'));
    }
    if (!empty($vars['secondary_links'])) {
        $vars['secondary_menu'] = theme('links', $vars['secondary_links'], array('class' => 'secondary-links clear-block'));
    }
    // Section class. The section class is printed on the body element and allows you to theme site sections.
    // We use the path alias otherwise all nodes will be in "section-node".
    $path_alias = drupal_get_path_alias($_GET['q']);
    if (!$vars['is_front']) {
        list($section, ) = explode('/', $path_alias, 2);
        $vars['section_class'] = 'class="' . safe_string('section-' . $section) . '"';
    }
    // Body Classes. In Genesis these are printed on the #container wrapper div, not on the body.
    $classes = explode(' ', $vars['body_classes']);
    // Remove the useless page-arg(0) class.
    if ($class = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) {
        unset($classes[$class]);
    }
    /** 
     * Optional Region body classes
     * Uncomment the following if you need to set
     * a body class for each active region.
     */
    /*		
    if (!empty($vars['leaderboard'])) {
      $classes[] = 'leaderboard';
    }
    if (!empty($vars['header'])) {
      $classes[] = 'header-blocks';
    }
    if (!empty($vars['secondary_content'])) {
      $classes[] = 'secondary-content';
    }
    if (!empty($vars['tertiary_content'])) {
      $classes[] = 'tertiary-content';
    }
    if (!empty($vars['footer'])) {
      $classes[] = 'footer';
    }
    */
    /**
     * Additional body classes to help out themers.
     */
    if (!$vars['is_front']) {
        $normal_path = drupal_get_normal_path($_GET['q']);
        // Set a class based on Drupals internal path, e.g. page-node-1.
        // Using the alias is fragile because path alias's can change, $normal_path is more reliable.
        $classes[] = safe_string('page-' . $normal_path);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                $classes[] = 'page-node-add';
                // Add .node-add class.
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                $classes[] = 'page-node-' . arg(2);
                // Add .node-edit or .node-delete classes.
            }
        }
    }
    $vars['classes'] = implode(' ', $classes);
    // Concatenate with spaces.
}
function make_archive_list($ye, $mo, $da, $title)
{
    global $Weblogs, $Current_weblog, $db, $entry, $maxlength, $filtercat;
    $db = new db();
    $current_cats = find_cats_in_weblog($Current_weblog);
    if ($da > 0 && $da < 32 && $mo > 0 && $mo < 13) {
        // get a list of the entries for the current day
        list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-%02d-00-00", $ye, $mo, $da), 'day');
    } else {
        if ($mo > 0 && $mo < 13) {
            // get a list of the entries for the current month
            list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-01-00-00", $ye, $mo), 'month');
        } else {
            // get a list of the entries for the current year
            list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-01-00-00", $ye, $mo), 'year');
        }
    }
    $list_entries = $db->getlist_range($start_date, $stop_date, "", "", FALSE);
    if ($title != "") {
        // Normalizing requested title and title of possible entries (once).
        $title = str_replace("http://", "", $title);
        $title = str_replace("http", "", $title);
        $title = safe_string(strtolower($title), TRUE);
        foreach ($list_entries as $key => $value) {
            $entrytitle = $list_entries[$key]['title'];
            $entrytitle = str_replace("http://", "", $entrytitle);
            $entrytitle = str_replace("http", "", $entrytitle);
            $entrytitle = safe_string(strtolower($entrytitle), TRUE);
            $list_entries[$key]['title'] = $entrytitle;
        }
        // we try to see if we can match a given name to a title..
        foreach ($list_entries as $entry) {
            if ($title == $entry['title']) {
                $_POST['id'] = $entry['code'];
                include 'entry.php';
                die;
            }
        }
        // next, we see if the start is the same..
        foreach ($list_entries as $entry) {
            if (substr($title, 0, 19) == substr($entry['title'], 0, 19)) {
                $_POST['id'] = $entry['code'];
                include 'entry.php';
                die;
            }
        }
        // next, we see if the start is the same..
        foreach ($list_entries as $entry) {
            if (substr($title, 0, 7) == substr($entry['title'], 0, 7)) {
                $_POST['id'] = $entry['code'];
                include 'entry.php';
                die;
            }
        }
    }
    // We continue with the selected entries, and display the bunch
    $arc_list = "";
    foreach ($list_entries as $list_entry) {
        // added by sam
        $valid_entry_cats = array_intersect($list_entry['category'], $current_cats);
        if ($valid_entry_cats && (!isset($filtercat) || @in_array($filtercat, $list_entry['category']))) {
            // if we don't filter, or we filter on the entry's category..
            if ($list_entry['status'] == 'publish') {
                //if the entry is published
                $diffdate = format_date($list_entry['date'], $Weblogs[$Current_weblog]['diffdate_format']);
                $date = format_date($list_entry['date'], $Weblogs[$Current_weblog]['entrydate_format']);
                $link = make_filelink($list_entry['code'], "", "");
                if ($diffdate != $lastdiffdate) {
                    $arc_list .= "<br />" . $diffdate . "<br />\n";
                    $lastdiffdate = $diffdate;
                }
                $arc_list .= sprintf("%s <a href='%s' title=\"(%s, %s comments)\">%s</a><br />\n", $date, $link, implode(", ", $valid_entry_cats), $list_entry['commcount'], trimtext($list_entry['title'], $maxlength));
            }
        }
    }
    // 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();
}
Beispiel #8
0
/**
 * Display the screen to moderate and delete comments.
 *
 * @param string $msg
 */
function moderate_comments($msg = "")
{
    global $Cfg, $Pivot_Vars, $Users;
    PageHeader(lang('userbar', 'moderate_comments'), 1);
    PageAnkeiler(lang('userbar', 'comments') . ' &raquo; ' . lang('userbar', 'moderate_comments'));
    // First check if there are any comments waiting to be moderated..
    if (file_exists("db/ser_modqueue.php")) {
        $modqueue = array_reverse(load_serialize("db/ser_modqueue.php", true, true));
    } else {
        $modqueue = array();
    }
    // If we have $_POST or $_GET, we might have to allow or delete some comments.
    // Loop through the moderation queue
    foreach ($modqueue as $key => $comm) {
        $commentkey = urlencode(safe_string($comm['name'], TRUE) . "-" . format_date($comm['date'], "%ye%%month%%day%%hour24%%minute%"));
        if (isset($Pivot_Vars[$commentkey])) {
            moderate_process($comm, $Pivot_Vars[$commentkey]);
            unset($modqueue[$key]);
            $queue_changed = true;
        }
    }
    if ($queue_changed) {
        save_serialize("db/ser_modqueue.php", $modqueue);
        buildfrontpage_function();
    }
    if (count($modqueue) > 0) {
        printf("<form id='modqueue' method='post' name='modqueue' action='index.php?menu=moderate_comments&amp;session=%s'>\n", $Pivot_Vars['session']);
        printf("<table cellspacing='0' class='tabular_border' border='0' width='800'>\n");
        printf("<tr class='tabular_header'><th>%s</th><th>%s</th><th>%s</th><th>%s/%s</th><th>%s</th><th>%s</th>\n", lang('general', 'approve'), lang('general', 'delete'), lang('entries', 'title'), lang('weblog_text', 'name'), lang('weblog_text', 'ip'), lang('entries', 'date'), lang('weblog_text', 'comment'));
        $linecount = 1;
        foreach ($modqueue as $comm) {
            if ($linecount % 2 == 0) {
                $bg_color = "tabular_line_even";
            } else {
                $bg_color = "tabular_line_odd";
            }
            $commentkey = urlencode(safe_string($comm['name'], TRUE) . "-" . format_date($comm['date'], "%ye%%month%%day%%hour24%%minute%"));
            printf("<tr class='%s'><td valign='top' width='1'><input type='radio' name='%s' value='1' /></td>", $bg_color, $commentkey);
            printf("<td valign='top' width='1'><input type='radio' name='%s' value='2' /></td>", $commentkey);
            printf("<td valign='top'>%s", trimtext($comm['title'], 30, TRUE));
            printf("<td valign='top'>%s", $comm['name']);
            if ($comm['email'] != "") {
                printf("/ %s", $comm['email']);
            }
            printf("<br />%s", $comm['ip']);
            if ($comm['link'] != "") {
                printf("/ %s", $comm['link']);
            }
            printf("<td valign='top'>%s", format_date($comm['date'], "%day%-%monname%-%ye% %hour24%:%minute%"));
            printf("</td><td valign='top' style='white-space: normal;'><small>%s</small></td></tr>", $comm['comment']);
            $linecount++;
        }
        printf("<tr class='tabular_header'>");
        printf('<th><a href="#" onclick=\'javascript:setRadiobuttons("modqueue", 1); return false;\'>' . lang('forms', 'c_all') . '</a></th>');
        printf('<th><a href="#" onclick=\'javascript:setRadiobuttons("modqueue", 2); return false;\'>' . lang('forms', 'c_all') . '</a></th>');
        printf('<th colspan="4">&nbsp;</th>');
        printf('</table>');
        printf("<br /><input type='submit' value='%s' />", lang('userbar', 'moderate_comments'));
        printf('<form>');
    } else {
        printf("<p>%s</p>", lang("userbar", "moderate_nocomments_desc"));
    }
    PageFooter();
}
Beispiel #9
0
    $s = ereg_replace(">", "&gt;", $s);
    $s = ereg_replace("\\\\'", "'", $s);
    $s = ereg_replace("\\\\\"", "\"", $s);
    $s = ereg_replace("'", "&#39;", $s);
    $s = ereg_replace("\"", "&quot;", $s);
    //echo $s;
    return $s;
}
$query = "CREATE TABLE IF NOT EXISTS " . $module_name . "_url (url text DEFAULT '')";
$success = $Q->query($DB, $query);
$url_from = ereg_replace("http://", "", $_SERVER['HTTP_REFERER']);
$url_from = ereg_replace("/.*", "", $url_from);
//echo $url_from;
//exit;
foreach ($_POST as $var => $value) {
    ${$var} = safe_string($value);
}
$current_url = $HTTP_HOST . $REQUEST_URI;
$query = "select * from " . $module_name . "_url  where url='" . $current_url . "'";
$success = $Q->query($DB, $query);
$count = $Q->numrows();
if (!$count) {
    // OK
    if ($url_from == $HTTP_HOST || $REQUEST_URI == "/") {
        $query = "insert into " . $module_name . "_url  values('" . $current_url . "')";
        $success = $Q->query($DB, $query);
    } else {
        // access is not allowed
        header("Location: /error.php");
    }
}
function snippet_search($nobutton = '', $button_name = '', $placeholder = "", $fieldname = "", $weblog = "", $template = "")
{
    global $Cfg, $Paths, $Current_weblog;
    $search_formname = lang('accessibility', 'search_formname');
    $search_idname = lang('accessibility', 'search_idname');
    if ($fieldname != "") {
        $search_fldname = $fieldname;
    } else {
        $search_fldname = lang('accessibility', 'search_fldname');
    }
    if ($placeholder != "") {
        $search_placeholder = $placeholder;
    } else {
        $search_placeholder = lang('accessibility', 'search_placeholder');
    }
    $search_url = $Paths['pivot_url'] . "search.php";
    if ($template != "") {
        $search_url .= "?t=" . $template;
    }
    $output = '<form method="post" action="' . $search_url . '"  class="pivot-search">' . "\n";
    $output .= '<fieldset><legend>' . $search_formname . '</legend>' . "\n";
    $output .= '<label for="' . $search_idname . '">' . $search_fldname . '</label>' . "\n";
    $output .= '<input id="' . $search_idname . '" type="text" name="search" class="searchbox" value="';
    $output .= $search_placeholder . '" onblur="if(this.value==\'\') this.value=\'';
    $output .= $search_placeholder . '\';" onfocus="if(this.value==\'' . $search_placeholder;
    $output .= '\') this.value=\'\'; this.select();return true;" />' . "\n";
    if ('nobutton' != $nobutton) {
        if ('' == $button_name) {
            $button_name = lang('weblog_text', 'search');
        }
        $output .= '<input type="submit" class="searchbutton" value="' . $button_name . '" />';
    }
    if ($Cfg['weblog_count'] > 1) {
        $weblog = trim($weblog);
        if ($weblog != "") {
            $output .= '<input type="hidden" name="w" value="' . strtolower(safe_string($weblog, true)) . '" />' . "\n";
        } else {
            $output .= '<input type="hidden" name="w" value="' . $Current_weblog . '" />' . "\n";
        }
    }
    $output .= '</fieldset></form>' . "\n";
    return $output;
}
Beispiel #11
0
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']));
}
Beispiel #12
0
/**
 * Save an edited weblog, then show the weblogs overview screen
 */
function main_blog_save()
{
    global $Pivot_Vars, $blog_settings, $Weblogs;
    // check against unauthorised direct access.
    check_csrf();
    // unserialize the parsed temp_weblog..
    $temp_weblog = unserialize(urldecode($Pivot_Vars['temp_weblog']));
    // urldecode category names and create a list of all categories
    // in the weblog, not only per subweblog.
    $categories = array();
    foreach ($temp_weblog['sub_weblog'] as $sub_weblog_key => $sub_weblog_value) {
        foreach ($sub_weblog_value['categories'] as $category_key => $category_name) {
            $temp_weblog['sub_weblog'][$sub_weblog_key]['categories'][$category_key] = urldecode($category_name);
            $categories[] = urldecode($category_name);
        }
    }
    $temp_weblog['categories'] = array_unique($categories);
    // Here we determine if we save an edited or a new weblog..
    if (isset($Pivot_Vars['orig_name']) && strlen($Pivot_Vars['orig_name']) > 1) {
        $orig_name = $Pivot_Vars['orig_name'];
        $msg = lang('weblog_config', 'saved_update');
    } else {
        // Urlencode the key/internal name for the weblog, to allow
        // weblogs with non US-ascii characters.
        $orig_name = urlencode(strtolower(safe_string($temp_weblog['name'], TRUE)));
        $msg = lang('weblog_config', 'saved_create');
        // We make sure the new weblog does not overwrite a previous one.
        if (isset($Weblogs[$orig_name])) {
            // It already exists, so we look for the first incremental name that's not yet taken..
            $i = 0;
            do {
                $i++;
                $incr_name = $orig_name . "_" . $i;
            } while (isset($Weblogs[$incr_name]));
            $orig_name = $incr_name;
        }
    }
    // add the new stuff
    $temp_weblog['rss'] = $Pivot_Vars['rss'];
    $temp_weblog['rss_filename'] = $Pivot_Vars['rss_filename'];
    $temp_weblog['atom_filename'] = $Pivot_Vars['atom_filename'];
    $temp_weblog['rss_path'] = fixPathSlash($Pivot_Vars['rss_path']);
    $temp_weblog['rss_full'] = $Pivot_Vars['rss_full'];
    $temp_weblog['rss_link'] = $Pivot_Vars['rss_link'];
    $temp_weblog['rss_img'] = $Pivot_Vars['rss_img'];
    $temp_weblog['lastcomm_amount'] = $Pivot_Vars['lastcomm_amount'];
    $temp_weblog['lastcomm_length'] = $Pivot_Vars['lastcomm_length'];
    $temp_weblog['lastcomm_format'] = stripslashes($Pivot_Vars['lastcomm_format']);
    $temp_weblog['lastcomm_redirect'] = stripslashes($Pivot_Vars['lastcomm_redirect']);
    $temp_weblog['lastref_amount'] = $Pivot_Vars['lastref_amount'];
    $temp_weblog['lastref_length'] = $Pivot_Vars['lastref_length'];
    $temp_weblog['lastref_format'] = stripslashes($Pivot_Vars['lastref_format']);
    $temp_weblog['lastref_graphic'] = stripslashes($Pivot_Vars['lastref_graphic']);
    $temp_weblog['emoticons'] = $Pivot_Vars['emoticons'];
    $temp_weblog['encode_email_addresses'] = $Pivot_Vars['encode_email_addresses'];
    $temp_weblog['target_blank'] = $Pivot_Vars['target_blank'];
    $temp_weblog['search_format'] = stripslashes($Pivot_Vars['search_format']);
    $temp_weblog['fulldate_format'] = stripslashes($Pivot_Vars['fulldate_format']);
    $temp_weblog['entrydate_format'] = stripslashes($Pivot_Vars['entrydate_format']);
    $temp_weblog['diffdate_format'] = stripslashes($Pivot_Vars['diffdate_format']);
    $temp_weblog['comment_sendmail'] = $Pivot_Vars['comment_sendmail'];
    $temp_weblog['comment_emailto'] = $Pivot_Vars['comment_emailto'];
    $temp_weblog['comment_texttolinks'] = $Pivot_Vars['comment_texttolinks'];
    $temp_weblog['comment_wrap'] = $Pivot_Vars['comment_wrap'];
    $temp_weblog['comments_text_0'] = stripslashes($Pivot_Vars['comments_text_0']);
    $temp_weblog['comments_text_1'] = stripslashes($Pivot_Vars['comments_text_1']);
    $temp_weblog['comments_text_2'] = stripslashes($Pivot_Vars['comments_text_2']);
    $temp_weblog['comment_pop'] = $Pivot_Vars['comment_pop'];
    $temp_weblog['comment_width'] = $Pivot_Vars['comment_width'];
    $temp_weblog['comment_height'] = $Pivot_Vars['comment_height'];
    $temp_weblog['comment_format'] = stripslashes($Pivot_Vars['comment_format']);
    $temp_weblog['comment_reply'] = stripslashes($Pivot_Vars['comment_reply']);
    $temp_weblog['comment_forward'] = stripslashes($Pivot_Vars['comment_forward']);
    $temp_weblog['comment_backward'] = stripslashes($Pivot_Vars['comment_backward']);
    $temp_weblog['comment_textile'] = $Pivot_Vars['comment_textile'];
    $temp_weblog['comment_gravatardefault'] = $Pivot_Vars['comment_gravatardefault'];
    $temp_weblog['comment_gravatarhtml'] = $Pivot_Vars['comment_gravatarhtml'];
    $temp_weblog['comment_gravatarsize'] = $Pivot_Vars['comment_gravatarsize'];
    $temp_weblog['trackbacks_text_0'] = stripslashes($Pivot_Vars['trackbacks_text_0']);
    $temp_weblog['trackbacks_text_1'] = stripslashes($Pivot_Vars['trackbacks_text_1']);
    $temp_weblog['trackbacks_text_2'] = stripslashes($Pivot_Vars['trackbacks_text_2']);
    $temp_weblog['trackback_format'] = stripslashes($Pivot_Vars['trackback_format']);
    $temp_weblog['trackback_link_format'] = stripslashes($Pivot_Vars['trackback_link_format']);
    $temp_weblog['blogroll_id'] = $Pivot_Vars['blogroll_id'];
    $temp_weblog['blogroll_fg'] = $Pivot_Vars['blogroll_fg'];
    $temp_weblog['blogroll_bg'] = $Pivot_Vars['blogroll_bg'];
    $temp_weblog['blogroll_line1'] = $Pivot_Vars['blogroll_line1'];
    $temp_weblog['blogroll_line2'] = $Pivot_Vars['blogroll_line2'];
    $temp_weblog['blogroll_c1'] = $Pivot_Vars['blogroll_c1'];
    $temp_weblog['blogroll_c2'] = $Pivot_Vars['blogroll_c2'];
    $temp_weblog['blogroll_c3'] = $Pivot_Vars['blogroll_c3'];
    $temp_weblog['blogroll_c4'] = $Pivot_Vars['blogroll_c4'];
    $Weblogs[$orig_name] = $temp_weblog;
    save_serialize('pv_cfg_weblogs.php', $Weblogs);
    main_blogs($msg);
}
Beispiel #13
0
/**
 * Override or insert variables into all templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered.
 */
function LCNG_preprocess_page(&$vars)
{
    $vars['tabs'] = menu_primary_local_tasks();
    $vars['tabs2'] = menu_secondary_local_tasks();
    if (arg(0) == 'user') {
        $vars['tabs'] = "";
    }
    if (arg(0) == "user" && !is_numeric(arg(1))) {
        $vars['template_file'] = 'page-userauth';
    }
    if (drupal_is_front_page() && !user_is_logged_in()) {
        $vars['template_file'] = 'page-front-anonymous';
    }
    if (drupal_is_front_page() && user_is_logged_in()) {
        $vars['template_file'] = 'page-h2panel';
    }
    if (arg(0) == "user" && is_numeric(arg(1)) || arg(0) == "start") {
        $vars['template_file'] = 'page-h2panel';
    }
    // Set variables for the logo and site_name.
    if (!empty($vars['logo'])) {
        // Return the site_name even when site_name is disabled in theme settings.
        $vars['logo_alt_text'] = variable_get('site_name', '');
        $vars['site_logo'] = '<a href="' . $vars['front_page'] . '" title="' . t('Home page') . '" rel="home"><img src="' . $vars['logo'] . '" alt="' . $vars['logo_alt_text'] . ' ' . t('logo') . '" /></a>';
    }
    if (!empty($vars['site_name'])) {
        $vars['site_name'] = '<a href="' . $vars['front_page'] . '" title="' . t('Home page') . '" rel="home">' . $vars['site_name'] . '</a>';
    }
    // Set variables for the primary and secondary links.
    if (!empty($vars['primary_links'])) {
        $vars['primary_menu'] = theme('links', $vars['primary_links'], array('class' => 'primary-links clear-block'));
    }
    if (!empty($vars['secondary_links'])) {
        $vars['secondary_menu'] = theme('links', $vars['secondary_links'], array('class' => 'secondary-links clear-block'));
    }
    // Section class. The section class is printed on the body element and allows you to theme site sections.
    // We use the path alias otherwise all nodes will be in "section-node".
    $path_alias = drupal_get_path_alias($_GET['q']);
    if (!$vars['is_front']) {
        list($section, ) = explode('/', $path_alias, 2);
        $vars['section_class'] = 'class="' . safe_string('section-' . $section) . '"';
    }
    // Body Classes. In Genesis these are printed on the #container wrapper div, not on the body.
    $classes = explode(' ', $vars['body_classes']);
    // Remove the useless page-arg(0) class.
    if ($class = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) {
        unset($classes[$class]);
    }
    /**
     * Additional body classes to help out themers.
     */
    if (!$vars['is_front']) {
        $normal_path = drupal_get_normal_path($_GET['q']);
        // Set a class based on Drupals internal path, e.g. page-node-1.
        // Using the alias is fragile because path alias's can change, $normal_path is more reliable.
        $classes[] = safe_string('page-' . $normal_path);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                $classes[] = 'page-node-add';
                // Add .node-add class.
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                $classes[] = 'page-node-' . arg(2);
                // Add .node-edit or .node-delete classes.
            }
        }
    }
    $status = $vars['title'];
    switch ($status) {
        case "Access denied":
        case "Page not found":
            $classes[] = 'page-error';
            // Add error page class.
            break;
    }
    $vars['classes'] = implode(' ', $classes);
    // Concatenate with spaces.
}
Beispiel #14
0
function make_tag($tags)
{
    if (isset($tags)) {
        $tags = explode(" ", $tags);
        for ($count = 0; $count < count($tags); $count++) {
            $current = $tags[$count];
            if ($current != "") {
                $current = safe_string($current);
                if (isset($all_tag)) {
                } else {
                    $all_tag = NULL;
                }
                $all_tag .= $current . " ";
            }
        }
        return rtrim($all_tag);
    }
}
Beispiel #15
0
/**
 * 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}'");
            }
        }
    }
}
Beispiel #16
0
function pingWeblogs($name, $url, $server)
{
    global $Paths, $Cfg, $Pivot_Vars;
    if (!isset($Cfg['spampingurl'])) {
        $server = parse_url("http://www.pivotlog.net/global_phrases/ping.php");
    } else {
        $server = parse_url($Cfg['spampingurl'] . "ping.php");
    }
    if ($server['path'] == "") {
        $server['path'] = "/";
    }
    if ($server['port'] == "") {
        $server['port'] = "80";
    }
    //printf("<p><b>%s:%s%s</b>:<br />", $server['host'], $server['port'], $server['path']);
    flush();
    // Get the entry
    $db = new db();
    $db->read_entry(intval($_GET['entry']));
    // Initialize the XMLRPC client.
    $client = new xmlrpc_client($server['path'], $server['host'], $server['port']);
    //$client->setDebug(2);
    $type = safe_string($_GET['type'], true);
    // Compose the xmlrpc message, depending on the type
    if ($type == "comment") {
        // Check if it's a link in the form of name@date..
        // If so, we'll have to walk the comments, selecting the correct one.
        if (strpos($_GET['n'], "@") > 0) {
            list($delname, $deldate) = explode("@", $_GET['n']);
            $_GET['n'] = -1;
            foreach ($db->entry['comments'] as $key => $value) {
                if ($value['name'] == $delname && $value['date'] == $deldate) {
                    $_GET['n'] = $key;
                }
            }
        }
        $comment = $db->entry['comments'][intval($_GET['n'])];
        if ($comment['name'] != "") {
            $ok = true;
            $message = new xmlrpcmsg("spamReport.commentping", array(new xmlrpcval($type), new xmlrpcval($comment['name']), new xmlrpcval($comment['url']), new xmlrpcval($comment['comment']), new xmlrpcval($comment['ip']), new xmlrpcval($Pivot_Vars['user']), new xmlrpcval($Cfg['sitename']), new xmlrpcval($Cfg['server_spam_key'])));
        } else {
            $ok = false;
        }
    } else {
        $track = $db->entry['trackbacks'][intval($_GET['n'])];
        if ($comment['name'] != "") {
            $ok = true;
            $message = new xmlrpcmsg("spamReport.commentping", array(new xmlrpcval($type), new xmlrpcval($track['title']), new xmlrpcval($track['url']), new xmlrpcval($track['excerpt']), new xmlrpcval($track['ip']), new xmlrpcval($Pivot_Vars['user']), new xmlrpcval($Cfg['sitename']), new xmlrpcval($Cfg['server_spam_key'])));
        } else {
            $ok = false;
        }
    }
    if ($ok) {
        $result = $client->send($message);
        if (!$result || $result->faultCode()) {
            echo "<br />Pivot says: could not send ping. Check if you set the server address correctly, or else the server may be temporarily down. This happens sometimes, and if this error occurs out of the blue, it's likely that it will go away in a few hours or days. <br /></p>";
            echo "<!-- \n";
            print_r($result);
            echo "\n -->\n\n\n";
            return false;
        }
        $msg = $result->serialize();
        $msg = preg_replace("/.*<\\/boolean>/si", "", $msg);
        $msg = preg_replace("/.*<value>/si", "", $msg);
        $msg = preg_replace("/<\\/value>.* /si", "", $msg);
        $msg = escape($msg);
        echo $msg;
        return true;
    } else {
        echo "Could not ping: Comment or trackback could not be found";
    }
}