From c2accdedcc07a607fb8b3b811ae812c28fd8db47 Mon Sep 17 00:00:00 2001 From: azett Date: Sat, 24 Oct 2020 20:42:59 +0200 Subject: [PATCH] Description and authors of all default plugins reworked. (Original plugin authors are mentioned in CONTRIBUTORS.md from now on.) --- .../plugin.accessibleantispam.php | 140 ++-- fp-plugins/adminarea/plugin.adminarea.php | 8 +- fp-plugins/akismet/plugin.akismet.php | 85 +- fp-plugins/archives/plugin.archives.php | 151 ++-- fp-plugins/bbcode/plugin.bbcode.php | 10 +- fp-plugins/blockparser/plugin.blockparser.php | 8 +- fp-plugins/calendar/plugin.calendar.php | 46 +- fp-plugins/categories/plugin.categories.php | 30 +- .../commentcenter/plugin.commentcenter.php | 4 +- fp-plugins/favicon/plugin.favicon.php | 25 +- fp-plugins/footnotes/plugin.footnotes.php | 10 +- fp-plugins/jquery/plugin.jquery.php | 32 +- .../lastcomments/plugin.lastcomments.php | 197 +++-- .../plugin.lastcommentsadmin.php | 65 +- fp-plugins/lastentries/plugin.lastentries.php | 83 +- fp-plugins/lightbox2/plugin.lightbox2.php | 46 +- .../mediamanager/plugin.mediamanager.php | 60 +- fp-plugins/postviews/plugin.postviews.php | 45 +- fp-plugins/prettyurls/plugin.prettyurls.php | 777 +++++++++--------- fp-plugins/qspam/plugin.qspam.php | 85 +- fp-plugins/readmore/plugin.readmore.php | 10 +- fp-plugins/searchbox/plugin.searchbox.php | 8 +- fp-plugins/thumb/plugin.thumb.php | 116 +-- 23 files changed, 1011 insertions(+), 1030 deletions(-) diff --git a/fp-plugins/accessibleantispam/plugin.accessibleantispam.php b/fp-plugins/accessibleantispam/plugin.accessibleantispam.php index 1fe73c7..86fc524 100755 --- a/fp-plugins/accessibleantispam/plugin.accessibleantispam.php +++ b/fp-plugins/accessibleantispam/plugin.accessibleantispam.php @@ -1,22 +1,20 @@ append('error', $lang['plugin']['accessibleantispam']['error']); + + $smarty->append('error', $lang ['plugin'] ['accessibleantispam'] ['error']); } - - if ( AASPAM_DEBUG && $f=@fopen(AASPAM_LOG, 'a') ) { - $arr['aaspam-q'] = $_POST['aaspam']; - $arr['aaspam-a'] = $v; - $arr['SUCCESS'] = $ret; - - $s = date('r'). "|" . session_id().'|'.utils_kimplode($arr)."\r\n"; - @fwrite($f, $s); - @fclose($f); - } - - + + if (AASPAM_DEBUG && $f = @fopen(AASPAM_LOG, 'a')) { + $arr ['aaspam-q'] = $_POST ['aaspam']; + $arr ['aaspam-a'] = $v; + $arr ['SUCCESS'] = $ret; + + $s = date('r') . "|" . session_id() . '|' . utils_kimplode($arr) . "\r\n"; + @fwrite($f, $s); + @fclose($f); + } + return $ret; } function plugin_aaspam_comment_form() { - + // we get a random arithmetic operation // between sum, subtraction and multiplication; - + // we intentionally left out division because // it can lead to situations like division by zero // or floating point numbers + $myop = array_rand($ops = array( + '+', + '-', + '*' + )); + $op = $ops [$myop]; - $myop = array_rand($ops=array('+','-','*')); - $op=$ops[$myop]; - // we get two random integers between 1 and 10 $v1 = mt_rand(1, 10); - // we rand $v2 until it differs from $v1 - // (otherwise result for subtractions is zero) - while (($v2 = mt_rand(1, 10))==$v1); - + // we rand $v2 until it differs from $v1 + // (otherwise result for subtractions is zero) + while (($v2 = mt_rand(1, 10)) == $v1) + ; + // if operation is subtraction // the higher number must always come first // or you'll get a negative integer - if ($v2>$v1 && $op=='-') { + if ($v2 > $v1 && $op == '-') { $tmp = $v1; $v1 = $v2; $v2 = $tmp; - } // execute the operation - switch($op) { - case '+' : - $v = $v1+$v2; + switch ($op) { + case '+': + $v = $v1 + $v2; break; - case '-' : - $v = $v1-$v2; + case '-': + $v = $v1 - $v2; break; - case '*' : - $v = $v1*$v2; + case '*': + $v = $v1 * $v2; break; - } - + } - sess_add('aaspam', $v); - + // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:accessibleantispam'); - - $langstrings =& $lang['plugin']['accessibleantispam']; - + + $langstrings = & $lang ['plugin'] ['accessibleantispam']; + // get the correct question depending on the operation - switch($op) { - case '+' : - $question = $langstrings['sum']; + switch ($op) { + case '+': + $question = $langstrings ['sum']; break; - case '-' : - $question = $langstrings['sub']; + case '-': + $question = $langstrings ['sub']; break; - case '*' : - $question = $langstrings['prod']; + case '*': + $question = $langstrings ['prod']; break; - } - + } + // format the question with numbers at the proper positions $question = sprintf($question, $v1, $v2); - - if ( AASPAM_DEBUG && $f=@fopen(AASPAM_LOG, 'a') ) { - $arr['aaspam-q'] = $v; - @fwrite($f, date('r'). '|'.session_id() .'|'. utils_kimplode($arr)."\r\n"); + + if (AASPAM_DEBUG && $f = @fopen(AASPAM_LOG, 'a')) { + $arr ['aaspam-q'] = $v; + @fwrite($f, date('r') . '|' . session_id() . '|' . utils_kimplode($arr) . "\r\n"); @fclose($f); } - + // echoes the question and the form part echo <<
-

-STR; - +


+

+ STR; } - ?> diff --git a/fp-plugins/adminarea/plugin.adminarea.php b/fp-plugins/adminarea/plugin.adminarea.php index 5d8d10c..f446f9e 100644 --- a/fp-plugins/adminarea/plugin.adminarea.php +++ b/fp-plugins/adminarea/plugin.adminarea.php @@ -2,11 +2,11 @@ /* * Plugin Name: AdminArea - * Plugin URI: http://www.nowhereland.it/ - * Description: AdminArea plugin. Part of the standard distribution ;) - * Author: NoWhereMan + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: AdminArea plugin. Part of the standard distribution. * Version: 1.0 - * Author URI: http://www.nowhereland.it/ */ function plugin_adminarea_widget() { diff --git a/fp-plugins/akismet/plugin.akismet.php b/fp-plugins/akismet/plugin.akismet.php index 20d4401..890bb51 100644 --- a/fp-plugins/akismet/plugin.akismet.php +++ b/fp-plugins/akismet/plugin.akismet.php @@ -1,14 +1,12 @@ setAuthor($contents['name']); - $akismet->setAuthorEmail(isset($contents['email'])? $contents['email'] : ''); - $akismet->setAuthorURL(isset($contents['url'])? $contents['url'] : ''); - $akismet->setContent($contents['content']); - - if ($v= $akismet->isSpam()){ - global $smarty; - $smarty->assign('error', array('ERROR: Comment is invalid')); + if (!$bool) return false; - } + + global $fp_config; + + $akismet = new Akismet($fp_config ['general'] ['www'], plugin_getoptions('akismet', 'apikey')); + $akismet->setAuthor($contents ['name']); + $akismet->setAuthorEmail(isset($contents ['email']) ? $contents ['email'] : ''); + $akismet->setAuthorURL(isset($contents ['url']) ? $contents ['url'] : ''); + $akismet->setContent($contents ['content']); + + if ($v = $akismet->isSpam()) { + global $smarty; + $smarty->assign('error', array( + 'ERROR: Comment is invalid' + )); + return false; + } return true; } -if (class_exists('AdminPanelAction')){ +if (class_exists('AdminPanelAction')) { + + class admin_plugin_akismet extends AdminPanelAction { - class admin_plugin_akismet extends AdminPanelAction { - var $langres = 'plugin:akismet'; - + function setup() { $this->smarty->assign('admin_resource', "plugin:akismet/admin.plugin.akismet"); } - + function main() { $akismetconf = plugin_getoptions('akismet'); $this->smarty->assign('akismetconf', $akismetconf); } - + function onsubmit() { global $fp_config; - - if ($_POST['wp-apikey']){ - - plugin_addoption('akismet', 'apikey', $_POST['wp-apikey']); + + if ($_POST ['wp-apikey']) { + + plugin_addoption('akismet', 'apikey', $_POST ['wp-apikey']); plugin_saveoptions('akismet'); - + $this->smarty->assign('success', 1); } else { - $this->smarty->assign('success', -1); + $this->smarty->assign('success', -1); } - + return 2; } - + } admin_addpanelaction('plugin', 'akismet', true); - } diff --git a/fp-plugins/archives/plugin.archives.php b/fp-plugins/archives/plugin.archives.php index d00061d..760fd37 100644 --- a/fp-plugins/archives/plugin.archives.php +++ b/fp-plugins/archives/plugin.archives.php @@ -1,86 +1,84 @@ _directory === $directory) { - // add year to the list (do not closes li, because - // we may have nested elements) - $this->_year = $file; - $lnk = get_year_link($file); - $this->_htmllist[$this->_year] = "
  • 20$file"; - return 1; - } elseif (is_dir($f)) { - $this->_months[] = $file; - return 0; - } + + var $_directory = CONTENT_DIR; + + var $_list = array(); + + var $_htmllist = array(); + + var $_months = array(); + + var $_year = ''; + + function _checkFile($directory, $file) { + $f = "$directory/$file"; + + if (ctype_digit($file)) { + if ($this->_directory === $directory) { + // add year to the list (do not closes li, because + // we may have nested elements) + $this->_year = $file; + $lnk = get_year_link($file); + $this->_htmllist [$this->_year] = "
  • 20$file"; + return 1; + } elseif (is_dir($f)) { + $this->_months [] = $file; + return 0; } } - - function _exitingDir($directory = null, $file=null) { - - $y = $this->_year; - - if ($mos =& $this->_months) { - sort($mos); - $list = ''; - $linearlist = array(); - foreach($mos as $mth) { - $lnk = get_month_link($y, $mth); - $the_month = theme_date_format( mktime(0, 0, 0, $mth, 1, 0 ), '%B'); - $list = "
  • ". - $the_month - .'
  • ' . $list; - $linearlist["$the_month 20{$this->_year}"] = $lnk; - } - $list = ''; + } + + function _exitingDir($directory = null, $file = null) { + $y = $this->_year; + + if ($mos = & $this->_months) { + sort($mos); + $list = ''; + $linearlist = array(); + foreach ($mos as $mth) { + $lnk = get_month_link($y, $mth); + $the_month = theme_date_format(mktime(0, 0, 0, $mth, 1, 0), '%B'); + $list = "
  • " . $the_month . '
  • ' . $list; + $linearlist ["$the_month 20{$this->_year}"] = $lnk; } - - $mos = array(); - - // we close year's li - $this->_list[$y] = $linearlist; - $this->_htmllist[$y] .= $list . ''; + $list = ''; } - function getList() { - krsort($this->_list); - return $this->_list; - } - - function getHtmlList() { - krsort($this->_htmllist); - return implode($this->_htmllist); - } - - + $mos = array(); + + // we close year's li + $this->_list [$y] = $linearlist; + $this->_htmllist [$y] .= $list . ''; + } + + function getList() { + krsort($this->_list); + return $this->_list; + } + + function getHtmlList() { + krsort($this->_htmllist); + return implode($this->_htmllist); + } + } - function plugin_archives_head() { - global $PLUGIN_ARCHIVES_MONTHLIST; - $PLUGIN_ARCHIVES_MONTHLIST = new plugin_archives_monthlist; + $PLUGIN_ARCHIVES_MONTHLIST = new plugin_archives_monthlist(); echo "\n\n"; - foreach($PLUGIN_ARCHIVES_MONTHLIST->getList() as $y => $months) { + foreach ($PLUGIN_ARCHIVES_MONTHLIST->getList() as $y => $months) { foreach ($months as $ttl => $link) echo "\n"; } @@ -90,19 +88,14 @@ function plugin_archives_head() { add_filter('wp_head', 'plugin_archives_head'); function plugin_archives_widget() { - lang_load('plugin:archives'); global $lang, $PLUGIN_ARCHIVES_MONTHLIST; - - + return array( - 'subject' => $lang['plugin']['archives']['subject'], - - 'content' => ($list = $PLUGIN_ARCHIVES_MONTHLIST->getHtmlList()) ? - '' - : - "

    {$lang['plugin']['archives']['no_posts']}

    " - ); + 'subject' => $lang ['plugin'] ['archives'] ['subject'], + + 'content' => ($list = $PLUGIN_ARCHIVES_MONTHLIST->getHtmlList()) ? '' : "

    {$lang['plugin']['archives']['no_posts']}

    " + ); } register_widget('archives', 'Archives', 'plugin_archives_widget'); diff --git a/fp-plugins/bbcode/plugin.bbcode.php b/fp-plugins/bbcode/plugin.bbcode.php index 2b6a2d3..8da1d52 100644 --- a/fp-plugins/bbcode/plugin.bbcode.php +++ b/fp-plugins/bbcode/plugin.bbcode.php @@ -1,11 +1,11 @@ BBCode markup; provides automatic integration with lightbox. - * Author: Hydra, NoWhereMan - * Author URI: http://flatpress.sf.net + * Version: 1.6 + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Allows using BBCode markup; provides automatic integration with lightbox. Part of the standard distribution. */ require (plugin_getdir('bbcode') . '/inc/stringparser_bbcode.class.php'); require (plugin_getdir('bbcode') . '/panels/admin.plugin.panel.bbcode.php'); diff --git a/fp-plugins/blockparser/plugin.blockparser.php b/fp-plugins/blockparser/plugin.blockparser.php index 3947524..ccc463b 100644 --- a/fp-plugins/blockparser/plugin.blockparser.php +++ b/fp-plugins/blockparser/plugin.blockparser.php @@ -2,12 +2,12 @@ /* * Plugin Name: BlockParser - * Plugin URI: http://www.nowhereland.it/ * Type: Block - * Description: BlockParser plugin. Part of the standard distribution ;) This allow you to use simple non-plugin custom blocks :) - * Author: NoWhereMan real_nowhereman at user dot sf dot net * Version: 1.0 - * Author URI: http://www.nowhereland.it/ + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Allows you to use simple non-plugin custom blocks. Part of the standard distribution. */ // define('BLOCKS_DIR', CONTENT_DIR . 'blocks/'); diff --git a/fp-plugins/calendar/plugin.calendar.php b/fp-plugins/calendar/plugin.calendar.php index 86a3cc0..a8cb584 100755 --- a/fp-plugins/calendar/plugin.calendar.php +++ b/fp-plugins/calendar/plugin.calendar.php @@ -3,11 +3,11 @@ /* * Plugin Name: Calendar * Version: 1.1 - * Plugin URI: http://flatpress.sf.net * Type: Block - * Description: Adds a Calendar block level element - * Author: NoWhereMan - * Author URI: http://flatpress.sf.net + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Adds a calendar widget. Part of the standard distribution. */ // PHP Calendar (version 2.3), written by Keith Devens @@ -19,17 +19,17 @@ function generate_calendar($year, $month, $days = array(), $day_name_length = 3, // remember that mktime will automatically correct if invalid dates are entered // for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998 // this provides a built in "rounding" feature to generate_calendar() - + $day_names = array(); // generate all the day names according to the current locale for($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) // January 4, 1970 was a Sunday $day_names [$n] = ucfirst(date_strformat('%A', $t)); // %A means full textual day name - + list ($month, $year, $month_name, $weekday) = explode(',', date_strformat('%m,%Y,%B,%w', $first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; // adjust for $first_day $title = htmlentities(ucfirst($month_name)) . ' ' . $year; // note that some locales don't capitalize month and day names - + // Begin calendar. Uses a real . See http://diveintomark.org/archives/2002/07/03 - + // PHP7 compatibility: Since $pn is never passed, we do not need to create "previous" and "next" elements. $p = ''; $n = ''; @@ -37,16 +37,16 @@ function generate_calendar($year, $month, $days = array(), $day_name_length = 3, // @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable // if($p) $p = ''.($pl ? ''.$p.'' : $p).' '; // if($n) $n = ' '.($nl ? ''.$n.'' : $n).''; - + $calendar = '' . "\n" . '\n"; - + if ($day_name_length) { // if the day names should be shown ($day_name_length > 0) // if day_name_length is >3, the full name of the day will be printed foreach ($day_names as $d) $calendar .= ''; $calendar .= "\n"; } - + if ($weekday > 0) $calendar .= ''; // initial 'empty' days for($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) { @@ -64,49 +64,49 @@ function generate_calendar($year, $month, $days = array(), $day_name_length = 3, } if ($weekday != 7) $calendar .= ''; // remaining "empty" days - + return $calendar . "\n
    ' . $p . ($month_href ? '' . $title . '' : $title) . $n . "
    ' . htmlentities($day_name_length < 4 ? substr($d, 0, $day_name_length) : $d) . '
      
    \n"; } function plugin_calendar_widget() { global $fp_params; - + $y = isset($fp_params ['y']) ? $fp_params ['y'] : date('y'); $m = isset($fp_params ['m']) ? $fp_params ['m'] : date('m'); - + global $fpdb; - + $q = new FPDB_Query(array( 'fullparse' => false, 'y' => $y, 'm' => $m, 'count' => -1 ), null); - + $days = array(); - + while ($q->hasmore($queryId)) { - + list ($id, $entry) = $q->getEntry($queryId); $date = date_from_id($id); $d = (int) $date ['d']; - + $days [$d] = array( get_day_link($y, $m, str_pad($d, 2, '0', STR_PAD_LEFT)), 'linked-day' ); - + $count++; } - + // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:calendar'); - + $widget = array(); $widget ['subject'] = $lang ['plugin'] ['calendar'] ['subject']; $widget ['content'] = ''; - + return $widget; } diff --git a/fp-plugins/categories/plugin.categories.php b/fp-plugins/categories/plugin.categories.php index 4425057..25b4446 100755 --- a/fp-plugins/categories/plugin.categories.php +++ b/fp-plugins/categories/plugin.categories.php @@ -1,34 +1,32 @@ assign('categories_showcount', false); - + // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:categories'); - - $entry['subject'] = $lang['plugin']['categories']['subject']; - $entry['content'] = $smarty->fetch('plugin:categories/widget'); + + $entry ['subject'] = $lang ['plugin'] ['categories'] ['subject']; + $entry ['content'] = $smarty->fetch('plugin:categories/widget'); return $entry; } diff --git a/fp-plugins/commentcenter/plugin.commentcenter.php b/fp-plugins/commentcenter/plugin.commentcenter.php index 33f6b68..a15ba3d 100644 --- a/fp-plugins/commentcenter/plugin.commentcenter.php +++ b/fp-plugins/commentcenter/plugin.commentcenter.php @@ -4,9 +4,9 @@ * Plugin Name: Comment Center * Version: 1.1.2 * Plugin URI: https://www.flatpress.org - * Description: Manage your blog's comments: Set policies, publish or reject comments. - * Author: FlatPress (credits to Piero VDFN) + * Author: FlatPress * Author URI: https://www.flatpress.org + * Description: Manage your blog's comments: Set policies, publish or reject comments. Part of the standard distribution. */ /** diff --git a/fp-plugins/favicon/plugin.favicon.php b/fp-plugins/favicon/plugin.favicon.php index 6e949d7..c1e4cde 100755 --- a/fp-plugins/favicon/plugin.favicon.php +++ b/fp-plugins/favicon/plugin.favicon.php @@ -1,21 +1,20 @@ '; + echo ''; } - + add_action('wp_head', 'plugin_favicon_head'); - + ?> diff --git a/fp-plugins/footnotes/plugin.footnotes.php b/fp-plugins/footnotes/plugin.footnotes.php index 47a1d27..f7dda8c 100755 --- a/fp-plugins/footnotes/plugin.footnotes.php +++ b/fp-plugins/footnotes/plugin.footnotes.php @@ -1,11 +1,11 @@ jQuery locally. -Author: Piero VDFN -Author URI: http://www.vdfn.altervista.org/ -JQuery and JQueryUI version bump by Arvid Zimmermann -*/ - -## Original author: NoWhereMan (http://www.nowhereland.it) + * Plugin Name: jQuery + * Version: 2.0.1 + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Provides jQuery locally. Part of the standard distribution. + */ +// # Original author: NoWhereMan (http://www.nowhereland.it) add_action('wp_head', 'plugin_jquery_head', 0); - function plugin_jquery_head() { - - $pdir=plugin_geturl('jquery'); + $pdir = plugin_geturl('jquery'); echo << - - - -JSUTILS; + + + + + JSUTILS; } ?> diff --git a/fp-plugins/lastcomments/plugin.lastcomments.php b/fp-plugins/lastcomments/plugin.lastcomments.php index 1f6c72e..e15d462 100644 --- a/fp-plugins/lastcomments/plugin.lastcomments.php +++ b/fp-plugins/lastcomments/plugin.lastcomments.php @@ -1,32 +1,30 @@ '; - + // cimangi Aggiunta traduzione stringhe // load plugin strings @@ -36,48 +34,47 @@ function plugin_lastcomments_widget() { if ($count = count($list)) { while ($arr = array_pop($list)) { theme_comments_filters($arr, $id); - - - $q = new FPDB_Query(array('id' => $arr['entry']), null); + + $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){ + @list (, $entry) = $q->getEntry($query); + + if (!$entry) { $count--; - $update = true; + $update = true; continue; } - $content .= - "
  • + $content .= "
  • {$arr['content']} -

    {$arr['name']} - {$entry['subject']}

    +

    {$arr['name']} - {$entry['subject']}

  • \n"; } - $subject = $lang['plugin']['lastcomments']['last'] . ' ' . $count . ' '. $lang['plugin']['lastcomments']['comments']; + $subject = $lang ['plugin'] ['lastcomments'] ['last'] . ' ' . $count . ' ' . $lang ['plugin'] ['lastcomments'] ['comments']; } - + if (!$count) { if ($update) fs_delete(LASTCOMMENTS_CACHE_FILE); - $content .= '
  • ' . $lang['plugin']['lastcomments']['no_comments'] .'
  • '; - $subject = $lang['plugin']['lastcomments']['no_new_comments']; - } - + $content .= '
  • ' . $lang ['plugin'] ['lastcomments'] ['no_comments'] . '
  • '; + $subject = $lang ['plugin'] ['lastcomments'] ['no_new_comments']; + } + $content .= ''; - $entry['subject'] = $subject; - $entry['content'] = $content; - + $entry ['subject'] = $subject; + $entry ['content'] = $content; + return $entry; } /** * function plugin_lastcomments_cache - * + * * comment cache is a reverse queue; we put * element on the top, and we delete elements * from bottom; this is because the output @@ -85,104 +82,102 @@ function plugin_lastcomments_widget() { * All this headache stuff just to say that * in the end the widget will show up elements ordered * from newer to older :P - * - * @param $entryid string entry id i.e. entryNNNNNN-NNNNNN - * @param $comment array where $comment[0] is $commentid i.e. commentNNNNNN-NNNNNN - * and $comment[1] is the actual content array + * + * @param $entryid string + * entry id i.e. entryNNNNNN-NNNNNN + * @param $comment array + * where $comment[0] is $commentid i.e. commentNNNNNN-NNNNNN + * and $comment[1] is the actual content array */ - - function plugin_lastcomments_cache($entryid, $comment) { // max num of chars per comment $CHOP_AT = 30; - - list($id, $content) = $comment; - + list ($id, $content) = $comment; + comment_clean($content); - - - if (false===($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { + + if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { // no comments in cache - $list = array(); + $list = array(); } else { // if file exists and its correctly read, we get the stored list // (it is stored in encoded form) $list = unserialize($f); - - if (count($list)+1 > LASTCOMMENTS_MAX) { + + if (count($list) + 1 > LASTCOMMENTS_MAX) { // comments are more than allowed maximum: - // we delete the last in queue. + // we delete the last in queue. array_shift($list); } } - - if (strlen($content['content']) > $CHOP_AT) { - $string = substr($content['content'], 0, $CHOP_AT) . '...'; - } else {$string = $content['content'];} - - array_push($list, array('name'=>$content['name'], - 'content'=>$string, - 'id'=> $id, - 'entry'=> $entryid) - ); - + + if (strlen($content ['content']) > $CHOP_AT) { + $string = substr($content ['content'], 0, $CHOP_AT) . '...'; + } else { + $string = $content ['content']; + } + + array_push($list, array( + 'name' => $content ['name'], + 'content' => $string, + 'id' => $id, + 'entry' => $entryid + )); + return io_write_file(LASTCOMMENTS_CACHE_FILE, serialize($list)); - - } register_widget('lastcomments', 'LastComments', 'plugin_lastcomments_widget'); -function plugin_lastcomments_rss () { +function plugin_lastcomments_rss() { global $smarty; - - - if (false===($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { + + if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) { // no comments in cache - $list = array(); + $list = array(); } else { // if file exists and its correctly read, we get the stored list // (it is stored in encoded form) $list = unserialize($f); } - + $newlist = array(); - foreach($list as $c) { - $newlist[] = comment_parse($list['entryid'], $list['id']); + foreach ($list as $c) { + $newlist [] = comment_parse($list ['entryid'], $list ['id']); } - + $smarty->assign('lastcomments_list', $newlist); } /* - -function plugin_lastcomments_def_rss_link() { - return BLOG_BASEURL . "?feed=lastcomments-rss2"; -} - -function plugin_lastcomments_rss_link() { - return apply_filters('plugin_lastcomments_rss_link', ''); -} - -add_action('wp_head', 'plugin_lastcomments_rsshead'); -function plugin_lastcomments_rsshead() { - echo "\n\n"; -} - -add_action('init', 'plugin_lastcomments_rssinit'); -function plugin_lastcomments_rssinit() { - global $smarty; - - if (isset($_GET['feed']) && $_GET['feed']=='lastcomments-rss2') { - $smarty->display('plugin:lastcomments/plugin.lastcomments-feed'); - exit(); - } -} - -*/ + * + * function plugin_lastcomments_def_rss_link() { + * return BLOG_BASEURL . "?feed=lastcomments-rss2"; + * } + * + * function plugin_lastcomments_rss_link() { + * return apply_filters('plugin_lastcomments_rss_link', ''); + * } + * + * add_action('wp_head', 'plugin_lastcomments_rsshead'); + * function plugin_lastcomments_rsshead() { + * echo "\n\n"; + * } + * + * add_action('init', 'plugin_lastcomments_rssinit'); + * function plugin_lastcomments_rssinit() { + * global $smarty; + * + * if (isset($_GET['feed']) && $_GET['feed']=='lastcomments-rss2') { + * $smarty->display('plugin:lastcomments/plugin.lastcomments-feed'); + * exit(); + * } + * } + * + */ ?> diff --git a/fp-plugins/lastcommentsadmin/plugin.lastcommentsadmin.php b/fp-plugins/lastcommentsadmin/plugin.lastcommentsadmin.php index 647e4bfb..330a55c 100644 --- a/fp-plugins/lastcommentsadmin/plugin.lastcommentsadmin.php +++ b/fp-plugins/lastcommentsadmin/plugin.lastcommentsadmin.php @@ -1,65 +1,68 @@ smarty->assign('admin_resource', "plugin:lastcommentsadmin/admin.plugin.lastcommentsadmin"); } - + function main() { - if (!function_exists('plugin_lastcomments_cache')){ + if (!function_exists('plugin_lastcomments_cache')) { $this->smarty->assign('success', -2); } } - + function onsubmit($data = NULL) { global $fp_config; - - if (isset($_POST['lastcommentadmin_clear'])){ + + if (isset($_POST ['lastcommentadmin_clear'])) { fs_delete(LASTCOMMENTS_CACHE_FILE); $this->smarty->assign('success', 1); } - - if (isset($_POST['lastcommentadmin_rebuild'])){ + + if (isset($_POST ['lastcommentadmin_rebuild'])) { fs_delete(LASTCOMMENTS_CACHE_FILE); $coms = Array(); - - $q = new FPDB_Query(array('fullparse'=>false,'start'=>0,'count'=>-1), null); + + $q = new FPDB_Query(array( + 'fullparse' => false, + 'start' => 0, + 'count' => -1 + ), null); while ($q->hasmore()) { - list($id,$e) = $q->getEntry(); + list ($id, $e) = $q->getEntry(); $obj = new comment_indexer($id); - foreach($obj->getList() as $value){ - $coms[$value]=$id; + foreach ($obj->getList() as $value) { + $coms [$value] = $id; } ksort($coms); - $coms = array_slice($coms, -LASTCOMMENTS_MAX ); + $coms = array_slice($coms, -LASTCOMMENTS_MAX); } - foreach($coms as $cid=>$eid){ + foreach ($coms as $cid => $eid) { $c = comment_parse($eid, $cid); - plugin_lastcomments_cache($eid, array($cid, $c)); + plugin_lastcomments_cache($eid, array( + $cid, + $c + )); } $this->smarty->assign('success', 2); } - + return 2; } - + } admin_addpanelaction('plugin', 'lastcommentsadmin', true); - } \ No newline at end of file diff --git a/fp-plugins/lastentries/plugin.lastentries.php b/fp-plugins/lastentries/plugin.lastentries.php index 6a8fae8..1afd343 100755 --- a/fp-plugins/lastentries/plugin.lastentries.php +++ b/fp-plugins/lastentries/plugin.lastentries.php @@ -1,65 +1,68 @@ query("fullparse:false,start:0,count:$num"); - $fpdb->doquery($queryId); - - $fpdb->getQuery - */ - - $q = new FPDB_Query(array('fullparse'=>false,'start'=>0,'count'=>$num), null); - + * $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 = '
      '; - - + $count = 0; - + while ($q->hasmore()) { - - list($id, $entry) = $q->getEntry(); - + + list ($id, $entry) = $q->getEntry(); + $link = get_permalink($id); - - $string .='
    • '; + + $string .= '
    • '; $admin = BLOG_BASEURL . "admin.php?p=entry&entry="; if (user_loggedin()) // if loggedin prints a "edit" link - $string .= "[".$lang['plugin']['lastentries']['edit']."]"; + $string .= "[" . $lang ['plugin'] ['lastentries'] ['edit'] . "]"; $string .= "{$entry['subject']}
    • \n"; $count++; } - - if ($string == '
        '){ - $string .= '
      • '.$lang['plugin']['lastentries']['add_entry'].'
      • '; - $subject = $lang['plugin']['lastentries']['no_entries']; - } else $subject = $lang['plugin']['lastentries']['subject_before_count'] . $count . $lang['plugin']['lastentries']['subject_after_count']; - + + if ($string == '
          ') { + $string .= '
        • ' . $lang ['plugin'] ['lastentries'] ['add_entry'] . '
        • '; + $subject = $lang ['plugin'] ['lastentries'] ['no_entries']; + } else + $subject = $lang ['plugin'] ['lastentries'] ['subject_before_count'] . $count . $lang ['plugin'] ['lastentries'] ['subject_after_count']; + $string .= '
        '; $widget = array(); - $widget['subject'] = $subject; - $widget['content'] = $string; - + $widget ['subject'] = $subject; + $widget ['content'] = $string; + return $widget; } diff --git a/fp-plugins/lightbox2/plugin.lightbox2.php b/fp-plugins/lightbox2/plugin.lightbox2.php index ecb1660..1d5d8ea 100644 --- a/fp-plugins/lightbox2/plugin.lightbox2.php +++ b/fp-plugins/lightbox2/plugin.lightbox2.php @@ -1,47 +1,45 @@ SlimBox 2 requires jQuery (modified jsutils plugin) -Author: Piero VDFN -Author URI: http://www.vdfn.altervista.org/ -*/ -## Original author: NoWhereMan (http://www.nowhereland.it) +/* + * Plugin Name: LightBox2 + * Version: 2.0 + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Lightbox overlays using SlimBox 2 requires jQuery (modified jsutils plugin). Part of the standard distribution. + */ + +// # Original author: NoWhereMan (http://www.nowhereland.it) // if PLUGINS_DIR is not fp-plugins please edit res/lightbox.js - function plugin_lightbox2_setup() { - return function_exists('plugin_jquery_head')? 1:-1; + return function_exists('plugin_jquery_head') ? 1 : -1; } function plugin_lightbox2_head() { - - $pdir=plugin_geturl('lightbox2'); + $pdir = plugin_geturl('lightbox2'); echo << - - -LBOXHEAD; + + + + LBOXHEAD; } add_action('wp_head', 'plugin_lightbox2_head'); function plugin_lightbox2_footer() { - - $pdir=plugin_geturl('lightbox2'); + $pdir = plugin_geturl('lightbox2'); echo << - - -LBOXHEAD; + + + + LBOXHEAD; } add_action('wp_footer', 'plugin_lightbox2_footer'); function plugin_lightbox2_hook($popup, $abspath) { global $lightbox_rel; // the other $popup is just dropped - return $lightbox_rel? "rel=\"lightbox[$lightbox_rel]\"" : ' rel="lightbox"'; + return $lightbox_rel ? "rel=\"lightbox[$lightbox_rel]\"" : ' rel="lightbox"'; } add_action('bbcode_img_popup', 'plugin_lightbox2_hook', 5, 2); diff --git a/fp-plugins/mediamanager/plugin.mediamanager.php b/fp-plugins/mediamanager/plugin.mediamanager.php index 2734f53..b20be00 100644 --- a/fp-plugins/mediamanager/plugin.mediamanager.php +++ b/fp-plugins/mediamanager/plugin.mediamanager.php @@ -1,60 +1,55 @@ hasMore()) { - list($id, $e) = $q->getEntry(); - if (isset($e['content'])){ - foreach($fupd as $id){ - if (is_null($files[$id]['usecount'])) $files[$id]['usecount']=0; - if ($files[$id]['type']=='gallery'){ - $searchterm="[gallery=images/".$files[$id]['name']; + list ($id, $e) = $q->getEntry(); + if (isset($e ['content'])) { + foreach ($fupd as $id) { + if (is_null($files [$id] ['usecount'])) + $files [$id] ['usecount'] = 0; + if ($files [$id] ['type'] == 'gallery') { + $searchterm = "[gallery=images/" . $files [$id] ['name']; } else { - $searchterm=$files[$id]['type']."/".$files[$id]['name']; + $searchterm = $files [$id] ['type'] . "/" . $files [$id] ['name']; } - if (strpos($e['content'], $searchterm) !== false) $files[$id]['usecount']++; + if (strpos($e ['content'], $searchterm) !== false) + $files [$id] ['usecount']++; } } } - $usecount=array(); - foreach($files as $info){ - $usecount[$info['name']]=$info['usecount']; + $usecount = array(); + foreach ($files as $info) { + $usecount [$info ['name']] = $info ['usecount']; } plugin_addoption('mediamanager', 'usecount', $usecount); plugin_saveoptions('mediamanager'); } +if (class_exists('AdminPanelAction')) { -if (class_exists('AdminPanelAction')){ - - - include(plugin_getdir('mediamanager') .'/panels/panel.mediamanager.file.php'); - - + include (plugin_getdir('mediamanager') . '/panels/panel.mediamanager.file.php'); } - - /* invalidate count on entry save and delete */ -function mediamanager_invalidatecount($arg){ +function mediamanager_invalidatecount($arg) { plugin_addoption('mediamanager', 'usecount', array()); plugin_saveoptions('mediamanager'); return $arg; @@ -62,5 +57,4 @@ function mediamanager_invalidatecount($arg){ add_filter('delete_post', 'mediamanager_invalidatecount', 1); add_filter('content_save_pre', 'mediamanager_invalidatecount', 1); - ?> diff --git a/fp-plugins/postviews/plugin.postviews.php b/fp-plugins/postviews/plugin.postviews.php index ba60b60..b5a2bbe 100644 --- a/fp-plugins/postviews/plugin.postviews.php +++ b/fp-plugins/postviews/plugin.postviews.php @@ -1,25 +1,24 @@ getQuery(); $calc = $q->single; - - $v = plugin_postviews_calc($id, $calc); - - $smarty->assign('views', $v); + $v = plugin_postviews_calc($id, $calc); + + $smarty->assign('views', $v); } - - ?> diff --git a/fp-plugins/prettyurls/plugin.prettyurls.php b/fp-plugins/prettyurls/plugin.prettyurls.php index 6c3858c..8e33283 100644 --- a/fp-plugins/prettyurls/plugin.prettyurls.php +++ b/fp-plugins/prettyurls/plugin.prettyurls.php @@ -1,12 +1,12 @@ categories) - return; - + + function categories($force = true) { + if ($this->categories) + return; + if ($force || !file_exists(PRETTYURLS_CATS)) { $d = entry_categories_get('defs'); $list = array(); - foreach ($d as $k=>$v) { - $list[$k] = sanitize_title($v); + foreach ($d as $k => $v) { + $list [$k] = sanitize_title($v); } io_write_file(PRETTYURLS_CATS, serialize($list)); } else { @@ -62,216 +62,194 @@ class Plugin_PrettyURLs { } $this->categories = $list; } - - + function md5($id, $title) { $date = date_from_id($id); - return md5($date['y'].$date['m'].$date['d'].$title); + return md5($date ['y'] . $date ['m'] . $date ['d'] . $title); } - - function permalink($str, $id) { global $fpdb, $post; if (PRETTYURLS_TITLES) - $title = sanitize_title($post['subject']); - else + $title = sanitize_title($post ['subject']); + else $title = $id; $date = date_from_id($id); - // yeah, hackish, I know... - - return $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/$title/"; + // yeah, hackish, I know... + + return $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/$title/"; } - + function commentlink($str, $id) { $link = $this->permalink($str, $id); return $link . "comments/"; } - + function feedlink($str, $type) { - return $this->baseurl . "feed/{$type}/"; - + return $this->baseurl . "feed/{$type}/"; } - + function commentsfeedlink($str, $type, $id) { $link = $this->commentlink($str, $id); - return $link . "feed/{$type}/"; + return $link . "feed/{$type}/"; } - function staticlink($str, $id) { - return $this->baseurl . "$id/"; + return $this->baseurl . "$id/"; } - function categorylink($str, $catid) { if (PRETTYURLS_TITLES) { - if (@$this->categories[$catid]) - return $this->baseurl . "category/{$this->categories[$catid]}/"; - else return $str; + if (@$this->categories [$catid]) + return $this->baseurl . "category/{$this->categories[$catid]}/"; + else + return $str; } else { - return $this->baseurl . "category/{$catid}/"; + return $this->baseurl . "category/{$catid}/"; } } - - + function yearlink($str, $y) { - return $this->baseurl . "20$y/"; + return $this->baseurl . "20$y/"; } - + function monthlink($str, $y, $m) { return $this->yearlink($str, $y) . "$m/"; } - + function daylink($str, $y, $m, $d) { return $this->monthlink($str, $y, $m) . "$d/"; } - - + function cache_create() { - $this->index = array(); /* - $o =& entry_init(); - - $entries = $o->getList(); + * $o =& entry_init(); + * + * $entries = $o->getList(); */ - $o = new FPDB_Query(array('start'=>0,'count'=>-1,'fullparse'=>false), null); - - - #foreach ($entries as $id => $contents) { + $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(); + 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; + 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 handle_categories($matches) { - - - if (!$this->categories) + if (!$this->categories) return; - - if (PRETTYURLS_TITLES) { - if ($c = array_search($matches[1], $this->categories)) - $this->fp_params['cat'] = $c; - else return $matches[0]; - } else { - $this->fp_params['cat'] = $matches[1]; - } - - } - - /* - named matches are not supported here - */ - - function handle_date($matches) { - - $this->fp_params['y'] = $matches[1]; - if (isset($matches[3])) $this->fp_params['m'] = $matches[3] ; - if (isset($matches[5])) $this->fp_params['d'] = $matches[5]; - - $this->date_handled = true; - - } - - - function handle_static($matches) { - $this->fp_params['page'] = $matches[1]; - $this->status = 2; - } - - function handle_entry($matches) { - - if (PRETTYURLS_TITLES) { - - #isset($this->index[ - if ($this->cache_get($this->fp_params['y'],$this->fp_params['m'], $this->fp_params['d'], md5($matches[1]))) { - $this->fp_params['entry'] = $this->index[$this->fp_params['y']][$this->fp_params['m']][$this->fp_params['d']][md5($matches[1])]; - } else { - // a bit hackish: we make up a fake url when there is no match, - // so that at the higher level the system will 404... - $this->fp_params['entry'] = 'a'; - } - } else { - $this->fp_params['entry'] = $matches[1]; - } - + if (PRETTYURLS_TITLES) { + if ($c = array_search($matches [1], $this->categories)) + $this->fp_params ['cat'] = $c; + else + return $matches [0]; + } else { + $this->fp_params ['cat'] = $matches [1]; + } } - - function handle_page($matches) { - $this->fp_params['paged'] = $matches[1]; + + /* + * named matches are not supported here + */ + function handle_date($matches) { + $this->fp_params ['y'] = $matches [1]; + if (isset($matches [3])) + $this->fp_params ['m'] = $matches [3]; + if (isset($matches [5])) + $this->fp_params ['d'] = $matches [5]; + + $this->date_handled = true; + } + + function handle_static($matches) { + $this->fp_params ['page'] = $matches [1]; $this->status = 2; } - - - function handle_comment($matches) { - $this->fp_params['comments'] = true; - } - - function handle_feed($matches) { - - $this->fp_params['feed'] = isset($matches[2])? $matches[2]:'rss2'; + + function handle_entry($matches) { + if (PRETTYURLS_TITLES) { + + // isset($this->index[ + if ($this->cache_get($this->fp_params ['y'], $this->fp_params ['m'], $this->fp_params ['d'], md5($matches [1]))) { + $this->fp_params ['entry'] = $this->index [$this->fp_params ['y']] [$this->fp_params ['m']] [$this->fp_params ['d']] [md5($matches [1])]; + } else { + // a bit hackish: we make up a fake url when there is no match, + // so that at the higher level the system will 404... + $this->fp_params ['entry'] = 'a'; + } + } else { + $this->fp_params ['entry'] = $matches [1]; + } } + function handle_page($matches) { + $this->fp_params ['paged'] = $matches [1]; + $this->status = 2; + } + + function handle_comment($matches) { + $this->fp_params ['comments'] = true; + } + + function handle_feed($matches) { + $this->fp_params ['feed'] = isset($matches [2]) ? $matches [2] : 'rss2'; + } function get_url() { $baseurl = BLOG_BASEURL; $opt = plugin_getoptions('prettyurls', 'mode'); - $url = substr($_SERVER['REQUEST_URI'], strlen(BLOG_ROOT)-1); + $url = substr($_SERVER ['REQUEST_URI'], strlen(BLOG_ROOT) - 1); - $urllenght = strlen($url); - - if (isset($_SERVER['PATH_INFO'])) { - $pathinfo = $_SERVER['PATH_INFO']; - } else { - $pathinfo = ''; - } + $urllenght = strlen($url); - switch($opt) { + if (isset($_SERVER ['PATH_INFO'])) { + $pathinfo = $_SERVER ['PATH_INFO']; + } else { + $pathinfo = ''; + } + + switch ($opt) { case null: case 0: - $opt = file_exists(ABS_PATH . '.htaccess') ? 3 : 1; + $opt = file_exists(ABS_PATH . '.htaccess') ? 3 : 1; case 1: - $baseurl .= 'index.php/'; - if ($urllenght < 2) { - $url = "/"; - } else { - // $url = $_SERVER['PATH_INFO']; - $url = $pathinfo; - } + $baseurl .= 'index.php/'; + if ($urllenght < 2) { + $url = "/"; + } else { + // $url = $_SERVER['PATH_INFO']; + $url = $pathinfo; + } break; case 2: - $baseurl .= '?u=/'; - $url = @$_GET['u']; + $baseurl .= '?u=/'; + $url = @$_GET ['u']; /* case 3: do nothing, it's BLOG_BASEURL */ } $this->baseurl = $baseurl; $this->mode = $opt; - return $url; - + return $url; } - - /* * here is where the real work is done. * @@ -285,40 +263,34 @@ class Plugin_PrettyURLs { * so that FlatPress can find it where it is expected * */ - - function cache_init() { - global $fp_params; - - $this->fp_params =& $fp_params; + + $this->fp_params = & $fp_params; $url = $this->get_url(); - + if (PRETTYURLS_TITLES) { - #if ($f = io_load_file(PRETTYURLS_CACHE)) - $this->index = array(); #unserialize($f); - + // if ($f = io_load_file(PRETTYURLS_CACHE)) + $this->index = array(); // unserialize($f); + if (!file_exists(PRETTYURLS_CACHE)) $this->cache_create(); - $this->categories(false); } if (!defined('MOD_INDEX')) return; - - -// # this is not working if you reach flatpress via symlink -// # unless you don't edit manually defaults.php -// if (strpos($_SERVER['REQUEST_URI'], BLOG_ROOT)!==false) { -// $url = $_SERVER['REQUEST_URI']; -// $del = BLOG_ROOT; -// if (strpos($url, 'index.php')!==false) -// $del = $del . 'index.php/'; -// $url = substr($url, strlen($del)-1); -// } + // # this is not working if you reach flatpress via symlink + // # unless you don't edit manually defaults.php + // if (strpos($_SERVER['REQUEST_URI'], BLOG_ROOT)!==false) { + // $url = $_SERVER['REQUEST_URI']; + // $del = BLOG_ROOT; + // if (strpos($url, 'index.php')!==false) + // $del = $del . 'index.php/'; + // $url = substr($url, strlen($del)-1); + // } // removes querystrings if (false !== $i = strpos($url, '?')) @@ -328,330 +300,363 @@ class Plugin_PrettyURLs { if (false !== $i = strpos($url, '#')) $url = substr($url, 0, $i); - - if (strrpos($url, '/') != (strlen($url)-1)) { + if (strrpos($url, '/') != (strlen($url) - 1)) { $url .= '/'; } - - if ($url=='/') + if ($url == '/') return; - - - //date - $url = preg_replace_callback( - '!^/[0-9]{2}(?P[0-9]{2})(/(?P[0-9]{2})(/(?P[0-9]{2}))?)?!', - array(&$this, 'handle_date'), - $url - ); - - - if (!$this->date_handled){ + // date + $url = preg_replace_callback('!^/[0-9]{2}(?P[0-9]{2})(/(?P[0-9]{2})(/(?P[0-9]{2}))?)?!', array( + &$this, + 'handle_date' + ), $url); + + if (!$this->date_handled) { // static page - $url = preg_replace_callback('|^/([a-zA-Z0-9_-]+)/$|', array(&$this, 'handle_static'), $url); + $url = preg_replace_callback('|^/([a-zA-Z0-9_-]+)/$|', array( + &$this, + 'handle_static' + ), $url); if ($this->status == 2) return $this->check_url($url); } - - - $url = preg_replace_callback('{category/([^/]+)/}', array(&$this, 'handle_categories'), $url); - - - $url = preg_replace_callback('|page/([0-9]+)/$|', array(&$this, 'handle_page'), $url); + + $url = preg_replace_callback('{category/([^/]+)/}', array( + &$this, + 'handle_categories' + ), $url); + + $url = preg_replace_callback('|page/([0-9]+)/$|', array( + &$this, + 'handle_page' + ), $url); if ($this->status == 2) - return $this->check_url($url); - - if ($this->date_handled){ - $url = preg_replace_callback('|^/([^/]+)|', array(&$this, 'handle_entry'), $url); + return $this->check_url($url); + + if ($this->date_handled) { + $url = preg_replace_callback('|^/([^/]+)|', array( + &$this, + 'handle_entry' + ), $url); // if status = 2 - /* - utils_error(404); - */ - - $url = preg_replace_callback('|^/comments|', array(&$this, 'handle_comment'), $url); + /* + * utils_error(404); + */ + + $url = preg_replace_callback('|^/comments|', array( + &$this, + 'handle_comment' + ), $url); } - - - $url = preg_replace_callback('|^/feed(/([^/]*))?|', array(&$this, 'handle_feed'), $url); - + + $url = preg_replace_callback('|^/feed(/([^/]*))?|', array( + &$this, + 'handle_feed' + ), $url); + $this->check_url($url); - } function check_url($url) { if (!empty($url) && $url != '/') { - $this->fp_params = array('entry'=>'entry000000-000000'); + $this->fp_params = array( + 'entry' => 'entry000000-000000' + ); $url = apply_filters('prettyurls_unhandled_url', $url); } } function cache_delete_elem($id, $date) { - - # is this a title change? - if (false !== ($ids = $this->cache_get( $date['y'] , $date['m'] , $date['d'] ))) + + // is this a title change? + if (false !== ($ids = $this->cache_get($date ['y'], $date ['m'], $date ['d']))) $hash = array_search($id, $ids); else return; - + if ($hash) { - unset($this->index[ $date['y'] ] [ $date['m'] ][ $date['d'] ][ $hash ]); - - if (empty($this->index[ $date['y'] ] [ $date['m'] ][ $date['d'] ])) { - unset($this->index[ $date['y'] ] [ $date['m'] ][ $date['d'] ]); - - if (empty($this->index[ $date['y'] ] [ $date['m'] ])) { - unset($this->index[ $date['y'] ] [ $date['m'] ]); - - if (empty($this->index[ $date['y'] ])) { - unset($this->index[ $date['y'] ]); + unset($this->index [$date ['y']] [$date ['m']] [$date ['d']] [$hash]); + + if (empty($this->index [$date ['y']] [$date ['m']] [$date ['d']])) { + unset($this->index [$date ['y']] [$date ['m']] [$date ['d']]); + + if (empty($this->index [$date ['y']] [$date ['m']])) { + unset($this->index [$date ['y']] [$date ['m']]); + + if (empty($this->index [$date ['y']])) { + unset($this->index [$date ['y']]); } - } - } - } $this->cache_save(); - - } - - function cache_add($id, $arr) { - - $date = date_from_id($id); - $title = sanitize_title($arr['subject']); - - $this->cache_delete_elem($id, $date); - - $this->index[ $date['y'] ] [ $date['m'] ][ $date['d'] ][ md5($title) ] = $id; - - $this->cache_save(); - - - return true; - } - function cache_get($y,$m,$d=null,$h=null) { - if (!isset($this->index[$y][$m])) { - $s = @io_load_file(PRETTYURLS_CACHE.$y.$m); - $this->index[$y][$m] = $s? unserialize($s) : false; + function cache_add($id, $arr) { + $date = date_from_id($id); + $title = sanitize_title($arr ['subject']); + + $this->cache_delete_elem($id, $date); + + $this->index [$date ['y']] [$date ['m']] [$date ['d']] [md5($title)] = $id; + + $this->cache_save(); + + return true; + } + + function cache_get($y, $m, $d = null, $h = null) { + if (!isset($this->index [$y] [$m])) { + $s = @io_load_file(PRETTYURLS_CACHE . $y . $m); + $this->index [$y] [$m] = $s ? unserialize($s) : false; } if (is_null($d)) - return $this->index[$y][$m]; + return $this->index [$y] [$m]; if (is_null($h)) - return isset($this->index[$y][$m][$d])? $this->index[$y][$m][$d] : false; + return isset($this->index [$y] [$m] [$d]) ? $this->index [$y] [$m] [$d] : false; - if (isset($this->index[$y][$m][$d])) - return isset($this->index[$y][$m][$d][$h]); + if (isset($this->index [$y] [$m] [$d])) + return isset($this->index [$y] [$m] [$d] [$h]); else return false; } - + function cache_delete($id) { $date = date_from_id($id); $this->cache_delete_elem($id, $date); $this->cache_save(); - } function cache_save() { if ($this->index) { foreach ($this->index as $year => $months) { foreach ($months as $month => $days) - io_write_file(PRETTYURLS_CACHE.$year.$month, serialize($days)); + io_write_file(PRETTYURLS_CACHE . $year . $month, serialize($days)); } - } - + return true; - } function nextprevlink($nextprev, $v) { - - global $fpdb; - $q =& $fpdb->getQuery(); - - list($caption, $id) = call_user_func(array(&$q, 'get'.$nextprev)); - + global $fpdb; + $q = & $fpdb->getQuery(); + + list ($caption, $id) = call_user_func(array( + &$q, + 'get' . $nextprev + )); + if (!$id) return array(); - - + if ($q->single) { $date = date_from_id($id); if (PRETTYURLS_TITLES) $title = sanitize_title($caption); - else $title = $id; - $url = $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/$title/"; - - if ($v>0) - $caption = $caption . ' » '; + else + $title = $id; + $url = $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/$title/"; + + if ($v > 0) + $caption = $caption . ' » '; else $caption = ' « ' . $caption; - - return array($caption,$url); - + + return array( + $caption, + $url + ); } - - + // else, we build a complete url - + /* todo: clean up this mess... which means cleaning up the mess above. oh, my! */ - - $l = $this->baseurl ; - - - if ( ( is_numeric($cid = @$this->fp_params['category']) ) || - is_numeric($cid = @$this->fp_params['cat']) ) + + $l = $this->baseurl; + + if ((is_numeric($cid = @$this->fp_params ['category'])) || is_numeric($cid = @$this->fp_params ['cat'])) $l = $this->categorylink($l, $cid); - - if (isset($this->fp_params['y']) && $this->fp_params['y']) { - $l .= '20'. $this->fp_params['y'] . '/'; - - if (isset($this->fp_params['m']) && $this->fp_params['m']) { - $l .= $this->fp_params['m'] . '/'; - - if (isset($this->fp_params['d']) && $this->fp_params['d']) - $l .= $this->fp_params['d'] . '/'; - + + if (isset($this->fp_params ['y']) && $this->fp_params ['y']) { + $l .= '20' . $this->fp_params ['y'] . '/'; + + if (isset($this->fp_params ['m']) && $this->fp_params ['m']) { + $l .= $this->fp_params ['m'] . '/'; + + if (isset($this->fp_params ['d']) && $this->fp_params ['d']) + $l .= $this->fp_params ['d'] . '/'; } - } - + $page = 1; - - if (isset($this->fp_params['paged']) && $this->fp_params['paged']>1) $page = $this->fp_params['paged']; - + + if (isset($this->fp_params ['paged']) && $this->fp_params ['paged'] > 1) + $page = $this->fp_params ['paged']; + $page += $v; - + if ($page > 0) { $l .= 'page/' . $page . '/'; } - - - return array($caption,$l); - - - } - - - -} - global $plugin_prettyurls; - $plugin_prettyurls = new Plugin_PrettyURLs; - $plugin_prettyurls->categories(); - - - if (!defined('MOD_ADMIN_PANEL')){ - - if (!function_exists('get_nextpage_link')) : - + return array( + $caption, + $l + ); + } + +} + +global $plugin_prettyurls; +$plugin_prettyurls = new Plugin_PrettyURLs(); +$plugin_prettyurls->categories(); + +if (!defined('MOD_ADMIN_PANEL')) { + + if (!function_exists('get_nextpage_link')) : + function get_nextpage_link() { global $plugin_prettyurls; return $plugin_prettyurls->nextprevlink('NextPage', 1); } + function get_prevpage_link() { global $plugin_prettyurls; - return $plugin_prettyurls->nextprevlink('PrevPage',-1); + return $plugin_prettyurls->nextprevlink('PrevPage', -1); } endif; - - } - - - add_filter('post_link', array(&$plugin_prettyurls,'permalink'), 0, 2); - add_filter('comments_link', array(&$plugin_prettyurls, 'commentlink'), 0, 2); - add_filter('feed_link', array(&$plugin_prettyurls, 'feedlink'), 0, 2); - add_filter('post_comments_feed_link', array(&$plugin_prettyurls, 'commentsfeedlink'), 0, 3); - add_filter('category_link', array(&$plugin_prettyurls,'categorylink'), 0, 2); - add_filter('page_link', array(&$plugin_prettyurls, 'staticlink'), 0, 2); - - // date related functions - add_filter('year_link', array(&$plugin_prettyurls,'yearlink'), 0, 2); - add_filter('month_link', array(&$plugin_prettyurls,'monthlink'), 0, 3); - add_filter('day_link', array(&$plugin_prettyurls,'daylink'), 0, 4); +} - if (PRETTYURLS_TITLES) { - add_filter('publish_post', array(&$plugin_prettyurls, 'cache_add'), 5, 2); - add_filter('delete_post', array(&$plugin_prettyurls, 'cache_delete')); - add_action('update_categories', array(&$plugin_prettyurls, 'categories')); - } +add_filter('post_link', array( + &$plugin_prettyurls, + 'permalink' +), 0, 2); +add_filter('comments_link', array( + &$plugin_prettyurls, + 'commentlink' +), 0, 2); +add_filter('feed_link', array( + &$plugin_prettyurls, + 'feedlink' +), 0, 2); +add_filter('post_comments_feed_link', array( + &$plugin_prettyurls, + 'commentsfeedlink' +), 0, 3); +add_filter('category_link', array( + &$plugin_prettyurls, + 'categorylink' +), 0, 2); +add_filter('page_link', array( + &$plugin_prettyurls, + 'staticlink' +), 0, 2); - add_filter('init', array(&$plugin_prettyurls, 'cache_init')); +// date related functions +add_filter('year_link', array( + &$plugin_prettyurls, + 'yearlink' +), 0, 2); +add_filter('month_link', array( + &$plugin_prettyurls, + 'monthlink' +), 0, 3); +add_filter('day_link', array( + &$plugin_prettyurls, + 'daylink' +), 0, 4); -if (class_exists('AdminPanelAction')){ +if (PRETTYURLS_TITLES) { + add_filter('publish_post', array( + &$plugin_prettyurls, + 'cache_add' + ), 5, 2); + add_filter('delete_post', array( + &$plugin_prettyurls, + 'cache_delete' + )); + add_action('update_categories', array( + &$plugin_prettyurls, + 'categories' + )); +} + +add_filter('init', array( + &$plugin_prettyurls, + 'cache_init' +)); + +if (class_exists('AdminPanelAction')) { + + class admin_plugin_prettyurls extends AdminPanelAction { - class admin_plugin_prettyurls extends AdminPanelAction { - var $langres = 'plugin:prettyurls'; - var $_config = array('mode'=>0); - + + var $_config = array( + 'mode' => 0 + ); + function setup() { $this->smarty->assign('admin_resource', "plugin:prettyurls/admin.plugin.prettyurls"); - $this->_config['mode'] = plugin_getoptions('prettyurls', 'mode'); + $this->_config ['mode'] = plugin_getoptions('prettyurls', 'mode'); $this->smarty->assign('pconfig', $this->_config); $blogroot = BLOG_ROOT; $f = ABS_PATH . '.htaccess'; $txt = io_load_file($f); if (!$txt) { - -$txt =<< -RewriteEngine On -RewriteBase {$blogroot} -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . {$blogroot}index.php [L] - -STR; + $txt = << + RewriteEngine On + RewriteBase {$blogroot} + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . {$blogroot}index.php [L] + + STR; } - - - $this->smarty->assign('cantsave', - ( !is_writable(ABS_PATH) || (file_exists($f) && !is_writable($f)) ) - ); - $this->smarty->assign('htaccess', $txt); + + $this->smarty->assign('cantsave', (!is_writable(ABS_PATH) || (file_exists($f) && !is_writable($f)))); + $this->smarty->assign('htaccess', $txt); } - - - + function onsubmit($data = null) { global $fp_config; - if (isset($_POST['saveopt'])) { - $this->_config['mode'] = (int) $_POST['mode'] ; - plugin_addoption('prettyurls', 'mode', $this->_config['mode']); - if( plugin_saveoptions() ) + if (isset($_POST ['saveopt'])) { + $this->_config ['mode'] = (int) $_POST ['mode']; + plugin_addoption('prettyurls', 'mode', $this->_config ['mode']); + if (plugin_saveoptions()) $this->smarty->assign('success', 2); - else $this->smarty->assign('success', -2); + else + $this->smarty->assign('success', -2); } - - if (isset($_POST['htaccess-submit'])) { - if (!empty($_POST['htaccess']) && io_write_file(ABS_PATH.'.htaccess', $_POST['htaccess'])){ - $this->smarty->assign('success', 1); - } else { - $this->smarty->assign('success', -1); - } + + if (isset($_POST ['htaccess-submit'])) { + if (!empty($_POST ['htaccess']) && io_write_file(ABS_PATH . '.htaccess', $_POST ['htaccess'])) { + $this->smarty->assign('success', 1); + } else { + $this->smarty->assign('success', -1); + } } - + return 2; } - + } admin_addpanelaction('plugin', 'prettyurls', true); - } ?> diff --git a/fp-plugins/qspam/plugin.qspam.php b/fp-plugins/qspam/plugin.qspam.php index 8ed5abd..bc514e4 100755 --- a/fp-plugins/qspam/plugin.qspam.php +++ b/fp-plugins/qspam/plugin.qspam.php @@ -1,20 +1,23 @@ = $qscfg['number']) { + if ($count >= $qscfg ['number']) { global $smarty; $lang = lang_load('plugin:qspam'); - $smarty->assign('error', array($lang['plugin']['qspam']['error'])); + $smarty->assign('error', array( + $lang ['plugin'] ['qspam'] ['error'] + )); return false; } return true; } add_action('comment_validate', 'plugin_qspam_validate', 5, 2); -if (class_exists('AdminPanelAction')){ +if (class_exists('AdminPanelAction')) { + /** * Provides an admin panel entry for QuickSpam setup. */ class admin_plugin_qspam extends AdminPanelAction { + var $langres = 'plugin:qspam'; - + /** * Initializes this panel. */ function setup() { $this->smarty->assign('admin_resource', "plugin:qspam/admin.plugin.qspam"); } - + /** * Setups the default panel. */ function main() { $qscfg = plugin_getoptions('qspam'); - $qscfg['wordlist'] = isset($qscfg['wordlist']) && is_array($qscfg['wordlist']) - ? implode("\n", $qscfg['wordlist']) - : ''; - $qscfg['number'] = isset($qscfg['number']) - ? $qscfg['number'] - : 1; + $qscfg ['wordlist'] = isset($qscfg ['wordlist']) && is_array($qscfg ['wordlist']) ? implode("\n", $qscfg ['wordlist']) : ''; + $qscfg ['number'] = isset($qscfg ['number']) ? $qscfg ['number'] : 1; $this->smarty->assign('qscfg', $qscfg); } - + /** * Will be executed when the QSF configuration is send. * * @return int */ function onsubmit($data = null) { - if ($_POST['qs-wordlist']){ - $wordlist = isset($_POST['qs-wordlist']) - ? stripslashes($_POST['qs-wordlist']) - : ''; + if ($_POST ['qs-wordlist']) { + $wordlist = isset($_POST ['qs-wordlist']) ? stripslashes($_POST ['qs-wordlist']) : ''; $wordlist = str_replace("\r", "\n", $wordlist); // DMKE: Works neither recursive correct nor in a loop... *grrr* - #$wordlist = str_replace("\n\n", "\n", $wordlist); + // $wordlist = str_replace("\n\n", "\n", $wordlist); $wordlist = explode("\n", $wordlist); - $wordlist = array_filter($wordlist, array($this, '_array_filter')); - $number = isset($_POST['qs-number']) && is_numeric($_POST['qs-number']) - ? (int)$_POST['qs-number'] - : 1; + $wordlist = array_filter($wordlist, array( + $this, + '_array_filter' + )); + $number = isset($_POST ['qs-number']) && is_numeric($_POST ['qs-number']) ? (int) $_POST ['qs-number'] : 1; plugin_addoption('qspam', 'wordlist', $wordlist); plugin_addoption('qspam', 'number', $number); plugin_saveoptions('qspam'); $this->smarty->assign('success', 1); } else { - $this->smarty->assign('success', -1); + $this->smarty->assign('success', -1); } return 2; } - + /** - * Array filter callback function. Culls empty array values. + * Array filter callback function. + * Culls empty array values. * Life is hell ._. * * @param string $str @@ -114,6 +118,7 @@ if (class_exists('AdminPanelAction')){ function _array_filter($str) { return strlen(trim($str)) > 0; } + } admin_addpanelaction('plugin', 'qspam', true); } diff --git a/fp-plugins/readmore/plugin.readmore.php b/fp-plugins/readmore/plugin.readmore.php index 4008cc8..0cb7869 100755 --- a/fp-plugins/readmore/plugin.readmore.php +++ b/fp-plugins/readmore/plugin.readmore.php @@ -2,11 +2,11 @@ /* * Plugin Name: ReadMore - * Plugin URI: http://www.nowhereland.it/ - * Description: ReadMore plugin. Chops a lengthy entry and appends a "read more" link :) - * Author: NoWhereMan - * Version: 0.703 - * Author URI: http://www.nowhereland.it/ + * Version: 1.0 + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Chops lengthy entries in the overview and appends a "read more" link. Part of the standard distribution. */ // $MODE specifies when you want to chop your entry diff --git a/fp-plugins/searchbox/plugin.searchbox.php b/fp-plugins/searchbox/plugin.searchbox.php index 4e2453c..126ed5b 100755 --- a/fp-plugins/searchbox/plugin.searchbox.php +++ b/fp-plugins/searchbox/plugin.searchbox.php @@ -2,10 +2,10 @@ /* * Plugin Name: SearchBox * Version: 1.0 - * Plugin URI: http://flatpress.sf.net - * Description: SearchBox which interfaces with standard search function - * Author: NoWhereMan - * Author URI: http://flatpress.sf.net + * Plugin URI: https://www.flatpress.org + * Author: FlatPress + * Author URI: https://www.flatpress.org + * Description: Adds a search box widget. Part of the standard distribution. */ define('SEARCHBOX_BIG', false); diff --git a/fp-plugins/thumb/plugin.thumb.php b/fp-plugins/thumb/plugin.thumb.php index ade2a72..bf735b9 100755 --- a/fp-plugins/thumb/plugin.thumb.php +++ b/fp-plugins/thumb/plugin.thumb.php @@ -1,28 +1,24 @@