Description and authors of all default plugins reworked. (Original plugin authors are mentioned in CONTRIBUTORS.md from now on.)

This commit is contained in:
azett 2020-10-24 20:42:59 +02:00
parent 6830a2b0e8
commit c2accdedcc
23 changed files with 1011 additions and 1030 deletions

View File

@ -1,20 +1,18 @@
<?php
/*
Plugin Name: Accessible Antispam
Plugin URI: http://flatpress.nowherland.it/
Description: Antispam asking to answer a simple math question.
Author: NoWhereMan (E.Vacchi)
Version: 3.0
Author URI: http://www.nowhereland.it
* Plugin Name: Accessible Antispam
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Antispam asking to answer a simple math question. Part of the standard distribution.
* Version: 3.0
*/
define('AASPAM_DEBUG', false);
define('AASPAM_LOG', CACHE_DIR . 'aaspamlog.txt');
add_action('comment_validate', 'plugin_aaspam_validate', 5, 2);
add_action('comment_form', 'plugin_aaspam_comment_form');
function plugin_aaspam_validate($bool, $arr) {
// if boolean $bool==false
@ -53,7 +51,6 @@ function plugin_aaspam_validate($bool, $arr) {
@fclose($f);
}
return $ret;
}
@ -65,15 +62,19 @@ function plugin_aaspam_comment_form() {
// we intentionally left out division because
// it can lead to situations like division by zero
// or floating point numbers
$myop = array_rand($ops=array('+','-','*'));
$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);
while (($v2 = mt_rand(1, 10)) == $v1)
;
// if operation is subtraction
// the higher number must always come first
@ -82,7 +83,6 @@ function plugin_aaspam_comment_form() {
$tmp = $v1;
$v1 = $v2;
$v2 = $tmp;
}
// execute the operation
@ -98,8 +98,6 @@ function plugin_aaspam_comment_form() {
break;
}
sess_add('aaspam', $v);
// load plugin strings
@ -135,8 +133,6 @@ function plugin_aaspam_comment_form() {
<p><label class="textlabel" for="aaspam">{$lang['plugin']['accessibleantispam']['prefix']} <strong>$question (*)</strong></label><br />
<input type="text" name="aaspam" id="aaspam" /></p>
STR;
}
?>

View File

@ -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() {

View File

@ -1,14 +1,12 @@
<?php
/*
Plugin Name: Akismet
Version: 0.1
Plugin URI: http://flatpress.sf.net
Description: Integration with Akismet powerful Antispam system!
Author: NoWhereMan
Author URI: http://flatpress.sf.net
* Plugin Name: Akismet
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Integration with Akismet powerful Antispam system. Part of the standard distribution.
* Version: 1.0
*/
define('AKISMET_TIMEOUT', 10);
require plugin_getdir('akismet') . '/inc/Akismet.class.php';
@ -28,8 +26,8 @@ if (plugin_getoptions('akismet','apikey')) {
}
function plugin_akismet_validate($bool, $contents) {
if (!$bool) return false;
if (!$bool)
return false;
global $fp_config;
@ -41,7 +39,9 @@ function plugin_akismet_validate($bool, $contents) {
if ($v = $akismet->isSpam()) {
global $smarty;
$smarty->assign('error', array('ERROR: Comment is invalid'));
$smarty->assign('error', array(
'ERROR: Comment is invalid'
));
return false;
}
return true;
@ -81,5 +81,4 @@ if (class_exists('AdminPanelAction')){
}
admin_addpanelaction('plugin', 'akismet', true);
}

View File

@ -1,19 +1,23 @@
<?php
/*
Plugin Name: Archives
Version: 1.0
Plugin URI: http://flatpress.sf.net
Description: Adds an Archive widget element
Author: NoWhereMan
Author URI: http://flatpress.sf.net
*/
/*
* Plugin Name: Archives
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Adds an Archive widget element. Part of the standard distribution.
* Version: 1.0
*/
class plugin_archives_monthlist extends fs_filelister {
var $_directory = CONTENT_DIR;
var $_list = array();
var $_htmllist = array();
var $_months = array();
var $_year = '';
function _checkFile($directory, $file) {
@ -35,7 +39,6 @@ class plugin_archives_monthlist extends fs_filelister {
}
function _exitingDir($directory = null, $file = null) {
$y = $this->_year;
if ($mos = & $this->_months) {
@ -45,9 +48,7 @@ class plugin_archives_monthlist extends fs_filelister {
foreach ($mos as $mth) {
$lnk = get_month_link($y, $mth);
$the_month = theme_date_format(mktime(0, 0, 0, $mth, 1, 0), '%B');
$list = "<li class=\"archive-month archive-m$mth\"><a href=\"$lnk\">".
$the_month
.' </a></li>' . $list;
$list = "<li class=\"archive-month archive-m$mth\"><a href=\"$lnk\">" . $the_month . ' </a></li>' . $list;
$linearlist ["$the_month 20{$this->_year}"] = $lnk;
}
$list = '<ul>' . $list . '</ul>';
@ -70,14 +71,11 @@ class plugin_archives_monthlist extends fs_filelister {
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<!-- archives -->\n";
foreach ($PLUGIN_ARCHIVES_MONTHLIST->getList() as $y => $months) {
@ -90,18 +88,13 @@ 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()) ?
'<ul>' . $list . '</ul>'
:
"<p>{$lang['plugin']['archives']['no_posts']}</p>"
'content' => ($list = $PLUGIN_ARCHIVES_MONTHLIST->getHtmlList()) ? '<ul>' . $list . '</ul>' : "<p>{$lang['plugin']['archives']['no_posts']}</p>"
);
}

View File

@ -1,11 +1,11 @@
<?php
/*
* Plugin Name: BBCode
* Version: 1.5
* Plugin URI: http://flatpress.sf.net
* Description: Allows using <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> 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 <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> 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');

View File

@ -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/');

View File

@ -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

View File

@ -1,17 +1,15 @@
<?php
/*
Plugin Name: Categories
Plugin URI: http://www.nowhereland.it/
Type: Block
Description: Lists your categories in a widget.
Author: NoWhereMan
Version: 1.0
Author URI: http://www.nowhereland.it/
* Plugin Name: Categories
* Type: Block
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Lists your categories in a widget. Part of the standard distribution.
*/
function plugin_categories_widget() {
global $smarty;
// set this to true if you want show the number

View File

@ -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.
*/
/**

View File

@ -1,19 +1,18 @@
<?php
/*
Plugin Name: FavIcon
Plugin URI: http://www.flatpress.org/
Description: Adds a favicon to FlatPress
Author: NoWhereMan
Version: 1.0
Author URI: http://www.nowhereland.it/
*/
/*
* Plugin Name: FavIcon
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Adds a favicon to FlatPress. Part of the standard distribution.
*/
function plugin_favicon_head() {
// your file *must* be named favicon.ico
// and be a ICO file (not a renamed png, jpg, gif, etc...)
// or it won't work in IE
echo '<link rel="shortcut icon" href="' .
plugin_geturl('favicon') .'imgs/favicon.ico" />';
echo '<link rel="shortcut icon" href="' . plugin_geturl('favicon') . 'imgs/favicon.ico" />';
}
add_action('wp_head', 'plugin_favicon_head');

View File

@ -1,11 +1,11 @@
<?php
/*
* Plugin Name: FootNotes
* Version: 0.1
* Plugin URI: http://flatpress.nowhereland.it
* Description: footnotes in your entry
* Author: NoWhereMan
* Author URI: http://flatpress.nowhereland.it
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Enables footnotes in your entries. Part of the standard distribution.
*/
define('FOOTNOTES_START', '[footnotes]');

View File

@ -1,21 +1,17 @@
<?php
/*
Plugin Name: jQuery
Version: 2.0.1
Plugin URI: http://www.vdfn.altervista.org/
Description: Provides <a href="http://jquery.com/" title="jQuery">jQuery</a> locally.
Author: Piero VDFN
Author URI: http://www.vdfn.altervista.org/
JQuery and JQueryUI version bump by Arvid Zimmermann
* Plugin Name: jQuery
* Version: 2.0.1
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Provides <a href="http://jquery.com/" title="jQuery">jQuery</a> locally. Part of the standard distribution.
*/
## Original author: NoWhereMan (http://www.nowhereland.it)
// # Original author: NoWhereMan (http://www.nowhereland.it)
add_action('wp_head', 'plugin_jquery_head', 0);
function plugin_jquery_head() {
$pdir = plugin_geturl('jquery');
echo <<<JSUTILS
<!-- start of jsUtils -->

View File

@ -1,21 +1,19 @@
<?php
/*
Plugin Name: LastComments
Plugin URI: http://www.nowhereland.it/
Type: Block
Description: LastComments plugin. Part of the standard distribution ;)
Author: NoWhereMan
Version: 1.0
Author URI: http://www.nowhereland.it/
* Plugin Name: LastComments
* Type: Block
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Adds a widget that shows the latest comments. Part of the standard distribution.
*/
define('LASTCOMMENTS_CACHE_FILE', CACHE_DIR . 'lastcomments.tmp');
define('LASTCOMMENTS_MAX', 8);
add_action('comment_post', 'plugin_lastcomments_cache', 0, 2);
function plugin_lastcomments_widget() {
if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) {
// no comments in cache
$list = array();
@ -37,8 +35,9 @@ function plugin_lastcomments_widget() {
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);
@ -49,12 +48,10 @@ function plugin_lastcomments_widget() {
continue;
}
$content .=
"<li>
$content .= "<li>
<blockquote class=\"comment-quote\" cite=\"comments.php?entry={$arr['entry']}#{$arr['id']}\">
{$arr['content']}
<p><a href=\"".get_comments_link($arr['entry']).
"#{$arr['id']}\">{$arr['name']} - {$entry['subject']}</a></p>
<p><a href=\"" . get_comments_link($arr ['entry']) . "#{$arr['id']}\">{$arr['name']} - {$entry['subject']}</a></p>
</blockquote></li>\n";
}
$subject = $lang ['plugin'] ['lastcomments'] ['last'] . ' ' . $count . ' ' . $lang ['plugin'] ['lastcomments'] ['comments'];
@ -86,23 +83,21 @@ function plugin_lastcomments_widget() {
* 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
* @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;
comment_clean($content);
if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) {
// no comments in cache
$list = array();
@ -120,17 +115,18 @@ function plugin_lastcomments_cache($entryid, $comment) {
if (strlen($content ['content']) > $CHOP_AT) {
$string = substr($content ['content'], 0, $CHOP_AT) . '...';
} else {$string = $content['content'];}
} else {
$string = $content ['content'];
}
array_push($list, array('name'=>$content['name'],
array_push($list, array(
'name' => $content ['name'],
'content' => $string,
'id' => $id,
'entry'=> $entryid)
);
'entry' => $entryid
));
return io_write_file(LASTCOMMENTS_CACHE_FILE, serialize($list));
}
register_widget('lastcomments', 'LastComments', 'plugin_lastcomments_widget');
@ -138,7 +134,6 @@ register_widget('lastcomments', 'LastComments', 'plugin_lastcomments_widget');
function plugin_lastcomments_rss() {
global $smarty;
if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) {
// no comments in cache
$list = array();
@ -157,32 +152,32 @@ function plugin_lastcomments_rss () {
}
/*
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<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Get RSS 2.0 Feed\" href=\"".
plugin_lastcomments_rss_link()
."\" />\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<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Get RSS 2.0 Feed\" href=\"".
* plugin_lastcomments_rss_link()
* ."\" />\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();
* }
* }
*
*/
?>

View File

@ -1,15 +1,12 @@
<?php
/*
Plugin Name: Last Comments Admin
Version: 0.1
Plugin URI: http://kirgroup.com/blog/
Description: Manage last comments cache. Require LastComment plugin.
Author: Fabrixxm
Author URI: http://kirgroup.com/blog/
* Plugin Name: LastComments Admin
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Manage the cache of the LastComments plugin. Requires LastComment plugin enabled. Part of the standard distribution.
*/
if (class_exists('AdminPanelAction')) {
class admin_plugin_lastcommentsadmin extends AdminPanelAction {
@ -38,7 +35,11 @@ if (class_exists('AdminPanelAction')){
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();
$obj = new comment_indexer($id);
@ -50,7 +51,10 @@ if (class_exists('AdminPanelAction')){
}
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);
}
@ -61,5 +65,4 @@ if (class_exists('AdminPanelAction')){
}
admin_addpanelaction('plugin', 'lastcommentsadmin', true);
}

View File

@ -1,16 +1,15 @@
<?php
/*
Plugin Name: LastEntries
Plugin URI: http://www.nowhereland.it/
Type: Block
Description: LastEntries plugin. Part of the standard distribution ;)
Author: NoWhereMan
Version: 1.0
Author URI: http://www.nowhereland.it/
* Plugin Name: LastEntries
* Version: 1.0
* Type: Block
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Adds a widget that lists the latest entries. Part of the standard distribution.
*/
function plugin_lastentries_widget() {
global $fpdb;
// load plugin strings
@ -18,20 +17,23 @@ function plugin_lastentries_widget() {
$lang = lang_load('plugin:lastentries');
$num = 10;
####################
// ###################
/*
$queryId = $fpdb->query("fullparse:false,start:0,count:$num");
$fpdb->doquery($queryId);
$fpdb->getQuery
* $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);
$q = new FPDB_Query(array(
'fullparse' => false,
'start' => 0,
'count' => $num
), null);
$string = '<ul>';
$count = 0;
while ($q->hasmore()) {
@ -52,7 +54,8 @@ function plugin_lastentries_widget() {
if ($string == '<ul>') {
$string .= '<li><a href="admin.php?p=entry&amp;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'];
} else
$subject = $lang ['plugin'] ['lastentries'] ['subject_before_count'] . $count . $lang ['plugin'] ['lastentries'] ['subject_after_count'];
$string .= '</ul>';

View File

@ -1,23 +1,22 @@
<?php
/*
Plugin Name: LightBox2
Version: 2.0
Plugin URI: http://www.vdfn.altervista.org/
Description: Lightbox overlays using <a href="http://www.digitalia.be/software/slimbox2">SlimBox 2</a> requires <a href="http://jquery.com" title="jQuery">jQuery</a> (modified jsutils plugin)
Author: Piero VDFN
Author URI: http://www.vdfn.altervista.org/
* Plugin Name: LightBox2
* Version: 2.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Lightbox overlays using <a href="http://www.digitalia.be/software/slimbox2">SlimBox 2</a> requires <a href="http://jquery.com" title="jQuery">jQuery</a> (modified jsutils plugin). Part of the standard distribution.
*/
## Original author: NoWhereMan (http://www.nowhereland.it)
// # 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;
}
function plugin_lightbox2_head() {
$pdir = plugin_geturl('lightbox2');
echo <<<LBOXHEAD
<!-- start of lightbox -->
@ -28,7 +27,6 @@ LBOXHEAD;
add_action('wp_head', 'plugin_lightbox2_head');
function plugin_lightbox2_footer() {
$pdir = plugin_geturl('lightbox2');
echo <<<LBOXHEAD
<!-- start of lightbox -->

View File

@ -1,17 +1,16 @@
<?php
/*
Plugin Name: Media Manager
Version: 0.4
Plugin URI: http://kirgroup.com/blog/
Description: Manage uloaded files ad photo galleries
Author: Fabrix.xm
Author URI: http://kirgroup.com/fabrixxm/
* Plugin Name: Media Manager
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Manage uploaded files and photo galleries. Part of the standard distribution.
*/
// config
define('ITEMSPERPAGE', 10);
//
function mediamanager_updateUseCountArr(&$files, $fupd) {
$params = array();
@ -23,13 +22,15 @@ function mediamanager_updateUseCountArr(&$files,$fupd){
list ($id, $e) = $q->getEntry();
if (isset($e ['content'])) {
foreach ($fupd as $id) {
if (is_null($files[$id]['usecount'])) $files[$id]['usecount']=0;
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'];
}
if (strpos($e['content'], $searchterm) !== false) $files[$id]['usecount']++;
if (strpos($e ['content'], $searchterm) !== false)
$files [$id] ['usecount']++;
}
}
}
@ -42,17 +43,11 @@ function mediamanager_updateUseCountArr(&$files,$fupd){
plugin_saveoptions('mediamanager');
}
if (class_exists('AdminPanelAction')) {
include (plugin_getdir('mediamanager') . '/panels/panel.mediamanager.file.php');
}
/* invalidate count on entry save and delete */
function mediamanager_invalidatecount($arg) {
plugin_addoption('mediamanager', 'usecount', array());
@ -62,5 +57,4 @@ function mediamanager_invalidatecount($arg){
add_filter('delete_post', 'mediamanager_invalidatecount', 1);
add_filter('content_save_pre', 'mediamanager_invalidatecount', 1);
?>

View File

@ -1,19 +1,18 @@
<?php
/*
Plugin Name: PostViews
Plugin URI: http://www.nowhereland.it/
Description: PostViews plugin.
Author: NoWhereMan
Version: 1.0
Author URI: http://www.nowhereland.it/
* Plugin Name: PostViews
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Counts and displays entry views. Part of the standard distribution.
*/
add_action('entry_block', 'plugin_postviews_do');
function plugin_postviews_calc($id, $calc) {
$dir = entry_dir($id);
if (!$dir) return;
if (!$dir)
return;
$f = $dir . '/view_counter' . EXT;
@ -38,7 +37,6 @@ function plugin_postviews_calc($id, $calc) {
}
function plugin_postviews_do($id) {
global $fpdb, $smarty;
$q = $fpdb->getQuery();
@ -47,9 +45,6 @@ function plugin_postviews_do($id) {
$v = plugin_postviews_calc($id, $calc);
$smarty->assign('views', $v);
}
?>

View File

@ -1,11 +1,11 @@
<?php
/*
Plugin Name: PrettyURLs
Plugin URI: http://flatpress.nowherland.it/
Description: Url prettifier (powered by htaccess)
Author: NoWhereMan (E.Vacchi)
Version: 3.0
Author URI: http://www.nowhereland.it
* Plugin Name: PrettyURLs
* Version: 3.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Enables SEO friendly, pretty URLs (via htaccess). Part of the standard distribution.
*/
/**
@ -20,11 +20,9 @@ define('PRETTYURLS_CATS', CACHE_DIR . '%%prettyurls-cats.tmp');
* File existance check
*/
# memo
# register_plugin_setup('plugin_id', 'setup_func');
// memo
// register_plugin_setup('plugin_id', 'setup_func');
function plugin_prettyurls_setup() {
if (file_exists(ABS_PATH . '.htaccess'))
return 1;
@ -38,14 +36,16 @@ function plugin_prettyurls_setup() {
class Plugin_PrettyURLs {
var $index = array();
var $status = 0;
var $date_handled = false;
var $categories = null;
var $fp_params;
function categories($force = true) {
if ($this->categories)
return;
@ -63,14 +63,11 @@ class Plugin_PrettyURLs {
$this->categories = $list;
}
function md5($id, $title) {
$date = date_from_id($id);
return md5($date ['y'] . $date ['m'] . $date ['d'] . $title);
}
function permalink($str, $id) {
global $fpdb, $post;
@ -91,7 +88,6 @@ class Plugin_PrettyURLs {
function feedlink($str, $type) {
return $this->baseurl . "feed/{$type}/";
}
function commentsfeedlink($str, $type, $id) {
@ -99,23 +95,21 @@ class Plugin_PrettyURLs {
return $link . "feed/{$type}/";
}
function staticlink($str, $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;
else
return $str;
} else {
return $this->baseurl . "category/{$catid}/";
}
}
function yearlink($str, $y) {
return $this->baseurl . "20$y/";
}
@ -128,21 +122,22 @@ class Plugin_PrettyURLs {
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);
$o = new FPDB_Query(array(
'start' => 0,
'count' => -1,
'fullparse' => false
), null);
#foreach ($entries as $id => $contents) {
// foreach ($entries as $id => $contents) {
while ($o->hasMore()) {
list ($id, $contents) = $o->getEntry();
$date = date_from_id($id);
@ -150,57 +145,48 @@ class Plugin_PrettyURLs {
$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)
return;
if (PRETTYURLS_TITLES) {
if ($c = array_search($matches [1], $this->categories))
$this->fp_params ['cat'] = $c;
else return $matches[0];
else
return $matches [0];
} else {
$this->fp_params ['cat'] = $matches [1];
}
}
/*
named matches are not supported here
* 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];
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[
// 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 {
@ -211,8 +197,6 @@ class Plugin_PrettyURLs {
} else {
$this->fp_params ['entry'] = $matches [1];
}
}
function handle_page($matches) {
@ -220,17 +204,14 @@ class Plugin_PrettyURLs {
$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');
@ -267,11 +248,8 @@ class Plugin_PrettyURLs {
$this->mode = $opt;
return $url;
}
/*
* here is where the real work is done.
*
@ -285,31 +263,25 @@ class Plugin_PrettyURLs {
* so that FlatPress can find it where it is expected
*
*/
function cache_init() {
global $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) {
@ -328,67 +300,77 @@ class Plugin_PrettyURLs {
if (false !== $i = strpos($url, '#'))
$url = substr($url, 0, $i);
if (strrpos($url, '/') != (strlen($url) - 1)) {
$url .= '/';
}
if ($url == '/')
return;
// date
$url = preg_replace_callback(
'!^/[0-9]{2}(?P<y>[0-9]{2})(/(?P<m>[0-9]{2})(/(?P<d>[0-9]{2}))?)?!',
array(&$this, 'handle_date'),
$url
);
$url = preg_replace_callback('!^/[0-9]{2}(?P<y>[0-9]{2})(/(?P<m>[0-9]{2})(/(?P<d>[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('{category/([^/]+)/}', array(&$this, 'handle_categories'), $url);
$url = preg_replace_callback('|page/([0-9]+)/$|', array(&$this, 'handle_page'), $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);
$url = preg_replace_callback('|^/([^/]+)|', array(
&$this,
'handle_entry'
), $url);
// if status = 2
/*
utils_error(404);
* utils_error(404);
*/
$url = preg_replace_callback('|^/comments|', array(&$this, 'handle_comment'), $url);
$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?
// is this a title change?
if (false !== ($ids = $this->cache_get($date ['y'], $date ['m'], $date ['d'])))
$hash = array_search($id, $ids);
else
@ -406,19 +388,14 @@ class Plugin_PrettyURLs {
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']);
@ -428,9 +405,7 @@ class Plugin_PrettyURLs {
$this->cache_save();
return true;
}
function cache_get($y, $m, $d = null, $h = null) {
@ -455,7 +430,6 @@ class Plugin_PrettyURLs {
$date = date_from_id($id);
$this->cache_delete_elem($id, $date);
$this->cache_save();
}
function cache_save() {
@ -464,29 +438,29 @@ class Plugin_PrettyURLs {
foreach ($months as $month => $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));
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;
else
$title = $id;
$url = $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/$title/";
if ($v > 0)
@ -494,20 +468,19 @@ class Plugin_PrettyURLs {
else
$caption = ' &laquo; ' . $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']) )
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']) {
@ -518,14 +491,13 @@ class Plugin_PrettyURLs {
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;
@ -533,21 +505,18 @@ class Plugin_PrettyURLs {
$l .= 'page/' . $page . '/';
}
return array($caption,$l);
return array(
$caption,
$l
);
}
}
global $plugin_prettyurls;
$plugin_prettyurls = new Plugin_PrettyURLs;
$plugin_prettyurls = new Plugin_PrettyURLs();
$plugin_prettyurls->categories();
if (!defined('MOD_ADMIN_PANEL')) {
if (!function_exists('get_nextpage_link')) :
@ -556,6 +525,7 @@ class Plugin_PrettyURLs {
global $plugin_prettyurls;
return $plugin_prettyurls->nextprevlink('NextPage', 1);
}
function get_prevpage_link() {
global $plugin_prettyurls;
return $plugin_prettyurls->nextprevlink('PrevPage', -1);
@ -565,34 +535,74 @@ class Plugin_PrettyURLs {
}
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('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);
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('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'));
add_filter('init', array(
&$plugin_prettyurls,
'cache_init'
));
if (class_exists('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");
@ -617,15 +627,10 @@ RewriteRule . {$blogroot}index.php [L]
STR;
}
$this->smarty->assign('cantsave',
( !is_writable(ABS_PATH) || (file_exists($f) && !is_writable($f)) )
);
$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;
@ -634,7 +639,8 @@ STR;
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'])) {
@ -651,7 +657,6 @@ STR;
}
admin_addpanelaction('plugin', 'prettyurls', true);
}
?>

View File

@ -1,20 +1,23 @@
<?php
/*
Plugin Name: QuickSpamFilter
Plugin URI: http://flatpress.nowherland.it/
Description: Quick ban words (edit the plugin to add more to the list)
Author: NoWhereMan
Version: 3.5.1
Author URI: http://www.nowhereland.it
* Plugin Name: QuickSpamFilter
* Version: 3.5.1
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Block comments by "bad" words. Part of the standard distribution.
*/
/**
* This plugin denies comments when they're containing "bad words",
* e.g. "href" (which indexes links)., etc.
* e.g.
* "href" (which indexes links)., etc.
*
* @global $smarty
* @param boolean $bool
* @param string $contents The comment
* @param string $contents
* The comment
* @return unknown
*/
function plugin_qspam_validate($bool, $contents) {
@ -28,11 +31,12 @@ function plugin_qspam_validate($bool, $contents) {
$BAN_WORDS = $qscfg ['wordlist'];
} else {
// rudimentary ban of links
$BAN_WORDS = array('href', '[url');
$BAN_WORDS = array(
'href',
'[url'
);
}
$qscfg['number'] = isset($qscfg['number'])
? $qscfg['number']
: 1;
$qscfg ['number'] = isset($qscfg ['number']) ? $qscfg ['number'] : 1;
$txt = strtolower(trim($contents ['content']));
$count = 0;
while ($w = array_pop($BAN_WORDS)) {
@ -41,7 +45,9 @@ function plugin_qspam_validate($bool, $contents) {
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;
@ -49,10 +55,12 @@ function plugin_qspam_validate($bool, $contents) {
add_action('comment_validate', 'plugin_qspam_validate', 5, 2);
if (class_exists('AdminPanelAction')) {
/**
* Provides an admin panel entry for QuickSpam setup.
*/
class admin_plugin_qspam extends AdminPanelAction {
var $langres = 'plugin:qspam';
/**
@ -67,12 +75,8 @@ if (class_exists('AdminPanelAction')){
*/
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);
}
@ -83,17 +87,16 @@ if (class_exists('AdminPanelAction')){
*/
function onsubmit($data = null) {
if ($_POST ['qs-wordlist']) {
$wordlist = isset($_POST['qs-wordlist'])
? stripslashes($_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');
@ -105,7 +108,8 @@ if (class_exists('AdminPanelAction')){
}
/**
* 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);
}

View File

@ -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

View File

@ -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);

View File

@ -1,28 +1,24 @@
<?php
/*
Plugin Name: Thumbnails
Plugin URI: http://www.nowhereland.it/
Description: Thumbnail plugin. Part of the standard distribution ;) If this is loaded scale parameter of images will create a scaled version of your img
Author: NoWhereMan real_nowhereman at user dot sf dot net
Version: 1.0
Author URI: http://www.nowhereland.it/
* Plugin Name: Thumbnails
* Version: 1.0
* Plugin URI: https://www.flatpress.org
* Author: FlatPress
* Author URI: https://www.flatpress.org
* Description: Creates thumbnails for scaled images. Part of the standard distribution.
*/
define('THUMB_DIR', '.thumbs');
if (!function_exists('imagegd2'))
{ define('PLUGIN_THUMB_ENABLED', false); }
else { define('PLUGIN_THUMB_ENABLED', true); }
function plugin_thumb_setup() {
return PLUGIN_THUMB_ENABLED? 1 : -1;
if (!function_exists('imagegd2')) {
define('PLUGIN_THUMB_ENABLED', false);
} else {
define('PLUGIN_THUMB_ENABLED', true);
}
function plugin_thumb_setup() {
return PLUGIN_THUMB_ENABLED ? 1 : -1;
}
/**
*
@ -30,17 +26,17 @@ function plugin_thumb_setup() {
*
* creates a thumbnail and caches the thumbnail in IMAGES_DIR/.thumb
*
* @param string $fpath string with filepath
* @param array $infos infos from getimagesize($fpath) function
* @param string $fpath
* string with filepath
* @param array $infos
* infos from getimagesize($fpath) function
* @param int $new_width
* @param int $new_height
*
* @return array array(string $thumbpath, int $thumbwidth, int $thumbheight)
*
*/
function plugin_thumb_create($fpath, $infos, $new_width, $new_height) {
if (!defined('PLUGIN_THUMB_ENABLED')) {
return array();
}
@ -58,33 +54,37 @@ function plugin_thumb_create($fpath, $infos, $new_width, $new_height) {
$thumbdir = dirname($fpath) . '/' . THUMB_DIR;
$thumbpath = $thumbdir . '/' . $thumbname;
if (file_exists($thumbpath)) {
$oldthumbinfo = getimagesize($thumbpath);
if ($new_width == $oldthumbinfo [0]) {
// already scaled
return array($thumbpath, $new_width, $new_height);
return array(
$thumbpath,
$new_width,
$new_height
);
}
}
@fs_mkdir($thumbdir);
// we support only jpeg's, png's and gif's
switch ($infos [2]) {
case 1: $image = imagecreatefromgif($fpath); break;
case 2: $image = imagecreatefromjpeg ($fpath); break;
case 3: $image = imagecreatefrompng($fpath);
case 1:
$image = imagecreatefromgif($fpath);
break;
case 2:
$image = imagecreatefromjpeg($fpath);
break;
case 3:
$image = imagecreatefrompng($fpath);
}
// $image = imagecreatefromgd2 ($fpath);
// create empty scaled and copy(resized) the picture
$scaled = imagecreatetruecolor($new_width, $new_height);
/*
* If gif or png preserve the alpha channel
@ -112,15 +112,17 @@ function plugin_thumb_create($fpath, $infos, $new_width, $new_height) {
}
@chmod($thumbpath, FILE_PERMISSIONS);
return array($thumbpath, $new_width, $new_height);
return array(
$thumbpath,
$new_width,
$new_height
);
}
function plugin_thumb_bbcodehook($actualpath, $props, $newsize) {
list ($width, $height) = $newsize;
if ($thumb = plugin_thumb_create($actualpath, $props, $width, $height))
$thumb = BBCODE_USE_WRAPPER?
("getfile.php?f=" . basename($actualpath) .'&amp;thumb=true') : $thumb[0];
$thumb = BBCODE_USE_WRAPPER ? ("getfile.php?f=" . basename($actualpath) . '&amp;thumb=true') : $thumb [0];
return $thumb;
}