function plugin_lastcomments_widget() { if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { // no comments in cache $list = array(); } else { // if file exists and its correctly read, we get the stored list // (it is stored in encoded form) $list = unserialize($f); } $content = '<ul class="last-comments">'; // cimangi Aggiunta traduzione stringhe // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:lastcomments'); if ($count = count($list)) { while ($arr = array_pop($list)) { theme_comments_filters($arr, $id); $q = new FPDB_Query(array('id' => $arr['entry']), null); // first element of the array is dropped, as it is the ID, which // we already know @(list(, $entry) = $q->getEntry($query)); if (!$entry) { $count--; $update = true; continue; } $content .= "<li>\n\t\t\t<blockquote class=\"comment-quote\" cite=\"comments.php?entry={$arr['entry']}#{$arr['id']}\">\n\t\t\t{$arr['content']}\n\t\t\t<p><a href=\"" . get_comments_link($arr['entry']) . "#{$arr['id']}\">{$arr['name']} - {$entry['subject']}</a></p>\n\t\t\t</blockquote></li>\n"; } $subject = $lang['plugin']['lastcomments']['last'] . ' ' . $count . ' ' . $lang['plugin']['lastcomments']['comments']; } if (!$count) { if ($update) { fs_delete(LASTCOMMENTS_CACHE_FILE); } $content .= '<li>' . $lang['plugin']['lastcomments']['no_comments'] . '</li>'; $subject = $lang['plugin']['lastcomments']['no_new_comments']; } $content .= '</ul>'; $entry['subject'] = $subject; $entry['content'] = $content; return $entry; }
function search_do($keywords) { global $smarty, $srchresults; // get parameters $srchkeywords = $keywords; $params = array(); $params['start'] = 0; $params['count'] = -1; !empty($_GET['Date_Day']) && $_GET['Date_Day'] != '--' ? $params['d'] = $_GET['Date_Day'] : null; isset($_GET['Date_Month']) && $_GET['Date_Month'] != '--' ? $params['m'] = $_GET['Date_Month'] : null; !empty($_GET['Date_Year']) && $_GET['Date_Year'] != '--' ? $params['y'] = substr($_GET['Date_Year'], 2) : null; isset($_GET['cats']) ? $params = $_GET['cats'] : null; $params['fullparse'] = false; if (!empty($_GET['stype']) && $_GET['stype'] == 'full') { $params['fullparse'] = true; } $srchparams = $params; $list = array(); $q = new FPDB_Query($params, null); while ($q->hasMore()) { list($id, $e) = $q->getEntry(); $match = false; if ($keywords == '*') { $match = true; } else { $match = strpos(strtolower($e['subject']), $keywords) !== false; if (!$match && $params['fullparse']) { $match = strpos(strtolower($e['content']), $keywords) !== false; } } if ($match) { $list[$id] = $e; } } $smarty->register_block('search_result_block', 'smarty_search_results_block'); $smarty->register_block('search_result', 'smarty_search_result'); if (!$list) { $smarty->assign('noresults', true); } $srchresults = $list; }
function plugin_lastentries_widget() { global $fpdb; // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:lastentries'); $num = 10; #################### /* $queryId = $fpdb->query("fullparse:false,start:0,count:$num"); $fpdb->doquery($queryId); $fpdb->getQuery */ $q = new FPDB_Query(array('fullparse' => false, 'start' => 0, 'count' => $num), null); $string = '<ul>'; $count = 0; while ($q->hasmore()) { list($id, $entry) = $q->getEntry(); $link = get_permalink($id); $string .= '<li>'; $admin = BLOG_BASEURL . "admin.php?p=entry&entry="; if (user_loggedin()) { // if loggedin prints a "edit" link $string .= "<a href=\"{$admin}{$id}\">[" . $lang['plugin']['lastentries']['edit'] . "]</a>"; } $string .= "<a href=\"{$link}\">{$entry['subject']}</a></li>\n"; $count++; } if ($string == '<ul>') { $string .= '<li><a href="admin.php?p=entry&action=write">' . $lang['plugin']['lastentries']['add_entry'] . '</a></li>'; $subject = $lang['plugin']['lastentries']['no_entries']; } else { $subject = $lang['plugin']['lastentries']['subject_before_count'] . $count . $lang['plugin']['lastentries']['subject_after_count']; } $string .= '</ul>'; $widget = array(); $widget['subject'] = $subject; $widget['content'] = $string; return $widget; }
function cache_create() { $this->index = array(); /* $o =& entry_init(); $entries = $o->getList(); */ $o = new FPDB_Query(array('start' => 0, 'count' => -1, 'fullparse' => false), null); #foreach ($entries as $id => $contents) { while ($o->hasMore()) { list($id, $contents) = $o->getEntry(); $date = date_from_id($id); echo $contents['subject'], "\n"; $md5 = md5(sanitize_title($contents['subject'])); $this->index[$date['y']][$date['m']][$date['d']][$md5] = $id; } #} $this->cache_save(); io_write_file(PRETTYURLS_CACHE, 'dummy'); }
function commentform() { global $smarty, $lang, $fpdb, $fp_params; $comment_formid = 'fp-comments'; $smarty->assign('comment_formid', $comment_formid); if (!empty($_POST)) { # utils_nocache_headers(); // add http to url if (!empty($_POST['url']) && strpos($_POST['url'], 'http://') === false) { $_POST['url'] = 'http://' . $_POST['url']; } // custom hook here!! if ($arr = comment_validate()) { global $fp_config; $id = comment_save($fp_params['entry'], $arr); do_action('comment_post', $fp_params['entry'], array($id, $arr)); $q = new FPDB_Query(array('id' => $fp_params['entry'], 'fullparse' => false), null); list($entryid, $e) = $q->getEntry(); if ($fp_config['general']['notify'] && !user_loggedin()) { global $post; $comm_mail = isset($arr['email']) ? "<{$arr['email']}>" : ''; $from_mail = $fp_config['general']['email']; $post = $e; // plugin such as prettyurls might need this... $lang = lang_load('comments'); $mail = str_replace(array('%toname%', '%fromname%', '%frommail%', '%entrytitle%', '%commentlink%', '%content%', '%blogtitle%'), array($fp_config['general']['author'], $arr['name'], $comm_mail, $e['subject'], get_comments_link($entryid) . '#' . $id, $arr['content'], $fp_config['general']['title']), $lang['comments']['mail']); @utils_mail($from_mail, "New comment on {$fp_config['general']['title']}", $mail); } // if comment is valid, this redirect will clean the postdata $location = str_replace('&', '&', get_comments_link($entryid)) . '#' . $id; utils_redirect($location, true); exit; } else { $smarty->assign('values', $_POST); } } // Cookies $smarty->assign('cookie', array('name' => @$_COOKIE['comment_author_' . COOKIEHASH], 'email' => @$_COOKIE['comment_author_email_' . COOKIEHASH], 'url' => @$_COOKIE['comment_author_url_' . COOKIEHASH])); }