From 5ec74810302fc246442a8b067fc36fdf937e3c36 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Mon, 6 May 2013 09:47:19 +0200 Subject: [PATCH] Port of patch #16 to 2.0 --- bundled-libs/Onyx/RSS.php | 2 +- .../plugins/ImageManager/Classes/NetPBM.php | 2 +- htmlarea/plugins/SuperClean/tidy.php | 2 +- include/admin/category.inc.php | 2 +- include/admin/importers/blogger.inc.php | 2 +- include/admin/importers/livejournal.inc.php | 3 +-- include/db/sqlrelay.inc.php | 3 +-- include/functions.inc.php | 2 +- include/functions_images.inc.php | 17 ++++++++--------- include/functions_smarty.inc.php | 2 +- include/plugin_internal.inc.php | 4 ++-- .../serendipity_event_entryproperties.php | 2 +- .../serendipity_event_karma.php | 6 ++++-- .../serendipity_event_spamblock.php | 13 ++++++++----- .../serendipity_event_statistics.php | 4 ++-- .../serendipity_event_textile/classTextile.php | 2 -- plugins/serendipity_event_textile/textile.php | 4 +--- 17 files changed, 35 insertions(+), 37 deletions(-) diff --git a/bundled-libs/Onyx/RSS.php b/bundled-libs/Onyx/RSS.php index 6f001add..dffac932 100644 --- a/bundled-libs/Onyx/RSS.php +++ b/bundled-libs/Onyx/RSS.php @@ -166,7 +166,7 @@ class ONYX_RSS clearstatcache(); if (!($fp = @fopen($file, 'r'))) { - $this->raiseError((__LINE__-2), 'Could not read contents of cache file ('.$cache_file.').'); + $this->raiseError((__LINE__-2), 'Could not read contents of cache file ('.$file.').'); return false; } $this->data = unserialize(fread($fp, filesize($file))); diff --git a/htmlarea/plugins/ImageManager/Classes/NetPBM.php b/htmlarea/plugins/ImageManager/Classes/NetPBM.php index 2e3f58f6..aee67864 100755 --- a/htmlarea/plugins/ImageManager/Classes/NetPBM.php +++ b/htmlarea/plugins/ImageManager/Classes/NetPBM.php @@ -177,7 +177,7 @@ Class Image_Transform_Driver_NetPBM extends Image_Transform ."$size -x $x -y ".$y+$size." -text \"$text\""; } // End addText - function _postProcess($type, $quality, $save_type) + function _postProcess($type, $quality, $save_type=null) { $type = is_null($type) || $type==''? $this->type : $type; $save_type = is_null($save_type) || $save_type==''? $this->type : $save_type; diff --git a/htmlarea/plugins/SuperClean/tidy.php b/htmlarea/plugins/SuperClean/tidy.php index 5812b93f..76ddf2f8 100755 --- a/htmlarea/plugins/SuperClean/tidy.php +++ b/htmlarea/plugins/SuperClean/tidy.php @@ -64,7 +64,7 @@ die('disabled in s9y'); $socket = fsockopen($Host, 80, $errno, $errstr); if (!$socket) { $result = "($errno) $errstr"; - return $Result; + return $result; } fputs($socket, $ReqHeader); diff --git a/include/admin/category.inc.php b/include/admin/category.inc.php index ccb208dc..45853f02 100644 --- a/include/admin/category.inc.php +++ b/include/admin/category.inc.php @@ -54,7 +54,7 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) { WHERE categoryid = ". (int)$parentid); $data['subcat'] = sprintf(ALREADY_SUBCATEGORY, htmlspecialchars($r[0]['category_name']), htmlspecialchars($name)); } else { - serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub']); + serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub'], $admin_category); serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'read', $serendipity['POST']['cat']['read_authors']); serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'write', $serendipity['POST']['cat']['write_authors']); } diff --git a/include/admin/importers/blogger.inc.php b/include/admin/importers/blogger.inc.php index 767ac422..f0600076 100644 --- a/include/admin/importers/blogger.inc.php +++ b/include/admin/importers/blogger.inc.php @@ -184,7 +184,7 @@ class Serendipity_Import_Blogger extends Serendipity_Import { 'realname' => $author, 'username' => $author, 'userlevel' => 0, - 'password' => md5($defaultpass)) + 'password' => md5($this->data['defaultpass'])) ); $authorid = serendipity_db_insert_id('authors', 'authorid'); $authorList[$authorid] = $author; diff --git a/include/admin/importers/livejournal.inc.php b/include/admin/importers/livejournal.inc.php index 2665b05e..d34957cd 100644 --- a/include/admin/importers/livejournal.inc.php +++ b/include/admin/importers/livejournal.inc.php @@ -156,9 +156,8 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import { } function gatherComments($entrydata) { - $comments; + $comments = array(); if (is_array($entrydata['children'])) { - $comments = array(); foreach($entrydata['children'] AS $idx3 => $commententry) { if ($commententry['tag'] == 'comment' && is_array($commententry['children'])) { $comment = array( diff --git a/include/db/sqlrelay.inc.php b/include/db/sqlrelay.inc.php index 776f3a5b..e03f42de 100644 --- a/include/db/sqlrelay.inc.php +++ b/include/db/sqlrelay.inc.php @@ -387,7 +387,6 @@ function serendipity_db_limit_sql($limitstring) { case "mysql": return ' LIMIT ' . $limitstring; case "postgresql": - $limit; $limit_split = explode(',', $limitstring); if (count($limit_split) > 1) { $limit = ' LIMIT ' . $limit_split[0] . ' OFFSET ' . $limit_split[1]; @@ -510,7 +509,7 @@ function serendipity_db_schema_import($query) { */ function serendipity_db_probe($hash, &$errs) { global $serendipity; - $c; + $c = null; if (!function_exists('sqlrcon_alloc')) { $errs[] = 'No sql_relay extension found. Please check your webserver installation or contact your systems administrator regarding this problem.'; diff --git a/include/functions.inc.php b/include/functions.inc.php index 45d9536f..5fa45058 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1072,7 +1072,7 @@ function serendipity_addCategory($name, $desc, $authorid, $icon, $parentid) { * @param int The new category subcat hiding * @return null */ -function serendipity_updateCategory($cid, $name, $desc, $authorid, $icon, $parentid, $sort_order = 0, $hide_sub = 0) { +function serendipity_updateCategory($cid, $name, $desc, $authorid, $icon, $parentid, $sort_order = 0, $hide_sub = 0, $admin_category = '') { global $serendipity; $query = "UPDATE {$serendipity['dbPrefix']}category diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php index 7894c604..1a3f7695 100644 --- a/include/functions_images.inc.php +++ b/include/functions_images.inc.php @@ -52,7 +52,7 @@ function serendipity_isActiveFile($file) { * @param boolean Apply strict directory checks, or include subdirectories? * @return array Resultset of images */ -function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order = false, $ordermode = false, $directory = '', $filename = '', $keywords = '', $filter = array(), $strict_directory = false) { +function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total=null, $order = false, $ordermode = false, $directory = '', $filename = '', $keywords = '', $filter = array(), $strict_directory = false) { global $serendipity; $cond = array( @@ -1132,7 +1132,7 @@ function serendipity_syncThumbs($deleteThumbs = false) { if ($tdim['noimage']) { // Delete it so it can be regenerated if (@unlink($fthumb)) { - printf(DELETE_THUMBNAIL . "
\n", $sthumb); + printf(DELETE_THUMBNAIL . "
\n", $sThumb); $i++; } } else { @@ -1144,7 +1144,7 @@ function serendipity_syncThumbs($deleteThumbs = false) { // This thumbnail is incorrect; delete it so // it can be regenerated if (@unlink($fthumb)) { - printf(DELETE_THUMBNAIL . "
\n", $sthumb); + printf(DELETE_THUMBNAIL . "
\n", $sThumb); $i++; } } @@ -2257,7 +2257,6 @@ function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $is_ed $dprops = explode(';', $serendipity['mediaProperties']); $keywords = explode(';', $serendipity['mediaKeywords']); - $now = serendipity_serverOffsetHour(); $show = array(); foreach($new_media AS $idx => $media) { $props =& serendipity_fetchMediaProperties($media['image_id']); @@ -2287,7 +2286,7 @@ function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $is_ed return serendipity_showMedia( $show, $mirror, - $url, + '', false, 1, false, @@ -2399,7 +2398,7 @@ function serendipity_parseMediaProperties(&$dprops, &$keywords, &$media, &$props if (empty($val)) { switch($parts[0]) { case 'DATE': - $default_iptc_val = $now; + $default_iptc_val = serendipity_serverOffsetHour(); case 'RUN_LENGTH': if (!isset($default_iptc_val)) { @@ -2533,7 +2532,7 @@ function serendipity_mediaTypeCast($key, $val, $invert = false) { * @return array array('image_id') holding the last created thumbnail for immediate processing * */ -function serendipity_insertMediaProperty($property_group, $property_subgroup = '', $image_id, &$media, $use_cast = true) { +function serendipity_insertMediaProperty($property_group, $property_subgroup, $image_id, &$media, $use_cast = true) { global $serendipity; serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mediaproperties @@ -2562,7 +2561,7 @@ function serendipity_insertMediaProperty($property_group, $property_subgroup = ' VALUES (%d, '%s', '%s', '%s', '%s')", $image_id, serendipity_db_escape_string($property_group), - serendipity_db_escape_string($useproperty_subgroup), + serendipity_db_escape_string($use_property_subgroup), serendipity_db_escape_string($insert_key), serendipity_db_escape_string($insert_val)); serendipity_db_query($q); @@ -2850,7 +2849,7 @@ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lin 'nextIMG' => serendipity_getTemplateFile('admin/img/next.png'), 'token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, - 'blimit_path' => basename($limit_path), + 'blimit_path' => empty($smarty_vars['limit_path']) ? '':basename($smarty_vars['limit_path']), 'only_path' => $serendipity['GET']['only_path'], 'only_filename' => $serendipity['GET']['only_filename'], 'sortorder' => $serendipity['GET']['sortorder'], diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index d1dbb8cb..2c851f2c 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -584,7 +584,7 @@ function serendipity_smarty_refhookPlugin(&$eventData, $hook, $addData = null) { // $serendipity['skip_smarty_hook'] = array('entries_header'); // That would only skip the entries_header event hook, but allow all others. // Of course it cannot be used in conjunction with the all-blocking skip_smarty_hooks. - if (isset($serendipity['skip_smarty_hook']) && is_array($serendipity['skip_smarty_hook']) && isset($serendipity['skip_smarty_hook'][$params['hook']])) { + if (isset($serendipity['skip_smarty_hook']) && is_array($serendipity['skip_smarty_hook']) && isset($serendipity['skip_smarty_hook'][$hook])) { return; } diff --git a/include/plugin_internal.inc.php b/include/plugin_internal.inc.php index fcda5f87..1c5c956d 100644 --- a/include/plugin_internal.inc.php +++ b/include/plugin_internal.inc.php @@ -663,7 +663,7 @@ class serendipity_topreferrers_plugin extends serendipity_plugin { } else { $use_links = serendipity_db_bool($use_links); } - echo serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7)); + serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7)); } } @@ -729,7 +729,7 @@ class serendipity_topexits_plugin extends serendipity_plugin { $use_links = serendipity_db_bool($use_links); } - echo serendipity_displayTopExits($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7)); + serendipity_displayTopExits($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7)); } } diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index ddc506b1..a79326b6 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -559,7 +559,7 @@ class serendipity_event_entryproperties extends serendipity_event $elements = explode(',', $this->get_config('sequence')); foreach($elements AS $element) { - $this->showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more); + $this->showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users); } ?> diff --git a/plugins/serendipity_event_karma/serendipity_event_karma.php b/plugins/serendipity_event_karma/serendipity_event_karma.php index 3814cdaa..f9145eb9 100644 --- a/plugins/serendipity_event_karma/serendipity_event_karma.php +++ b/plugins/serendipity_event_karma/serendipity_event_karma.php @@ -713,7 +713,7 @@ class serendipity_event_karma extends serendipity_event if ($this->image_name) { // Is this a single-image bar, or a single segment? $ratio = $this->image_width / $this->image_height; - if ($ratio < $max_segment_ratio) { + if ($ratio < $this->max_segment_ratio) { // This is probably a single segment. Square segments // will have a ratio of 0.3; long, flat segments won't // get up to 1.0 unless they're 3 times as wide as they @@ -1760,6 +1760,8 @@ function invertSelection() { * @return string an HTML string including working images of all the rating bars in the img/ directory. */ function createRatingSelector() { + global $serendipity; + // Since the inputs are set up with the proper names, the config item // gets saved automatically, with no need for magic @@ -1817,7 +1819,7 @@ function invertSelection() { $width = $fdata['width']; $ratio = $width / $height; // If this is a single segment, adjust width - if ($ratio < $max_segment_ratio) { + if ($ratio < $this->max_segment_ratio) { $width = $width * 5; } $height = $height / 3; diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index dca9dc9e..514544e8 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -478,7 +478,9 @@ var $filter_defaults; } } - function akismetRequest($api_key, $data, &$ret, $action = 'comment-check') { + function akismetRequest($api_key, $data, &$ret, $action = 'comment-check', $eventData = null, $addData = null) { + global $serendipity; + $opt = array( 'method' => 'POST', 'http' => '1.1', @@ -515,7 +517,7 @@ var $filter_defaults; } if (empty($server)) { - $this->log($this->logfile, $eventData['id'], 'AKISMET_SERVER', 'No Akismet server found', $addData); + $this->log($this->logfile, is_null($eventData) ? 0:$eventData['id'], 'AKISMET_SERVER', 'No Akismet server found', $addData); $ret['is_spam'] = false; $ret['message'] = 'No server for Akismet request'; return; @@ -589,7 +591,7 @@ var $filter_defaults; } - function tellAboutComment($where, $api_key = '', $comment_id, $is_spam) { + function tellAboutComment($where, $api_key, $comment_id, $is_spam) { global $serendipity; $comment = serendipity_db_query(" SELECT C.*, L.useragent as log_useragent, E.title as entry_title " . " FROM {$serendipity['dbPrefix']}comments C, {$serendipity['dbPrefix']}spamblocklog L , {$serendipity['dbPrefix']}entries E " @@ -627,7 +629,7 @@ var $filter_defaults; if (function_exists('serendipity_request_end')) serendipity_request_end(); } - function &getBlacklist($where, $api_key = '', &$eventData, &$addData) { + function &getBlacklist($where, $api_key, &$eventData, &$addData) { global $serendipity; $ret = false; @@ -998,7 +1000,7 @@ var $filter_defaults; $tipval_method = ($trackback_ipvalidation_option == 'reject'?'REJECTED':'MODERATE'); // Getting host from url successfully? if (!is_array($parts)) { // not a valid URL - $this->log($logfile, $eventData['id'], $tipval_method, sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_IPVALIDATION, $addData['url'], '', '')); + $this->log($logfile, $eventData['id'], $tipval_method, sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_IPVALIDATION, $addData['url'], '', ''), $addData); if ($trackback_ipvalidation_option == 'reject') { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_IPVALIDATION, $addData['url']); @@ -1543,6 +1545,7 @@ var $filter_defaults; if($ftc) { // Check for maximum number of links before rejecting $link_count = substr_count(strtolower($addData['comment']), 'http://'); + $links_reject = $this->get_config('links_reject', 20); if ($links_reject > 0 && $link_count > $links_reject) { $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_REJECT, $addData); $eventData = array('allow_comments' => false); diff --git a/plugins/serendipity_event_statistics/serendipity_event_statistics.php b/plugins/serendipity_event_statistics/serendipity_event_statistics.php index f5b1c393..cfb8fe42 100644 --- a/plugins/serendipity_event_statistics/serendipity_event_statistics.php +++ b/plugins/serendipity_event_statistics/serendipity_event_statistics.php @@ -532,11 +532,11 @@ class serendipity_event_statistics extends serendipity_event
-
+

-
+

$max_items)); ?> diff --git a/plugins/serendipity_event_textile/classTextile.php b/plugins/serendipity_event_textile/classTextile.php index f8e8338f..edf8e9d9 100644 --- a/plugins/serendipity_event_textile/classTextile.php +++ b/plugins/serendipity_event_textile/classTextile.php @@ -1092,8 +1092,6 @@ class Textile function textile_popup_help($name, $helpvar, $windowW, $windowH) { return ' ' . $name . '
'; - - return $out; } // ------------------------------------------------------------- diff --git a/plugins/serendipity_event_textile/textile.php b/plugins/serendipity_event_textile/textile.php index c18c58e0..dc0f1ec2 100644 --- a/plugins/serendipity_event_textile/textile.php +++ b/plugins/serendipity_event_textile/textile.php @@ -262,7 +262,7 @@ Applying Attributes: $matched = str_replace($pl[0],'',$matched); } if(preg_match("/([)]+)/",$matched,$pr)) { - dump($pr); +# dump($pr); $textile_style[] = "padding-right:".strlen($pr[1])."em;"; $matched = str_replace($pr[0],'',$matched); } @@ -882,8 +882,6 @@ Applying Attributes: // ------------------------------------------------------------- function textile_popup_help($name,$helpvar,$windowW,$windowH) { return ' '.$name.'
'; - - return $out; } // -------------------------------------------------------------