/** * Indexes entries in the Pivot database and returns true * if there are more entries to index. * * @param int $start Code for first entry to index * @param int $stop Code for last entry to index * @param int $time Indexing time. * @return boolean */ function start_index($start, $stop, $time) { $db = new db(); $entries = $db->db_lowlevel->date_index; $count = 0; // 2004/10/17 =*=*= JM - doing these in loop will slow things $date = date('Y-m-d-H-i'); $cats = cfg_cat_nosearchindex(); debug("index excludes cats: " . implode(',', $cats)); foreach ($entries as $key => $value) { if ($count++ < $start) { continue; } if ($count > $stop) { break; } // 2004/10/17 =*=*= JM - New searchIndex tests... $entry = $db->read_entry($key); // rules: index if all are true: // - ( status == 'publish' )or(( status == 'timed')&&( publish_date <= date )) // - at least one category is not in exclusion array // check status and date if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= $date) { // categories... if (can_search_cats($cats, $entry['category'])) { if ($count % 50 == 0) { printf("%1.2f sec: Processed %d entries.." . "<br />\n", timetaken('int') + $time, $count); flush(); } strip_words($entry); } } } echo "<br /><br />"; // decide if we need to do some more. if (count($entries) > $stop) { return TRUE; } else { return FALSE; } }
/** * The screen to edit a weblog, screen 2 */ function main_blogs_edit2() { global $Cfg, $Pivot_Vars, $blog_settings, $Weblogs, $Current_subweblog; PageHeader(lang('weblog_config', 'create_2')); PageAnkeiler(lang('userbar', 'admin') . ' » ' . lang('weblog_config', 'create_2')); $temp_weblog = array('name' => stripslashes($Pivot_Vars['name']), 'payoff' => stripslashes($Pivot_Vars['payoff']), 'siteurl' => stripslashes($Pivot_Vars['siteurl']), 'front_filename' => $Pivot_Vars['front_filename'], 'front_path' => fixPathSlash($Pivot_Vars['front_path']), 'ssi_prefix' => $Pivot_Vars['ssi_prefix'], 'language' => $Pivot_Vars['language'], 'live_entries' => $Pivot_Vars['live_entries'], 'entry_filename' => $Pivot_Vars['entry_filename'], 'entry_path' => fixPathSlash($Pivot_Vars['entry_path']), 'read_more' => stripslashes($Pivot_Vars['read_more']), 'archive_filename' => $Pivot_Vars['archive_filename'], 'archive_path' => fixPathSlash($Pivot_Vars['archive_path']), 'archive_unit' => $Pivot_Vars['archive_unit'], 'archive_amount' => $Pivot_Vars['archive_amount'], 'archive_link' => stripslashes($Pivot_Vars['archive_link']), 'archive_linkfile' => stripslashes($Pivot_Vars['archive_linkfile']), 'archive_order' => stripslashes($Pivot_Vars['archive_order']), 'front_template' => $Pivot_Vars['front_template'], 'archive_template' => $Pivot_Vars['archive_template'], 'entry_template' => $Pivot_Vars['entry_template'], 'extra_template' => $Pivot_Vars['extra_template']); if (isset($Pivot_Vars['orig_name']) && strlen($Pivot_Vars['orig_name']) > 1) { $blog_settings = $Weblogs[$Pivot_Vars['orig_name']]; $orig_name = $Pivot_Vars['orig_name']; MidHeading(sprintf(lang('weblog_config', 'edit_weblog') . ' \'%s\'', $Weblogs[$Pivot_Vars['orig_name']]['name'])); } else { $blog_settings = get_tempweblog(); $orig_name = ""; MidHeading(lang('weblog_config', 'create_new')); } StartForm('blog_edit3', 1); StartTable(); EndForm(lang('go'), 2, lang('weblog_config', 'subw_heading')); // initialize the settings array.. $settings = array(); $settings[] = array('orig_name', 'originalname', '', 7, $orig_name); $settings[] = array('temp_weblog', 'tempweblog', '', 7, urlencode(serialize($temp_weblog))); $templates = gettemplates('_sub'); $categories = cfg_cats(); $template_html = load_template($temp_weblog['front_template']); // to cater for users that upgraded their old templates, we // assume [[weblog]] to be [[weblog:standard]] $template_html = str_replace("[[weblog]]", "[[weblog:standard]]", $template_html); preg_match_all("/\\[\\[(sub)?weblog:([^:]*)(:.*)?\\]\\]/mUi", $template_html, $match); $subweblogs = $match[2]; foreach ($subweblogs as $key) { $key = trim($key); // if the subweblog is in the template, but not in the config files, assume some defaults if (!isset($blog_settings['sub_weblog'][$key])) { $blog_settings['sub_weblog'][$key]['template'] = "_sub_entry_standard.html"; $blog_settings['sub_weblog'][$key]['num_entries'] = 10; $blog_settings['sub_weblog'][$key]['comments'] = 1; $blog_settings['sub_weblog'][$key]['categories'] = array(); } $subweblog = $blog_settings['sub_weblog'][$key]; $settings[] = array('heading', $key, '', 8, '', 2); $settings[] = array('sub_weblog[' . $key . '][template]', lang('weblog_config', 'shortentry_template'), lang('weblog_config', 'shortentry_template_desc'), 3, $templates, '', $key); $settings[] = array('sub_weblog[' . $key . '][num_entries]', lang('weblog_config', 'num_entries'), lang('weblog_config', 'num_entries_desc'), 0, $subweblog['num_entries']); $settings[] = array('sub_weblog[' . $key . '][offset]', lang('weblog_config', 'offset'), lang('weblog_config', 'offset_desc'), 0, $subweblog['offset']); // JM - 2004/10/15 - lang abstraction inserted $settings[] = array('', lang('weblog_config', 'publish_cats'), '', 6); $style_nosearch = 'style="background-color:#eee;"'; // NOTE - include style if a no-index category... $cats_nosearch = cfg_cat_nosearchindex(); foreach ($categories as $category) { $label = sprintf(' ' . $category['name']); $name = urlencode($category['name']); if (in_array($category['name'], $subweblog['categories'])) { $settings[] = array('sub_weblog[' . $key . '][categories][' . $name . ']', $label, '', 2, 1, '', ''); } else { $settings[] = array('sub_weblog[' . $key . '][categories][' . $name . ']', $label, '', 2, 0, '', ''); } } $numentries = $blog_settings['sub_weblog'][$key]['num_entries']; } DisplaySettings($settings, 'blog_settings'); EndForm(lang('go'), 1); PageFooter(); }
/** * The screen you'll see after submitting an entry. It stores the entry, updates the indices (pivot's * content indices, and the search index), rebuilds the frontpage and XML & Atom feeds, and then it * displays a list of the latest entries. * */ function entrysubmit_screen() { global $db, $config_array, $Pivot_Vars, $entry, $Cfg, $Users, $Paths, $Weblogs, $filtered_words; // check against unauthorised direct access. check_csrf(); $db = new db(); $entry = get_entry_from_post(); if (!$entry['title'] == "" || !$entry['introduction'] == "" || !$entry['user'] == "") { // in this part, we remove the entry from the categories in which // the current user is not allowed to post entries foreach ($entry['category'] as $my_cat) { $allowed = explode("|", $Cfg['cat-' . $my_cat]); if (in_array($Pivot_Vars['user'], $allowed)) { $allowed_cats[] = $my_cat; } else { $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_catnopost'), $m_cat); debug("not in category: " . $my_cat); } } $entry['category'] = $allowed_cats; $db->set_entry($entry); if ($db->save_entry(TRUE)) { $message = sprintf(lang('entries', 'entry_saved_ok') . $message, '<i>' . trimtext($entry['title'], 25) . '</i>'); } else { $message = sprintf(lang('entries', 'entry_saved_ok'), '<i>' . trimtext($entry['title'], 25) . '</i>'); } // only trigger the ping if it's a new entry.. if ($entry['code'] == ">" && $entry['status'] == "publish") { $ping = TRUE; } else { $ping = FALSE; } // only notify if entry is published, and is either new or status changed to publish. if ($entry['status'] == "publish") { if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") { $notified = notify_new('entry', $db->entry); $notified = "<br /><br />" . $notified; } } // if the global index as they are made var is set - can continue if ('1' == $Cfg['search_index']) { /* 2004/10/16 =*=*= JM an entry should only be indexed if both are true: - 'publish'==$entry['status'] - current date is at least equal to $entry['publish_date'] I lie, there is another case... it is conceivable that this is a timed publish AND the time has come I will leave this to timed publish routines - if I can find them... -> pvLib ... it's flagged and of course, providing that there is at least one category where it would be indexed... something else that can't be tested... if the user changes a normal publish to a timed-publish, or puts on hold when it was previously normal. user should reindex in this case */ // check status and date if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= date('Y-m-d-H-i')) { // categories... if (can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) { include_once 'modules/module_search.php'; update_index($db->entry); debug('update search index: ' . $db->entry['code']); } } } // perhaps send a trackback ping. if ($Pivot_Vars['tb_url'] != "" && $entry['status'] == "publish") { debug("tburl: " . $Pivot_Vars['tb_url']); require_once 'includes/send_trackback.php'; $weblogs = find_weblogs_with_cat($db->entry['category']); if (isset($Weblogs[$weblogs[0]])) { $my_url = $Paths['host'] . make_filelink($db->entry['code'], $weblogs[0], ''); $weblog_title = $Weblogs[$weblogs[0]]['name']; debug("TRACKBACK ping: {$my_url}"); $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_ping_sent'), $Pivot_Vars['tb_url']); $tb_urls = explode("\n", $Pivot_Vars['tb_url']); // make the contents of what to send with the trackback.. $tb_contents = parse_step4($entry['introduction']); if ($Pivot_Vars['convert_lb'] == 2) { $tb_contents = pivot_textile($tb_contents); } else { if ($Pivot_Vars['convert_lb'] == 3 || $Pivot_Vars['convert_lb'] == 4) { $tb_contents = pivot_markdown($tb_contents, $Pivot_Vars['convert_lb']); } } $tb_contents = trimtext(strip_tags($tb_contents), 255); foreach ($tb_urls as $tb_url) { $tb_url = trim($tb_url); if (isurl($tb_url)) { trackback_send($Pivot_Vars['tb_url'], $my_url, $entry['title'], $weblog_title, $tb_contents); } } } } // Update the tags for this entry if it's published and remove the old tags if not if ($db->entry['status'] == 'publish') { writeTags($db->entry['keywords'], $_POST['f_keywords_old'], $db->entry['code']); } else { deleteTags($_POST['f_keywords_old'], $db->entry['code']); } } generate_pages($db->entry['code'], TRUE, TRUE, TRUE, $ping); entries_screen($message . $notified); }
function 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; } }