Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Sep 15, 2018
1 parent 24f907a commit 4bad8e0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 54 deletions.
18 changes: 8 additions & 10 deletions public_html/lib-common.php
Expand Up @@ -8,7 +8,7 @@
// | |
// | Geeklog common library. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2017 by the following authors: |
// | Copyright (C) 2000-2018 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
// | Mark Limburg - mlimburg AT users DOT sourceforge DOT net |
Expand Down Expand Up @@ -286,7 +286,7 @@
/**
* This provides the ability to set css and javascript.
*
* @global $_SCRIPTS Scripts
* @global \Geeklog\Resource $_SCRIPTS
*/
//$_SCRIPTS = new Scripts();

Expand Down Expand Up @@ -6072,19 +6072,19 @@ function COM_getTopicSQL($type = 'WHERE', $u_id = 0, $table = '')
* Strip slashes from a string only when magic_quotes_gpc = on.
*
* @param string $text The text
* @return string The text, possibly without slashes.
* @return string|array The text, possibly without slashes.
*/
function COM_stripslashes($text)
{
if (@get_magic_quotes_gpc()) {
if (is_array($text)) {
return (array_map('stripslashes', $text));
return array_map('stripslashes', $text);
} else {
return (stripslashes($text));
return stripslashes($text);
}
}

return ($text);
return $text;
}

/**
Expand Down Expand Up @@ -6456,16 +6456,15 @@ function COM_dateDiff($interval, $date1, $date2)
* @param string $dir Directory to clean of files and folders
* @param array $leave_dirs Array of directory names to not delete
* @param array $leave_files Array of file names to not delete
* @return nothing
*/
function COM_cleanDirectory($dir, $leave_dirs = array(), $leave_files = array()) {

foreach( glob("$dir/*") as $file ) {
foreach (glob("$dir/*") as $file) {
if (is_dir($file)) {
if (!in_array(basename($file), $leave_dirs)) {
COM_deleteFiles($file); // delete all sub directories and files in those directories
}
} elseif( !in_array(basename($file), $leave_files) ) {
} elseif (!in_array(basename($file), $leave_files) ) {
unlink($file);
}
}
Expand All @@ -6476,7 +6475,6 @@ function COM_cleanDirectory($dir, $leave_dirs = array(), $leave_files = array())
*
* @since Geeklog-2.2.0
* @param string $dir Directory to clean of files and folders
* @return nothing
*/
function COM_deleteFiles($dir) {

Expand Down
19 changes: 9 additions & 10 deletions system/classes/search.class.php
Expand Up @@ -8,7 +8,7 @@
// | |
// | Geeklog search class. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2011 by the following authors: |
// | Copyright (C) 2000-2018 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT geeklog DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
Expand All @@ -31,7 +31,7 @@
// | |
// +---------------------------------------------------------------------------+

if (stripos($_SERVER['PHP_SELF'], 'search.class.php') !== false) {
if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file can not be used on its own.');
}

Expand Down Expand Up @@ -379,7 +379,7 @@ public function showForm()
*/
private function _searchStories()
{
global $_TABLES, $_DB_dbms, $LANG09;
global $_TABLES, $LANG09;

// Make sure the query is SQL safe
$query = trim(DB_escapeString($this->_query));
Expand Down Expand Up @@ -441,7 +441,7 @@ private function _searchStories()
$sql .= 'AND (c.uid = \'' . $this->_author . '\') ';
}

$search_c = new SearchCriteria('comments', array($LANG09[65], $LANG09[66]));
$search_c = new SearchCriteria('comments', $LANG09[66]);

$columns = array('title' => 'c.title', 'comment');
$sql .= $search_c->getDateRangeSQL('AND', 'c.date', $this->_dateStart, $this->_dateEnd);
Expand Down Expand Up @@ -563,7 +563,7 @@ public function doSearch()
$num_results = 0;

foreach ($result_plugins as $result) {
if (is_a($result, 'SearchCriteria')) {
if ($result instanceof SearchCriteria) {
$debug_info = $result->getName() . ' using APIv2';

if ($this->_type !== 'all' && $this->_type != $result->getName()) {
Expand Down Expand Up @@ -840,7 +840,6 @@ private function _shortenText($keyword, $text, $num_words = 7)
$end = 0;
$rt = '<b>...</b> ';
} else {
$str = substr($text, $pos, $pos_space - $pos);
$m = (int) (($num_words - 1) / 2);
$key = $this->_arraySearch($keyword, $words);
if ($key === false) {
Expand All @@ -851,9 +850,9 @@ private function _shortenText($keyword, $text, $num_words = 7)
} elseif ($key <= $m) {
// Keyword at the start of text
$start = 0 - $key;
$end = $num_words - 1;
$end = ($key + $m <= $word_count - 1)
? $key : $word_count - $m - 1;
? $key
: $word_count - $m - 1;
$abs_length = abs($start) + abs($end) + 1;
if ($abs_length < $num_words) {
$end += ($num_words - $abs_length);
Expand Down Expand Up @@ -953,10 +952,10 @@ private function _convertsqlCallback($replace, $match)
}

/**
* Converts the MySQL CONCAT function to the MS SQL / Postgres equivalents
* Converts the MySQL CONCAT function to the Postgres equivalents
*
* @param string $sql The SQL to convert
* @return string MS SQL or PostgreSQL friendly SQL
* @return string PostgreSQL friendly SQL
*/
private function _convertSql($sql)
{
Expand Down
16 changes: 5 additions & 11 deletions system/lib-article.php
Expand Up @@ -933,8 +933,8 @@ function STORY_deleteImages($sid)
* Delete a story.
* This is used to delete a story from the list of stories.
*
* @param string $sid ID of the story to delete
* @return string HTML, e.g. a meta redirect
* @param string $sid ID of the story to delete
* @return array
*/
function STORY_deleteStory($sid)
{
Expand Down Expand Up @@ -1419,8 +1419,6 @@ function plugin_moderationvalues_story_draft()
*/
function plugin_moderationdelete_story_draft($sid)
{
global $_TABLES;

STORY_deleteStory($sid);

return '';
Expand Down Expand Up @@ -1475,15 +1473,13 @@ function plugin_moderationapprove_story_draft($sid)
*
* @param int $grp_id Group ID
* @param string $mode type of change: 'new', 'edit', or 'delete'
* @return void
*/
function plugin_group_changed_story($grp_id, $mode)
{
global $_TABLES, $_GROUPS;

if ($mode == 'delete') {
// Change any deleted group ids to Story Admin if exist, if does not change to root group
$new_group_id = 0;
if (isset($_GROUPS['Story Admin'])) {
$new_group_id = $_GROUPS['Story Admin'];
} else {
Expand All @@ -1499,7 +1495,7 @@ function plugin_group_changed_story($grp_id, $mode)

// Update Story with new group id
$sql = "UPDATE {$_TABLES['stories']} SET group_id = $new_group_id WHERE group_id = $grp_id";
$result = DB_query($sql);
DB_query($sql);
}
}

Expand Down Expand Up @@ -1645,7 +1641,7 @@ function plugin_autotags_story($op, $content = '', $autotag = array())
*/
function plugin_savecomment_article($title, $comment, $id, $pid, $postmode)
{
global $_CONF, $_TABLES, $LANG03, $_USER;
global $_CONF, $_TABLES, $LANG03;

$retval = '';

Expand Down Expand Up @@ -1887,7 +1883,7 @@ function plugin_configchange_article($group, $changes = array())
*/
function service_submit_story($args, &$output, &$svc_msg)
{
global $_CONF, $_TABLES, $_USER, $LANG24, $MESSAGE, $_GROUPS;
global $_CONF, $_TABLES, $_USER, $LANG24, $MESSAGE;

$output = ''; // Initialize as a string variable

Expand Down Expand Up @@ -2375,8 +2371,6 @@ function service_get_story($args, &$output, &$svc_msg)
{
global $_CONF, $_TABLES, $_USER;

$retval = 0;

if (!isset($_CONF['atom_max_stories'])) {
$_CONF['atom_max_stories'] = 10; // set a reasonable default
}
Expand Down
40 changes: 17 additions & 23 deletions system/lib-plugins.php
Expand Up @@ -8,7 +8,7 @@
// | |
// | This file implements plugin support in Geeklog. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2017 by the following authors: |
// | Copyright (C) 2000-2018 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
// | Blaine Lang - blaine AT portalparts DOT com |
Expand Down Expand Up @@ -84,7 +84,6 @@
*
* @param string $function_name holds name of function to call
* @param array $args arguments to send to function
* @return void
* @access private
* @internal not to be used by plugins
*/
Expand Down Expand Up @@ -381,7 +380,7 @@ function PLG_uninstall($type)
*/
function PLG_enableStateChange($type, $enable)
{
global $_CONF, $_TABLES, $_DB_table_prefix;
global $_CONF;

$args[1] = $enable;

Expand All @@ -391,19 +390,16 @@ function PLG_enableStateChange($type, $enable)
require_once($_CONF['path'] . 'plugins/' . $type . '/functions.inc');
}

return PLG_callFunctionForOnePlugin('plugin_enablestatechange_' . $type,
$args);
return PLG_callFunctionForOnePlugin('plugin_enablestatechange_' . $type, $args);
}

/**
* Checks to see if user is a plugin moderator
* Geeklog is asking if the user is a moderator for any installed plugins.
*
* @return boolean True if current user is moderator of plugin otherwise false
*/
function PLG_isModerator()
{
return PLG_callFunctionForAllPlugins('ismoderator');
PLG_callFunctionForAllPlugins('ismoderator');
}

/**
Expand Down Expand Up @@ -759,16 +755,16 @@ function PLG_getSearchTypes()
* and return their results. Results come back in an array of HTML
* formatted table rows that can be quickly printed by search.php
*
* @param string $query What the user searched for
* @param string $dateStart beginning of date range to search for
* @param string $dateEnd ending date range to search for
* @param string $topic the topic the user searched within
* @param string $type Type of items they are searching, or 'all'
* @param int $author UID...only return results for this person
* @param string $keyType search key type: 'all', 'phrase', 'any'
* @param int $page page number of current search (deprecated)
* @param int $perPage number of results per page (deprecated)
* @return array Returns search results
* @param string $query What the user searched for
* @param string $dateStart beginning of date range to search for
* @param string $dateEnd ending date range to search for
* @param string $topic the topic the user searched within
* @param string $type Type of items they are searching, or 'all'
* @param int $author UID...only return results for this person
* @param string $keyType search key type: 'all', 'phrase', 'any'
* @param int $page page number of current search (deprecated)
* @param int $perPage number of results per page (deprecated)
* @return array of SearchCriteria
*/
function PLG_doSearch($query, $dateStart, $dateEnd, $topic, $type, $author, $keyType = 'all', $page = 1, $perPage = 10)
{
Expand Down Expand Up @@ -1323,9 +1319,8 @@ function PLG_groupChanged($grp_id, $mode)
* Geeklog is about to display the edit form for the user's profile. Plugins
* now get a chance to add their own variables and input fields to the form.
*
* @param int $uid user id of the user profile to be edited
* @param ref &$template reference of the Template for the profile edit form
* @return void
* @param int $uid user id of the user profile to be edited
* @param Template $template reference of the Template for the profile edit form
*/
function PLG_profileVariablesEdit($uid, &$template)
{
Expand Down Expand Up @@ -3157,7 +3152,7 @@ function PLG_pluginStateChange($type, $status)
function PLG_resolveDependencies()
{
global $_PLUGINS, $_TABLES;
$retval = '';

$flag = true; // false means that all dependencies are resolved
while ($flag) { // loop until ALL dependencies are satisfied
$flag = false; // set this if any plugin has been disabled during the loop
Expand Down Expand Up @@ -3322,7 +3317,6 @@ function PLG_checkDependencies($pi_name)
{
global $_TABLES, $_DB_dbms;

$retval = true;
$params = PLG_getParams($pi_name);

$dbSupported = false; // True if we support the database that the plugin is requiring
Expand Down

0 comments on commit 4bad8e0

Please sign in to comment.