Vergleich inc/functions.php - 1.8.35 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3255Zeile 3255
	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);

	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);


foreach($counters as $counter)

	
if($user)

	{

	{

		if(array_key_exists($counter, $changes))

		foreach($counters as $counter)

		{

		{

			if(substr($changes[$counter], 0, 2) == "+-")

			if(array_key_exists($counter, $changes))

			{

			{

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if((int)$changes[$counter] != 0)

				if(substr($changes[$counter], 0, 2) == "+-")






				{

				{

					$update_query[$counter] = $user[$counter] + $changes[$counter];



















					$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $user[$counter] + $changes[$counter];
}
}
else
{
$update_query[$counter] = $changes[$counter];
}

// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;

				}

				}

			}
else
{
$update_query[$counter] = $changes[$counter];
}

// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;

 
			}
}
}

			}
}
}

Zeile 3903Zeile 3906
		$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1));
$subscription = $db->fetch_array($query);


		$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1));
$subscription = $db->fetch_array($query);


		if(!empty($subscription) && $subscription['tid'])

		if($subscription)

		{
$subscription_method = (int)$subscription['notification'] + 1;
}

		{
$subscription_method = (int)$subscription['notification'] + 1;
}

Zeile 4703Zeile 4706
		if(!forum_password_validated($forum, true))
{
$pwverified = 0;

		if(!forum_password_validated($forum, true))
{
$pwverified = 0;

		}
else
{

		}
else
{

			// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)

			// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)

Zeile 6141Zeile 6144
	}

return $string_length;

	}

return $string_length;

}

/**

}

/**

 * Cuts a string at a specified point, mb strings accounted for
*
* @param string $string The string to cut.

 * Cuts a string at a specified point, mb strings accounted for
*
* @param string $string The string to cut.

Zeile 6151Zeile 6154
 * @param int $length (optional) How much to cut
* @param bool $handle_entities (optional) Properly handle HTML entities?
* @return string The cut part of the string.

 * @param int $length (optional) How much to cut
* @param bool $handle_entities (optional) Properly handle HTML entities?
* @return string The cut part of the string.

 */

 */

function my_substr($string, $start, $length=null, $handle_entities = false)
{
if($handle_entities)

function my_substr($string, $start, $length=null, $handle_entities = false)
{
if($handle_entities)

Zeile 6203Zeile 6206
	else
{
$string = strtolower($string);

	else
{
$string = strtolower($string);

	}

	}


return $string;
}


return $string;
}

Zeile 6323Zeile 6326
									. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)

									. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)

	{

	{

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

Zeile 6332Zeile 6335
	{
return false;
}

	{
return false;
}

}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.

}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.

 * @return string|bool The characterized ascii. False on failure
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));

 * @return string|bool The characterized ascii. False on failure
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));

}

/**

}

/**

 * Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)

 * Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)

{

{

	return unichr($matches[1]);
}


	return unichr($matches[1]);
}


Zeile 6383Zeile 6386
	$event_date = explode("-", $event['date']);
$event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

	$event_date = explode("-", $event['date']);
$event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);





	return $event_date;
}

/**
* Get the profile link.

	return $event_date;
}

/**
* Get the profile link.

 *
* @param int $uid The user id of the profile.

 *
* @param int $uid The user id of the profile.

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.


/**
* Get the announcement link.

Zeile 6443Zeile 6446
		}

if(!empty($onclick))

		}

if(!empty($onclick))

		{

		{

			$onclick = " onclick=\"{$onclick}\"";
}

			$onclick = " onclick=\"{$onclick}\"";
}





		return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

		return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

	}
}


	}
}


/**
* Build the forum link.
*
* @param int $fid The forum id of the forum.
* @param int $page (Optional) The page number of the forum.
* @return string The url to the forum.

/**
* Build the forum link.
*
* @param int $fid The forum id of the forum.
* @param int $page (Optional) The page number of the forum.
* @return string The url to the forum.

 */

 */

function get_forum_link($fid, $page=0)
{
if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

function get_forum_link($fid, $page=0)
{
if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

Zeile 6484Zeile 6487
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

	{
if($action)
{
$link = THREAD_URL_ACTION;

	{
if($action)
{
$link = THREAD_URL_ACTION;

			$link = str_replace("{action}", $action, $link);
}
else

			$link = str_replace("{action}", $action, $link);
}
else

Zeile 6503Zeile 6506
		if($action)
{
$link = THREAD_URL_ACTION;

		if($action)
{
$link = THREAD_URL_ACTION;

			$link = str_replace("{action}", $action, $link);

			$link = str_replace("{action}", $action, $link);

		}
else
{

		}
else
{

Zeile 6621Zeile 6624
		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

	{
return $user_cache[$uid];

	{
return $user_cache[$uid];

	}
elseif($uid > 0)
{

	}
elseif($uid > 0)
{

Zeile 6630Zeile 6633
		$user_cache[$uid] = $db->fetch_array($query);

return $user_cache[$uid];

		$user_cache[$uid] = $db->fetch_array($query);

return $user_cache[$uid];

	}

	}

	return array();
}


	return array();
}


Zeile 6682Zeile 6685
	if(isset($options['fields']))
{
$fields = array_merge((array)$options['fields'], $fields);

	if(isset($options['fields']))
{
$fields = array_merge((array)$options['fields'], $fields);

	}


	}


	$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));

if(isset($options['exists']))
{
return (bool)$db->num_rows($query);

	$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));

if(isset($options['exists']))
{
return (bool)$db->num_rows($query);

	}


	}


	return $db->fetch_array($query);
}

/**
* Get the forum of a specific forum id.

	return $db->fetch_array($query);
}

/**
* Get the forum of a specific forum id.

 *

 *

 * @param int $fid The forum id of the forum.
* @param int $active_override (Optional) If set to 1, will override the active forum status
* @return array|bool The database row of a forum. False on failure

 * @param int $fid The forum id of the forum.
* @param int $active_override (Optional) If set to 1, will override the active forum status
* @return array|bool The database row of a forum. False on failure

Zeile 6742Zeile 6745
 * @return array|bool The database row of the thread. False on failure
*/
function get_thread($tid, $recache = false)

 * @return array|bool The database row of the thread. False on failure
*/
function get_thread($tid, $recache = false)

{

{

	global $db;
static $thread_cache;

	global $db;
static $thread_cache;





	$tid = (int)$tid;

if(isset($thread_cache[$tid]) && !$recache)

	$tid = (int)$tid;

if(isset($thread_cache[$tid]) && !$recache)

	{

	{

		return $thread_cache[$tid];
}
else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");
$thread = $db->fetch_array($query);

		return $thread_cache[$tid];
}
else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");
$thread = $db->fetch_array($query);





		if($thread)

		if($thread)

		{

		{

			$thread_cache[$tid] = $thread;
return $thread;

			$thread_cache[$tid] = $thread;
return $thread;

		}
else
{

		}
else
{

			$thread_cache[$tid] = false;
return false;
}

			$thread_cache[$tid] = false;
return false;
}

Zeile 6800Zeile 6803
		else
{
$post_cache[$pid] = false;

		else
{
$post_cache[$pid] = false;

			return false;
}
}

			return false;
}
}

}

/**

}

/**

Zeile 6817Zeile 6820
	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

	}


$inactive = array();



$inactive = array();


Zeile 6840Zeile 6843

return $inactiveforums;
}


return $inactiveforums;
}





/**
* Checks to make sure a user has not tried to login more times than permitted
*

/**
* Checks to make sure a user has not tried to login more times than permitted
*

Zeile 6862Zeile 6865
		$attempts = $db->fetch_array($query);

if($attempts['loginattempts'] <= 0)

		$attempts = $db->fetch_array($query);

if($attempts['loginattempts'] <= 0)

		{

		{

			return 0;
}
}

			return 0;
}
}

Zeile 6981Zeile 6984
	if($db->fetch_field($query, "emails") > 0)
{
return true;

	if($db->fetch_field($query, "emails") > 0)
{
return true;

	}


	}


	return false;
}


	return false;
}


Zeile 7045Zeile 7048
		"~"
);
$terms = str_replace($bad_characters, '', $terms);

		"~"
);
$terms = str_replace($bad_characters, '', $terms);

 
	$words = array();


// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)
{
$inquote = false;
$terms = explode("\"", $terms);


// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)
{
$inquote = false;
$terms = explode("\"", $terms);

		$words = array();

 
		foreach($terms as $phrase)
{
$phrase = htmlspecialchars_uni($phrase);

		foreach($terms as $phrase)
{
$phrase = htmlspecialchars_uni($phrase);

Zeile 7097Zeile 7100
				$words[] = trim($word);
}
}

				$words[] = trim($word);
}
}

	}

if(!is_array($words))
{
return false;

 
	}

// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, 'build_highlight_array_sort');

	}

// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, 'build_highlight_array_sort');

 

$highlight_cache = array();


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)