Esempio n. 1
0
function generate_last_trackbacks($temptrack)
{
    global $entry, $Cfg;
    // if it exists, load it
    $lasttrack = load_serialize("db/ser_lasttrack.php", true, true);
    $lasttrack[] = array('title' => $temptrack['title'], 'excerpt' => trimtext($temptrack['excerpt'], 250), 'name' => $temptrack['name'], 'url' => $temptrack['url'], 'date' => $temptrack['date'], 'code' => $entry['code'], 'category' => $entry['category'], 'ip' => $temptrack['ip']);
    if (count($lasttrack) > $Cfg['lastcomm_amount_max']) {
        array_shift($lasttrack);
    }
    save_serialize("db/ser_lasttrack.php", $lasttrack);
}
Esempio n. 2
0
/**
 * Creates the file that holds the queue for comment moderation.
 *
 * @param array $tempcomm
 */
function generate_moderation_queue($tempcomm)
{
    global $my_weblog, $db;
    // if it exists, load it
    if (file_exists("db/ser_modqueue.php")) {
        $lastcomm = load_serialize("db/ser_modqueue.php", true, true);
    } else {
        $lastcomm = array();
    }
    $lastcomm[] = array('name' => $tempcomm['name'], 'email' => $tempcomm['email'], 'url' => $tempcomm['url'], 'date' => $tempcomm['date'], 'comment' => $tempcomm['comment'], 'code' => $db->entry['code'], 'title' => trimtext($db->entry['title'], 50), 'category' => $db->entry['category'], 'ip' => $tempcomm['ip']);
    save_serialize("db/ser_modqueue.php", $lastcomm);
}
Esempio n. 3
0
function log_search()
{
    global $Paths;
    $search_str = trim($_POST['search'] . " " . $_GET['q']);
    // is there anything to save?
    if ('' != $search_str) {
        // set path
        $log_path = $Paths['pivot_path'] . 'db/';
        // is there an old to load?
        if (file_exists($log_path . 'log_search.php')) {
            // file exists - load if writable
            if (is_writable($log_path . 'log_search.php')) {
                $log_search_array = load_serialize($log_path . 'log_search.php');
                $log_exists = TRUE;
            }
        }
        // just in case
        if (!is_array($log_search_array)) {
            $log_search_array = array();
        }
        // add to the log
        $log_search_array[$search_str]++;
        if (isset($log_exists) && TRUE == $log_exists) {
            // easy route - now serialize and save
            save_serialize($log_path . 'log_search.php', $log_search_array);
        } else {
            // else attempt to make it - suppress errors
            @makedir($log_path, 0700);
            @touch($log_path . 'log_search.php');
            @chmod($log_path . 'log_search.php', 0777);
            // final check
            if (is_writable($log_path . 'log_search.php')) {
                save_serialize($log_path . 'log_search.php', $log_search_array);
            }
        }
    }
}
Esempio n. 4
0
/**
 * Get the TagCosmos. Preferably use the cached version, otherwise just make it
 * on the fly. (and then we store the cached version)
 *
 * If $max is given, it will return at most that many tags, ordered by size.
 * If $weblogname is given, only tags for that weblog will be returned.
 *
 * Returns an array with the following elements:
 * 'minvalue' => minimum value of a tag
 * 'maxvalue' => maximum value of a tag
 * 'amount' => number of tags
 * 'tags' => array of the tags. The indices are the tags, the values the number of occurences
 *
 * @param integer $max
 * @param string $weblogname 
 * @return array
 *
 */
function getTagCosmos($max = 0, $weblogname = '')
{
    global $Paths, $Cfg, $Weblogs;
    if ($weblogname == '' || $Cfg['weblog_count'] == 1) {
        $weblogname = '_all_';
    }
    // If the cached version is fresh enough, we restore that
    if (file_exists($Paths['pivot_path'] . "db/ser_tags.php") && filectime($Paths['pivot_path'] . "db/ser_tags.php") > time() - 60 * $Cfg['tag_cache_timeout']) {
        // Just load it..
        $data = load_serialize("db/ser_tags.php");
        $tagcosmos = $data[$weblogname];
    } else {
        // We have to read it..
        $tagcosmos = array();
        if ($Cfg['weblog_count'] > 1) {
            $temp_db = new db(FALSE);
        }
        foreach ($Weblogs as $weblog => $weblogdata) {
            $tagcosmos[$weblog] = array();
        }
        $tagdir = dir($Paths['pivot_path'] . "db/tagdata/");
        // Read all tags, build the tag index and save it or later.
        while (false !== ($entry = $tagdir->read())) {
            if (getextension($entry) == "tag") {
                list($tagname) = explode(".", $entry);
                $tagfile = implode("", file($Paths['pivot_path'] . "db/tagdata/" . $entry));
                $tagfile = explode(",", $tagfile);
                // If magic_quotes_gpc is set, we need to strip slashes..
                if (get_magic_quotes_gpc()) {
                    $tagname = stripslashes($tagname);
                }
                if ($tagname != "") {
                    $tagcosmos['_all_']['tags'][$tagname] = count($tagfile);
                    if ($Cfg['weblog_count'] > 1) {
                        foreach ($tagfile as $entrycode) {
                            $temp_entry = $temp_db->read_entry($entrycode);
                            $cat_weblogs = find_weblogs_with_cat($temp_entry['category']);
                            foreach ($cat_weblogs as $cat_weblog) {
                                $tagcosmos[$cat_weblog]['tags'][$tagname]++;
                            }
                        }
                    }
                }
            }
        }
        $tagdir->close();
        save_serialize($Paths['pivot_path'] . "db/ser_tags.php", $tagcosmos);
        $tagcosmos = $tagcosmos[$weblogname];
    }
    $tagcosmos['amount'] = count($tagcosmos['tags']);
    // if $max is given, we need to filter out the smaller tags, until the required size is reached.
    if ($max != 0 && $max < count($tagcosmos['tags'])) {
        arsort($tagcosmos['tags']);
        $tagcosmos['tags'] = array_slice($tagcosmos['tags'], 0, $max);
    }
    ksort($tagcosmos['tags']);
    $tagcosmos['minvalue'] = 1000;
    $tagcosmos['maxvalue'] = 0;
    // We determine what the min and max-value in the cosmos is.
    foreach ($tagcosmos['tags'] as $key => $value) {
        $tagcosmos['maxvalue'] = max($tagcosmos['maxvalue'], $value);
        $tagcosmos['minvalue'] = min($tagcosmos['minvalue'], $value);
    }
    return $tagcosmos;
}
Esempio n. 5
0
function spam()
{
    global $Paths, $Pivot_Vars;
    $entry_url = '<a target="_blank" href="index.php?menu=entries&amp;func=modify&amp;id=%s">%s</a>';
    $com_url = '<a target="_blank" href="index.php?menu=entries&amp;func=editcomments&amp;id=%s&amp;edit=%s">%s</a>';
    $tb_url = '<a target="_blank" href="index.php?menu=entries&amp;func=edittrackbacks&amp;id=%s&amp;edit=%s">%s</a>';
    if ($_REQUEST["what"] == "Trackbacks" || $_REQUEST["what"] == "Both") {
        $trackbacks = true;
    } else {
        $trackbacks = false;
    }
    if ($_REQUEST["what"] == "Comments" || $_REQUEST["what"] == "Both") {
        $comments = true;
    } else {
        $comments = false;
    }
    $tot_com_spam = 0;
    $tot_tb_spam = 0;
    if ($_REQUEST["submit"] == "Remove Spam") {
        if ($comments) {
            $last_comms = load_serialize("./db/ser_lastcomm.php", true, true);
        }
        if ($trackbacks) {
            $last_tracks = load_serialize("./db/ser_lasttrack.php", true, true);
        }
    }
    $spam_db = new db();
    $entries = $spam_db->getlist($spam_db->get_entries_count());
    foreach ($entries as $entry) {
        $entry_id = $entry['code'];
        $data = $spam_db->read_entry($entry_id);
        foreach ($data as $key => $value) {
            if ($key == "trackbacks" && count($data["trackbacks"]) > 0 && $trackbacks) {
                foreach ($data["trackbacks"] as $tbid => $tb) {
                    $text = implode(" ", $tb);
                    if (strpos(strtolower($text), strtolower($_REQUEST["spamword"])) !== false) {
                        $output .= sprintf("<tr class='%s'><td valign='top'>%s</td><td valign='top'>%s</td>\r\n                        \t\t\t<td valign='top'>%s</td>", ($tot_tb_spam + $tot_com_spam) % 2 ? "tabular_line_even" : "tabular_line_odd", sprintf($entry_url, $entry_id, $entry_id), sprintf($tb_url, $entry_id, $tbid, "Trackback&nbsp;" . $tbid), $text);
                        $tot_tb_spam++;
                        unset($data["trackbacks"][$tbid]);
                        //remove the trackback from last_trackbacks if it's in there..
                        if ($_REQUEST["submit"] == "Remove Spam" && count($last_tracks) > 0) {
                            foreach ($last_tracks as $lt_key => $last_track) {
                                if ($last_track['code'] == $data['code'] && $last_track['name'] == $tb['name'] && $last_track['date'] == $tb['date']) {
                                    unset($last_tracks[$lt_key]);
                                }
                            }
                        }
                    }
                }
            }
            if ($key == "comments" && count($data["comments"]) > 0 && $comments) {
                foreach ($data["comments"] as $comid => $com) {
                    $text = implode(" ", $com);
                    if (strpos(strtolower($text), strtolower($_REQUEST["spamword"])) !== false) {
                        $output .= sprintf("<tr class='%s'><td valign='top'>%s</td><td valign='top'>%s</td>\r\n                        \t\t\t<td valign='top'>%s</td>", ($tot_tb_spam + $tot_com_spam) % 2 ? "tabular_line_even" : "tabular_line_odd", sprintf($entry_url, $entry_id, $entry_id), sprintf($com_url, $entry_id, $comid, "Comment&nbsp;" . $comid), wordwrap($text, 90, " <br />", true));
                        $tot_com_spam++;
                        unset($data["comments"][$comid]);
                        //remove the comment from last_comments if it's in there..
                        if ($_REQUEST["submit"] == "Remove Spam" && count($last_comms) > 0) {
                            foreach ($last_comms as $lc_key => $last_comm) {
                                if ($last_comm['code'] == $data['code'] && $last_comm['name'] == $com['name'] && $last_comm['date'] == $com['date']) {
                                    unset($last_comms[$lc_key]);
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($_REQUEST["submit"] == "Remove Spam") {
            $spam_db->set_entry($data);
            $spam_db->save_entry();
        }
    }
    if ($_REQUEST["submit"] == "Remove Spam") {
        echo "<br />";
        if ($trackbacks) {
            save_serialize("./db/ser_lasttrack.php", $last_tracks);
            echo "<p>Removed {$tot_tb_spam} Spam Trackbacks</p>\n";
        }
        if ($comments) {
            save_serialize("./db/ser_lastcomm.php", $last_comms);
            echo "<p>Removed {$tot_com_spam} Spam Comments</p>\n";
        }
        $link = sprintf("index.php?session=%s&amp;menu=admin&amp;func=admin&amp;do=spamwasher", $Pivot_Vars['session']);
        echo "<br /><p><b>Done!</b></p>";
        echo '<p>To remove the spam from the generated pages as well, you should:
        <a href="index.php?menu=admin&amp;func=admin&amp;do=build_index">Rebuild the Index</a> and then
        <a href="index.php?menu=admin&amp;func=admin&amp;do=regen">Rebuild All Files</a></em>.<br />
        Or go back to the <a href="' . $link . '">Spam Washer page</a> to remove more spam before
        rebuilding.</p>';
    } elseif ($_REQUEST["submit"] == "List Spam") {
        echo "<br />";
        if ($trackbacks) {
            echo "<p>Found {$tot_tb_spam} Spam Trackbacks</p>\n";
        }
        if ($comments) {
            echo "<p>Found {$tot_com_spam} Spam Comments</p>\n";
        }
        if ($tot_com_spam > 0 || $tot_tb_spam > 0) {
            echo '<br />
        		<h3>Complete Spam Listing for "' . $_REQUEST["spamword"] . '"</h3>
        		<table class="tabular_border" cellspacing="0" cellpadding="2">
        		<tr class="tabular_header"><th>Entry</th><th>Type</th><th>Text</th></tr>' . $output . "</table>\n";
        }
    }
}
Esempio n. 6
0
/**
 * Write the index to file (using the global variable $master_index.
 *
 * @param boolean $silent
 * @return void
 */
function write_index($silent = FALSE)
{
    global $master_index;
    if (is_array($master_index)) {
        debug("saving " . count($master_index) . " indices.");
        if (0 != count($master_index)) {
            $wordcount = 0;
            foreach ($master_index as $key => $index) {
                $filename = "db/search/" . $key . ".php";
                // load the index if it exists..
                if (file_exists($filename)) {
                    $temp = load_serialize($filename);
                } else {
                    $temp = array();
                }
                // add the new stuff..
                foreach ($index as $key => $val) {
                    if (isset($temp[$key])) {
                        $occurr = explode("|", $temp[$key]);
                        $occurr[] = $val;
                        $val = implode("|", array_unique($occurr));
                        $temp[$key] = $val;
                    } else {
                        $temp[$key] = $val;
                    }
                }
                save_serialize($filename, $temp);
                $wordcount += count($index);
            }
            if ($silent != TRUE) {
                echo "<p>A total of " . $wordcount . " different words have been indexed.</p>";
            }
        }
    } else {
        debug("nothing to save");
    }
}
Esempio n. 7
0
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();
}
Esempio n. 8
0
/**
 * Displays the screen to edit and delete trackbacks.
 *
 * @param string $msg
 * @see submit_trackback()
 */
function edit_trackbacks($msg = "")
{
    global $Cfg, $Pivot_Vars, $Users;
    PageHeader(lang('userbar', 'trackbacks'), 1);
    PageAnkeiler(lang('userbar', 'trackbacks') . ' &raquo; ' . lang('userbar', 'trackbacks_title'));
    $id = $Pivot_Vars['id'];
    $db = new db();
    // read entry if it's not in memory yet.
    $db->read_entry($id, true);
    printf("<p><strong>%s</strong>: %s<br />", lang('entries', 'title'), $db->entry['title']);
    printf("<strong>%s</strong>: %s<br />", lang('entries', 'author'), $db->entry['user']);
    printf("<strong>%s</strong>: %s</p><br />", lang('entries', 'date'), $db->entry['date']);
    if ($Pivot_Vars['user'] == $db->entry['user']) {
        // allowed to edit own trackbacks
        MinLevel(2);
    } else {
        // allowed to edit trackbacks on other people's entries
        MinLevel(3);
    }
    if (!$db->entry['trackbacks'] || count($db->entry['trackbacks']) < 1) {
        // print if there are no trackbacks
        echo "<p><B>" . lang('notice', 'trackback_none') . "</b><br /><br /></p>";
    } else {
        // print the trackbacks..
        // perhaps delete a trackback.
        if (isset($Pivot_Vars['del'])) {
            $del_track = $db->entry['trackbacks'][$Pivot_Vars['del']];
            //remove the trackback from last_trackbacks if it's in there..
            if (file_exists("db/ser_lasttrack.php")) {
                $last_tracks = load_serialize("db/ser_lasttrack.php", true, true);
            } else {
                $last_tracks = array();
            }
            if ($last_tracks !== false && count($last_tracks) > 0) {
                foreach ($last_tracks as $key => $last_track) {
                    if ($last_track['code'] == $db->entry['code'] && $last_track['name'] == $del_track['name'] && $last_track['date'] == $del_track['date']) {
                        unset($last_tracks[$key]);
                        save_serialize("db/ser_lasttrack.php", $last_tracks);
                    }
                }
            }
            // *argh* evil hack to directly delete trackbacks.. I should write a
            // proper wrapper
            unset($db->entry['trackbacks'][$Pivot_Vars['del']]);
            unset($db->db_lowlevel->entry['trackbacks'][$Pivot_Vars['del']]);
            $db->save_entry();
            $msg = lang('notice', 'trackback_deleted');
        }
        // perhaps add an ip-block for single ip.
        if (isset($Pivot_Vars['blocksingle'])) {
            $msg = "Added block for IP " . $Pivot_Vars['blocksingle'];
            add_block($Pivot_Vars['blocksingle']);
        }
        // perhaps add an ip-block for single ip.
        if (isset($Pivot_Vars['blockrange'])) {
            $iprange = make_mask($Pivot_Vars['blockrange']);
            $msg = "Added block for IP-range " . $iprange;
            add_block($iprange);
        }
        // perhaps remove an ip-block for single ip.
        if (isset($Pivot_Vars['unblocksingle'])) {
            $msg = "Removed block for IP " . $Pivot_Vars['unblocksingle'];
            rem_block($Pivot_Vars['unblocksingle']);
        }
        // perhaps remove an ip-block for single ip.
        if (isset($Pivot_Vars['unblockrange'])) {
            $iprange = make_mask($Pivot_Vars['unblockrange']);
            $msg = "Removed block for IP-range " . $iprange;
            rem_block($iprange);
        }
        // print a message, if there is one.
        if ($msg != "") {
            echo "<p><B>{$msg}</b><br /><br /></p>";
        }
        // show the edit form, to edit a trackback..
        if (isset($Pivot_Vars['edit'])) {
            StartForm('submittrackback', 0);
            StartTable();
            $mytrack = $db->entry['trackbacks'][$Pivot_Vars['edit']];
            $settings = array();
            $settings[] = array('heading', lang('weblog_config', 'shortentry_template'), '', 8, '', 2, '');
            $settings[] = array('id', '', '', 7, $id, '', '');
            $settings[] = array('count', '', '', 7, $Pivot_Vars['edit'], '', '');
            $settings[] = array('name', lang('weblog_text', 'blog_name'), '', 0, unentify($mytrack['name']), 60, '');
            $settings[] = array('title', lang('weblog_text', 'title'), '', 0, unentify($mytrack['title']), 60, '');
            $settings[] = array('excerpt', lang('weblog_text', 'excerpt'), '', 5, unentify($mytrack['excerpt']), '60', 'rows=5');
            $settings[] = array('url', lang('weblog_text', 'url'), '', 0, $mytrack['url'], 60, '');
            $settings[] = array('ip', lang('weblog_text', 'ip'), '', 0, $mytrack['ip'], 30, '');
            $settings[] = array('date', lang('weblog_text', 'date'), '', 0, $mytrack['date'], 30, '');
            DisplaySettings($settings, 'blog_settings');
            EndForm(lang('weblog_config', 'save_trackback'), 1);
        }
        // print out all the trackbacks..
        foreach ($db->entry['trackbacks'] as $key => $trackback) {
            $myblock = block_type($trackback['ip']);
            if ($myblock == "single" || $myblock == "range") {
                $strike = "style='text-decoration: line-through;'";
            } else {
                $strike = "";
            }
            // strip stuff from lamers' trackbacks..
            $trackback['url'] = strip_tags($trackback['url']);
            printf("<table border=0 cellpadding=2 cellspacing=2 width='95%%' style='border-bottom:" . " 2px solid #999;'><tr><td width='40%%' valign='top'>" . lang('weblog_text', 'title') . ":&nbsp;<b %s>%s</b><br />", $strike, stripslashes($trackback['title']));
            printf(lang('weblog_text', 'blog_name') . ":&nbsp;%s<br />", $trackback['name']);
            printf(lang('weblog_text', 'url') . ":&nbsp;%s<br />", $trackback['url']);
            printf(lang('weblog_text', 'ip') . ":&nbsp;%s<br />", $trackback['ip']);
            printf(lang('weblog_text', 'date') . ":&nbsp;%s<br />", $trackback['date']);
            printf("<td valign='top'><span %s>%s</span></td>", $strike, nl2br(htmlspecialchars($trackback['excerpt'])));
            // only show the option to edit and delete links if the user is an advanced user.
            if ($Users[$Pivot_Vars['user']]['userlevel'] >= 2) {
                $link = sprintf("index.php?session=%s&amp;menu=entries&amp;func=edittrackbacks&amp;", $Pivot_Vars['session']);
                $editlink = sprintf("%sid=%s&amp;edit=%s", $link, $db->entry['code'], $key);
                $dellink = sprintf("%sid=%s&amp;del=%s", $link, $db->entry['code'], $key);
                $reportpopup = sprintf("openReportTrackback('%s', '%s','%s','%s');", $Pivot_Vars['session'], $db->entry['code'], $key, $dellink);
                printf("</tr><tr class='tabular_line_odd'><td><a href='%s'>%s</a> /", $editlink, lang('entries', 'edit_trackback'));
                printf(" <a href='%s'>%s</a> / ", $dellink, lang('entries', 'delete_trackback'));
                // only ping.
                // printf(" <a href='#' onclick=\"%s\">%s</a>&nbsp;&nbsp;", $reportpopup, lang('entries', 'report_trackback') );
                // ping and delete
                printf(" <a href='#' onclick=\"%s\">%s</a>&nbsp;&nbsp;", $reportpopup, lang('entries', 'report_trackback'));
            } else {
                printf("<td>&nbsp;</td>");
            }
            // only show the option to add or remove ip-blocks if the user is an administrator.
            if ($Users[$Pivot_Vars['user']]['userlevel'] >= 3) {
                if ($myblock == "none") {
                    $blocktext1 = str_replace("%s", $trackback['ip'], lang('entries', 'block_single'));
                    $blocklink1 = sprintf("%sid=%s&blocksingle=%s", $link, $db->entry['code'], $trackback['ip']);
                    $blocktext2 = str_replace("%s", make_mask($trackback['ip']), lang('entries', 'block_range'));
                    $blocklink2 = sprintf("%sid=%s&blockrange=%s", $link, $db->entry['code'], $trackback['ip']);
                    printf("<td><a href='%s'>%s</a> / ", $blocklink1, $blocktext1);
                    printf("<a href='%s'>%s</a></td>", $blocklink2, $blocktext2);
                } else {
                    if ($myblock == "single") {
                        $blocktext1 = str_replace("%s", $trackback['ip'], lang('entries', 'unblock_single'));
                        $blocklink1 = sprintf("%sid=%s&unblocksingle=%s", $link, $db->entry['code'], $trackback['ip']);
                        printf("<td><a href='%s'>%s</a></td>", $blocklink1, $blocktext1);
                    } else {
                        $blocktext1 = str_replace("%s", make_mask($trackback['ip']), lang('entries', 'unblock_range'));
                        $blocklink1 = sprintf("%sid=%s&unblockrange=%s", $link, $db->entry['code'], $trackback['ip']);
                        printf("<td><a href='%s'>%s</a></td>", $blocklink1, $blocktext1);
                    }
                }
            } else {
                printf("<td>&nbsp;</td>");
            }
            printf("</td></tr></table><br />");
        }
        // end of printing trackbacks
    }
    // Table for editing the entry / trackbacks (this will be replaced after 1.30,
    // When we put the form-builder in place.
    echo '<table  width="95%"  border="0" cellpadding="5" cellspacing="0">';
    $link = sprintf("index.php?session=%s&amp;menu=entries&amp;func=modify&amp;id=%s", $Pivot_Vars['session'], $db->entry['code']);
    printf('<!-- edit entry --><tr><td width="32" valign="top">');
    print_icon('overview', 'new_entry', "<a href=\"" . $link . "\">");
    printf('</td><td><h3><a href="%s">%s</a></h3><p class="dim">%s</p></td></tr>', $link, lang('entries', 'edit_entry'), lang('entries', 'edit_entry_desc'));
    $link = sprintf("index.php?session=%s&amp;menu=entries&amp;func=editcomments&amp;id=%s", $Pivot_Vars['session'], $db->entry['code']);
    printf('<!-- edit comments --><tr><td width="32" valign="top">');
    print_icon('entry', 'edit_comments', "<a href=\"" . $link . "\">");
    printf('</td><td><h3><a href="%s">%s</a></h3><p class="dim">%s</p></td></tr>', $link, lang('entries', 'edit_comments'), lang('entries', 'edit_comments_desc'));
    $link = sprintf("index.php?session=%s&amp;menu=entries&amp;doaction=1&amp;action=delete&amp;check[%s]=1", $Pivot_Vars['session'], $db->entry['code']);
    printf('<!-- delete entry --><tr><td width="32" valign="top">');
    print_icon('entry', 'del_entry', "<a href=\"" . $link . "\">");
    printf('</td><td><h3><a href="%s">%s</a></h3><p class="dim">%s</p></td></tr>', $link, lang('entries', 'delete_entry'), lang('entries', 'delete_entry_desc'));
    echo "</table>";
    // End of table for editing the entry / trackbacks
    PageFooter();
    echo "<br /><br /><br /><br />";
}
Esempio n. 9
0
/**
 * The screen to delete a weblog..
 */
function main_blog_delete()
{
    global $Weblogs, $Pivot_Vars;
    // Did the user confirm that he wants to delete?
    if ($Pivot_Vars['confirmed'] != 1) {
        // Not confirmed, show the confirmation option..
        // Keep the (internal) name urlencoded since it is stored in the weblogs
        // array with an urlencoded key.
        $internal_name = urlencode($Pivot_Vars['name']);
        $vars = array('name', $internal_name, 'blog_delete', 1);
        $msg = lang('weblog_config', 'confirm_delete');
        $msg = str_replace("%1", $Weblogs[$internal_name]['name'], $msg);
        ConfirmPage(lang('ufield_main', 'del_title'), $vars, $msg);
    } else {
        // Confirmed, so delete the weblog.
        // check against unauthorised direct access.
        check_csrf();
        $name = $Pivot_Vars['name'];
        unset($Weblogs[$name]);
        save_serialize('pv_cfg_weblogs.php', $Weblogs);
        $msg = lang('weblog_config', 'deleted');
        main_blogs($msg);
    }
}
Esempio n. 10
0
 function write_date_index()
 {
     global $pivot_path;
     asort($this->date_index);
     debug("Save date index (" . count($this->date_index) . "," . count($this->cat_index) . ")");
     save_serialize($pivot_path . "db/ser-dates.php", $this->date_index);
     save_serialize($pivot_path . "db/ser-cats.php", $this->cat_index);
 }
Esempio n. 11
0
/**
 * Process a comment for moderation. Action 1 = allow,
 * action 2 = delete.
 *
 * When allowed, the comment is changed in the entry, so it is displayed, and it
 * is added to the last_comments. Whene deleted it'll be deleted from the entry
 *
 * @param array $comm
 * @param integer $action
 */
function moderate_process($comm, $action)
{
    global $db, $Paths, $Current_weblog, $Cfg;
    if (!isset($db)) {
        $db = new db();
    }
    if ($action == 1) {
        // Allow comment.
        // First, get the entry..
        $entry = $db->read_entry($comm['code'], true);
        $send_notifaction = false;
        foreach ($entry['comments'] as $key => $loopcomm) {
            if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                // fix the entry..
                $entry['comments'][$key]['moderate'] = 0;
                // Store the comment that's approved. We need it a bit later on to send the notifications
                $modcomment = $entry['comments'][$key];
                // Save it..
                $db->set_entry($entry);
                $db->save_entry();
                // Add it to the 'last comments'..
                if (file_exists("db/ser_lastcomm.php")) {
                    $lastcomm = load_serialize("db/ser_lastcomm.php", true, true);
                } else {
                    $lastcomm = array();
                }
                $lastcomm[] = $comm;
                if (count($lastcomm) > $Cfg['lastcomm_amount_max']) {
                    array_shift($lastcomm);
                }
                save_serialize("db/ser_lastcomm.php", $lastcomm);
                $send_notifaction = true;
            }
        }
        // Regenerate the entry page (if it's static) and the corresponding archive page.
        generate_pages($comm['code'], TRUE, FALSE, TRUE, FALSE, FALSE);
        if ($send_notifaction) {
            // We need to determine the current weblog..
            $weblogs = find_weblogs_with_cat($entry['category']);
            $Current_weblog = current($weblogs);
            // Handle the users that want to be notified via email..
            notify_new('comment', array($entry, $modcomment));
        }
    } else {
        if ($action == 2) {
            // Delete comment.
            // First, get the entry..
            $entry = $db->read_entry($comm['code'], true);
            foreach ($entry['comments'] as $key => $loopcomm) {
                if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                    // fix the entry..
                    unset($entry['comments'][$key]);
                    // Save it..
                    $db->set_entry($entry);
                    $db->save_entry();
                }
            }
        }
    }
}
Esempio n. 12
0
function save_user($user)
{
    global $Cfg, $Paths;
    $name_md5 = strtolower(md5(strtolower($user['name'])));
    if (save_serialize($Paths['pivot_path'] . 'db/users/' . $name_md5 . '.php', $user)) {
        // echo "User stored!<br /><br />";
    } else {
        echo "Could not store user!!<br /><br />";
    }
}
Esempio n. 13
0
	$Cfg['encode_email_addresses'] = $Pivot_Vars['encode_email_addresses'];

}
*/
$var = "Setupstep{$setupstepn}";
if ($setupstepn == 1) {
    $next = 'proceed to login';
} else {
    // Set several options in Config.
    $Cfg['installed'] = 1;
    $Cfg['sitename'] = $Pivot_Vars['sitename'];
    $Cfg['deflang'] = $Pivot_Vars['deflang'];
    // Set the language for the default weblog.
    $Weblogs['my_weblog']['language'] = $Pivot_Vars['deflang'];
    // Save the settings..
    SaveSettings();
    // Save the weblog..
    save_serialize('pv_cfg_weblogs.php', $Weblogs);
    // Go to the index page to log in.
    redirect('index.php');
}
//it's nice to use it as a variable so we can look at $BigAssArray[$i][0] for a list of variables to save in config.
echo "<div style='padding: 20px;'>";
StartForm('setup');
StartTable($caption);
DisplaySettings(${$var});
EndForm($next, 1);
PageFooter();
?>