当前位置: 首页>>代码示例>>PHP>>正文


PHP db::read_entry方法代码示例

本文整理汇总了PHP中db::read_entry方法的典型用法代码示例。如果您正苦于以下问题:PHP db::read_entry方法的具体用法?PHP db::read_entry怎么用?PHP db::read_entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db的用法示例。


在下文中一共展示了db::read_entry方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: make_filelink

/**
 * Make a link to an entry, using the settings for how they should be formed.
 *
 * @param mixed $data
 * @param string $weblog
 * @param string $anchor
 * @param string $parameter
 * @param boolean $para_weblog
 */
function make_filelink($data = "", $weblog = "", $anchor = "comm", $parameter = "", $para_weblog = false)
{
    global $db, $Weblogs, $Current_weblog, $Cfg, $Paths;
    // Set the weblog, if it isn't set already.
    if ($weblog == "") {
        $weblog = $Current_weblog;
    }
    // Set the 'log_url' path, if it isn't set already.
    if (empty($Paths['log_url'])) {
        $Paths['log_url'] = dirname(get_log_url('index')) . "/";
        if ($Paths['log_url'] == "//") {
            $Paths['log_url'] = "/";
        }
    }
    // Set $entry (and $code)
    if (empty($data)) {
        // Using current entry - the db object must exist and be set
        $entry = $db->entry;
        $code = $entry['code'];
    } elseif (is_array($data)) {
        // Using passed/inputed entry
        $entry = $data;
        $code = $entry['code'];
    } elseif (is_numeric($data)) {
        $code = $data;
        // Using the entry with the given $code
        // If it's not the current one, we need to load it
        if (!isset($db) || $code != $db->entry['code']) {
            $fl_db = new db(FALSE);
            $fl_db->read_entry($code);
            $entry = $fl_db->entry;
        } else {
            $entry = $db->entry;
        }
    } else {
        debug('Entry code must be an integer/numeric - no output.');
        return;
    }
    if (!$Weblogs[$weblog]['live_entries']) {
        $filelink = $Paths['pivot_url'] . $Weblogs[$weblog]['entry_path'] . $Weblogs[$weblog]['entry_filename'];
    } else {
        if (isset($Cfg['mod_rewrite']) && $Cfg['mod_rewrite'] != 0 && $entry['date'] != "") {
            // if $entry['date'] is not set, we cant make the non-crufty url,
            // and we fall back to the crufty one..
            switch ($Cfg['mod_rewrite']) {
                // archive/2005/04/20/title_of_entry
                case "1":
                    $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70);
                    $name = safe_string(trim($name), TRUE);
                    if (strlen($name) > 30) {
                        $name = substr($name, 0, 30);
                    }
                    list($yr, $mo, $da, $ho, $mi) = split("-", $entry['date']);
                    $filelink = $Paths['log_url'] . "/archive/{$yr}/{$mo}/{$da}/" . $name;
                    // Reverted it to original, since suggested fix breaks htaccess mod rewrite
                    // $filelink = $Paths['log_url'] . $Weblogs[$weblog]['archive_path'] . "/$yr/$mo/$da/".$name;
                    break;
                    // archive/2005-04-20/title_of_entry
                // archive/2005-04-20/title_of_entry
                case "2":
                    $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70);
                    $name = safe_string(trim($name), TRUE);
                    if (strlen($name) > 30) {
                        $name = substr($name, 0, 30);
                    }
                    list($yr, $mo, $da, $ho, $mi) = split("-", $entry['date']);
                    $filelink = $Paths['log_url'] . "/archive/{$yr}-{$mo}-{$da}/" . $name;
                    // Reverted it to original, since suggested fix breaks htaccess mod rewrite
                    // $filelink = $Paths['log_url'] . $Weblogs[$weblog]['archive_path'] . "/$yr-$mo-$da/".$name;
                    break;
                    // entry/1234
                // entry/1234
                case "3":
                    $filelink = $Paths['log_url'] . "/entry/" . $code;
                    break;
                    // entry/1234/title_of_entry
                // entry/1234/title_of_entry
                case "4":
                    $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70);
                    $name = safe_string(trim($name), TRUE);
                    if (strlen($name) > 30) {
                        $name = substr($name, 0, 30);
                    }
                    $filelink = $Paths['log_url'] . "/entry/" . $code . "/{$name}";
                    break;
            }
        } else {
            $filelink = $Paths['pivot_url'] . "entry.php?id=%1{$parameter}";
        }
    }
    // Add a weblog parameter if asked for, or if multiple weblogs, and the current weblog is not the first one..
//.........这里部分代码省略.........
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:101,代码来源:module_parser.php

示例2: spam

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) {
//.........这里部分代码省略.........
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:101,代码来源:spamwasher.php

示例3: get_entries_with_tag

/**
 * 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 "";
    }
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:43,代码来源:module_tags.php

示例4: smarty_previousentry

/**
 * Link to the previous entry
 *
 * @param array $params
 * @return string
 */
function smarty_previousentry($params)
{
    global $PIVOTX;
    // This tag is only allowed on entrypages..
    if ($PIVOTX['parser']->modifier['pagetype'] != "entry") {
        return;
    }
    $params = cleanParams($params);
    // initialize a temporary db..
    $temp_db = new db(FALSE);
    // we fetch the next one, until we get one that is set to 'publish'
    $get_prev_amount = 1;
    // If possible, we filter on the wanted categories, to make the loop more
    // efficient..
    if (isset($params['category'])) {
        $categories = explode(",", safeString($params['category']));
        $categories = array_map("trim", $categories);
    } else {
        $categories = $params['incategory'] == true ? $PIVOTX['db']->entry['category'] : $PIVOTX['weblogs']->getCategories();
    }
    do {
        $prev_code = $PIVOTX['db']->get_previous_code($get_prev_amount, $categories);
        if ($prev_code) {
            $temp_entry = $temp_db->read_entry($prev_code);
            // it's 'ok' if the entry shares at least one category with the current entry.
            // Note: It might seem redundant to do this check here, but the Flat File DB
            // currently returns entries, regardless of the requested categories.
            $ok = count(array_intersect($categories, $temp_entry['category']));
        }
        $get_prev_amount++;
    } while (!($prev_code === FALSE) && !($temp_entry['status'] == "publish" && $ok));
    unset($temp_db);
    $text = getDefault($params['text'], '&laquo; <a href="%link%">%title%</a>');
    $cutoff = getDefault($params['cutoff'], 20);
    if ($prev_code) {
        $title = strlen($temp_entry['title']) > 2 ? $temp_entry['title'] : substr($temp_entry['introduction'], 0, 100);
        $link = makeFileLink($temp_entry, "", "");
        $output = $text;
        $output = str_replace("%link%", $link, $output);
        $output = str_replace("%code%", $prev_code, $output);
        $output = str_replace("%title%", trimText($title, $cutoff), $output);
        $output = str_replace("%subtitle%", trimText($temp_entry['subtitle'], $cutoff), $output);
        return entifyAmpersand($output);
    } else {
        return "";
    }
}
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:53,代码来源:module_smarty.php

示例5: getword

/**
 * Checks if a word is part of the search index and if so sets the global variable
 * $matches to the matching entry codes.
 * 
 * @param string $word Word to search for.
 * @return boolean False if not found, else true.
 */
function getword($word)
{
    global $search_all, $Current_weblog, $index_file, $db, $matches;
    if (isset($index_file[$word[0]][$word])) {
        if (!isset($db)) {
            $db = new db();
        }
        $tmp_matches = explode("|", $index_file[$word[0]][$word]);
        // All entries should be searched.
        if ($search_all) {
            if (count($tmp_matches) > 0) {
                $matches[] = $tmp_matches;
                return TRUE;
            } else {
                return FALSE;
            }
        }
        // OK, we are run from a weblog - check if the matched entries
        // belong to the current weblog, and are still published,
        // i.e., not set on hold.
        foreach ($tmp_matches as $match) {
            $db->read_entry($match);
            $weblogs = find_weblogs_with_cat($db->entry['category']);
            if (in_array($Current_weblog, $weblogs) && $db->entry['status'] == "publish") {
                $valid_matches[] = $match;
            }
        }
        if (count($valid_matches) > 0) {
            $matches[] = $valid_matches;
            return TRUE;
        }
    }
    return FALSE;
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:41,代码来源:module_search.php

示例6: submit_trackback

/**
 * Store an edited trackback, and then show the edit_trackbacks screen
 *
 * @see edit_trackbacks()
 *
 */
function submit_trackback()
{
    global $Cfg, $Pivot_Vars;
    // If magic_quotes_gpc is set, we need to strip slashes..
    if (get_magic_quotes_gpc()) {
        $Pivot_Vars['title'] = stripslashes($Pivot_Vars['title']);
        $Pivot_Vars['excerpt'] = stripslashes($Pivot_Vars['excerpt']);
        $Pivot_Vars['name'] = stripslashes($Pivot_Vars['name']);
    }
    $mytrack = array('title' => entify($Pivot_Vars['title']), 'excerpt' => entify($Pivot_Vars['excerpt']), 'name' => entify($Pivot_Vars['name']), 'url' => $Pivot_Vars['url'], 'ip' => $Pivot_Vars['ip'], 'date' => $Pivot_Vars['date']);
    $db = new db();
    $entry = $db->read_entry($Pivot_Vars['id']);
    $entry['trackbacks'][$Pivot_Vars['count']] = $mytrack;
    $db->set_entry($entry);
    $db->save_entry();
    // remove it from cache, to make sure the laters one is used.
    $db->unread_entry($entry['code']);
    $msg = lang('notice', 'trackback_saved');
    edit_trackbacks($msg);
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:26,代码来源:pv_core.php

示例7: getTagCosmosFlat

/**
 * Get the TagCosmos. Flat file version.
 *
 * Preferably use the cached version, otherwise just make it
 * on the fly. (and then we store the cached version)
 *
 * The $weblogname parameter is used to return tags for a single weblog.
 * A value of '_all_' returns the tags for all weblogs combined.
 * If $max is given, it will return at most that many tags, ordered by size.
 *
 * 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
 * @see getTagCosmos
 *
 */
function getTagCosmosFlat($max = 0, $weblogname, $match, $exclude = array())
{
    global $PIVOTX;
    // If the cached version is fresh enough, we restore that
    if (file_exists($PIVOTX['paths']['db_path'] . "ser_tags.php") && filectime($PIVOTX['paths']['db_path'] . "ser_tags.php") > time() - 60 * $PIVOTX['config']->get('tag_cache_timeout')) {
        // Just load it..
        $data = loadSerialize($PIVOTX['paths']['db_path'] . "ser_tags.php");
        $tagcosmos = $data[$weblogname];
    } else {
        // We have to compute it..
        $tagcosmos = array();
        $tagcosmos['tags'] = array();
        $multi_weblog = false;
        if (count($PIVOTX['weblogs']->getWeblogNames()) > 1) {
            $multi_weblog = true;
            foreach ($PIVOTX['weblogs']->getWeblogNames() as $name) {
                $tagcosmos[$name] = array();
            }
            $temp_db = new db(FALSE);
        }
        $tagdir = dir($PIVOTX['paths']['db_path'] . "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);
                $tagname = urldecode($tagname);
                $tagfile = implode("", file($PIVOTX['paths']['db_path'] . "tagdata/" . $entry));
                $tagfile = explode(",", $tagfile);
                if (!in_array($tagname, $exclude)) {
                    if ($tagname != "") {
                        $tagcosmos['_all_']['tags'][$tagname] = count($tagfile);
                        if ($multi_weblog) {
                            foreach ($tagfile as $entrycode) {
                                $temp_entry = $temp_db->read_entry($entrycode);
                                $cat_weblogs = $PIVOTX['weblogs']->getWeblogsWithCat($temp_entry['category']);
                                foreach ($cat_weblogs as $cat_weblog) {
                                    $tagcosmos[$cat_weblog]['tags'][$tagname]++;
                                }
                            }
                        }
                    }
                }
            }
        }
        $tagdir->close();
        saveSerialize($PIVOTX['paths']['db_path'] . "ser_tags.php", $tagcosmos);
        $tagcosmos = $tagcosmos[$weblogname];
    }
    if (isset($tagcosmos['tags'])) {
        $tagcosmos['amount'] = count($tagcosmos['tags']);
    } else {
        $tagcosmos['amount'] = 0;
        $tagcosmos['tags'] = array();
    }
    if ($tagcosmos['amount'] > 0) {
        // 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);
        }
    }
    return $tagcosmos;
}
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:85,代码来源:module_tags.php

示例8: snippet_previousentryincategory

function snippet_previousentryincategory($text = '', $cutoff = '')
{
    global $db;
    // initialize a temporary db..
    $temp_db = new db(FALSE);
    $cat = $db->entry['category'];
    // we fetch the next one, until we get one that is set to 'publish'
    $get_prev_amount = 1;
    do {
        $prev_code = $db->get_previous_code($get_prev_amount);
        if ($prev_code) {
            $temp_entry = $temp_db->read_entry($prev_code);
        }
        $get_prev_amount++;
        if ($prev_code === FALSE) {
            break;
        }
    } while (!($temp_entry['status'] == "publish") || count(@array_intersect($temp_entry['category'], $cat)) == 0);
    unset($temp_db);
    if ('' == $text) {
        $text = '&laquo; <a href="%link%">%title%</a>';
    }
    if ('' == $cutoff) {
        $cutoff = 20;
    }
    if ($prev_code) {
        $title = strlen($temp_entry['title']) > 2 ? $temp_entry['title'] : substr($temp_entry['introduction'], 0, 100);
        $link = make_filelink($temp_entry, "", "");
        $output = "{$text}";
        $output = str_replace("%link%", $link, $output);
        $output = str_replace("%code%", $prev_code, $output);
        $output = str_replace("%title%", trimtext($title, $cutoff), $output);
        return $output;
    } else {
        return "";
    }
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:37,代码来源:module_snippets.php

示例9: setcookie

    }
    setcookie("piv_rememberinfo", "yes", time() + 2592000, $Paths['cookie_url']);
    //debug ("cookiezet: ". stripslashes($Pivot_Vars['piv_name']));
} else {
    if ($Pivot_Vars['piv_rememberinfo'] == "no") {
        setcookie("piv_name", "", time() - 1000, $Paths['cookie_url']);
        setcookie("piv_email", "", time() - 1000, $Paths['cookie_url']);
        setcookie("piv_url", "", time() - 1000, $Paths['cookie_url']);
        setcookie("piv_rememberinfo", "", time() - 1000, $Paths['cookie_url']);
        //debug("delcookie: " );
    }
}
// load an entry
if (isset($Pivot_Vars['piv_code'])) {
    $db = new db();
    $entry = $db->read_entry($Pivot_Vars['piv_code']);
    execute_hook("submit", "pre", $Pivot_Vars);
    if (isset($Pivot_Vars['vote'])) {
        // we vote !!
        $ip = $Pivot_Vars['group'] . $Pivot_Vars['REMOTE_ADDR'];
        $value = $Pivot_Vars['vote'];
        if (isset($entry['votes'][$ip])) {
            $message = lang('karma', 'already');
            //debug("vote '$value' from '".$ip."' not added (already voted).");
        } else {
            $entry['votes'][$ip] = $value;
            $message = lang('karma', 'register');
            debug("vote '{$value}' from '" . $ip . "' added.");
            $myval = isset($lang['karma'][$value]) ? lang('karma', $value) : $value;
            $message = str_replace('%val%', $myval, $message);
            // generating the page.
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:31,代码来源:submit.php

示例10: makeFilelink

/**
 * Make a link to an entry, using the settings for how they should be formed.
 *
 * @param mixed $data
 * @param string $weblog
 * @param string $anchor
 * @param string $parameter
 * @param boolean $para_weblog
 */
function makeFilelink($data = "", $weblog = "", $anchor = "comm", $parameter = "", $para_weblog = false)
{
    global $PIVOTX;
    // Set the weblog, if it isn't set already.
    if ($weblog == "") {
        $weblog = $PIVOTX['weblogs']->getCurrent();
    }
    // Set $entry (and $code)
    if (empty($data)) {
        // Using current entry - the db object must exist and be set
        $template_vars = $PIVOTX['template']->get_template_vars();
        $uid = $template_vars['uid'];
    } elseif (is_array($data)) {
        // Using passed/inputed entry
        $entry = $data;
        $uid = $entry['uid'];
    } elseif (is_numeric($data)) {
        $uid = $data;
        // Using the entry with the given $code
        // If it's not the current one, we need to load it
        if (!isset($PIVOTX['db']) || $uid != $PIVOTX['db']->entry['uid']) {
            $fl_db = new db(FALSE);
            $fl_db->read_entry($uid);
            $entry = $fl_db->entry;
        } else {
            $entry = $PIVOTX['db']->entry;
        }
    } else {
        debug('Entry code must be an integer/numeric - no output.');
        return;
    }
    $site_url = getDefault($PIVOTX['weblogs']->get($weblog, 'site_url'), $PIVOTX['paths']['site_url']);
    $site_url = addTrailingSlash($site_url);
    switch ($PIVOTX['config']->get('mod_rewrite')) {
        // Mod rewrite disabled..
        case "0":
        case "":
            $filelink = sprintf("%s?e=%s%s", $site_url, $uid, $parameter);
            break;
            // archive/2005/04/20/title_of_entry
        // archive/2005/04/20/title_of_entry
        case "1":
            $name = $entry['uri'];
            $archiveprefix = makeURI(getDefault($PIVOTX['config']->get('localised_archive_prefix'), "archive"));
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$archiveprefix}/{$yr}/{$mo}/{$da}/{$name}";
            break;
            // archive/2005-04-20/title_of_entry
        // archive/2005-04-20/title_of_entry
        case "2":
            $name = $entry['uri'];
            $archiveprefix = makeURI(getDefault($PIVOTX['config']->get('localised_archive_prefix'), "archive"));
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$archiveprefix}/{$yr}-{$mo}-{$da}/{$name}";
            break;
            // entry/1234
        // entry/1234
        case "3":
            $entryprefix = makeURI(getDefault($PIVOTX['config']->get('localised_entry_prefix'), "entry"));
            $filelink = $site_url . "{$entryprefix}/{$uid}";
            break;
            // entry/1234/title_of_entry
        // entry/1234/title_of_entry
        case "4":
            $name = $entry['uri'];
            $entryprefix = makeURI(getDefault($PIVOTX['config']->get('localised_entry_prefix'), "entry"));
            $filelink = $site_url . "{$entryprefix}/{$uid}/{$name}";
            break;
            // 2005/04/20/title_of_entry
        // 2005/04/20/title_of_entry
        case "5":
            $name = $entry['uri'];
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$yr}/{$mo}/{$da}/{$name}";
            break;
            // 2005-04-20/title_of_entry
        // 2005-04-20/title_of_entry
        case "6":
            $name = $entry['uri'];
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$yr}-{$mo}-{$da}/{$name}";
            break;
    }
    // Add a weblog parameter if asked for, or if multiple weblogs
    if ($para_weblog || paraWeblogNeeded($weblog)) {
        if ($PIVOTX['config']->get('mod_rewrite')) {
            // we treat it as an extra 'folder'
            $filelink .= "/" . para_weblog($weblog);
        } else {
            $filelink .= "&amp;w=" . para_weblog($weblog);
        }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:101,代码来源:module_parser.php

示例11: killspam

/**
 * Check the message for spam (currently using SpamQuiz and HashCash if enabled).
 *
 * @return void
 */
function killspam()
{
    global $Cfg, $Paths, $Pivot_Vars;
    if (strlen($Cfg["spam_redirect"]) > 10) {
        $sRedirURL = $Cfg["spam_redirect"];
    } else {
        $sRedirURL = "http://spammerbegone.com/";
    }
    if (isset($Pivot_Vars["preview"]) || isset($Pivot_Vars["vote"])) {
        $noCheck = true;
    } else {
        $noCheck = false;
    }
    // Do the Spamquiz check (if enabled and entry old enough).
    // If Spamquiz is violated we can block him immediately as well.
    if ($Cfg["spamquiz"] == 1 && !$noCheck) {
        $sqDateOK = true;
        if (isset($Pivot_Vars['piv_code'])) {
            $pbl_db = new db();
            $entry = $pbl_db->read_entry($Pivot_Vars['piv_code']);
            $entryDate = substr($entry['date'], 0, 10);
            $then = strtotime($entryDate);
            $secsPerDay = 60 * 60 * 24;
            $now = strtotime('now');
            $diff = $now - $then;
            $dayDiff = $diff / $secsPerDay;
            $numDaysOld = (int) $dayDiff;
            if ($numDaysOld < $Cfg["spamquiz_days"]) {
                $sqDateOK = false;
            }
        }
        if ($sqDateOK) {
            if (strlen(trim($Cfg["spamquiz_question"])) > 0) {
                if (strtolower(trim($Pivot_Vars["spamquiz_answer"])) != strtolower(trim($Cfg["spamquiz_answer"]))) {
                    logspammer($_SERVER["REMOTE_ADDR"], "spamquiz");
                    header("location: " . $sRedirURL);
                    exit;
                }
            }
            setcookie("spamquiz_answer", $Pivot_Vars["spamquiz_answer"], time() + 3600 * 24 * 30, $Paths['cookie_url'], preg_replace("/^www./", "", $_SERVER["SERVER_NAME"]));
        }
    }
    // Executing HashCash check
    if ($Cfg["hashcash"] == 1 && !$noCheck) {
        if (!hashcash_check_hidden_tag() && !$noCheck) {
            header("location: " . $sRedirURL);
            exit;
        }
    }
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:55,代码来源:module_spamkiller.php

示例12: timedpublishcheck

function timedpublishcheck()
{
    global $serialize_cache, $Cfg, $Paths;
    $temp_db = new db();
    if (isset($Cfg['check_for_timed_publish']) && $Cfg['check_for_timed_publish'] > 0) {
        $amount = $Cfg['check_for_timed_publish'];
    } else {
        $amount = 10;
    }
    $entries = $temp_db->getlist(-$amount, 0, "", "", false, "date");
    $date = date("Y-m-d-H-i", get_current_date());
    $regen = false;
    foreach ($entries as $entry) {
        if ($entry['status'] == "timed") {
            $entry = $temp_db->read_entry($entry['code']);
            if ($entry['publish_date'] <= $date) {
                debug("toggle");
                $entry['date'] = $entry['publish_date'];
                $entry['status'] = "publish";
                $temp_db->set_entry($entry);
                $temp_db->save_entry(TRUE);
                notify_new('entry', $entry);
                $regen = TRUE;
                // 2004/10/17 =*=*= JM
                // can only do this if we know Cfg['search_index'] status...
                if (isset($Cfg)) {
                    // if the global index as they are made var is set - can continue
                    // the rest is copied from 'entrysubmit_screen()' in pv_core.php
                    if ('1' == $Cfg['search_index'] && can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) {
                        include_once 'modules/module_search.php';
                        update_index($temp_db->entry);
                        debug('update search index: ' . $temp_db->entry['code']);
                    }
                }
            }
        }
    }
    if ($regen) {
        buildfrontpage_function();
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:44,代码来源:pvlib.php

示例13: pingWeblogs

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";
    }
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:72,代码来源:spamping.php

示例14: respondExit

    respondExit(lang('trackback', 'noid'), 1);
}
// Open database
$db = new db();
// Exit if non-existing ID supplied
if (!$db->entry_exists($Pivot_Vars['tb_id'])) {
    respondExit('Non-existing ID', 1);
}
$my_trackback = array('name' => entify(urldecode(stripslashes($Pivot_Vars['blog_name']))), 'title' => entify(urldecode(stripslashes($Pivot_Vars['title']))), 'url' => urldecode($Pivot_Vars['url']), 'ip' => $Pivot_Vars['REMOTE_ADDR'], 'date' => format_date("", "%year%-%month%-%day%-%hour24%-%minute%"), 'excerpt' => strip_trailing_space(urldecode(stripslashes($Pivot_Vars['excerpt']))));
// Exit if no URL is given - need to know URL to foreign entry that
// trackbacked us.
if (empty($my_trackback['url'])) {
    respondExit(lang('trackback', 'nourl'), 1);
}
// load an entry
$entry = $db->read_entry($Pivot_Vars['tb_id']);
//here we do a check to prevent double entries...
$duplicate = FALSE;
if (isset($entry['trackbacks']) && count($entry['trackbacks']) > 0) {
    foreach ($entry['trackbacks'] as $loop_trackback) {
        $diff = 1 / (min(strlen($loop_trackback['excerpt']), 200) / (levenshtein(substr($loop_trackback['excerpt'], -200), substr($my_trackback['excerpt'], -200)) + 1));
        if ($diff < 0.25 && $loop_trackback['ip'] == $my_trackback['ip']) {
            $duplicate = TRUE;
        }
    }
}
if (!$duplicate) {
    // update the current entry
    $entry['trackbacks'][] = $my_trackback;
    $Pivot_Vars['post'] = TRUE;
} else {
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:31,代码来源:tb.php


注:本文中的db::read_entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。