Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaning and bugfixing #585

Merged
merged 11 commits into from
Jun 24, 2013
2 changes: 1 addition & 1 deletion sources/controllers/Recent.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function action_unread()

$query_this_board = 'id_board IN ({array_int:boards})';
$query_parameters['boards'] = $boards;
$context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
$context['querystring_board_limits'] = ';c=' . $_REQUEST['c'] . ';start=%1$d';
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions sources/subs/Bans.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,6 @@ function updateBanMembers()

function getMemberData($id)
{
$db = database();

$suggestions = array();
require_once(SUBSDIR . '/Members.subs.php');
$result = getBasicMemberData($id, array('moderation' => true));
Expand Down
10 changes: 4 additions & 6 deletions sources/subs/Cache.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function cache_quick_get($key, $file, $function, $params, $level = 1)
*/
function cache_put_data($key, $value, $ttl = 120)
{
global $boardurl, $modSettings, $memcached;
global $cache_hits, $cache_count, $db_show_debug;
global $modSettings, $memcached, $cache_hits, $cache_count, $db_show_debug;
global $cache_accelerator, $cache_enable;

if (empty($cache_enable))
Expand Down Expand Up @@ -210,9 +209,8 @@ function cache_put_data($key, $value, $ttl = 120)
*/
function cache_get_data($key, $ttl = 120)
{
global $boardurl, $modSettings, $memcached;
global $cache_hits, $cache_count, $db_show_debug;
global $cache_accelerator, $cache_enable;
global $modSettings, $memcached, $cache_hits, $cache_count, $db_show_debug;
global $cache_accelerator, $cache_enable, $expired;

if (empty($cache_enable))
return;
Expand Down Expand Up @@ -308,7 +306,7 @@ function cache_get_data($key, $ttl = 120)
*/
function get_memcached_server($level = 3)
{
global $modSettings, $memcached, $db_persist, $cache_memcached;
global $memcached, $db_persist, $cache_memcached;

$servers = explode(',', $cache_memcached);
$server = explode(':', trim($servers[array_rand($servers)]));
Expand Down
4 changes: 2 additions & 2 deletions sources/subs/Calendar.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,10 @@ function getEventProperties($event_id, $calendar_only = false)
SELECT
c.id_event, c.id_board, c.id_topic, MONTH(c.start_date) AS month,
DAYOFMONTH(c.start_date) AS day, YEAR(c.start_date) AS year,
(TO_DAYS(c.end_date) - TO_DAYS(c.start_date)) AS span, c.id_member, c.title' . ($simple ? '' : ',
(TO_DAYS(c.end_date) - TO_DAYS(c.start_date)) AS span, c.id_member, c.title' . ($calendar_only ? '' : ',
t.id_first_msg, t.id_member_started,
mb.real_name, m.modified_time') . '
FROM {db_prefix}calendar AS c' . ($simple ? '' : '
FROM {db_prefix}calendar AS c' . ($calendar_only ? '' : '
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = c.id_topic)
LEFT JOIN {db_prefix}members AS mb ON (mb.id_member = t.id_member_started)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)') . '
Expand Down
2 changes: 0 additions & 2 deletions sources/subs/Drafts.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ function draftsCount($member_id, $draft_type)
*/
function draftsRecipients($allRecipients, $recipient_ids)
{
$db = database();

// holds our results
$recipients = array(
'to' => array(),
Expand Down
2 changes: 1 addition & 1 deletion sources/subs/Graphics.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function resizeImageFile($source, $destination, $max_width, $max_height, $prefer
*/
function resizeImage($src_img, $destName, $src_width, $src_height, $max_width, $max_height, $force_resize = false, $preferred_format = 0)
{
global $gd2, $modSettings;
global $gd2;

if (checkImagick())
{
Expand Down
4 changes: 2 additions & 2 deletions sources/subs/List.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

function createList($listOptions)
{
global $context, $settings, $options, $txt, $modSettings, $scripturl;
global $context;

assert(isset($listOptions['id']));
assert(isset($listOptions['columns']));
Expand Down Expand Up @@ -275,4 +275,4 @@ function createList($listOptions)

// Make sure the template is loaded.
loadTemplate('GenericList');
}
}
33 changes: 6 additions & 27 deletions sources/subs/Profile.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ function setupProfileContext($fields)
{
global $profile_fields, $context, $cur_profile, $txt;

$db = database();

// Make sure we have this!
loadProfileFields(true);

Expand Down Expand Up @@ -290,9 +288,7 @@ function loadCustomFields($memID, $area = 'summary')
*/
function loadProfileFields($force_reload = false)
{
global $context, $profile_fields, $txt, $scripturl, $modSettings, $user_info, $old_profile, $cur_profile, $language;

$db = database();
global $context, $profile_fields, $txt, $scripturl, $modSettings, $user_info, $cur_profile, $language;

// Don't load this twice!
if (!empty($profile_fields) && !$force_reload)
Expand Down Expand Up @@ -927,10 +923,7 @@ function $preload: A function that is used to load data required for this eleme
*/
function saveProfileFields()
{
global $profile_fields, $profile_vars, $context, $old_profile;
global $post_errors, $modSettings, $cur_profile;

$db = database();
global $profile_fields, $profile_vars, $context, $old_profile, $post_errors, $cur_profile;

// Load them up.
loadProfileFields();
Expand Down Expand Up @@ -1070,8 +1063,6 @@ function saveProfileFields()
*/
function profileValidateEmail($email, $memID = 0)
{
global $context;

$db = database();

$email = strtr($email, array(''' => '\''));
Expand Down Expand Up @@ -1111,11 +1102,7 @@ function profileValidateEmail($email, $memID = 0)
*/
function saveProfileChanges(&$profile_vars, &$post_errors, $memID)
{
global $user_info, $txt, $modSettings, $user_profile;
global $context, $settings;


$db = database();
global $context, $user_profile;

// These make life easier....
$old_profile = &$user_profile[$memID];
Expand Down Expand Up @@ -1515,8 +1502,6 @@ function profileSendActivation()
{
global $profile_vars, $txt, $context, $scripturl, $cookiename, $cur_profile, $language, $modSettings;

$db = database();

require_once(SUBSDIR . '/Mail.subs.php');

// Shouldn't happen but just in case.
Expand Down Expand Up @@ -1568,8 +1553,6 @@ function profileLoadSignatureData()
{
global $modSettings, $context, $txt, $cur_profile, $memberContext;

$db = database();

// Signature limits.
list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
$sig_limits = explode(',', $sig_limits);
Expand Down Expand Up @@ -1758,9 +1741,7 @@ function profileLoadGroups()
*/
function profileLoadLanguages()
{
global $context, $modSettings, $settings, $cur_profile, $language;

$db = database();
global $context;

$context['profile_languages'] = array();

Expand All @@ -1782,9 +1763,7 @@ function profileLoadLanguages()
*/
function profileReloadUser()
{
global $modSettings, $context, $cur_profile, $profile_vars;

$db = database();
global $modSettings, $context, $cur_profile;

// Log them back in - using the verify password as they must have matched and this one doesn't get changed by anyone!
if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
Expand Down Expand Up @@ -2400,4 +2379,4 @@ function list_getUserWarningCount($memID)
$db->free_result($request);

return $total_warnings;
}
}
6 changes: 0 additions & 6 deletions sources/subs/Settings.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ static function prepare_db(&$config_vars)
*/
function save()
{
global $sc, $cookiename, $modSettings, $user_settings;
global $context;

validateToken('admin-ssc');

// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
Expand Down Expand Up @@ -434,8 +431,6 @@ function save()
*/
static function save_db(&$config_vars)
{
global $context;

validateToken('admin-dbsc');

$inlinePermissions = array();
Expand Down Expand Up @@ -648,7 +643,6 @@ static function save_file($config_vars)
if (filemtime(BOARDDIR . '/Settings.php') === $last_settings_change)
{
// save the old before we do anything
$file = BOARDDIR . '/Settings.php';
$settings_backup_fail = !@is_writable(BOARDDIR . '/Settings_bak.php') || !@copy(BOARDDIR . '/Settings.php', BOARDDIR . '/Settings_bak.php');
$settings_backup_fail = !$settings_backup_fail ? (!file_exists(BOARDDIR . '/Settings_bak.php') || filesize(BOARDDIR . '/Settings_bak.php') === 0) : $settings_backup_fail;

Expand Down
2 changes: 1 addition & 1 deletion sources/subs/Topic.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ function countMessagesSince($id_topic, $id_msg, $include_current = false, $only_
*/
function countMessagesBefore($id_topic, $id_msg, $include_current = false, $only_approved = false, $include_own = false)
{
global $modSettings, $user_info;
global $user_info;

$db = database();

Expand Down