Skip to content

Commit

Permalink
fixed a couple of stupid things
Browse files Browse the repository at this point in the history
Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele authored and emanuele45 committed Feb 27, 2013
1 parent ab6c9a7 commit bc74831
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions sources/admin/ManageBans.php
Expand Up @@ -887,7 +887,7 @@ function validateTriggers(&$triggers)
else
$context['ban_erros'][] = 'no_bantype_selected';

if (isset($value))
if (isset($value) && !is_array($value))
$log_info[] = array(
'value' => $value,
'bantype' => $key,
Expand Down Expand Up @@ -969,18 +969,18 @@ function addTriggers($group_id = 0, $triggers = array(), $logs = array())
'ip_high8' => 'int',
);

$ins_triggers = array();
$insertTriggers = array();
foreach ($triggers as $key => $trigger)
{
// Exceptions, exceptions, exceptions...always exceptions... :P
if (is_array($trigger))
if ($key == 'ips_m' || $key == 'ips_e')
foreach ($trigger as $real_trigger)
$ins_triggers[$key] = array_merge($values, $trigger);
$insertTriggers[] = array_merge($values, $real_trigger);
else
$ins_triggers[$key] = array_merge($values, $trigger);
$insertTriggers[] = array_merge($values, $trigger);
}

if (empty($triggers))
if (empty($insertTriggers))
$context['ban_errors'][] = 'ban_no_triggers';

if (!empty($context['ban_errors']))
Expand All @@ -989,7 +989,7 @@ function addTriggers($group_id = 0, $triggers = array(), $logs = array())
$smcFunc['db_insert']('',
'{db_prefix}ban_items',
$insertKeys,
$triggers,
$insertTriggers,
array('id_ban')
);

Expand Down
12 changes: 7 additions & 5 deletions themes/default/ManageBans.template.php
Expand Up @@ -130,7 +130,7 @@ function template_ban_edit()
<input type="text" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
</dd>
<dt>
<input type="checkbox" name="ban_suggestions[]" id="user_check" value="user" class="input_check" ', !empty($context['ban_suggestions']['user']) ? 'checked="checked" ' : '', '/>
<input type="checkbox" name="ban_suggestions[]" id="user_check" value="user" class="input_check" ', !empty($context['ban_suggestions']['user']) || isset($context['ban']['from_user']) ? 'checked="checked" ' : '', '/>
<label for="user_check">', $txt['ban_on_username'], '</label>:
</dt>
<dd>
Expand All @@ -144,13 +144,14 @@ function template_ban_edit()
<div>', $txt['ips_in_messages'], ':</div>
<dl class="settings">';

$count = 0;
foreach ($context['ban_suggestions']['message_ips'] as $ip)
echo '
<dt>
<input type="checkbox" name="ban_suggestions[ips_m][]" ', !empty($context['ban_suggestions']['ips_m']) && in_array($ip, $context['ban_suggestions']['ips_m']) ? 'checked="checked" ' : '', 'value="', $ip, '" class="input_check" />
<input type="checkbox" id="ban_suggestions_ips_m_', $count, '" name="ban_suggestions[ips_m][]" ', !empty($context['ban_suggestions']['ips_m']) && in_array($ip, $context['ban_suggestions']['ips_m']) ? 'checked="checked" ' : '', 'value="', $ip, '" class="input_check" />
</dt>
<dd>
', $ip, '
<label for="ban_suggestions_ips_m_', $count++, '">', $ip, '</label>
</dd>';
}

Expand All @@ -161,13 +162,14 @@ function template_ban_edit()
<div>', $txt['ips_in_errors'], '</div>
<dl class="settings">';

$count = 0;
foreach ($context['ban_suggestions']['error_ips'] as $ip)
echo '
<dt>
<input type="checkbox" name="ban_suggestions[ips_e][]" ', !empty($context['ban_suggestions']['ips_e']) && in_array($ip, $context['ban_suggestions']['ips_e']) ? 'checked="checked" ' : '', 'value="', $ip, '" class="input_check" />
<input type="checkbox" id="ban_suggestions_ips_e_', $count, '" name="ban_suggestions[ips_e][]" ', !empty($context['ban_suggestions']['ips_e']) && in_array($ip, $context['ban_suggestions']['ips_e']) ? 'checked="checked" ' : '', 'value="', $ip, '" class="input_check" />
</dt>
<dd>
', $ip, '
<label for="ban_suggestions_ips_m_', $count++, '">', $ip, '</label>
</dd>';
}

Expand Down

0 comments on commit bc74831

Please sign in to comment.