Mainly updates for additional/altered admin permission options ... note, you MUST empty your current auth_options table and insert the list from the mysql_basic, you will also need to empty the auth_user/auth_group tables and re-assign permissions, and you should clear the $acl_options array in config_cache

git-svn-id: file:///svn/phpbb/trunk@3020 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-11-09 00:04:18 +00:00
parent 1c5f838a2d
commit 1405e47fc1
18 changed files with 845 additions and 908 deletions

View file

@ -21,9 +21,9 @@
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
if( !empty($setmodules) ) if(!empty($setmodules))
{ {
if ( !$auth->acl_get('a_ban') ) if (!$auth->acl_get('a_ban'))
{ {
return; return;
} }
@ -42,15 +42,15 @@ require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
// Do we have ban permissions? // Do we have ban permissions?
if ( !$auth->acl_get('a_ban') ) if (!$auth->acl_get('a_ban'))
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
// Mode setting // Mode setting
if ( isset($_POST['mode']) || isset($_GET['mode']) ) if (isset($_POST['mode']) || isset($_GET['mode']))
{ {
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; $mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
} }
else else
{ {
@ -60,19 +60,19 @@ else
$current_time = time(); $current_time = time();
// Start program // Start program
if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) ) if (isset($_POST['bansubmit']) || isset($_GET['bansubmit']))
{ {
$ban = ( !empty($_POST['ban']) ) ? $_POST['ban'] : $_GET['ban']; $ban = (!empty($_POST['ban'])) ? $_POST['ban'] : $_GET['ban'];
$ban_list = array_unique(explode("\n", $ban)); $ban_list = array_unique(explode("\n", $ban));
$ban_list_log = implode(', ', $ban_list); $ban_list_log = implode(', ', $ban_list);
$ban_reason = ( isset($_POST['banreason']) ) ? $_POST['banreason'] : ''; $ban_reason = (isset($_POST['banreason'])) ? $_POST['banreason'] : '';
if ( !empty($_POST['banlength']) ) if (!empty($_POST['banlength']))
{ {
if ( $_POST['banlength'] != -1 || empty($_POST['banlengthother']) ) if ($_POST['banlength'] != -1 || empty($_POST['banlengthother']))
{ {
$ban_end = max($current_time, $current_time + ( intval($_POST['banlength']) * 60 )); $ban_end = max($current_time, $current_time + (intval($_POST['banlength']) * 60));
} }
else else
{ {
@ -87,7 +87,7 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$banlist = array(); $banlist = array();
switch ( $mode ) switch ($mode)
{ {
case 'user': case 'user':
$type = 'ban_userid'; $type = 'ban_userid';
@ -95,7 +95,7 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$banlist_tmp = array(); $banlist_tmp = array();
for($i = 0; $i < count($ban_list); $i++) for($i = 0; $i < count($ban_list); $i++)
{ {
if ( trim($ban_list[$i]) != '' ) if (trim($ban_list[$i]) != '')
{ {
$banlist_tmp[] = '\'' . trim($ban_list[$i]) . '\''; $banlist_tmp[] = '\'' . trim($ban_list[$i]) . '\'';
} }
@ -106,13 +106,13 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
WHERE username IN (" . implode(', ', $banlist_tmp) . ")"; WHERE username IN (" . implode(', ', $banlist_tmp) . ")";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$banlist[] = $row['user_id']; $banlist[] = $row['user_id'];
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
unset($banlist_tmp); unset($banlist_tmp);
break; break;
@ -122,18 +122,18 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
for($i = 0; $i < count($ban_list); $i++) for($i = 0; $i < count($ban_list); $i++)
{ {
if ( preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ban_list[$i]), $ip_range_explode) ) if (preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ban_list[$i]), $ip_range_explode))
{ {
// Don't ask about all this, just don't ask ... ! // Don't ask about all this, just don't ask ... !
$ip_1_counter = $ip_range_explode[1]; $ip_1_counter = $ip_range_explode[1];
$ip_1_end = $ip_range_explode[5]; $ip_1_end = $ip_range_explode[5];
while ( $ip_1_counter <= $ip_1_end ) while ($ip_1_counter <= $ip_1_end)
{ {
$ip_2_counter = ( $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[2] : 0; $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0;
$ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6];
if( $ip_2_counter == 0 && $ip_2_end == 254 ) if($ip_2_counter == 0 && $ip_2_end == 254)
{ {
$ip_2_counter = 256; $ip_2_counter = 256;
$ip_2_fragment = 256; $ip_2_fragment = 256;
@ -141,12 +141,12 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$banlist[] = "'$ip_1_counter.*'"; $banlist[] = "'$ip_1_counter.*'";
} }
while ( $ip_2_counter <= $ip_2_end ) while ($ip_2_counter <= $ip_2_end)
{ {
$ip_3_counter = ( $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[3] : 0; $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0;
$ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7];
if ( $ip_3_counter == 0 && $ip_3_end == 254 ) if ($ip_3_counter == 0 && $ip_3_end == 254)
{ {
$ip_3_counter = 256; $ip_3_counter = 256;
$ip_3_fragment = 256; $ip_3_fragment = 256;
@ -154,12 +154,12 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$banlist[] = "'$ip_1_counter.$ip_2_counter.*'"; $banlist[] = "'$ip_1_counter.$ip_2_counter.*'";
} }
while ( $ip_3_counter <= $ip_3_end ) while ($ip_3_counter <= $ip_3_end)
{ {
$ip_4_counter = ( $ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[4] : 0; $ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0;
$ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8];
if ( $ip_4_counter == 0 && $ip_4_end == 254 ) if ($ip_4_counter == 0 && $ip_4_end == 254)
{ {
$ip_4_counter = 256; $ip_4_counter = 256;
$ip_4_fragment = 256; $ip_4_fragment = 256;
@ -167,7 +167,7 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$banlist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'"; $banlist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'";
} }
while ( $ip_4_counter <= $ip_4_end ) while ($ip_4_counter <= $ip_4_end)
{ {
$banlist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'"; $banlist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'";
$ip_4_counter++; $ip_4_counter++;
@ -179,19 +179,19 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$ip_1_counter++; $ip_1_counter++;
} }
} }
else if ( preg_match('/^([\w\-_]\.?){2,}$/is', trim($ban_list[$i])) ) else if (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ban_list[$i])))
{ {
$ip = gethostbynamel(trim($ban_list[$i])); $ip = gethostbynamel(trim($ban_list[$i]));
for($j = 0; $j < count($ip); $j++) for($j = 0; $j < count($ip); $j++)
{ {
if ( !empty($ip[$j]) ) if (!empty($ip[$j]))
{ {
$banlist[] = '\'' . $ip[$j] . '\''; $banlist[] = '\'' . $ip[$j] . '\'';
} }
} }
} }
else if ( preg_match('/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/', trim($ban_list[$i])) || preg_match('/^[a-f0-9:]+\*?$/i', trim($ban_list[$i])) ) else if (preg_match('/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/', trim($ban_list[$i])) || preg_match('/^[a-f0-9:]+\*?$/i', trim($ban_list[$i])))
{ {
$banlist[] = '\'' . trim($ban_list[$i]) . '\''; $banlist[] = '\'' . trim($ban_list[$i]) . '\'';
} }
@ -206,7 +206,7 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
// This ereg match is based on one by php@unreelpro.com // This ereg match is based on one by php@unreelpro.com
// contained in the annotated php manual at php.com (ereg // contained in the annotated php manual at php.com (ereg
// section) // section)
if ( eregi('^(([[:alnum:]\*]+([-_.][[:alnum:]\*]+)*\.?)|(\*))@([[:alnum:]]+([-_]?[[:alnum:]]+)*\.){1,3}([[:alnum:]]{2,6})$', trim($ban_list[$i])) ) if (eregi('^(([[:alnum:]\*]+([-_.][[:alnum:]\*]+)*\.?)|(\*))@([[:alnum:]]+([-_]?[[:alnum:]]+)*\.){1,3}([[:alnum:]]{2,6})$', trim($ban_list[$i])))
{ {
$banlist[] = '\'' . trim($ban_list[$i]) . '\''; $banlist[] = '\'' . trim($ban_list[$i]) . '\'';
} }
@ -219,12 +219,12 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
WHERE $type <> ''"; WHERE $type <> ''";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
$banlist_tmp = array(); $banlist_tmp = array();
do do
{ {
switch ( $mode ) switch ($mode)
{ {
case 'user': case 'user':
$banlist_tmp[] = $row['ban_userid']; $banlist_tmp[] = $row['ban_userid'];
@ -239,13 +239,13 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
break; break;
} }
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
$banlist = array_unique(array_diff($banlist, $banlist_tmp)); $banlist = array_unique(array_diff($banlist, $banlist_tmp));
unset($banlist_tmp); unset($banlist_tmp);
} }
if ( sizeof($banlist) ) if (sizeof($banlist))
{ {
for($i = 0; $i < count($banlist); $i++) for($i = 0; $i < count($banlist); $i++)
{ {
@ -255,7 +255,7 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
} }
$sql = ''; $sql = '';
switch ( $mode ) switch ($mode)
{ {
case 'user': case 'user':
$sql = "WHERE session_user_id IN (" . implode(', ', $banlist) . ")"; $sql = "WHERE session_user_id IN (" . implode(', ', $banlist) . ")";
@ -272,20 +272,20 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$sql = ''; $sql = '';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$sql .= ( ( $sql != '' ) ? ', ' : '' ) . $row['user_id']; $sql .= (($sql != '') ? ', ' : '') . $row['user_id'];
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
$sql = "WHERE session_user_id IN (" . str_replace('*', '%', $sql) . ")"; $sql = "WHERE session_user_id IN (" . str_replace('*', '%', $sql) . ")";
} }
break; break;
} }
if ( $sql != '' ) if ($sql != '')
{ {
$sql = "DELETE FROM " . SESSIONS_TABLE . " $sql = "DELETE FROM " . SESSIONS_TABLE . "
$sql"; $sql";
@ -302,15 +302,15 @@ if ( isset($_POST['bansubmit']) || isset($_GET['bansubmit']) )
message_die(MESSAGE, $message); message_die(MESSAGE, $message);
} }
else if ( isset($_POST['unbansubmit']) ) else if (isset($_POST['unbansubmit']))
{ {
$unban_sql = ''; $unban_sql = '';
for($i = 0; $i < count($_POST['unban']); $i++ ) for($i = 0; $i < count($_POST['unban']); $i++)
{ {
$unban_sql .= ( ( $unban_sql != '' ) ? ', ' : '' ) . intval($_POST['unban'][$i]); $unban_sql .= (($unban_sql != '') ? ', ' : '') . intval($_POST['unban'][$i]);
} }
if ( $unban_sql != '' ) if ($unban_sql != '')
{ {
$sql = "DELETE FROM " . BANLIST_TABLE . " $sql = "DELETE FROM " . BANLIST_TABLE . "
WHERE ban_id IN ($unban_sql)"; WHERE ban_id IN ($unban_sql)";
@ -340,7 +340,7 @@ $db->sql_query($sql);
$ban_end_text = array(0 => $user->lang['Permanent'], 30 => $user->lang['30_Mins'], 60 => $user->lang['1_Hour'], 360 => $user->lang['6_Hours'], 1440 => $user->lang['1_Day'], 10080 => $user->lang['7_Days'], 20160 => $user->lang['2_Weeks'], 40320 => $user->lang['1_Month'], -1 => $user->lang['Other']); $ban_end_text = array(0 => $user->lang['Permanent'], 30 => $user->lang['30_Mins'], 60 => $user->lang['1_Hour'], 360 => $user->lang['6_Hours'], 1440 => $user->lang['1_Day'], 10080 => $user->lang['7_Days'], 20160 => $user->lang['2_Weeks'], 40320 => $user->lang['1_Month'], -1 => $user->lang['Other']);
$ban_end_options = ''; $ban_end_options = '';
foreach ( $ban_end_text as $length => $text ) foreach ($ban_end_text as $length => $text)
{ {
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
} }
@ -348,7 +348,7 @@ foreach ( $ban_end_text as $length => $text )
// //
// Title // Title
// //
switch ( $mode ) switch ($mode)
{ {
case 'user': case 'user':
$l_title = $user->lang['Ban_users']; $l_title = $user->lang['Ban_users'];
@ -372,13 +372,13 @@ page_header($l_title);
<?php <?php
switch ( $mode ) switch ($mode)
{ {
case 'user': case 'user':
$sql = "SELECT b.*, u.user_id, u.username $sql = "SELECT b.*, u.user_id, u.username
FROM " . BANLIST_TABLE . " b, " . USERS_TABLE . " u FROM " . BANLIST_TABLE . " b, " . USERS_TABLE . " u
WHERE ( b.ban_end >= " . time() . " WHERE (b.ban_end >= " . time() . "
OR b.ban_end = 0 ) OR b.ban_end = 0)
AND u.user_id = b.ban_userid AND u.user_id = b.ban_userid
AND b.ban_userid <> 0 AND b.ban_userid <> 0
AND u.user_id <> " . ANONYMOUS . " AND u.user_id <> " . ANONYMOUS . "
@ -388,15 +388,15 @@ switch ( $mode )
$banned_options = ''; $banned_options = '';
$banned_length = ''; $banned_length = '';
$banned_options = ''; $banned_options = '';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['username'] . '</option>'; $banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['username'] . '</option>';
$banned_length .= ( ( $banned_length != '' ) ? ', ' : '' ) . '\'' . ( $ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)] ) . '\''; $banned_length .= (($banned_length != '') ? ', ' : '') . '\'' . ($ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)]) . '\'';
$banned_reasons .= ( ( $banned_reasons != '' ) ? ', ' : '' ) . '\'' . addslashes($row['ban_reason']) . '\''; $banned_reasons .= (($banned_reasons != '') ? ', ' : '') . '\'' . addslashes($row['ban_reason']) . '\'';
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -414,23 +414,23 @@ switch ( $mode )
$sql = "SELECT * $sql = "SELECT *
FROM " . BANLIST_TABLE . " FROM " . BANLIST_TABLE . "
WHERE ( ban_end >= " . time() . " WHERE (ban_end >= " . time() . "
OR ban_end = 0 ) OR ban_end = 0)
AND ban_ip <> ''"; AND ban_ip <> ''";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$banned_reasons = ''; $banned_reasons = '';
$banned_length = ''; $banned_length = '';
$banned_options = ''; $banned_options = '';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['ban_ip'] . '</option>'; $banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['ban_ip'] . '</option>';
$banned_length .= ( ( $banned_length != '' ) ? ', ' : '' ) . '\'' . ( $ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)] ) . '\''; $banned_length .= (($banned_length != '') ? ', ' : '') . '\'' . ($ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)]) . '\'';
$banned_reasons .= ( ( $banned_reasons != '' ) ? ', ' : '' ) . '\'' . addslashes($row['ban_reason']) . '\''; $banned_reasons .= (($banned_reasons != '') ? ', ' : '') . '\'' . addslashes($row['ban_reason']) . '\'';
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -448,23 +448,23 @@ switch ( $mode )
$sql = "SELECT * $sql = "SELECT *
FROM " . BANLIST_TABLE . " FROM " . BANLIST_TABLE . "
WHERE ( ban_end >= " . time() . " WHERE (ban_end >= " . time() . "
OR ban_end = 0 ) OR ban_end = 0)
AND ban_email <> ''"; AND ban_email <> ''";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$banned_options = ''; $banned_options = '';
$banned_length = ''; $banned_length = '';
$banned_options = ''; $banned_options = '';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['ban_email'] . '</option>'; $banned_options .= '<option value="' . $row['ban_id'] . '">' . $row['ban_email'] . '</option>';
$banned_length .= ( ( $banned_length != '' ) ? ', ' : '' ) . '\'' . ( $ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)] ) . '\''; $banned_length .= (($banned_length != '') ? ', ' : '') . '\'' . ($ban_end_text[(($row['ban_end'] - $row['ban_start']) / 60)]) . '\'';
$banned_reasons .= ( ( $banned_reasons != '' ) ? ', ' : '' ) . '\'' . addslashes($row['ban_reason']) . '\''; $banned_reasons .= (($banned_reasons != '') ? ', ' : '') . '\'' . addslashes($row['ban_reason']) . '\'';
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -509,7 +509,7 @@ switch ( $mode )
<td class="row2"><input type="text" name="banreason" maxlength="255" size="40" /></td> <td class="row2"><input type="text" name="banreason" maxlength="255" size="40" /></td>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="2" align="center"> <input type="submit" name="bansubmit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" />&nbsp; <?php echo $s_submit_extra; ?></td> <td class="cat" colspan="2" align="center"> <input type="submit" name="bansubmit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" />&nbsp; <?php echo $s_submit_extra; ?></td>
</tr> </tr>
</table> </table>
@ -524,7 +524,7 @@ switch ( $mode )
<tr> <tr>
<?php <?php
if ( $banned_options != '' ) if ($banned_options != '')
{ {
?> ?>
@ -545,7 +545,7 @@ switch ( $mode )
?> ?>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="unbansubmit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" /></td> <td class="cat" colspan="2" align="center"><input type="submit" name="unbansubmit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /></td>
</tr> </tr>
</table></form> </table></form>

View file

@ -19,45 +19,68 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') )
{
return;
}
$file = basename(__FILE__); $file = basename(__FILE__);
$module['General']['Avatar_settings'] = "$file$SID&amp;mode=avatar"; $module['General']['Cookie_settings'] = ($auth->acl_get('a_cookies')) ? "$file$SID&amp;mode=cookie" : '';
$module['General']['Cookie_settings'] = "$file$SID&amp;mode=cookie"; $module['General']['Board_defaults'] = ($auth->acl_get('a_defaults')) ? "$file$SID&amp;mode=default" : '';
$module['General']['Board_defaults'] = "$file$SID&amp;mode=default"; $module['General']['Board_settings'] = ($auth->acl_get('a_board')) ? "$file$SID&amp;mode=setting" : '';
$module['General']['Board_settings'] = "$file$SID&amp;mode=setting"; $module['General']['Avatar_settings'] = ($auth->acl_get('a_board')) ? "$file$SID&amp;mode=avatar" : '';
$module['General']['Email_settings'] = "$file$SID&amp;mode=email"; $module['General']['Email_settings'] = ($auth->acl_get('a_server')) ? "$file$SID&amp;mode=email" : '';
$module['General']['Server_settings'] = "$file$SID&amp;mode=server"; $module['General']['Server_settings'] = ($auth->acl_get('a_server')) ? "$file$SID&amp;mode=server" : '';
$module['General']['Auth_settings'] = "$file$SID&amp;mode=auth"; $module['General']['Auth_settings'] = ($auth->acl_get('a_server')) ? "$file$SID&amp;mode=auth" : '';
return; return;
} }
// Let's set the root dir for phpBB
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
// Load default header
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
// Are we authed? // Get mode
if ( !$auth->acl_get('a_general') ) $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
// Check permissions/set title
switch ($mode)
{ {
trigger_error($user->lang['No_admin']); case 'cookie':
$l_title = 'Cookie_settings';
$which_auth = 'a_cookies';
break;
case 'default':
$l_title = 'Board_defaults';
$which_auth = 'a_defaults';
break;
case 'avatar':
$l_title = 'Avatar_settings';
$which_auth = 'a_board';
break;
case 'setting':
$l_title = 'Board_settings';
$which_auth = 'a_board';
break;
case 'email':
$l_title = 'Email_settings';
$which_auth = 'a_server';
break;
case 'server':
$l_title = 'Server_settings';
$which_auth = 'a_server';
break;
case 'auth':
$l_title = 'Auth_settings';
$which_auth = 'a_server';
break;
default:
return;
} }
// Get mod // Check permissions
if ( isset($_POST['mode']) || isset($_GET['mode']) ) if (!$auth->acl_get($which_acl))
{ {
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; trigger_error($user->lang['NO_ADMIN']);
}
else
{
$mode = '';
} }
// Pull all config data // Pull all config data
@ -65,15 +88,15 @@ $sql = "SELECT *
FROM " . CONFIG_TABLE; FROM " . CONFIG_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$config_name = $row['config_name']; $config_name = $row['config_name'];
$config_value = $row['config_value']; $config_value = $row['config_value'];
$default_config[$config_name] = $config_value; $default_config[$config_name] = $config_value;
$new[$config_name] = ( isset($_POST[$config_name]) ) ? $_POST[$config_name] : $default_config[$config_name]; $new[$config_name] = (isset($_POST[$config_name])) ? $_POST[$config_name] : $default_config[$config_name];
if ( isset($_POST['submit']) ) if (isset($_POST['submit']))
{ {
$sql = "UPDATE " . CONFIG_TABLE . " SET $sql = "UPDATE " . CONFIG_TABLE . " SET
config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' config_value = '" . str_replace("\'", "''", $new[$config_name]) . "'
@ -82,7 +105,7 @@ while ( $row = $db->sql_fetchrow($result) )
} }
} }
if ( isset($_POST['submit']) ) if (isset($_POST['submit']))
{ {
// Re-cache config data // Re-cache config data
config_config($new); config_config($new);
@ -91,39 +114,6 @@ if ( isset($_POST['submit']) )
trigger_error($user->lang['Config_updated']); trigger_error($user->lang['Config_updated']);
} }
//
// Which title?
//
switch ( $mode )
{
case 'cookie':
$l_title = 'Cookie_settings';
break;
case 'avatar':
$l_title = 'Avatar_settings';
break;
case 'default':
$l_title = 'Board_defaults';
break;
case 'setting':
$l_title = 'Board_settings';
break;
case 'email':
$l_title = 'Email_settings';
break;
case 'server':
$l_title = 'Server_settings';
break;
case 'login':
$l_title = 'Server_settings';
break;
case 'auth':
$l_title = 'Auth_settings';
break;
default:
return;
}
page_header($user->lang[$l_title]); page_header($user->lang[$l_title]);
?> ?>
@ -141,12 +131,12 @@ page_header($user->lang[$l_title]);
// //
// Output relevant page // Output relevant page
// //
switch ( $mode ) switch ($mode)
{ {
case 'cookie': case 'cookie':
$cookie_secure_yes = ( $new['cookie_secure'] ) ? 'checked="checked"' : ''; $cookie_secure_yes = ($new['cookie_secure']) ? 'checked="checked"' : '';
$cookie_secure_no = ( !$new['cookie_secure'] ) ? 'checked="checked"' : ''; $cookie_secure_no = (!$new['cookie_secure']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
@ -171,12 +161,12 @@ switch ( $mode )
case 'avatar': case 'avatar':
$avatars_local_yes = ( $new['allow_avatar_local'] ) ? 'checked="checked"' : ''; $avatars_local_yes = ($new['allow_avatar_local']) ? 'checked="checked"' : '';
$avatars_local_no = ( !$new['allow_avatar_local'] ) ? 'checked="checked"' : ''; $avatars_local_no = (!$new['allow_avatar_local']) ? 'checked="checked"' : '';
$avatars_remote_yes = ( $new['allow_avatar_remote'] ) ? 'checked="checked"' : ''; $avatars_remote_yes = ($new['allow_avatar_remote']) ? 'checked="checked"' : '';
$avatars_remote_no = ( !$new['allow_avatar_remote'] ) ? 'checked="checked"' : ''; $avatars_remote_no = (!$new['allow_avatar_remote']) ? 'checked="checked"' : '';
$avatars_upload_yes = ( $new['allow_avatar_upload'] ) ? 'checked="checked"' : ''; $avatars_upload_yes = ($new['allow_avatar_upload']) ? 'checked="checked"' : '';
$avatars_upload_no = ( !$new['allow_avatar_upload'] ) ? 'checked="checked"' : ''; $avatars_upload_no = (!$new['allow_avatar_upload']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
@ -217,29 +207,29 @@ switch ( $mode )
$lang_select = language_select($new['default_lang'], 'default_lang', '../language'); $lang_select = language_select($new['default_lang'], 'default_lang', '../language');
$timezone_select = tz_select($new['board_timezone'], 'board_timezone'); $timezone_select = tz_select($new['board_timezone'], 'board_timezone');
$override_user_style_yes = ( $new['override_user_style'] ) ? 'checked="checked"' : ''; $override_user_style_yes = ($new['override_user_style']) ? 'checked="checked"' : '';
$override_user_style_no = ( !$new['override_user_style'] ) ? 'checked="checked"' : ''; $override_user_style_no = (!$new['override_user_style']) ? 'checked="checked"' : '';
$topic_notify_yes = ( $new['allow_topic_notify'] ) ? 'checked="checked"' : ''; $topic_notify_yes = ($new['allow_topic_notify']) ? 'checked="checked"' : '';
$topic_notify_no = ( !$new['allow_topic_notify'] ) ? 'checked="checked"' : ''; $topic_notify_no = (!$new['allow_topic_notify']) ? 'checked="checked"' : '';
$forum_notify_yes = ( $new['allow_forum_notify'] ) ? 'checked="checked"' : ''; $forum_notify_yes = ($new['allow_forum_notify']) ? 'checked="checked"' : '';
$forum_notify_no = ( !$new['allow_forum_notify'] ) ? 'checked="checked"' : ''; $forum_notify_no = (!$new['allow_forum_notify']) ? 'checked="checked"' : '';
$html_yes = ( $new['allow_html'] ) ? 'checked="checked"' : ''; $html_yes = ($new['allow_html']) ? 'checked="checked"' : '';
$html_no = ( !$new['allow_html'] ) ? 'checked="checked"' : ''; $html_no = (!$new['allow_html']) ? 'checked="checked"' : '';
$bbcode_yes = ( $new['allow_bbcode'] ) ? 'checked="checked"' : ''; $bbcode_yes = ($new['allow_bbcode']) ? 'checked="checked"' : '';
$bbcode_no = ( !$new['allow_bbcode'] ) ? 'checked="checked"' : ''; $bbcode_no = (!$new['allow_bbcode']) ? 'checked="checked"' : '';
$smile_yes = ( $new['allow_smilies'] ) ? 'checked="checked"' : ''; $smile_yes = ($new['allow_smilies']) ? 'checked="checked"' : '';
$smile_no = ( !$new['allow_smilies'] ) ? 'checked="checked"' : ''; $smile_no = (!$new['allow_smilies']) ? 'checked="checked"' : '';
$sig_yes = ( $new['allow_sig'] ) ? 'checked="checked"' : ''; $sig_yes = ($new['allow_sig']) ? 'checked="checked"' : '';
$sig_no = ( !$new['allow_sig'] ) ? 'checked="checked"' : ''; $sig_no = (!$new['allow_sig']) ? 'checked="checked"' : '';
$namechange_yes = ( $new['allow_namechange'] ) ? 'checked="checked"' : ''; $namechange_yes = ($new['allow_namechange']) ? 'checked="checked"' : '';
$namechange_no = ( !$new['allow_namechange'] ) ? 'checked="checked"' : ''; $namechange_no = (!$new['allow_namechange']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
@ -312,22 +302,22 @@ switch ( $mode )
case 'setting': case 'setting':
$disable_board_yes = ( $new['board_disable'] ) ? 'checked="checked"' : ''; $disable_board_yes = ($new['board_disable']) ? 'checked="checked"' : '';
$disable_board_no = ( !$new['board_disable'] ) ? 'checked="checked"' : ''; $disable_board_no = (!$new['board_disable']) ? 'checked="checked"' : '';
$coppa_enable_yes = ( $new['coppa_enable'] ) ? 'checked="checked"' : ''; $coppa_enable_yes = ($new['coppa_enable']) ? 'checked="checked"' : '';
$coppa_enable_no = ( !$new['coppa_enable'] ) ? 'checked="checked"' : ''; $coppa_enable_no = (!$new['coppa_enable']) ? 'checked="checked"' : '';
$activation_none = ( $new['require_activation'] == USER_ACTIVATION_NONE ) ? 'checked="checked"' : ''; $activation_none = ($new['require_activation'] == USER_ACTIVATION_NONE) ? 'checked="checked"' : '';
$activation_user = ( $new['require_activation'] == USER_ACTIVATION_SELF ) ? 'checked="checked"' : ''; $activation_user = ($new['require_activation'] == USER_ACTIVATION_SELF) ? 'checked="checked"' : '';
$activation_admin = ( $new['require_activation'] == USER_ACTIVATION_ADMIN ) ? 'checked="checked"' : ''; $activation_admin = ($new['require_activation'] == USER_ACTIVATION_ADMIN) ? 'checked="checked"' : '';
$activation_disable = ( $new['require_activation'] == USER_ACTIVATION_DISABLE ) ? 'checked="checked"' : ''; $activation_disable = ($new['require_activation'] == USER_ACTIVATION_DISABLE) ? 'checked="checked"' : '';
$privmsg_on = ( !$new['privmsg_disable'] ) ? 'checked="checked"' : ''; $privmsg_on = (!$new['privmsg_disable']) ? 'checked="checked"' : '';
$privmsg_off = ( $new['privmsg_disable'] ) ? 'checked="checked"' : ''; $privmsg_off = ($new['privmsg_disable']) ? 'checked="checked"' : '';
$prune_yes = ( $new['prune_enable'] ) ? 'checked="checked"' : ''; $prune_yes = ($new['prune_enable']) ? 'checked="checked"' : '';
$prune_no = ( !$new['prune_enable'] ) ? 'checked="checked"' : ''; $prune_no = (!$new['prune_enable']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
@ -412,14 +402,14 @@ switch ( $mode )
case 'email': case 'email':
$email_yes = ( $new['email_enable'] ) ? 'checked="checked"' : ''; $email_yes = ($new['email_enable']) ? 'checked="checked"' : '';
$email_no = ( !$new['email_enable'] ) ? 'checked="checked"' : ''; $email_no = (!$new['email_enable']) ? 'checked="checked"' : '';
$board_email_form_yes = ( $new['board_email_form'] ) ? 'checked="checked"' : ''; $board_email_form_yes = ($new['board_email_form']) ? 'checked="checked"' : '';
$board_email_form_no = ( !$new['board_email_form'] ) ? 'checked="checked"' : ''; $board_email_form_no = (!$new['board_email_form']) ? 'checked="checked"' : '';
$smtp_yes = ( $new['smtp_delivery'] ) ? 'checked="checked"' : ''; $smtp_yes = ($new['smtp_delivery']) ? 'checked="checked"' : '';
$smtp_no = ( !$new['smtp_delivery'] ) ? 'checked="checked"' : ''; $smtp_no = (!$new['smtp_delivery']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
@ -460,13 +450,13 @@ switch ( $mode )
case 'server': case 'server':
$ip_all = ( $new['ip_check'] == 4 ) ? 'checked="checked"' : ''; $ip_all = ($new['ip_check'] == 4) ? 'checked="checked"' : '';
$ip_classc = ( $new['ip_check'] == 3 ) ? 'checked="checked"' : ''; $ip_classc = ($new['ip_check'] == 3) ? 'checked="checked"' : '';
$ip_classb = ( $new['ip_check'] == 2 ) ? 'checked="checked"' : ''; $ip_classb = ($new['ip_check'] == 2) ? 'checked="checked"' : '';
$ip_none = ( $new['ip_check'] == 0 ) ? 'checked="checked"' : ''; $ip_none = ($new['ip_check'] == 0) ? 'checked="checked"' : '';
$gzip_yes = ( $new['gzip_compress'] ) ? 'checked="checked"' : ''; $gzip_yes = ($new['gzip_compress']) ? 'checked="checked"' : '';
$gzip_no = ( !$new['gzip_compress'] ) ? 'checked="checked"' : ''; $gzip_no = (!$new['gzip_compress']) ? 'checked="checked"' : '';
?> ?>
<tr> <tr>
<td class="row1"><?php echo $user->lang['Server_name']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Server_name_explain']; ?></span></td> <td class="row1"><?php echo $user->lang['Server_name']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Server_name_explain']; ?></span></td>
@ -517,9 +507,9 @@ switch ( $mode )
$auth_plugins = array(); $auth_plugins = array();
$dp = opendir($phpbb_root_path . 'includes/auth'); $dp = opendir($phpbb_root_path . 'includes/auth');
while ( $file = readdir($dp) ) while ($file = readdir($dp))
{ {
if ( preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file) ) if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
{ {
$auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file); $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
} }
@ -528,9 +518,9 @@ switch ( $mode )
sort($auth_plugins); sort($auth_plugins);
$auth_select = ''; $auth_select = '';
foreach ( $auth_plugins as $method ) foreach ($auth_plugins as $method)
{ {
$selected = ( $config['auth_method'] == $method ) ? ' selected="selected"' : ''; $selected = ($config['auth_method'] == $method) ? ' selected="selected"' : '';
$auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>'; $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
} }
@ -541,23 +531,23 @@ switch ( $mode )
</tr> </tr>
<?php <?php
foreach ( $auth_plugins as $method ) foreach ($auth_plugins as $method)
{ {
if ( $method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx) ) if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
{ {
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx); include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
$method = 'admin_' . $method; $method = 'admin_' . $method;
if ( function_exists($method) ) if (function_exists($method))
{ {
if ( $config_fields = $method($new) ) if ($config_fields = $method($new))
{ {
// //
// Check if we need to create config fields for this plugin // Check if we need to create config fields for this plugin
// //
foreach( $config_fields as $field ) foreach($config_fields as $field)
{ {
if ( !isset($config[$field]) ) if (!isset($config[$field]))
{ {
$sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
VALUES ('$field', '')"; VALUES ('$field', '')";
@ -576,7 +566,7 @@ switch ( $mode )
?> ?>
<tr> <tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /></td> <td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /></td>
</tr> </tr>
</table></form> </table></form>

View file

@ -19,18 +19,13 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') )
{
return;
}
$filename = basename(__FILE__); $filename = basename(__FILE__);
$module['DB']['DB_Backup'] = $filename . "$SID&amp;mode=backup"; $module['DB']['DB_Backup'] = ($auth->acl_get('a_backup')) ? $filename . "$SID&amp;mode=backup" : '';
$file_uploads = @ini_get('file_uploads'); $file_uploads = @ini_get('file_uploads');
if (!empty($file_uploads) && $file_uploads !== 0 && strtolower($file_uploads) != 'off' && @phpversion() != '4.0.4pl1' ) if (!empty($file_uploads) && $file_uploads !== 0 && strtolower($file_uploads) != 'off' && @phpversion() != '4.0.4pl1' && $auth->acl_get('a_restore'))
{ {
$module['DB']['DB_Restore'] = $filename . "$SID&amp;mode=restore"; $module['DB']['DB_Restore'] = $filename . "$SID&amp;mode=restore";
} }
@ -39,40 +34,30 @@ if ( !empty($setmodules) )
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Load default header // Load default header
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// $mode = (isset($_GET['mode'])) ? $_GET['mode'] : '';
// Do we have DB backup/restore permissions?
//
if ( !$auth->acl_get('a_general') )
{
message_die(MESSAGE, $user->lang['No_admin']);
}
//
// Increase maximum execution time, but don't complain about it if it isn't // Increase maximum execution time, but don't complain about it if it isn't
// allowed. // allowed.
//
@set_time_limit(1200); @set_time_limit(1200);
$mode = ( isset($_GET['mode']) ) ? $_GET['mode'] : '';
//
// Begin program proper // Begin program proper
// switch($mode)
switch( $mode )
{ {
case 'backup': case 'backup':
if (!$auth->acl_get('a_backup'))
if ( SQL_LAYER == 'oracle' || SQL_LAYER == 'odbc' || SQL_LAYER == 'mssql' )
{ {
switch ( SQL_LAYER ) trigger_error($user->lang['NO_ADMIN']);
}
if (SQL_LAYER == 'oracle' || SQL_LAYER == 'odbc' || SQL_LAYER == 'mssql')
{
switch (SQL_LAYER)
{ {
case 'oracle': case 'oracle':
$db_type = 'Oracle'; $db_type = 'Oracle';
@ -85,17 +70,17 @@ switch( $mode )
break; break;
} }
message_die(MESSAGE, $user->lang['Backups_not_supported']); trigger_error($user->lang['Backups_not_supported']);
break; break;
} }
$additional_tables = ( isset($_POST['tables']) ) ? $_POST['tables'] : ( ( isset($_GET['tables']) ) ? $_GET['tables'] : '' ); $additional_tables = (isset($_POST['tables'])) ? $_POST['tables'] : ((isset($_GET['tables'])) ? $_GET['tables'] : '');
$backup_type = ( isset($_POST['type']) ) ? $_POST['type'] : ( ( isset($_GET['type']) ) ? $_GET['type'] : '' ); $backup_type = (isset($_POST['type'])) ? $_POST['type'] : ((isset($_GET['type'])) ? $_GET['type'] : '');
$search = ( !empty($_POST['search']) ) ? intval($_POST['search']) : ( ( !empty($_GET['search']) ) ? intval($_GET['search']) : 0 ); $search = (!empty($_POST['search'])) ? intval($_POST['search']) : ((!empty($_GET['search'])) ? intval($_GET['search']) : 0);
$store_path = ( isset($_POST['store']) ) ? $_POST['store'] : ( ( isset($_GET['store']) ) ? $_GET['store'] : '' ); $store_path = (isset($_POST['store'])) ? $_POST['store'] : ((isset($_GET['store'])) ? $_GET['store'] : '');
$compress = ( !empty($_POST['compress']) ) ? $_POST['compress'] : ( ( !empty($_GET['compress']) ) ? $_GET['compress'] : 'none' ); $compress = (!empty($_POST['compress'])) ? $_POST['compress'] : ((!empty($_GET['compress'])) ? $_GET['compress'] : 'none');
if ( !isset($_POST['backupstart']) && !isset($_GET['backupstart']) ) if (!isset($_POST['backupstart']) && !isset($_GET['backupstart']))
{ {
page_header($user->lang['DB_Backup']); page_header($user->lang['DB_Backup']);
@ -127,7 +112,7 @@ switch( $mode )
</tr> </tr>
<?php <?php
if ( extension_loaded('zlib') || extension_loaded('bz2') ) if (extension_loaded('zlib') || extension_loaded('bz2'))
{ {
?> ?>
@ -135,7 +120,7 @@ switch( $mode )
<td class="row1"><?php echo $user->lang['Compress_file']; ?>: </td> <td class="row1"><?php echo $user->lang['Compress_file']; ?>: </td>
<td class="row2"><input type="radio" name="compress" value="none" checked="checked" /> <?php echo $user->lang['None']; ?><?php <td class="row2"><input type="radio" name="compress" value="none" checked="checked" /> <?php echo $user->lang['None']; ?><?php
if ( extension_loaded('zlib') ) if (extension_loaded('zlib'))
{ {
@ -143,7 +128,7 @@ switch( $mode )
} }
if ( extension_loaded('bz2') ) if (extension_loaded('bz2'))
{ {
?>&nbsp;&nbsp;<input type="radio" name="compress" value="bzip" />.bz2<?php ?>&nbsp;&nbsp;<input type="radio" name="compress" value="bzip" />.bz2<?php
@ -166,21 +151,21 @@ switch( $mode )
break; break;
} }
else if ( !isset($_POST['startdownload']) && !isset($_GET['startdownload']) ) else if (!isset($_POST['startdownload']) && !isset($_GET['startdownload']))
{ {
$meta = "<meta http-equiv=\"refresh\" content=\"0;url=admin_database.$phpEx?mode=backup&amp;type=$backup_type&amp;tables=" . quotemeta($additional_tables) . "&amp;search=$search&amp;store=" . quotemeta($store_path) . "&amp;compress=$compress&amp;backupstart=1&amp;startdownload=1\">"; $meta = "<meta http-equiv=\"refresh\" content=\"0;url=admin_database.$phpEx?mode=backup&amp;type=$backup_type&amp;tables=" . quotemeta($additional_tables) . "&amp;search=$search&amp;store=" . quotemeta($store_path) . "&amp;compress=$compress&amp;backupstart=1&amp;startdownload=1\">";
$message = ( empty($store_path) ) ? $user->lang['Backup_download'] : $user->lang['Backup_writing']; $message = (empty($store_path)) ? $user->lang['Backup_download'] : $user->lang['Backup_writing'];
page_header($user->lang['DB_Backup'], $meta); page_header($user->lang['DB_Backup'], $meta);
page_message($user->lang['DB_Backup'], $message); page_message($user->lang['DB_Backup'], $message);
page_footer(); page_footer();
} }
$tables = ( SQL_LAYER != 'postgresql' ) ? mysql_get_tables() : pg_get_tables(); $tables = (SQL_LAYER != 'postgresql') ? mysql_get_tables() : pg_get_tables();
@sort($tables); @sort($tables);
if ( !empty($additional_tables) ) if (!empty($additional_tables))
{ {
$additional_tables = explode(',', $additional_tables); $additional_tables = explode(',', $additional_tables);
@ -206,7 +191,7 @@ switch( $mode )
echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n";
echo "#\n"; echo "#\n";
if ( SQL_LAYER == 'postgresql' ) if (SQL_LAYER == 'postgresql')
{ {
echo "\n" . pg_get_sequences("\n", $backup_type); echo "\n" . pg_get_sequences("\n", $backup_type);
} }
@ -215,7 +200,7 @@ switch( $mode )
{ {
$table_name = $tables[$i]; $table_name = $tables[$i];
if ( SQL_LAYER != 'mysql4' ) if (SQL_LAYER != 'mysql4')
{ {
$table_def_function = "get_table_def_" . SQL_LAYER; $table_def_function = "get_table_def_" . SQL_LAYER;
$table_content_function = "get_table_content_" . SQL_LAYER; $table_content_function = "get_table_content_" . SQL_LAYER;
@ -226,18 +211,18 @@ switch( $mode )
$table_content_function = "get_table_content_mysql"; $table_content_function = "get_table_content_mysql";
} }
if ( $backup_type != 'data' ) if ($backup_type != 'data')
{ {
echo "#\n# TABLE: " . $table_name . "\n#\n"; echo "#\n# TABLE: " . $table_name . "\n#\n";
echo $table_def_function($table_name, "\n") . "\n"; echo $table_def_function($table_name, "\n") . "\n";
} }
if ( $backup_type != 'structure' ) if ($backup_type != 'structure')
{ {
// //
// Skip search table data? // Skip search table data?
// //
if ( $search || ( !$search && !preg_match('/search_word/', $table_name) ) ) if ($search || (!$search && !preg_match('/search_word/', $table_name)))
{ {
$table_content_function($table_name, "output_table_content"); $table_content_function($table_name, "output_table_content");
} }
@ -247,7 +232,7 @@ switch( $mode )
// //
// Flush the buffer, send the file // Flush the buffer, send the file
// //
switch ( $compress ) switch ($compress)
{ {
case 'gzip': case 'gzip':
$extension = 'sql.gz'; $extension = 'sql.gz';
@ -258,7 +243,7 @@ switch( $mode )
case 'zip': case 'zip':
$extension = 'zip'; $extension = 'zip';
$zip = new zipfile; $zip = new zipfile;
$zip->addFile(ob_get_contents(), "phpbb_db_backup.sql", time()); $zip->add_file(ob_get_contents(), "phpbb_db_backup.sql", time());
ob_end_clean(); ob_end_clean();
$contents = $zip->file(); $contents = $zip->file();
break; break;
@ -277,7 +262,7 @@ switch( $mode )
add_admin_log('log_db_backup'); add_admin_log('log_db_backup');
if ( empty($store_path) ) if (empty($store_path))
{ {
header("Pragma: no-cache"); header("Pragma: no-cache");
header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.$extension\""); header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.$extension\"");
@ -288,12 +273,12 @@ switch( $mode )
} }
else else
{ {
if ( !($fp = fopen('./../' . $store_path . "/phpbb_db_backup.$extension", 'wb')) ) if (!($fp = fopen('./../' . $store_path . "/phpbb_db_backup.$extension", 'wb')))
{ {
message_die(ERROR, 'Could not open backup file'); message_die(ERROR, 'Could not open backup file');
} }
if ( !fwrite($fp, $contents) ) if (!fwrite($fp, $contents))
{ {
message_die(ERROR, 'Could not write backup file content'); message_die(ERROR, 'Could not write backup file content');
} }
@ -301,54 +286,58 @@ switch( $mode )
fclose($fp); fclose($fp);
unset($contents); unset($contents);
message_die(MESSAGE, $user->lang['Backup_success']); trigger_error($user->lang['Backup_success']);
} }
exit; exit;
break; break;
case 'restore': case 'restore':
if (!$auth->acl_get('a_restore'))
{
trigger_error($user->lang['No_admin']);
}
if ( isset($_POST['restorestart']) ) if (isset($_POST['restorestart']))
{ {
// //
// Handle the file upload .... // Handle the file upload ....
// If no file was uploaded report an error... // If no file was uploaded report an error...
// //
if ( !empty($_POST['local']) ) if (!empty($_POST['local']))
{ {
$file_tmpname = './../' . str_replace('\\\\', '/', $_POST['local']); $file_tmpname = './../' . str_replace('\\\\', '/', $_POST['local']);
$filename = substr($file_tmpname, strrpos($file_tmpname, '/')); $filename = substr($file_tmpname, strrpos($file_tmpname, '/'));
} }
else else
{ {
$filename = ( !empty($HTTP_POST_FILES['backup_file']['name']) ) ? $HTTP_POST_FILES['backup_file']['name'] : ''; $filename = (!empty($HTTP_POST_FILES['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : '';
$file_tmpname = ( $HTTP_POST_FILES['backup_file']['tmp_name'] != 'none' ) ? $HTTP_POST_FILES['backup_file']['tmp_name'] : ''; $file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != 'none') ? $HTTP_POST_FILES['backup_file']['tmp_name'] : '';
} }
if ( $file_tmpname == '' || $filename == '' || !file_exists($file_tmpname) ) if ($file_tmpname == '' || $filename == '' || !file_exists($file_tmpname))
{ {
message_die(MESSAGE, $user->lang['Restore_Error_no_file']); trigger_error($user->lang['Restore_Error_no_file']);
} }
$ext = substr($filename, strrpos($filename, '.') + 1); $ext = substr($filename, strrpos($filename, '.') + 1);
if ( !preg_match('/^(sql|gz|bz2)$/', $ext) ) if (!preg_match('/^(sql|gz|bz2)$/', $ext))
{ {
message_die(MESSAGE, $user->lang['Restore_Error_filename']); trigger_error($user->lang['Restore_Error_filename']);
} }
if ( ( !extension_loaded('zlib') && $ext == 'gz' ) || ( !extension_loaded('zip') && $ext == 'zip' ) || ( $ext == 'bz2' && !extension_loaded('bz2') ) ) if ((!extension_loaded('zlib') && $ext == 'gz') || (!extension_loaded('zip') && $ext == 'zip') || ($ext == 'bz2' && !extension_loaded('bz2')))
{ {
message_die(MESSAGE, $user->lang['Compress_unsupported']); trigger_error($user->lang['Compress_unsupported']);
} }
$sql_query = ''; $sql_query = '';
switch ( $ext ) switch ($ext)
{ {
case 'gz': case 'gz':
$fp = gzopen($file_tmpname, 'rb'); $fp = gzopen($file_tmpname, 'rb');
while ( !gzeof($fp) ) while (!gzeof($fp))
{ {
$sql_query .= gzgets($fp, 100000); $sql_query .= gzgets($fp, 100000);
} }
@ -359,11 +348,14 @@ switch( $mode )
$sql_query = bzdecompress(fread(fopen($file_tmpname, 'rb'), filesize($file_tmpname))); $sql_query = bzdecompress(fread(fopen($file_tmpname, 'rb'), filesize($file_tmpname)));
break; break;
case 'zip':
default; default;
$sql_query = fread(fopen($file_tmpname, 'r'), filesize($file_tmpname)); $sql_query = fread(fopen($file_tmpname, 'r'), filesize($file_tmpname));
} }
if ( $sql_query != '' ) if ($sql_query != '')
{ {
// Strip out sql comments... // Strip out sql comments...
$sql_query = remove_remarks($sql_query); $sql_query = remove_remarks($sql_query);
@ -374,7 +366,7 @@ switch( $mode )
{ {
$sql = trim($pieces[$i]); $sql = trim($pieces[$i]);
if ( !empty($sql) && $sql[0] != '#' ) if (!empty($sql) && $sql[0] != '#')
{ {
$db->sql_query($sql); $db->sql_query($sql);
} }
@ -383,7 +375,7 @@ switch( $mode )
add_admin_log('log_db_restore'); add_admin_log('log_db_restore');
message_die(MESSAGE, $user->lang['Restore_success']); trigger_error($user->lang['Restore_success']);
} }
// //
@ -406,11 +398,11 @@ switch( $mode )
echo $user->lang['Supported_extensions']; echo $user->lang['Supported_extensions'];
$types = ': <u>sql</u>'; $types = ': <u>sql</u>';
if ( extension_loaded('zlib') ) if (extension_loaded('zlib'))
{ {
$types .= ', <u>sql.gz</u>'; $types .= ', <u>sql.gz</u>';
} }
if ( extension_loaded('bz2') ) if (extension_loaded('bz2'))
{ {
$types .= ', <u>bz2</u>'; $types .= ', <u>bz2</u>';
} }
@ -434,6 +426,7 @@ switch( $mode )
break; break;
default: default:
trigger_error($user->lang['No_admin']);
exit; exit;
} }
@ -454,16 +447,16 @@ function mysql_get_tables()
$tables = array(); $tables = array();
$result = mysql_list_tables($db->dbname, $db->db_connect_id); $result = mysql_list_tables($db->dbname, $db->db_connect_id);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
if ( preg_match('/^' . $table_prefix . '/', $row[0]) ) if (preg_match('/^' . $table_prefix . '/', $row[0]))
{ {
$tables[] = $row[0]; $tables[] = $row[0];
} }
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
return $tables; return $tables;
@ -483,7 +476,7 @@ function pg_get_sequences($crlf, $backup_type)
$seq = $db->sql_query($get_seq_sql); $seq = $db->sql_query($get_seq_sql);
if( !$num_seq = $db->sql_numrows($seq) ) if (!$num_seq = $db->sql_numrows($seq))
{ {
$return_val = "# No Sequences Found $crlf"; $return_val = "# No Sequences Found $crlf";
@ -502,11 +495,11 @@ function pg_get_sequences($crlf, $backup_type)
$get_props_sql = "SELECT * FROM $sequence"; $get_props_sql = "SELECT * FROM $sequence";
$seq_props = $db->sql_query($get_props_sql); $seq_props = $db->sql_query($get_props_sql);
if($db->sql_numrows($seq_props) > 0) if ($db->sql_numrows($seq_props) > 0)
{ {
$row1 = $db->sql_fetchrow($seq_props); $row1 = $db->sql_fetchrow($seq_props);
if($backup_type == 'structure') if ($backup_type == 'structure')
{ {
$row['last_value'] = 1; $row['last_value'] = 1;
} }
@ -515,7 +508,7 @@ function pg_get_sequences($crlf, $backup_type)
} // End if numrows > 0 } // End if numrows > 0
if(($row['last_value'] > 1) && ($backup_type != 'structure')) if (($row['last_value'] > 1) && ($backup_type != 'structure'))
{ {
$return_val .= "SELECT NEXTVALE('$sequence'); $crlf"; $return_val .= "SELECT NEXTVALE('$sequence'); $crlf";
unset($row['last_value']); unset($row['last_value']);
@ -555,7 +548,7 @@ function get_table_def_postgresql($table, $crlf)
ORDER BY a.attnum"; ORDER BY a.attnum";
$result = $db->sql_query($field_query); $result = $db->sql_query($field_query);
if(!$result) if (!$result)
{ {
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query); message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query);
} // end if.. } // end if..
@ -641,12 +634,12 @@ function get_table_def_postgresql($table, $crlf)
ORDER BY index_name, tab_name, column_name "; ORDER BY index_name, tab_name, column_name ";
$result = $db->sql_query($sql_pri_keys); $result = $db->sql_query($sql_pri_keys);
if(!$result) if (!$result)
{ {
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_pri_keys); message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_pri_keys);
} }
while ( $row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
if ($row['primary_key'] == 't') if ($row['primary_key'] == 't')
{ {
@ -743,37 +736,29 @@ function get_table_def_mysql($table, $crlf)
$field_query = "SHOW FIELDS FROM $table"; $field_query = "SHOW FIELDS FROM $table";
$key_query = "SHOW KEYS FROM $table"; $key_query = "SHOW KEYS FROM $table";
//
// If the user has selected to drop existing tables when doing a restore. // If the user has selected to drop existing tables when doing a restore.
// Then we add the statement to drop the tables.... // Then we add the statement to drop the tables....
//
$schema_create .= "DROP TABLE IF EXISTS $table;$crlf"; $schema_create .= "DROP TABLE IF EXISTS $table;$crlf";
$schema_create .= "CREATE TABLE $table($crlf"; $schema_create .= "CREATE TABLE $table($crlf";
//
// Ok lets grab the fields... // Ok lets grab the fields...
//
$result = $db->sql_query($field_query); $result = $db->sql_query($field_query);
if(!result)
{
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query);
}
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$schema_create .= ' ' . $row['Field'] . ' ' . $row['Type']; $schema_create .= ' ' . $row['Field'] . ' ' . $row['Type'];
if(!empty($row['Default'])) if (!empty($row['Default']))
{ {
$schema_create .= ' DEFAULT \'' . $row['Default'] . '\''; $schema_create .= ' DEFAULT \'' . $row['Default'] . '\'';
} }
if($row['Null'] != "YES") if ($row['Null'] != "YES")
{ {
$schema_create .= ' NOT NULL'; $schema_create .= ' NOT NULL';
} }
if($row['Extra'] != "") if ($row['Extra'] != "")
{ {
$schema_create .= ' ' . $row['Extra']; $schema_create .= ' ' . $row['Extra'];
} }
@ -794,12 +779,12 @@ function get_table_def_mysql($table, $crlf)
{ {
$kname = $row['Key_name']; $kname = $row['Key_name'];
if(($kname != 'PRIMARY') && ($row['Non_unique'] == 0)) if (($kname != 'PRIMARY') && ($row['Non_unique'] == 0))
{ {
$kname = "UNIQUE|$kname"; $kname = "UNIQUE|$kname";
} }
if(!is_array($index[$kname])) if (!is_array($index[$kname]))
{ {
$index[$kname] = array(); $index[$kname] = array();
} }
@ -807,11 +792,11 @@ function get_table_def_mysql($table, $crlf)
$index[$kname][] = $row['Column_name']; $index[$kname][] = $row['Column_name'];
} }
while(list($x, $columns) = @each($index)) foreach ($index as $x => $columns)
{ {
$schema_create .= ", $crlf"; $schema_create .= ", $crlf";
if($x == 'PRIMARY') if ($x == 'PRIMARY')
{ {
$schema_create .= ' PRIMARY KEY (' . implode($columns, ', ') . ')'; $schema_create .= ' PRIMARY KEY (' . implode($columns, ', ') . ')';
} }
@ -827,7 +812,7 @@ function get_table_def_mysql($table, $crlf)
$schema_create .= "$crlf);"; $schema_create .= "$crlf);";
if(get_magic_quotes_runtime()) if (get_magic_quotes_runtime())
{ {
return(stripslashes($schema_create)); return(stripslashes($schema_create));
} }
@ -856,10 +841,7 @@ function get_table_content_postgresql($table, $handler)
{ {
global $db; global $db;
//
// Grab all of the data from current table. // Grab all of the data from current table.
//
$result = $db->sql_query("SELECT * FROM $table"); $result = $db->sql_query("SELECT * FROM $table");
$i_num_fields = $db->sql_numfields($result); $i_num_fields = $db->sql_numfields($result);
@ -872,24 +854,23 @@ function get_table_content_postgresql($table, $handler)
$iRec = 0; $iRec = 0;
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
unset($schema_vals); unset($schema_vals);
unset($schema_fields); unset($schema_fields);
unset($schema_insert); unset($schema_insert);
//
// Build the SQL statement to recreate the data. // Build the SQL statement to recreate the data.
//
for($i = 0; $i < $i_num_fields; $i++) for($i = 0; $i < $i_num_fields; $i++)
{ {
$strVal = $row[$aryName[$i]]; $strVal = $row[$aryName[$i]];
if (eregi("char|text|bool", $aryType[$i])) if (preg_match('#char|text|bool#i', $aryType[$i]))
{ {
$strQuote = "'"; $strQuote = "'";
$strEmpty = ""; $strEmpty = "";
$strVal = addslashes($strVal); $strVal = addslashes($strVal);
} }
elseif (eregi("date|timestamp", $aryType[$i])) elseif (preg_match('#date|timestamp#i', $aryType[$i]))
{ {
if ($empty($strVal)) if ($empty($strVal))
{ {
@ -913,18 +894,15 @@ function get_table_content_postgresql($table, $handler)
$schema_vals .= " $strQuote$strVal$strQuote,"; $schema_vals .= " $strQuote$strVal$strQuote,";
$schema_fields .= " $aryName[$i],"; $schema_fields .= " $aryName[$i],";
} }
$schema_vals = ereg_replace(",$", "", $schema_vals); $schema_vals = preg_replace('#,$#', '', $schema_vals);
$schema_vals = ereg_replace("^ ", "", $schema_vals); $schema_vals = preg_replace('#^ #', '', $schema_vals);
$schema_fields = ereg_replace(",$", "", $schema_fields); $schema_fields = preg_replace('#,$#', '', $schema_fields);
$schema_fields = ereg_replace("^ ", "", $schema_fields); $schema_fields = preg_replace('#^ #', '', $schema_fields);
//
// Take the ordered fields and their associated data and build it // Take the ordered fields and their associated data and build it
// into a valid sql statement to recreate that field in the data. // into a valid sql statement to recreate that field in the data.
//
$schema_insert = "INSERT INTO $table ($schema_fields) VALUES($schema_vals);"; $schema_insert = "INSERT INTO $table ($schema_fields) VALUES($schema_vals);";
$handler(trim($schema_insert)); $handler(trim($schema_insert));
@ -941,16 +919,13 @@ function get_table_content_postgresql($table, $handler)
function get_table_content_mysql($table, $handler) function get_table_content_mysql($table, $handler)
{ {
global $db; global $db;
//
// Grab the data from the table. // Grab the data from the table.
//
$result = $db->sql_query("SELECT * FROM $table"); $result = $db->sql_query("SELECT * FROM $table");
//
// Loop through the resulting rows and build the sql statement. // Loop through the resulting rows and build the sql statement.
//
$schema_insert = ""; $schema_insert = "";
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
$schema_insert = "\n#\n# Table Data for $table\n#\n"; $schema_insert = "\n#\n# Table Data for $table\n#\n";
@ -970,7 +945,7 @@ function get_table_content_mysql($table, $handler)
// //
// Get rid of the last comma // Get rid of the last comma
// //
$table_list = ereg_replace(', $', '', $table_list); $table_list = preg_replace('#, $#', '', $table_list);
$table_list .= ')'; $table_list .= ')';
// //
// Start building the SQL statement. // Start building the SQL statement.
@ -981,7 +956,7 @@ function get_table_content_mysql($table, $handler)
// //
for ($j = 0; $j < $num_fields; $j++) for ($j = 0; $j < $num_fields; $j++)
{ {
if(!isset($row[$j])) if (!isset($row[$j]))
{ {
// //
// If there is no data for the column set it to null. // If there is no data for the column set it to null.
@ -1003,14 +978,14 @@ function get_table_content_mysql($table, $handler)
// //
// Get rid of the the last comma. // Get rid of the the last comma.
// //
$schema_insert = ereg_replace(',$', '', $schema_insert); $schema_insert = preg_replace('#,$#', '', $schema_insert);
$schema_insert .= ');'; $schema_insert .= ');';
// //
// Go ahead and send the insert statement to the handler function. // Go ahead and send the insert statement to the handler function.
// //
$handler(trim($schema_insert)); $handler(trim($schema_insert));
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
return true; return true;
@ -1041,9 +1016,9 @@ class zipfile
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0; var $old_offset = 0;
function unix2DosTime($unixtime = 0) function unix_to_dos_time($unixtime = 0)
{ {
$timearray = ( $unixtime == 0 ) ? getdate() : getdate($unixtime); $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) if ($timearray['year'] < 1980)
{ {
@ -1055,15 +1030,15 @@ class zipfile
$timearray['seconds'] = 0; $timearray['seconds'] = 0;
} }
return ( ( $timearray['year'] - 1980) << 25 ) | ( $timearray['mon'] << 21 ) | ( $timearray['mday'] << 16 ) | return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
( $timearray['hours'] << 11 ) | ( $timearray['minutes'] << 5 ) | ( $timearray['seconds'] >> 1 ); ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} }
function addFile($data, $name, $time = 0) function add_file($data, $name, $time = 0)
{ {
$name = str_replace('\\', '/', $name); $name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time)); $dtime = dechex($this->unix_to_dos_time($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7] $hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[2] . $dtime[3]
@ -1111,14 +1086,14 @@ class zipfile
$cdrec .= pack('V', $crc); // crc32 $cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize $cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize $cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename $cdrec .= pack('v', strlen($name)); // length of filename
$cdrec .= pack('v', 0 ); // extra field length $cdrec .= pack('v', 0); // extra field length
$cdrec .= pack('v', 0 ); // file comment length $cdrec .= pack('v', 0); // file comment length
$cdrec .= pack('v', 0 ); // disk number start $cdrec .= pack('v', 0); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes $cdrec .= pack('v', 0); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set $cdrec .= pack('V', 32); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header $cdrec .= pack('V', $this -> old_offset); // relative offset of local header
$this -> old_offset = $new_offset; $this -> old_offset = $new_offset;
$cdrec .= $name; $cdrec .= $name;
@ -1140,7 +1115,6 @@ class zipfile
pack('V', strlen($data)) . // offset to start of central dir pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length "\x00\x00"; // .zip file comment length
} }
} }
// //

View file

@ -21,43 +21,36 @@
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
if( !empty($setmodules) ) if(!empty($setmodules))
{ {
if ( !$auth->acl_get('a_user') ) if (!$auth->acl_get('a_names'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['Users']['Disallow'] = basename(__FILE__) . $SID;
$module['Users']['Disallow'] = $filename . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
// // Check permissions
// Do we have user admin permissions? if (!$auth->acl_get('a_names'))
//
if ( !$auth->acl_get('a_user') )
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
if( isset($_POST['add_name']) ) if (isset($_POST['add_name']))
{ {
include($phpbb_root_path . 'includes/functions_validate.'.$phpEx); $disallowed_user = (isset($_POST['disallowed_user'])) ? $_POST['disallowed_user'] : $_GET['disallowed_user'];
$disallowed_user = ( isset($_POST['disallowed_user']) ) ? $_POST['disallowed_user'] : $_GET['disallowed_user'];
$disallowed_user = str_replace('*', '%', $disallowed_user); $disallowed_user = str_replace('*', '%', $disallowed_user);
if ( !validate_username($disallowed_user) ) if (validate_username($disallowed_user))
{ {
$message = $user->lang['Disallowed_already']; $message = $user->lang['Disallowed_already'];
} }
@ -65,7 +58,7 @@ if( isset($_POST['add_name']) )
{ {
$sql = "INSERT INTO " . DISALLOW_TABLE . " (disallow_username) $sql = "INSERT INTO " . DISALLOW_TABLE . " (disallow_username)
VALUES('" . str_replace("\'", "''", $disallowed_user) . "')"; VALUES('" . str_replace("\'", "''", $disallowed_user) . "')";
$result = $db->sql_query( $sql ); $result = $db->sql_query($sql);
$message = $user->lang['Disallow_successful']; $message = $user->lang['Disallow_successful'];
} }
@ -76,9 +69,9 @@ if( isset($_POST['add_name']) )
message_die(MESSAGE, $message); message_die(MESSAGE, $message);
} }
else if( isset($_POST['delete_name']) ) else if (isset($_POST['delete_name']))
{ {
$disallowed_id = ( isset($_POST['disallowed_id']) ) ? intval( $_POST['disallowed_id'] ) : intval( $_GET['disallowed_id'] ); $disallowed_id = (isset($_POST['disallowed_id'])) ? intval($_POST['disallowed_id']) : intval($_GET['disallowed_id']);
$sql = "DELETE FROM " . DISALLOW_TABLE . " $sql = "DELETE FROM " . DISALLOW_TABLE . "
WHERE disallow_id = $disallowed_id"; WHERE disallow_id = $disallowed_id";
@ -92,21 +85,19 @@ else if( isset($_POST['delete_name']) )
} }
//
// Grab the current list of disallowed usernames... // Grab the current list of disallowed usernames...
//
$sql = "SELECT * $sql = "SELECT *
FROM " . DISALLOW_TABLE; FROM " . DISALLOW_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$disallow_select = ''; $disallow_select = '';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>'; $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
// //
@ -133,7 +124,7 @@ page_header($user->lang['Users']);
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['Username']; ?><br /><span class="gensmall"><?php echo $user->lang['Delete_disallow_explain']; ?></span></td> <td class="row1"><?php echo $user->lang['Username']; ?><br /><span class="gensmall"><?php echo $user->lang['Delete_disallow_explain']; ?></span></td>
<td class="row2"><?php if ( $disallow_select != '' ) { ?><select name="disallowed_id"><?php echo $disallow_select; ?></select>&nbsp;<input type="submit" name="delete_name" value="<?php echo $user->lang['Delete']; ?>" class="liteoption" /><?php } else { echo $user->lang['No_disallowed']; } ?></td> <td class="row2"><?php if ($disallow_select != '') { ?><select name="disallowed_id"><?php echo $disallow_select; ?></select>&nbsp;<input type="submit" name="delete_name" value="<?php echo $user->lang['Delete']; ?>" class="liteoption" /><?php } else { echo $user->lang['No_disallowed']; } ?></td>
</tr> </tr>
</table></form> </table></form>

View file

@ -19,33 +19,28 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') ) if (!$auth->acl_get('a_email'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['General']['Mass_Email'] = basename(__FILE__) . $SID;
$module['General']['Mass_Email'] = $filename . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
// // Check permissions
// Do we have general admin permissions? if (!$auth->acl_get('a_email'))
//
if ( !$auth->acl_get('a_general') )
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
// //
@ -57,7 +52,7 @@ $subject = '';
// //
// Do the job ... // Do the job ...
// //
if ( isset($_POST['submit']) ) if (isset($_POST['submit']))
{ {
// //
// Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't // Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't
@ -67,10 +62,10 @@ if ( isset($_POST['submit']) )
$group_id = intval($_POST['g']); $group_id = intval($_POST['g']);
$sql = ( $group_id != -1 ) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE; $sql = ($group_id != -1) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( !($email_list = $db->sql_fetchrowset($g_result)) ) if (!($email_list = $db->sql_fetchrowset($g_result)))
{ {
// //
// Output a relevant GENERAL_MESSAGE about users/group // Output a relevant GENERAL_MESSAGE about users/group
@ -87,14 +82,14 @@ if ( isset($_POST['submit']) )
// //
$error = FALSE; $error = FALSE;
if ( !$error ) if (!$error)
{ {
include($phpbb_root_path . 'includes/emailer.'.$phpEx); include($phpbb_root_path . 'includes/emailer.'.$phpEx);
// //
// Let's do some checking to make sure that mass mail functions // Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php. // are working in win32 versions of php.
// //
if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$config['smtp_delivery'])
{ {
// We are running on windows, force delivery to use // We are running on windows, force delivery to use
// our smtp functions since php's are broken by default // our smtp functions since php's are broken by default
@ -108,7 +103,7 @@ if ( isset($_POST['submit']) )
$bcc_list = ''; $bcc_list = '';
for($i = 0; $i < count($email_list); $i++) for($i = 0; $i < count($email_list); $i++)
{ {
$bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $email_list[$i]['user_email']; $bcc_list .= (($bcc_list != '') ? ', ' : '') . $email_list[$i]['user_email'];
} }
$email_headers .= "Bcc: $bcc_list\n"; $email_headers .= "Bcc: $bcc_list\n";
@ -145,13 +140,13 @@ $sql = "SELECT group_id, group_name
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$select_list = '<select name = "g"><option value = "-1">' . $user->lang['All_users'] . '</option>'; $select_list = '<select name = "g"><option value = "-1">' . $user->lang['All_users'] . '</option>';
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$select_list .= '<option value = "' . $row['group_id'] . '">' . $row['group_name'] . '</option>'; $select_list .= '<option value = "' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$select_list .= '</select>'; $select_list .= '</select>';
@ -163,7 +158,7 @@ page_header($user->lang['Mass_Email']);
<p><?php echo $user->lang['Mass_email_explain']; ?></p> <p><?php echo $user->lang['Mass_email_explain']; ?></p>
<form method="post" action="<?php echo "admin_mass_email.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> <form method="post" action="admin_mass_email.<?php echo $phpEx.$SID; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1">
<tr> <tr>
<th colspan="2"><?php echo $user->lang['Compose']; ?></th> <th colspan="2"><?php echo $user->lang['Compose']; ?></th>
</tr> </tr>

View file

@ -21,45 +21,47 @@
if (!empty($setmodules)) if (!empty($setmodules))
{ {
if (!$auth->acl_get('a_forum')) if (!$auth->acl_gets('a_forum', 'a_forumadd', 'a_forumdel'))
{ {
return; return;
} }
$file = basename(__FILE__); $module['Forums']['Manage'] = basename(__FILE__) . $SID;
$module['Forums']['Manage'] = $file . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// // Get mode
// Do we have forum admin permissions? $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
//
if (!$auth->acl_get('a_forum')) // Do we have permissions?
switch ($mode)
{ {
message_die(MESSAGE, $user->lang['No_admin']); case 'add':
} if (!$auth->acl_get('a_forumadd'))
{
// trigger_error($user->lang['NO_ADMIN']);
// Mode setting }
// case 'del':
if (isset($_POST['mode']) || isset($_GET['mode'])) if (!$auth->acl_get('a_forumdel'))
{ {
$mode = (!empty($_POST['mode'])) ? $_POST['mode'] : $_GET['mode']; trigger_error($user->lang['NO_ADMIN']);
} }
else
{ default:
$mode = ''; if (!$auth->acl_get('a_forum'))
{
trigger_error($user->lang['NO_ADMIN']);
}
} }
// Major routines
switch ($mode) switch ($mode)
{ {
case 'move_up': case 'move_up':
@ -355,15 +357,13 @@ switch ($mode)
break; break;
case 'forum_sync': case 'forum_sync':
sync('forum', intval($_GET[POST_FORUM_URL])); sync('forum', intval($_GET['f']));
$show_index = TRUE; $show_index = TRUE;
break; break;
case 'add': case 'add':
case 'edit': case 'edit':
//
// Show form to create/modify a forum // Show form to create/modify a forum
//
if ($mode == 'edit') if ($mode == 'edit')
{ {
$forum_id = intval($_GET['f']); $forum_id = intval($_GET['f']);

View file

@ -19,18 +19,13 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_auth') )
{
return;
}
$filename = basename(__FILE__); $filename = basename(__FILE__);
$module['Forums']['Permissions'] = $filename . $SID . '&amp;mode=forums'; $module['Forums']['PERMISSIONS'] = ($auth->acl_get('a_auth')) ? $filename . $SID . '&amp;mode=forums' : '';
$module['Forums']['Moderators'] = $filename . $SID . '&amp;mode=moderators'; $module['Forums']['MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&amp;mode=moderators' : '';
$module['Forums']['Super_Moderators'] = $filename . $SID . '&amp;mode=supermoderators'; $module['Forums']['SUPER_MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&amp;mode=supermoderators' : '';
$module['General']['Administrators'] = $filename . $SID . '&amp;mode=administrators'; $module['General']['ADMINISTRATORS'] = ($auth->acl_get('a_authadmins')) ? $filename . $SID . '&amp;mode=administrators' : '';
return; return;
} }
@ -43,16 +38,10 @@ require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// Do we have forum admin permissions?
if ( !$auth->acl_get('a_auth') )
{
trigger_error($user->lang['No_admin']);
}
// Define some vars // Define some vars
if ( isset($_GET['f']) || isset($_POST['f']) ) if (isset($_REQUEST['f']))
{ {
$forum_id = ( isset($_POST['f']) ) ? intval($_POST['f']) : intval($_GET['f']); $forum_id = intval($_REQUEST['f']);
$forum_sql = " WHERE forum_id = $forum_id"; $forum_sql = " WHERE forum_id = $forum_id";
} }
else else
@ -61,88 +50,87 @@ else
$forum_sql = ''; $forum_sql = '';
} }
if ( isset($_GET['mode']) || isset($_POST['mode']) ) $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
{
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
}
else
{
$mode = '';
}
// Start program proper // Start program proper
switch ( $mode ) switch ($mode)
{ {
case 'forums': case 'forums':
$l_title = $user->lang['Permissions']; $l_title = $user->lang['PERMISSIONS'];
$l_title_explain = $user->lang['Permissions_explain']; $l_title_explain = $user->lang['PERMISSIONS_EXPLAIN'];
$l_can = '_can'; $which_acl = 'a_auth';
break; break;
case 'moderators': case 'moderators':
$l_title = $user->lang['Moderators']; $l_title = $user->lang['MODERATORS'];
$l_title_explain = $user->lang['Moderators_explain']; $l_title_explain = $user->lang['MODERATORS_EXPLAIN'];
$l_can = '_can'; $which_acl = 'a_authmods';
break; break;
case 'supermoderators': case 'supermoderators':
$l_title = $user->lang['Super_Moderators']; $l_title = $user->lang['SUPER_MODERATORS'];
$l_title_explain = $user->lang['Super_Moderators_explain']; $l_title_explain = $user->lang['SUPER_MODERATORS_EXPLAIN'];
$l_can = '_can'; $which_acl = 'a_authmods';
break; break;
case 'administrators': case 'administrators':
$l_title = $user->lang['Administrators']; $l_title = $user->lang['ADMINISTRATORS'];
$l_title_explain = $user->lang['Administrators_explain']; $l_title_explain = $user->lang['ADMINISTRATORS_EXPLAIN'];
$l_can = '_can_admin'; $which_acl = 'a_authadmins';
break; break;
} }
// Permission check
if (!$auth->acl_get($which_acl))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Call update or delete, both can take multiple user/group // Call update or delete, both can take multiple user/group
// ids. Additionally inheritance is handled (by the auth API) // ids. Additionally inheritance is handled (by the auth API)
if ( isset($_POST['update']) ) if (isset($_POST['update']))
{ {
$auth_admin = new auth_admin(); $auth_admin = new auth_admin();
// Admin wants subforums to inherit permissions ... so handle this // Admin wants subforums to inherit permissions ... so handle this
if ( !empty($_POST['inherit']) ) if (!empty($_POST['inherit']))
{ {
array_push($_POST['inherit'], $forum_id); array_push($_POST['inherit'], $forum_id);
$forum_id = $_POST['inherit']; $forum_id = $_POST['inherit'];
} }
foreach ( $_POST['entries'] as $id ) foreach ($_POST['entries'] as $id)
{ {
$auth_admin->acl_set($_POST['type'], $forum_id, $id, $_POST['option']); $auth_admin->acl_set($_POST['type'], $forum_id, $id, $_POST['option']);
} }
trigger_error('Permissions updated successfully'); trigger_error('Permissions updated successfully');
} }
else if ( isset($_POST['delete']) ) else if (isset($_POST['delete']))
{ {
$auth_admin = new auth_admin(); $auth_admin = new auth_admin();
$option_ids = false; $option_ids = false;
if ( !empty($_POST['option']) ) if (!empty($_POST['option']))
{ {
$sql = "SELECT auth_option_id $sql = "SELECT auth_option_id
FROM " . ACL_OPTIONS_TABLE . " FROM " . ACL_OPTIONS_TABLE . "
WHERE auth_value LIKE '" . $_POST['option'] . "_%'"; WHERE auth_value LIKE '" . $_POST['option'] . "_%'";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
$option_ids = array(); $option_ids = array();
do do
{ {
$option_ids[] = $row['auth_option_id']; $option_ids[] = $row['auth_option_id'];
} }
while( $row = $db->sql_fetchrow($result) ); while($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
foreach ( $_POST['entries'] as $id ) foreach ($_POST['entries'] as $id)
{ {
$auth_admin->acl_delete($_POST['type'], $forum_id, $id, $option_ids); $auth_admin->acl_delete($_POST['type'], $forum_id, $id, $option_ids);
} }
@ -152,12 +140,12 @@ else if ( isset($_POST['delete']) )
// Get required information, either all forums if no id was // Get required information, either all forums if no id was
// specified or just the requsted if it was // specified or just the requsted if it was
if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators' ) if (!empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators')
{ {
// Clear some vars, grab some info if relevant ... // Clear some vars, grab some info if relevant ...
$s_hidden_fields = ''; $s_hidden_fields = '';
if ( !empty($forum_id) ) if (!empty($forum_id))
{ {
$sql = "SELECT forum_name $sql = "SELECT forum_name
FROM " . FORUMS_TABLE . " FROM " . FORUMS_TABLE . "
@ -179,7 +167,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
<?php <?php
switch ( $mode ) switch ($mode)
{ {
case 'forums': case 'forums':
$type_sql = 'f'; $type_sql = 'f';
@ -204,17 +192,17 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
$sql = "SELECT group_id, group_name $sql = "SELECT group_id, group_name
FROM " . GROUPS_TABLE . " FROM " . GROUPS_TABLE . "
ORDER BY group_name"; ORDER BY group_type DESC, group_name";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$group_list = ''; $group_list = '';
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$group_list .= '<option value="' . $row['group_id'] . '">' . ( ( !empty($user->lang[$row['group_name']]) ) ? $user->lang[$row['group_name']] : $row['group_name'] ) . '</option>'; $group_list .= '<option value="' . $row['group_id'] . '">' . ((!empty($user->lang['G_' . $row['group_name']])) ? '* ' . $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if ( empty($_POST['advanced']) || empty($_POST['entries']) ) if (empty($_POST['advanced']) || empty($_POST['entries']))
{ {
?> ?>
@ -241,7 +229,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$users = ''; $users = '';
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$users .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; $users .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>';
} }
@ -268,13 +256,13 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
$forum_sql $forum_sql
AND a.auth_option_id = o.auth_option_id AND a.auth_option_id = o.auth_option_id
AND g.group_id = a.group_id AND g.group_id = a.group_id
ORDER BY g.group_name ASC"; ORDER BY g.group_type DESC, g.group_name ASC";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$groups = ''; $groups = '';
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$groups .= '<option value="' . $row['group_id'] . '">' . ( ( !empty($user->lang[$row['group_name']]) ) ? $user->lang[$row['group_name']] : $row['group_name'] ) . '</option>'; $groups .= '<option value="' . $row['group_id'] . '">' . ((!empty($user->lang['G_' . $row['group_name']])) ? '* ' . $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -301,7 +289,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
<td class="row1" align="center"><textarea cols="40" rows="4" name="entries"></textarea></td> <td class="row1" align="center"><textarea cols="40" rows="4" name="entries"></textarea></td>
</tr> </tr>
<tr> <tr>
<td class="cat" align="center"> <input type="submit" name="add" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" />&nbsp; <input type="submit" name="usersubmit" value="<?php echo $user->lang['Find_username']; ?>" class="liteoption" onclick="window.open('<?php echo "../search.$phpEx$SID"; ?>&amp;mode=searchuser&amp;form=2&amp;field=entries', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" /><input type="hidden" name="type" value="user" /><input type="hidden" name="advanced" value="1" /><input type="hidden" name="new" value="1" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /></td> <td class="cat" align="center"> <input type="submit" name="add" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" />&nbsp; <input type="submit" name="usersubmit" value="<?php echo $user->lang['Find_username']; ?>" class="liteoption" onclick="window.open('<?php echo "../search.$phpEx$SID"; ?>&amp;mode=searchuser&amp;form=2&amp;field=entries', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" /><input type="hidden" name="type" value="user" /><input type="hidden" name="advanced" value="1" /><input type="hidden" name="new" value="1" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /></td>
</tr> </tr>
</table></form></td> </table></form></td>
@ -313,7 +301,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
<td class="row1" align="center"><select name="entries[]" multiple="multiple" size="4"><?php echo $group_list; ?></select></td> <td class="row1" align="center"><select name="entries[]" multiple="multiple" size="4"><?php echo $group_list; ?></select></td>
</tr> </tr>
<tr> <tr>
<td class="cat" align="center"> <input type="submit" name="add" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /><input type="hidden" name="type" value="group" /><input type="hidden" name="advanced" value="1" /><input type="hidden" name="new" value="1" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /></td> <td class="cat" align="center"> <input type="submit" name="add" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" />&nbsp; <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /><input type="hidden" name="type" value="group" /><input type="hidden" name="advanced" value="1" /><input type="hidden" name="new" value="1" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /></td>
</tr> </tr>
</table></form></td> </table></form></td>
@ -328,7 +316,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
// Founder only operations ... these operations can // Founder only operations ... these operations can
// only be altered by someone with founder status // only be altered by someone with founder status
$founder_sql = ( !$userdata['user_founder'] ) ? ' AND founder_only <> 1' : ''; $founder_sql = (!$userdata['user_founder']) ? ' AND founder_only <> 1' : '';
$sql = "SELECT auth_option_id, auth_value $sql = "SELECT auth_option_id, auth_value
FROM " . ACL_OPTIONS_TABLE . " FROM " . ACL_OPTIONS_TABLE . "
@ -338,35 +326,35 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$auth_options = array(); $auth_options = array();
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$auth_options[] = $row; $auth_options[] = $row;
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if ( $_POST['type'] == 'user' && !empty($_POST['new']) ) if ($_POST['type'] == 'user' && !empty($_POST['new']))
{ {
$_POST['entries'] = explode("\n", $_POST['entries']); $_POST['entries'] = explode("\n", $_POST['entries']);
} }
$where_sql = ''; $where_sql = '';
foreach ( $_POST['entries'] as $value ) foreach ($_POST['entries'] as $value)
{ {
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . ( ( $_POST['type'] == 'user' && !empty($_POST['new']) ) ? '\'' . $value . '\'' : intval($value) ); $where_sql .= (($where_sql != '') ? ', ' : '') . (($_POST['type'] == 'user' && !empty($_POST['new'])) ? '\'' . $value . '\'' : intval($value));
} }
switch ( $_POST['type'] ) switch ($_POST['type'])
{ {
case 'group': case 'group':
$l_type = 'Group'; $l_type = 'Group';
$sql = ( empty($_POST['new']) ) ? "SELECT g.group_id AS id, g.group_name AS name, o.auth_value, a.auth_allow_deny FROM " . GROUPS_TABLE . " g, " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND g.group_id = a.group_id AND g.group_id IN ($where_sql) ORDER BY g.group_name ASC" : "SELECT group_id AS id, group_name AS name FROM " . GROUPS_TABLE . " WHERE group_id IN ($where_sql) ORDER BY group_name ASC"; $sql = (empty($_POST['new'])) ? "SELECT g.group_id AS id, g.group_name AS name, o.auth_value, a.auth_allow_deny FROM " . GROUPS_TABLE . " g, " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND g.group_id = a.group_id AND g.group_id IN ($where_sql) ORDER BY g.group_name ASC" : "SELECT group_id AS id, group_name AS name FROM " . GROUPS_TABLE . " WHERE group_id IN ($where_sql) ORDER BY group_name ASC";
break; break;
case 'user': case 'user':
$l_type = 'User'; $l_type = 'User';
$sql = ( empty($_POST['new']) ) ? "SELECT u.user_id AS id, u.username AS name, u.user_founder, o.auth_value, a.auth_allow_deny FROM " . USERS_TABLE . " u, " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND u.user_id = a.user_id AND u.user_id IN ($where_sql) ORDER BY u.username, u.user_regdate ASC" : "SELECT user_id AS id, username AS name, user_founder FROM " . USERS_TABLE . " WHERE username IN ($where_sql) ORDER BY username, user_regdate ASC"; $sql = (empty($_POST['new'])) ? "SELECT u.user_id AS id, u.username AS name, u.user_founder, o.auth_value, a.auth_allow_deny FROM " . USERS_TABLE . " u, " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND u.user_id = a.user_id AND u.user_id IN ($where_sql) ORDER BY u.username, u.user_regdate ASC" : "SELECT user_id AS id, username AS name, user_founder FROM " . USERS_TABLE . " WHERE username IN ($where_sql) ORDER BY username, user_regdate ASC";
break; break;
} }
@ -375,15 +363,15 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
$ug = '';; $ug = '';;
$ug_hidden = ''; $ug_hidden = '';
$auth = array(); $auth = array();
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$ug_test = ( !empty($user->lang[$row['name']]) ) ? $user->lang[$row['name']] : $row['name']; $ug_test = (!empty($user->lang[$row['name']])) ? $user->lang[$row['name']] : $row['name'];
$ug .= ( !strstr($ug, $ug_test) ) ? $ug_test . "\n" : ''; $ug .= (!strstr($ug, $ug_test)) ? $ug_test . "\n" : '';
$ug_test = '<input type="hidden" name="entries[]" value="' . $row['id'] . '" />'; $ug_test = '<input type="hidden" name="entries[]" value="' . $row['id'] . '" />';
$ug_hidden .= ( !strstr($ug_hidden, $ug_test) ) ? $ug_test : ''; $ug_hidden .= (!strstr($ug_hidden, $ug_test)) ? $ug_test : '';
$auth[$row['auth_value']] = ( isset($auth_group[$row['auth_value']]) ) ? min($auth_group[$row['auth_value']], $row['auth_allow_deny']) : $row['auth_allow_deny']; $auth[$row['auth_value']] = (isset($auth_group[$row['auth_value']])) ? min($auth_group[$row['auth_value']], $row['auth_allow_deny']) : $row['auth_allow_deny'];
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -451,7 +439,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
//--> //-->
</script> </script>
<p><?php echo $user->lang['ACL_explain']; ?></p> <p><?php echo $user->lang['ACL_EXPLAIN']; ?></p>
<form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><table cellspacing="1" cellpadding="0" border="0" align="center"> <form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><table cellspacing="1" cellpadding="0" border="0" align="center">
<tr> <tr>
@ -469,13 +457,13 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
for($i = 0; $i < sizeof($auth_options); $i++) for($i = 0; $i < sizeof($auth_options); $i++)
{ {
$row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
$l_can_cell = ( !empty($user->lang['acl_' . $auth_options[$i]['auth_value']]) ) ? $user->lang['acl_' . $auth_options[$i]['auth_value']] : ucfirst(preg_replace('#.*?_#', '', $auth_options[$i]['auth_value'])); $l_can_cell = (!empty($user->lang['acl_' . $auth_options[$i]['auth_value']])) ? $user->lang['acl_' . $auth_options[$i]['auth_value']] : ucfirst(preg_replace('#.*?_#', '', $auth_options[$i]['auth_value']));
$allow_type = ( $auth[$auth_options[$i]['auth_value']] == ACL_ALLOW ) ? ' checked="checked"' : ''; $allow_type = ($auth[$auth_options[$i]['auth_value']] == ACL_ALLOW) ? ' checked="checked"' : '';
$deny_type = ( $auth[$auth_options[$i]['auth_value']] == ACL_DENY ) ? ' checked="checked"' : ''; $deny_type = ($auth[$auth_options[$i]['auth_value']] == ACL_DENY) ? ' checked="checked"' : '';
$inherit_type = ( $auth[$auth_options[$i]['auth_value']] == ACL_INHERIT ) ? ' checked="checked"' : ''; $inherit_type = ($auth[$auth_options[$i]['auth_value']] == ACL_INHERIT) ? ' checked="checked"' : '';
?> ?>
<tr> <tr>
@ -488,11 +476,11 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
} }
if ( $type_sql == 'f' || $type_sql == 'm' ) if ($type_sql == 'f' || $type_sql == 'm')
{ {
$children = get_forum_branch($forum_id, 'children', 'descending', false); $children = get_forum_branch($forum_id, 'children', 'descending', false);
if ( !empty($children) ) if (!empty($children))
{ {
?> ?>
<tr> <tr>
@ -504,7 +492,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
<td colspan="4" height="16"><span class="gensmall"><?php echo $user->lang['Inheritance_explain']; ?></span></td> <td colspan="4" height="16"><span class="gensmall"><?php echo $user->lang['Inheritance_explain']; ?></span></td>
</tr> </tr>
<?php <?php
foreach ( $children as $row ) foreach ($children as $row)
{ {
?> ?>
@ -528,7 +516,7 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators
?> ?>
<tr> <tr>
<td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="update" value="<?php echo $user->lang['Update']; ?>" />&nbsp;&nbsp;<input class="liteoption" type="submit" name="cancel" value="<?php echo $user->lang['Cancel']; ?>" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /><input type="hidden" name="type" value="<?php echo $_POST['type']; ?>" /><?php echo $ug_hidden; ?></td> <td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="update" value="<?php echo $user->lang['Update']; ?>" />&nbsp;&nbsp;<input class="liteoption" type="submit" name="CANCEL" value="<?php echo $user->lang['CANCEL']; ?>" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /><input type="hidden" name="type" value="<?php echo $_POST['type']; ?>" /><?php echo $ug_hidden; ?></td>
</tr> </tr>
</table></td> </table></td>
</tr> </tr>

View file

@ -19,41 +19,38 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_forum') ) if (!$auth->acl_get('a_prune'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['Forums']['Prune'] = basename(__FILE__) . $SID . '&amp;mode=forums';
$module['Forums']['Prune'] = $filename . $SID . '&amp;mode=forums';
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// Do we have forum admin permissions? // Do we have permission?
if ( !$auth->acl_get('a_forum') ) if (!$auth->acl_get('a_prune'))
{ {
message_die(MESSAGE, $user->lang['No_admin']); trigger_error($user->lang['NO_ADMIN']);
} }
// //
// Get the forum ID for pruning // Get the forum ID for pruning
// //
if ( isset($_GET['f']) || isset($_POST['f']) ) if (isset($_REQUEST['f']))
{ {
$forum_id = ( isset($_POST['f']) ) ? intval($_POST['f']) : intval($_GET['f']); $forum_id = intval($_REQUEST['f']);
$forum_sql = ( $forum_id == -1 ) ? '' : "AND forum_id = $forum_id"; $forum_sql = ($forum_id == -1) ? '' : "AND forum_id = $forum_id";
} }
else else
{ {
@ -69,7 +66,7 @@ $sql = "SELECT forum_id, forum_name, left_id, right_id
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$forum_rows = array(); $forum_rows = array();
while( $row = $db->sql_fetchrow($result) ) while($row = $db->sql_fetchrow($result))
{ {
$forum_rows[] = $row; $forum_rows[] = $row;
} }
@ -78,12 +75,12 @@ $db->sql_freeresult($result);
// //
// Check for submit to be equal to Prune. If so then proceed with the pruning. // Check for submit to be equal to Prune. If so then proceed with the pruning.
// //
if ( isset($_POST['doprune']) ) if (isset($_POST['doprune']))
{ {
$prunedays = ( isset($_POST['prunedays']) ) ? intval($_POST['prunedays']) : 0; $prunedays = (isset($_POST['prunedays'])) ? intval($_POST['prunedays']) : 0;
// Convert days to seconds for timestamp functions... // Convert days to seconds for timestamp functions...
$prunedate = time() - ( $prunedays * 86400 ); $prunedate = time() - ($prunedays * 86400);
$template->set_filenames(array( $template->set_filenames(array(
'body' => 'admin/forum_prune_result_body.tpl') 'body' => 'admin/forum_prune_result_body.tpl')
@ -103,7 +100,7 @@ if ( isset($_POST['doprune']) )
'FORUM_POSTS' => $p_result['posts']) 'FORUM_POSTS' => $p_result['posts'])
); );
$log_data .= ( ( $log_data != '' ) ? ', ' : '' ) . $forum_rows[$i]['forum_name']; $log_data .= (($log_data != '') ? ', ' : '') . $forum_rows[$i]['forum_name'];
} }
$template->assign_vars(array( $template->assign_vars(array(
@ -125,7 +122,7 @@ else
// If they haven't selected a forum for pruning yet then // If they haven't selected a forum for pruning yet then
// display a select box to use for pruning. // display a select box to use for pruning.
// //
if ( empty($forum_id) ) if (empty($forum_id))
{ {
// //
// Output a selection table if no forum id has been specified. // Output a selection table if no forum id has been specified.
@ -135,15 +132,15 @@ else
$right = 0; $right = 0;
$subforum = ''; $subforum = '';
$forum_list = ''; $forum_list = '';
foreach ( $forum_rows as $row ) foreach ($forum_rows as $row)
{ {
if ( $row['left_id'] < $right ) if ($row['left_id'] < $right )
{ {
$subforum .= '&nbsp;&nbsp;&nbsp;'; $subforum .= '&nbsp;&nbsp;&nbsp;';
} }
else if ( $row['left_id'] > $right + 1 ) else if ($row['left_id'] > $right + 1)
{ {
$subforum = substr($subforum, 0, -18 * ( $row['left_id'] - $right + 1 )); $subforum = substr($subforum, 0, -18 * ($row['left_id'] - $right + 1));
} }
$select_list .= '<option value="' . $row['forum_id'] . '">' . $subforum . $row['forum_name'] . '</option>'; $select_list .= '<option value="' . $row['forum_id'] . '">' . $subforum . $row['forum_name'] . '</option>';
@ -171,7 +168,7 @@ else
} }
else else
{ {
$forum_name = ( $forum_id == -1 ) ? $user->lang['All_Forums'] : $forum_rows[0]['forum_name']; $forum_name = ($forum_id == -1) ? $user->lang['All_Forums'] : $forum_rows[0]['forum_name'];
$prune_data = $user->lang['Prune_topics_not_posted'] . " "; $prune_data = $user->lang['Prune_topics_not_posted'] . " ";
$prune_data .= '<input type="text" name="prunedays" size="4"> ' . $user->lang['Days']; $prune_data .= '<input type="text" name="prunedays" size="4"> ' . $user->lang['Days'];

View file

@ -19,61 +19,45 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_user') ) if (!$auth->acl_get('a_userdel'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['Users']['Prune_users'] = basename(__FILE__) . $SID;
$module['Users']['Prune_users'] = $filename . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
//
// Do we have forum admin permissions? // Do we have forum admin permissions?
// if (!$auth->acl_get('a_userdel'))
if ( !$auth->acl_get('a_user') )
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
//
// Set mode // Set mode
// $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
if( isset( $_POST['mode'] ) || isset( $_GET['mode'] ) )
{
$mode = ( isset( $_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
}
else
{
$mode = '';
}
// // Do prune
// if (isset($_POST['prune']))
//
if ( isset($_POST['prune']) )
{ {
if ( empty($_POST['confirm']) ) if (empty($_POST['confirm']))
{ {
$values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts'); $values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts');
$l_message = '<form method="post" action="admin_prune_users.' . $phpEx . $SID . '">' . $user->lang['Confirm_prune_users'] . '<br /><br /><input class="liteoption" type="submit" name="confirm" value="' . $user->lang['Yes'] . '" />&nbsp;&nbsp;<input class="liteoption" type="submit" name="cancel" value="' . $user->lang['No'] . '" />'; $l_message = '<form method="post" action="admin_prune_users.' . $phpEx . $SID . '">' . $user->lang['Confirm_prune_users'] . '<br /><br /><input class="liteoption" type="submit" name="confirm" value="' . $user->lang['Yes'] . '" />&nbsp;&nbsp;<input class="liteoption" type="submit" name="cancel" value="' . $user->lang['No'] . '" />';
foreach ( $values as $field ) foreach ($values as $field)
{ {
$l_message .= ( !empty($_POST[$field]) ) ? '<input type="hidden" name="' . $field . '" value="' . urlencode($_POST[$field]) . '" />' : ''; $l_message .= (!empty($_POST[$field])) ? '<input type="hidden" name="' . $field . '" value="' . urlencode($_POST[$field]) . '" />' : '';
} }
$l_message .= '</form>'; $l_message .= '</form>';
@ -92,40 +76,40 @@ if ( isset($_POST['prune']) )
page_footer(); page_footer();
} }
else if ( isset($_POST['confirm']) ) else if (isset($_POST['confirm']))
{ {
if ( !empty($_POST['users']) ) if (!empty($_POST['users']))
{ {
$users = explode("\n", urldecode($_POST['users'])); $users = explode("\n", urldecode($_POST['users']));
$where_sql = ''; $where_sql = '';
foreach ( $users as $username ) foreach ($users as $username)
{ {
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . '\'' . trim($username) . '\''; $where_sql .= (($where_sql != '') ? ', ' : '') . '\'' . trim($username) . '\'';
} }
$where_sql = " AND username IN ($where_sql)"; $where_sql = " AND username IN ($where_sql)";
} }
else else
{ {
$username = ( !empty($_POST['username']) ) ? urldecode($_POST['username']) : ''; $username = (!empty($_POST['username'])) ? urldecode($_POST['username']) : '';
$email = ( !empty($_POST['email']) ) ? urldecode($_POST['email']) : ''; $email = (!empty($_POST['email'])) ? urldecode($_POST['email']) : '';
$joined_select = ( !empty($_POST['joined_select']) ) ? $_POST['joined_select'] : 'lt'; $joined_select = (!empty($_POST['joined_select'])) ? $_POST['joined_select'] : 'lt';
$active_select = ( !empty($_POST['active_select']) ) ? $_POST['active_select'] :'lt'; $active_select = (!empty($_POST['active_select'])) ? $_POST['active_select'] :'lt';
$count_select = ( !empty($_POST['count_select']) ) ? $_POST['count_select'] : 'eq'; $count_select = (!empty($_POST['count_select'])) ? $_POST['count_select'] : 'eq';
$joined = ( !empty($_POST['joined']) ) ? explode('-', $_POST['joined']) : array(); $joined = (!empty($_POST['joined'])) ? explode('-', $_POST['joined']) : array();
$active = ( !empty($_POST['active']) ) ? explode('-', $_POST['active']) :array(); $active = (!empty($_POST['active'])) ? explode('-', $_POST['active']) :array();
$count = ( !empty($_POST['count']) ) ? intval($_POST['count']) : ''; $count = (!empty($_POST['count'])) ? intval($_POST['count']) : '';
$key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
$where_sql = ''; $where_sql = '';
$where_sql .= ( $username ) ? " AND username LIKE '" . str_replace('*', '%', $username) ."'" : ''; $where_sql .= ($username) ? " AND username LIKE '" . str_replace('*', '%', $username) ."'" : '';
$where_sql .= ( $email ) ? " AND user_email LIKE '" . str_replace('*', '%', $email) ."' " : ''; $where_sql .= ($email) ? " AND user_email LIKE '" . str_replace('*', '%', $email) ."' " : '';
$where_sql .= ( $joined ) ? " AND user_regdate " . $key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; $where_sql .= ($joined) ? " AND user_regdate " . $key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
$where_sql .= ( $count ) ? " AND user_posts " . $key_match[$count_select] . " $count " : ''; $where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . " $count " : '';
$where_sql .= ( $active ) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; $where_sql .= ($active) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
} }
$sql = "SELECT username, user_id FROM " . USERS_TABLE . " $sql = "SELECT username, user_id FROM " . USERS_TABLE . "
@ -136,26 +120,26 @@ if ( isset($_POST['prune']) )
$where_sql = ''; $where_sql = '';
$user_ids = array(); $user_ids = array();
$usernames = array(); $usernames = array();
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $row['user_id']; $where_sql .= (($where_sql != '') ? ', ' : '') . $row['user_id'];
$user_ids[] = $row['user_id']; $user_ids[] = $row['user_id'];
$usernames[] = $row['username']; $usernames[] = $row['username'];
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
$where_sql = " AND user_id IN ($where_sql)"; $where_sql = " AND user_id IN ($where_sql)";
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if ( $where_sql != '' ) if ($where_sql != '')
{ {
$sql = ''; $sql = '';
if ( !empty($_POST['delete']) ) if (!empty($_POST['delete']))
{ {
if ( !empty($_POST['deleteposts']) ) if (!empty($_POST['deleteposts']))
{ {
$l_admin_log = 'log_prune_user_del_del'; $l_admin_log = 'log_prune_user_del_del';
@ -178,7 +162,7 @@ if ( isset($_POST['prune']) )
$sql = "DELETE FROM " . USERS_TABLE; $sql = "DELETE FROM " . USERS_TABLE;
} }
else if ( !empty($_POST['deactivate']) ) else if (!empty($_POST['deactivate']))
{ {
$l_admin_log = 'log_prune_user_deac'; $l_admin_log = 'log_prune_user_deac';
@ -203,20 +187,20 @@ if ( isset($_POST['prune']) )
// //
$find_count = array('lt' => $user->lang['Less_than'], 'eq' => $user->lang['Equal_to'], 'gt' => $user->lang['More_than']); $find_count = array('lt' => $user->lang['Less_than'], 'eq' => $user->lang['Equal_to'], 'gt' => $user->lang['More_than']);
$s_find_count = ''; $s_find_count = '';
foreach ( $find_count as $key => $value ) foreach ($find_count as $key => $value)
{ {
$selected = ( $key == 'eq' ) ? ' selected="selected"' : ''; $selected = ($key == 'eq') ? ' selected="selected"' : '';
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
} }
$find_time = array('lt' => $user->lang['Before'], 'gt' => $user->lang['After']); $find_time = array('lt' => $user->lang['Before'], 'gt' => $user->lang['After']);
$s_find_join_time = ''; $s_find_join_time = '';
foreach ( $find_time as $key => $value ) foreach ($find_time as $key => $value)
{ {
$s_find_join_time .= '<option value="' . $key . '">' . $value . '</option>'; $s_find_join_time .= '<option value="' . $key . '">' . $value . '</option>';
} }
$s_find_active_time = ''; $s_find_active_time = '';
foreach ( $find_time as $key => $value ) foreach ($find_time as $key => $value)
{ {
$s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>'; $s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>';
} }
@ -237,7 +221,7 @@ page_header($user->lang['Prune_users']);
<th colspan="2"><?php echo $user->lang['Prune_users']; ?></th> <th colspan="2"><?php echo $user->lang['Prune_users']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['Username']; ?>: </td> <td class="row1"><?php echo $user->lang['USERNAME']; ?>: </td>
<td class="row2"><input class="post" type="text" name="username" /></td> <td class="row2"><input class="post" type="text" name="username" /></td>
</tr> </tr>
<tr> <tr>

View file

@ -19,52 +19,42 @@
* *
***************************************************************************/ ***************************************************************************/
define('IN_PHPBB', 1); if (!empty($setmodules))
if( !empty($setmodules) )
{ {
if ( !$auth->acl_get('a_user') ) if (!$auth->acl_get('a_ranks'))
{ {
return; return;
} }
$file = basename(__FILE__); $module['Users']['Ranks'] = basename(__FILE__) . $SID;
$module['Users']['Ranks'] = "$file$SID";
return; return;
} }
// define('IN_PHPBB', 1);
// Let's set the root dir for phpBB // Let's set the root dir for phpBB
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
// // Do we have permission?
// if (!$auth->acl_get('a_ranks'))
//
if ( !$auth->acl_get('a_user') )
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
// // Check mode
// if (isset($_REQUEST['mode']))
//
if ( isset($_GET['mode']) || isset($_POST['mode']) )
{ {
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; $mode = $_REQUEST['mode'];
} }
else else
{ {
//
// These could be entered via a form button // These could be entered via a form button
// if (isset($_POST['add']))
if ( isset($_POST['add']) )
{ {
$mode = 'add'; $mode = 'add';
} }
else if ( isset($_POST['save']) ) else if (isset($_POST['save']))
{ {
$mode = 'save'; $mode = 'save';
} }
@ -74,23 +64,21 @@ else
} }
} }
// // Process mode
// if ($mode != '')
//
if ( $mode != '' )
{ {
if ( $mode == 'edit' || $mode == 'add' ) if ($mode == 'edit' || $mode == 'add')
{ {
// //
// They want to add a new rank, show the form. // They want to add a new rank, show the form.
// //
$rank_id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0; $rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$s_hidden_fields = '<input type="hidden" name="mode" value="save" />'; $s_hidden_fields = '<input type="hidden" name="mode" value="save" />';
if ( $mode == 'edit' ) if ($mode == 'edit')
{ {
if ( empty($rank_id) ) if (empty($rank_id))
{ {
message_die(MESSAGE, $user->lang['Must_select_rank']); message_die(MESSAGE, $user->lang['Must_select_rank']);
} }
@ -126,15 +114,15 @@ if ( $mode != '' )
</tr> </tr>
<tr> <tr>
<td class="row1" width="40%"><?php echo $user->lang['Rank_special']; ?>: </td> <td class="row1" width="40%"><?php echo $user->lang['Rank_special']; ?>: </td>
<td class="row2"><input type="radio" name="special_rank" value="1"<?php echo ( $rank_info['rank_special'] ) ? ' checked="checked"' : ''; ?> /><?php echo $user->lang['Yes']; ?> &nbsp;&nbsp;<input type="radio" name="special_rank" value="0"<?php echo ( !$rank_info['rank_special'] ) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['No']; ?></td> <td class="row2"><input type="radio" name="special_rank" value="1"<?php echo ($rank_info['rank_special']) ? ' checked="checked"' : ''; ?> /><?php echo $user->lang['Yes']; ?> &nbsp;&nbsp;<input type="radio" name="special_rank" value="0"<?php echo (!$rank_info['rank_special']) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['No']; ?></td>
</tr> </tr>
<tr> <tr>
<td class="row1" width="40%"><?php echo $user->lang['Rank_minimum']; ?>: </td> <td class="row1" width="40%"><?php echo $user->lang['Rank_minimum']; ?>: </td>
<td class="row2"><input type="text" name="min_posts" size="5" maxlength="10" value="<?php echo ( $rank_info['rank_special'] ) ? '' : $rank_info['rank_min']; ?>" /></td> <td class="row2"><input type="text" name="min_posts" size="5" maxlength="10" value="<?php echo ($rank_info['rank_special']) ? '' : $rank_info['rank_min']; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td class="row1" width="40%"><?php echo $user->lang['Rank_image']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Rank_image_explain']; ?></span></td> <td class="row1" width="40%"><?php echo $user->lang['Rank_image']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Rank_image_explain']; ?></span></td>
<td class="row2"><input type="text" name="rank_image" size="40" maxlength="255" value="<?php echo ( $rank_info['rank_image'] != '' ) ? $rank_info['rank_image'] : ''; ?>" /><br /><?php echo ( $rank_info['rank_image'] != '' ) ? '<img src="../' . $rank_info['rank_image'] . '" />' : ''; ?></td> <td class="row2"><input type="text" name="rank_image" size="40" maxlength="255" value="<?php echo ($rank_info['rank_image'] != '') ? $rank_info['rank_image'] : ''; ?>" /><br /><?php echo ($rank_info['rank_image'] != '') ? '<img src="../' . $rank_info['rank_image'] . '" />' : ''; ?></td>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="submit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /></td> <td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="submit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /></td>
@ -146,24 +134,24 @@ if ( $mode != '' )
page_footer(); page_footer();
} }
else if ( $mode == 'save' ) else if ($mode == 'save')
{ {
// //
// Ok, they sent us our info, let's update it. // Ok, they sent us our info, let's update it.
// //
$rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : 0; $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$rank_title = ( isset($_POST['title']) ) ? trim($_POST['title']) : ''; $rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$special_rank = ( $_POST['special_rank'] == 1 ) ? TRUE : 0; $special_rank = ($_POST['special_rank'] == 1) ? TRUE : 0;
$min_posts = ( isset($_POST['min_posts']) ) ? intval($_POST['min_posts']) : -1; $min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
$rank_image = ( (isset($_POST['rank_image'])) ) ? trim($_POST['rank_image']) : ''; $rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : '';
if ( $rank_title == '' ) if ($rank_title == '')
{ {
message_die(MESSAGE, $user->lang['Must_select_rank']); message_die(MESSAGE, $user->lang['Must_select_rank']);
} }
if ( $special_rank == 1 ) if ($special_rank == 1)
{ {
$min_posts = -1; $min_posts = -1;
} }
@ -171,15 +159,15 @@ if ( $mode != '' )
// //
// The rank image has to be a jpg, gif or png // The rank image has to be a jpg, gif or png
// //
if ( $rank_image != '' ) if ($rank_image != '')
{ {
if ( !preg_match('/(\.gif|\.png|\.jpg|\.jpeg)$/is', $rank_image)) if (!preg_match('/(\.gif|\.png|\.jpg|\.jpeg)$/is', $rank_image))
{ {
$rank_image = ''; $rank_image = '';
} }
} }
if ( $rank_id ) if ($rank_id)
{ {
$sql = "UPDATE " . RANKS_TABLE . " $sql = "UPDATE " . RANKS_TABLE . "
SET rank_title = '" . str_replace("\'", "''", $rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . str_replace("\'", "''", $rank_image) . "' SET rank_title = '" . str_replace("\'", "''", $rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . str_replace("\'", "''", $rank_image) . "'
@ -202,22 +190,22 @@ if ( $mode != '' )
message_die(MESSAGE, $message); message_die(MESSAGE, $message);
} }
else if ( $mode == 'delete' ) else if ($mode == 'delete')
{ {
// //
// Ok, they want to delete their rank // Ok, they want to delete their rank
// //
if ( isset($_POST['id']) || isset($_GET['id']) ) if (isset($_POST['id']) || isset($_GET['id']))
{ {
$rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : intval($_GET['id']); $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
} }
else else
{ {
$rank_id = 0; $rank_id = 0;
} }
if ( $rank_id ) if ($rank_id)
{ {
$sql = "DELETE FROM " . RANKS_TABLE . " $sql = "DELETE FROM " . RANKS_TABLE . "
WHERE rank_id = $rank_id"; WHERE rank_id = $rank_id";
@ -265,23 +253,23 @@ $sql = "SELECT * FROM " . RANKS_TABLE . "
ORDER BY rank_min ASC, rank_special ASC"; ORDER BY rank_min ASC, rank_special ASC";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2'; $row_class = ($row_class != 'row1') ? 'row1' : 'row2';
?> ?>
<tr> <tr>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['rank_title']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['rank_title']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo ( $row['rank_special'] ) ? '-' : $row['rank_min']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['rank_special']) ? '-' : $row['rank_min']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo ( $row['rank_special'] ) ? $user->lang['Yes'] : $user->lang['No']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['rank_special']) ? $user->lang['Yes'] : $user->lang['No']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=edit&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['Edit']; ?></a></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=edit&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['Edit']; ?></a></td>
<td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=delete&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['Delete']; ?></a></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=delete&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['Delete']; ?></a></td>
</tr> </tr>
<?php <?php
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
?> ?>

View file

@ -19,59 +19,50 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') ) if (!$auth->acl_get('a_search'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['DB']['Search_indexing'] = basename(__FILE__) . $SID;
$module['DB']['Search_indexing'] = $filename . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.'.$phpEx); include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
// // Check permissions
// Do we have forum admin permissions? if (!$auth->acl_get('a_search'))
//
if ( !$auth->acl_get('a_general') )
{ {
message_die(MESSAGE, $user->lang['No_admin']); trigger_error($user->lang['NO_ADMIN']);
} }
//
// Start indexing // Start indexing
// if (isset($_POST['start']) || isset($_GET['batchstart']))
if ( isset($_POST['start']) || isset($_GET['batchstart']) )
{ {
$batchsize = 200; // Process this many posts per batch $batchsize = 200; // Process this many posts per batch
$batchstart = ( !isset($_GET['batchstart']) ) ? $row['min_post_id'] : $_GET['batchstart']; $batchstart = (!isset($_GET['batchstart'])) ? $row['min_post_id'] : $_GET['batchstart'];
$batchcount = ( !isset($_GET['batchcount']) ) ? 1 : $_GET['batchcount']; $batchcount = (!isset($_GET['batchcount'])) ? 1 : $_GET['batchcount'];
$loopcount = 0; $loopcount = 0;
$batchend = $batchstart + $batchsize; $batchend = $batchstart + $batchsize;
//
// Search re-indexing is tough on the server ... so we'll check the load // Search re-indexing is tough on the server ... so we'll check the load
// each loop and if we're on a 1min load of 3 or more we'll re-load the page // each loop and if we're on a 1min load of 3 or more we'll re-load the page
// and try again. No idea how well this will work in practice so we'll see ... // and try again. No idea how well this will work in practice so we'll see ...
// if (file_exists('/proc/loadavg'))
if ( file_exists('/proc/loadavg') )
{ {
if ( $load = @file('/proc/loadavg') ) if ($load = @file('/proc/loadavg'))
{ {
list($load) = explode(' ', $load[0]); list($load) = explode(' ', $load[0]);
if ( $load > 3 ) if ($load > 3)
{ {
header("Location: admin_search.$phpEx$SID&batchstart=$batchstart&batchcount=$batch_count"); header("Location: admin_search.$phpEx$SID&batchstart=$batchstart&batchcount=$batch_count");
exit; exit;
@ -79,27 +70,25 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
} }
} }
//
// Try and load stopword and synonym files // Try and load stopword and synonym files
//
$stopword_array = array(); $stopword_array = array();
$synonym_array = array(); $synonym_array = array();
$dir = opendir($phpbb_root_path . 'language/'); $dir = opendir($phpbb_root_path . 'language/');
while ( $file = readdir($dir) ) while ($file = readdir($dir))
{ {
if ( preg_match('#^lang_#', $file) && !is_file($phpbb_root_path . 'language/' . $file) && !is_link($phpbb_root_path . 'language/' . $file) ) if (preg_match('#^lang_#', $file) && !is_file($phpbb_root_path . 'language/' . $file) && !is_link($phpbb_root_path . 'language/' . $file))
{ {
unset($tmp_array); unset($tmp_array);
$tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_stopwords.txt'); $tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_stopwords.txt');
if ( is_array($tmp_array) ) if (is_array($tmp_array))
{ {
$stopword_array = array_unique(array_merge($stopword_array, $tmp_array)); $stopword_array = array_unique(array_merge($stopword_array, $tmp_array));
} }
unset($tmp_array); unset($tmp_array);
$tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_synonyms.txt'); $tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_synonyms.txt');
if ( is_array($tmp_array) ) if (is_array($tmp_array))
{ {
$synonym_array = array_unique(array_merge($synonym_array, $tmp_array)); $synonym_array = array_unique(array_merge($synonym_array, $tmp_array));
} }
@ -108,7 +97,7 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
closedir($dir); closedir($dir);
if ( !isset($_GET['batchstart']) ) if (!isset($_GET['batchstart']))
{ {
// //
// Take board offline // Take board offline
@ -146,7 +135,7 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
AND $batchend"; AND $batchend";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
@ -158,36 +147,36 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
$word = array(); $word = array();
$word_insert_sql = array(); $word_insert_sql = array();
foreach ( $search_raw_words as $word_in => $search_matches ) foreach ($search_raw_words as $word_in => $search_matches)
{ {
$word_insert_sql[$word_in] = ''; $word_insert_sql[$word_in] = '';
if ( !empty($search_matches) ) if (!empty($search_matches))
{ {
for ($i = 0; $i < count($search_matches); $i++) for ($i = 0; $i < count($search_matches); $i++)
{ {
$search_matches[$i] = trim($search_matches[$i]); $search_matches[$i] = trim($search_matches[$i]);
if ( $search_matches[$i] != '' ) if ($search_matches[$i] != '')
{ {
$word[] = $search_matches[$i]; $word[] = $search_matches[$i];
$word_insert_sql[$word_in] .= ( $word_insert_sql[$word_in] != '' ) ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'"; $word_insert_sql[$word_in] .= ($word_insert_sql[$word_in] != '') ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'";
} }
} }
} }
} }
if ( count($word) ) if (count($word))
{ {
$word_text_sql = ''; $word_text_sql = '';
$word = array_unique($word); $word = array_unique($word);
for($i = 0; $i < count($word); $i++) for($i = 0; $i < count($word); $i++)
{ {
$word_text_sql .= ( ( $word_text_sql != '' ) ? ', ' : '' ) . "'" . $word[$i] . "'"; $word_text_sql .= (($word_text_sql != '') ? ', ' : '') . "'" . $word[$i] . "'";
} }
$check_words = array(); $check_words = array();
switch( SQL_LAYER ) switch(SQL_LAYER)
{ {
case 'postgresql': case 'postgresql':
case 'msaccess': case 'msaccess':
@ -199,7 +188,7 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
WHERE word_text IN ($word_text_sql)"; WHERE word_text IN ($word_text_sql)";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
$check_words[$row['word_text']] = $row['word_id']; $check_words[$row['word_text']] = $row['word_id'];
} }
@ -211,21 +200,21 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
for ($i = 0; $i < count($word); $i++) for ($i = 0; $i < count($word); $i++)
{ {
$new_match = true; $new_match = true;
if ( isset($check_words[$word[$i]]) ) if (isset($check_words[$word[$i]]))
{ {
$new_match = false; $new_match = false;
} }
if ( $new_match ) if ($new_match)
{ {
switch( SQL_LAYER ) switch(SQL_LAYER)
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
$value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\')'; $value_sql .= (($value_sql != '') ? ', ' : '') . '(\'' . $word[$i] . '\')';
break; break;
case 'mssql': case 'mssql':
$value_sql .= ( ( $value_sql != '' ) ? ' UNION ALL ' : '' ) . "SELECT '" . $word[$i] . "'"; $value_sql .= (($value_sql != '') ? ' UNION ALL ' : '') . "SELECT '" . $word[$i] . "'";
break; break;
default: default:
$sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text)
@ -236,9 +225,9 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
} }
} }
if ( $value_sql != '' ) if ($value_sql != '')
{ {
switch ( SQL_LAYER ) switch (SQL_LAYER)
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -255,11 +244,11 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
} }
} }
foreach ( $word_insert_sql as $word_in => $match_sql ) foreach ($word_insert_sql as $word_in => $match_sql)
{ {
$title_match = ( $word_in == 'title' ) ? 1 : 0; $title_match = ($word_in == 'title') ? 1 : 0;
if ( $match_sql != '' ) if ($match_sql != '')
{ {
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)
SELECT $post_id, word_id, $title_match SELECT $post_id, word_id, $title_match
@ -270,22 +259,22 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
} }
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
// Remove common words after the first 2 batches and after every 4th batch after that. // Remove common words after the first 2 batches and after every 4th batch after that.
if ( $batchcount % 4 == 3 ) if ($batchcount % 4 == 3)
{ {
// remove_common('global', $config['common_search']); // remove_common('global', $config['common_search']);
} }
$batchcount++; $batchcount++;
if ( ( $batchstart + $batchsize ) < $max_post_id ) if (($batchstart + $batchsize) < $max_post_id)
{ {
header("Location: admin_search.$phpEx$SID&batchstart=" . ( $batchstart + $batchsize ) . "&batchcount=$batch_count"); header("Location: admin_search.$phpEx$SID&batchstart=" . ($batchstart + $batchsize) . "&batchcount=$batch_count");
exit; exit;
} }
else else
@ -312,7 +301,7 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) )
exit; exit;
} }
else if ( isset($_POST['cancel']) ) else if (isset($_POST['cancel']))
{ {
$sql = "UPDATE " . CONFIG_TABLE . " $sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '0' SET config_value = '0'

View file

@ -19,9 +19,9 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') ) if (!$auth->acl_get('a_icons'))
{ {
return; return;
} }
@ -34,42 +34,22 @@ if ( !empty($setmodules) )
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
//
// Do we have general permissions? // Do we have general permissions?
// if (!$auth->acl_get('a_icons'))
if (!$auth->acl_get('a_general'))
{ {
message_die(MESSAGE, $user->lang['No_admin']); message_die(MESSAGE, $user->lang['No_admin']);
} }
//
// Check to see what mode we should operate in. // Check to see what mode we should operate in.
// $type = (!empty($_REQUEST['type'])) ? $_REQUEST['type'] : '';
if (isset($_POST['type']) || isset($_GET['type'])) $mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
{
$type = (!empty($_POST['type'])) ? $_POST['type'] : $_GET['type'];
}
else
{
$type = '';
}
if (isset($_POST['mode']) || isset($_GET['mode']))
{
$mode = (!empty($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
}
else
{
$mode = '';
}
// What are we doing?
switch ($type) switch ($type)
{ {
case 'emoticons': case 'emoticons':
@ -603,7 +583,7 @@ function update_smile_dimensions()
</tr> </tr>
<?php <?php
} }
$row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2'; $row_class = ($row_class != 'row1') ? 'row1' : 'row2';
?> ?>
<tr> <tr>
<?php <?php

View file

@ -19,71 +19,57 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_user') ) if (!$auth->acl_gets('a_user', 'a_useradd', 'a_userdel'))
{ {
return; return;
} }
$filename = basename(__FILE__); $module['Users']['Manage'] = basename(__FILE__) . $SID;
$module['Users']['Manage'] = $filename . $SID;
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
// Include files // Include files
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
require($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
// Do we have forum admin permissions?
if ( !$auth->acl_get('a_user') )
{
trigger_error($user->lang['No_admin']);
}
echo $mode;
// Set mode // Set mode
if( isset( $_POST['mode'] ) || isset( $_GET['mode'] ) ) $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : 'main';
{
$mode = ( isset( $_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
}
else
{
$mode = 'main';
}
// Begin program // Begin program
if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) ) if (isset($_POST['username']) || isset($_GET['u']) || isset($_POST['u']))
{ {
// Grab relevant userdata // Grab relevant userdata
if( isset( $_GET['u']) || isset( $_POST['u']) ) if(isset($_REQUEST['u']))
{ {
$user_id = ( isset( $_POST['u']) ) ? intval( $_POST['u']) : intval( $_GET['u']); $user_id = intval($_REQUEST['u']);
if( !($userdata = get_userdata($user_id)) ) if(!($userdata = get_userdata($user_id)))
{ {
trigger_error($user->lang['No_user_id_specified'] ); trigger_error($user->lang['No_user_id_specified']);
} }
} }
else else
{ {
if( !$userdata = get_userdata( $_POST['username'] ) ) if(!$userdata = get_userdata($_POST['username']))
{ {
trigger_error($user->lang['No_user_id_specified'] ); trigger_error($user->lang['No_user_id_specified']);
} }
} }
// Update entry in DB // Update entry in DB
if( $_POST['deleteuser'] && !$userdata['user_founder'] && $auth->acl_get('a_userdel') ) if ($_POST['deleteuser'] && !$userdata['user_founder'])
{ {
if (!$auth->acl_get('a_userdel'))
{
trigger_error($user->lang['NO_ADMIN']);
}
$db->sql_transaction(); $db->sql_transaction();
$sql = "UPDATE " . POSTS_TABLE . " $sql = "UPDATE " . POSTS_TABLE . "
@ -108,6 +94,10 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); $db->sql_query($sql);
$sql = "DELETE FROM " . FORUMS_WATCH_TABLE . "
WHERE user_id = $user_id";
$db->sql_query($sql);
$sql = "DELETE FROM " . ACL_USERS_TABLE . " $sql = "DELETE FROM " . ACL_USERS_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); $db->sql_query($sql);
@ -149,13 +139,13 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
</tr> </tr>
<tr> <tr>
<td class="row1">Registered from IP: </td> <td class="row1">Registered from IP: </td>
<td class="row2"><?php if ( $userdata['user_ip'] ) { echo $userdata['user_ip']; ?> [ <a href="admin_users.<?php echo $phpEx . $SID; ?>&amp;u=<?php echo $userdata['user_id']; ?>&amp;mode=main&amp;do=iplookup">Lookup</a> | <a href="admin_ban.<?php echo $phpEx . $SID; ?>&amp;mode=ip&amp;ban=<?php echo $userdata['user_ip']; ?>&amp;bansubmit=true">Ban</a> ] <?php } else { echo 'Unknown'; } ?></td> <td class="row2"><?php if ($userdata['user_ip']) { echo $userdata['user_ip']; ?> [ <a href="admin_users.<?php echo $phpEx . $SID; ?>&amp;u=<?php echo $userdata['user_id']; ?>&amp;mode=main&amp;do=iplookup">Lookup</a> | <a href="admin_ban.<?php echo $phpEx . $SID; ?>&amp;mode=ip&amp;ban=<?php echo $userdata['user_ip']; ?>&amp;bansubmit=true">Ban</a> ] <?php } else { echo 'Unknown'; } ?></td>
</tr> </tr>
<?php <?php
if ( isset($_GET['do']) && $_GET['do'] == 'iplookup' ) if (isset($_GET['do']) && $_GET['do'] == 'iplookup')
{ {
if ( $userdata['user_ip'] != '' && $domain = gethostbyaddr($userdata['user_ip']) ) if ($userdata['user_ip'] != '' && $domain = gethostbyaddr($userdata['user_ip']))
{ {
?> ?>
<tr> <tr>
@ -164,7 +154,7 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
<tr> <tr>
<td class="row1" colspan="2"><?php <td class="row1" colspan="2"><?php
if ( $ipwhois = ipwhois($userdata['user_ip']) ) if ($ipwhois = ipwhois($userdata['user_ip']))
{ {
echo '<br /><pre align="left">' . trim($ipwhois) . '</pre>'; echo '<br /><pre align="left">' . trim($ipwhois) . '</pre>';
} }
@ -199,7 +189,7 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
foreach ($acl_options['global'] as $option_name => $option_id) foreach ($acl_options['global'] as $option_name => $option_id)
{ {
$type = substr($option_name, 0, strpos('_', $option_name) +1 ); $type = substr($option_name, 0, strpos('_', $option_name) +1);
$global[$type][$option_name] = $userauth->acl_get($option_name); $global[$type][$option_name] = $userauth->acl_get($option_name);
} }
@ -209,7 +199,7 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$permissions = array(); $permissions = array();
while( $row = $db->sql_fetchrow($result) ) while($row = $db->sql_fetchrow($result))
{ {
$forum_data[$row['forum_id']] = $row['forum_name']; $forum_data[$row['forum_id']] = $row['forum_name'];
@ -245,14 +235,14 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
foreach ($auth_ary as $option => $allow) foreach ($auth_ary as $option => $allow)
{ {
if ( $option != $type .'_' ) if ($option != $type .'_')
{ {
$row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
$l_can_cell = ( !empty($user->lang['acl_' . $option]) ) ? $user->lang['acl_' . $option] : ucfirst(preg_replace('#.*?_#', '', $option)); $l_can_cell = (!empty($user->lang['acl_' . $option])) ? $user->lang['acl_' . $option] : ucfirst(preg_replace('#.*?_#', '', $option));
$allow_type = ( $allow == ACL_ALLOW ) ? ' checked="checked"' : ''; $allow_type = ($allow == ACL_ALLOW) ? ' checked="checked"' : '';
$deny_type = ( $allow == ACL_DENY ) ? ' checked="checked"' : ''; $deny_type = ($allow == ACL_DENY) ? ' checked="checked"' : '';
?> ?>
<tr> <tr>
<td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td> <td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td>
@ -280,7 +270,7 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
foreach ($auth_ary as $option => $allow) foreach ($auth_ary as $option => $allow)
{ {
echo '<tr><td>' . $user->lang['acl_' . $option] . ' => ' . ( ( $allow ) ? 'Allowed' : 'Denied' ) . '</td></tr>'; echo '<tr><td>' . $user->lang['acl_' . $option] . ' => ' . (($allow) ? 'Allowed' : 'Denied') . '</td></tr>';
} }
?> ?>
@ -297,10 +287,14 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) )
page_footer(); page_footer();
} }
else
{
page_header($user->lang['Manage']); // Do we have permission?
if (!$auth->acl_get('a_user'))
{
trigger_error($user->lang['No_admin']);
}
page_header($user->lang['Manage']);
?> ?>
@ -308,7 +302,7 @@ else
<p><?php echo $user->lang['User_admin_explain']; ?></p> <p><?php echo $user->lang['User_admin_explain']; ?></p>
<form method="post" name="post" action="<?php echo "admin_users.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <form method="post" name="post" action="admin_users.<?php echo $phpEx.$SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th align="center"><?php echo $user->lang['Select_a_User']; ?></th> <th align="center"><?php echo $user->lang['Select_a_User']; ?></th>
</tr> </tr>
@ -319,12 +313,11 @@ else
<?php <?php
}
page_footer(); page_footer();
// // ---------
// // FUNCTIONS
function ipwhois($ip) function ipwhois($ip)
{ {
$ipwhois = ''; $ipwhois = '';
@ -336,25 +329,25 @@ function ipwhois($ip)
'#whois\.registro\.br#is' => 'whois.registro.br' '#whois\.registro\.br#is' => 'whois.registro.br'
); );
if ( ($fsk = fsockopen('whois.arin.net', 43)) ) if (($fsk = fsockopen('whois.arin.net', 43)))
{ {
@fputs($fsk, "$ip\n"); @fputs($fsk, "$ip\n");
while (!feof($fsk) ) while (!feof($fsk))
{ {
$ipwhois .= fgets($fsk, 1024); $ipwhois .= fgets($fsk, 1024);
} }
fclose($fsk); fclose($fsk);
} }
foreach ( array_keys($match) as $server ) foreach (array_keys($match) as $server)
{ {
if ( preg_match($server, $ipwhois) ) if (preg_match($server, $ipwhois))
{ {
$ipwhois = ''; $ipwhois = '';
if ( ($fsk = fsockopen($match[$server], 43)) ) if (($fsk = fsockopen($match[$server], 43)))
{ {
@fputs($fsk, "$ip\n"); @fputs($fsk, "$ip\n");
while (!feof($fsk) ) while (!feof($fsk))
{ {
$ipwhois .= fgets($fsk, 1024); $ipwhois .= fgets($fsk, 1024);
} }
@ -366,7 +359,7 @@ function ipwhois($ip)
return $ipwhois; return $ipwhois;
} }
// // FUNCTIONS
// // ---------
?> ?>

View file

@ -19,51 +19,43 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !empty($setmodules) ) if (!empty($setmodules))
{ {
if ( !$auth->acl_get('a_general') ) if (!$auth->acl_get('a_words'))
{ {
return; return;
} }
$file = basename(__FILE__); $module['Posts']['Word_Censor'] = basename(__FILE__) . $SID;
$module['Posts']['Word_Censor'] = "$file$SID";
return; return;
} }
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
//
// Include files // Include files
//
$phpbb_root_path = '../'; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
//
// Do we have forum admin permissions? // Do we have forum admin permissions?
// if (!$auth->acl_get('a_words'))
if ( !$auth->acl_get('a_general') )
{ {
return; trigger_error($user->lang['NO_ADMIN']);
} }
// // What do we want to do?
// if (isset($_REQUEST['mode']))
//
if ( isset($_GET['mode']) || isset($_POST['mode']) )
{ {
$mode = ( isset($_GET['mode']) ) ? $_GET['mode'] : $_POST['mode']; $mode = $_REQUEST['mode'];
} }
else else
{ {
//
// These could be entered via a form button // These could be entered via a form button
// if (isset($_POST['add']))
if ( isset($_POST['add']) )
{ {
$mode = 'add'; $mode = 'add';
} }
else if ( isset($_POST['save']) ) else if (isset($_POST['save']))
{ {
$mode = 'save'; $mode = 'save';
} }
@ -73,20 +65,20 @@ else
} }
} }
if( $mode != '' ) if ($mode != '')
{ {
switch ( $mode ) switch ($mode)
{ {
case 'edit': case 'edit':
case 'add': case 'add':
$word_id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0; $word_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$s_hidden_fields = ''; $s_hidden_fields = '';
if ( $mode == 'edit' ) if ($mode == 'edit')
{ {
if ( !$word_id ) if (!$word_id)
{ {
message_die(MESSAGE, $user->lang['No_word_selected']); trigger_error($user->lang['No_word_selected']);
} }
$sql = "SELECT * $sql = "SELECT *
@ -119,43 +111,43 @@ if( $mode != '' )
<td class="row2"><input type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td> <td class="row2"><input type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="save" value="<?php echo $user->lang['Submit']; ?>" /></td> <td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="save" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr> </tr>
</table></form> </table></form>
<?php <?php
page_footer();
break; break;
case 'save': case 'save':
$word_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : 0; $word_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$word = ( isset($_POST['word']) ) ? trim($_POST['word']) : ''; $word = (isset($_POST['word'])) ? trim($_POST['word']) : '';
$replacement = ( isset($_POST['replacement']) ) ? trim($_POST['replacement']) : ''; $replacement = (isset($_POST['replacement'])) ? trim($_POST['replacement']) : '';
if ( $word == '' || $replacement == '' ) if ($word == '' || $replacement == '')
{ {
message_die(MESSAGE, $user->lang['Must_enter_word']); trigger_error($user->lang['Must_enter_word']);
} }
$sql = ( $word_id ) ? "UPDATE " . WORDS_TABLE . " SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')"; $sql = ($word_id) ? "UPDATE " . WORDS_TABLE . " SET word = '" . sql_quote($word) . "', replacement = '" . sql_quote($replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . sql_quote($word) . "', '" . sql_quote($replacement) . "')";
$db->sql_query($sql); $db->sql_query($sql);
$log_action = ( $word_id ) ? 'log_edit_word' : 'log_add_word'; $log_action = ($word_id) ? 'log_edit_word' : 'log_add_word';
add_admin_log($log_action, stripslashes($word)); add_admin_log($log_action, stripslashes($word));
$message = ( $word_id ) ? $user->lang['Word_updated'] : $user->lang['Word_added']; $message = ($word_id) ? $user->lang['Word_updated'] : $user->lang['Word_added'];
message_die(MESSAGE, $message);
break; break;
case 'delete': case 'delete':
if ( isset($_POST['id']) || isset($_GET['id']) ) if (isset($_POST['id']) || isset($_GET['id']))
{ {
$word_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : intval($_GET['id']); $word_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
} }
else else
{ {
message_die(MESSAGE, $user->lang['Must_specify_word']); trigger_error($user->lang['Must_specify_word']);
} }
$sql = "DELETE FROM " . WORDS_TABLE . " $sql = "DELETE FROM " . WORDS_TABLE . "
@ -164,10 +156,34 @@ if( $mode != '' )
add_admin_log('log_delete_word'); add_admin_log('log_delete_word');
message_die(MESSAGE, $user->lang['Word_removed']); $message = $user->lang['Word_remove'];
break; break;
} }
$sql = "SELECT *
FROM " . WORDS_TABLE . "
ORDER BY word";
$result = $db->sql_query($sql);
$cache_str = "\$word_censors = array(\n";
$cache_str_match = $cache_str_replace = '';
if ($row = $db->sql_fetchrow($result))
{
do
{
$cache_str_match .= "\t\t'" . addslashes('#\b' . str_replace('\*', '.*?', preg_quote($row['word'], '#')) . '\b#i') . "',\n";
$cache_str_replace .= "\t\t'" . addslashes($row['replacement']) . "',\n";
}
while ($row = $db->sql_fetchrow($result));
$cache_str .= "\t'match' => array(\n$cache_str_match\t),\n\t'replace' => array(\n$cache_str_replace\t)\n);";
}
$db->sql_freeresult($result);
config_cache_write('\$word_censors = array\(.*?\);', $cache_str);
trigger_error($message);
} }
else else
{ {
@ -194,11 +210,11 @@ else
ORDER BY word"; ORDER BY word";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
<tr> <tr>
@ -210,8 +226,9 @@ else
<?php <?php
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result);
?> ?>
<tr> <tr>
@ -221,8 +238,8 @@ else
<?php <?php
page_footer();
} }
page_footer()
?> ?>

View file

@ -22,8 +22,8 @@
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
// Define some vars // Define some vars
$pane = ( isset($_GET['pane']) ) ? $_GET['pane'] : ''; $pane = (isset($_GET['pane'])) ? $_GET['pane'] : '';
$update = ( $pane == 'right' ) ? true : false; $update = ($pane == 'right') ? true : false;
// Include files // Include files
$phpbb_root_path = '../'; $phpbb_root_path = '../';
@ -31,13 +31,13 @@ require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
// Do we have any admin permissions at all? // Do we have any admin permissions at all?
if ( !$auth->acl_get('a_') ) if (!$auth->acl_get('a_'))
{ {
trigger_error('No_admin'); trigger_error($user->lang['NO_ADMIN']);
} }
// Generate relevant output // Generate relevant output
if ( isset($_GET['pane']) && $_GET['pane'] == 'top' ) if (isset($_GET['pane']) && $_GET['pane'] == 'top')
{ {
page_header('', '', false); page_header('', '', false);
@ -55,7 +55,7 @@ if ( isset($_GET['pane']) && $_GET['pane'] == 'top' )
page_footer(false); page_footer(false);
} }
else if ( isset($_GET['pane']) && $_GET['pane'] == 'left' ) else if (isset($_GET['pane']) && $_GET['pane'] == 'left')
{ {
// Cheat and use the meta tag to change some stylesheet info // Cheat and use the meta tag to change some stylesheet info
page_header('', '<style type="text/css">body {background-color: #98AAB1}</style>', false); page_header('', '<style type="text/css">body {background-color: #98AAB1}</style>', false);
@ -64,9 +64,9 @@ else if ( isset($_GET['pane']) && $_GET['pane'] == 'left' )
$dir = @opendir('.'); $dir = @opendir('.');
$setmodules = 1; $setmodules = 1;
while ( $file = @readdir($dir) ) while ($file = @readdir($dir))
{ {
if ( preg_match('/^admin_(.*?)\.' . $phpEx . '$/', $file) ) if (preg_match('/^admin_(.*?)\.' . $phpEx . '$/', $file))
{ {
include($file); include($file);
} }
@ -92,12 +92,12 @@ else if ( isset($_GET['pane']) && $_GET['pane'] == 'left' )
</tr> </tr>
<?php <?php
if ( is_array($module) ) if (is_array($module))
{ {
@ksort($module); @ksort($module);
foreach ( $module as $cat => $action_ary ) foreach ($module as $cat => $action_ary)
{ {
$cat = ( !empty($user->lang[$cat . '_cat']) ) ? $user->lang[$cat . '_cat'] : preg_replace('/_/', ' ', $cat); $cat = (empty($user->lang[$cat . '_cat'])) ? $user->lang[$cat . '_cat'] : preg_replace('/_/', ' ', $cat);
?> ?>
<tr> <tr>
@ -107,20 +107,23 @@ else if ( isset($_GET['pane']) && $_GET['pane'] == 'left' )
@ksort($action_ary); @ksort($action_ary);
foreach ( $action_ary as $action => $file ) foreach ($action_ary as $action => $file)
{ {
$action = ( !empty($user->lang[$action]) ) ? $user->lang[$action] : preg_replace('/_/', ' ', $action); if (!empty($file))
{
$action = (!empty($user->lang[$action])) ? $user->lang[$action] : preg_replace('/_/', ' ', $action);
$cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
<tr> <tr>
<td class="<?php echo $cell_bg; ?>"><a class="genmed" href="<?php echo $file; ?>" target="main"><?php echo $action; ?></a></td> <td class="<?php echo $row_class; ?>"><a class="genmed" href="<?php echo $file; ?>" target="main"><?php echo $action; ?></a></td>
</tr> </tr>
<?php <?php
} }
} }
} }
}
?> ?>
</table></td> </table></td>
@ -134,24 +137,29 @@ else if ( isset($_GET['pane']) && $_GET['pane'] == 'left' )
page_footer(false); page_footer(false);
} }
elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' ) elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
{ {
if ( ( isset($_POST['activate']) || isset($_POST['delete']) ) && !empty($_POST['mark']) ) if ((isset($_POST['activate']) || isset($_POST['delete'])) && !empty($_POST['mark']))
{ {
if ( is_array($_POST['mark']) ) if (!$auth->acl_get('a_user'))
{ {
$in_sql = ''; trigger_error($user->lang['NO_ADMIN']);
foreach( $_POST['mark'] as $user_id )
{
$in_sql .= ( ( $in_sql != '' ) ? ', ' : '' ) . $user_id;
} }
if ( $in_sql != '' ) if (is_array($_POST['mark']))
{ {
$sql = ( isset($_POST['activate']) ) ? "UPDATE " . USERS_TABLE . " SET user_active = 1 WHERE user_id IN ($in_sql)" : "DELETE FROM " . USERS_TABLE . " WHERE user_id IN ($in_sql)"; $in_sql = '';
foreach ($_POST['mark'] as $user_id)
{
$in_sql .= (($in_sql != '') ? ', ' : '') . intval($user_id);
}
if ($in_sql != '')
{
$sql = (isset($_POST['activate'])) ? "UPDATE " . USERS_TABLE . " SET user_active = 1 WHERE user_id IN ($in_sql)" : "DELETE FROM " . USERS_TABLE . " WHERE user_id IN ($in_sql)";
$db->sql_query($sql); $db->sql_query($sql);
if ( isset($_POST['delete']) ) if (isset($_POST['delete']))
{ {
$sql = "UPDATE " . CONFIG_TABLE . " $sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = config_value - " . sizeof($_POST['mark']) . " SET config_value = config_value - " . sizeof($_POST['mark']) . "
@ -159,16 +167,20 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
$db->sql_query($sql); $db->sql_query($sql);
} }
$log_action = ( isset($_POST['activate']) ) ? 'log_index_activate' : 'log_index_delete'; $log_action = (isset($_POST['activate'])) ? 'log_index_activate' : 'log_index_delete';
add_admin_log($log_action, sizeof($_POST['mark'])); add_admin_log($log_action, sizeof($_POST['mark']));
} }
} }
} }
else if ( isset($_POST['remind']) ) else if (isset($_POST['remind']))
{ {
if (!$auth->acl_get('a_user'))
{
trigger_error($user->lang['NO_ADMIN']);
}
} }
else if ( isset($_POST['resetonline']) ) else if (isset($_POST['resetonline']))
{ {
} }
@ -180,7 +192,7 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
$start_date = $user->format_date($config['board_startdate']); $start_date = $user->format_date($config['board_startdate']);
$boarddays = ( time() - $config['board_startdate'] ) / 86400; $boarddays = (time() - $config['board_startdate']) / 86400;
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays); $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays); $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
@ -188,11 +200,11 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
$avatar_dir_size = 0; $avatar_dir_size = 0;
if ( $avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']) ) if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
{ {
while ( $file = @readdir($avatar_dir) ) while ($file = @readdir($avatar_dir))
{ {
if ( $file != '.' && $file != '..' ) if ($file != '.' && $file != '..')
{ {
$avatar_dir_size += @filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); $avatar_dir_size += @filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
} }
@ -202,11 +214,11 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
// This bit of code translates the avatar directory size into human readable format // This bit of code translates the avatar directory size into human readable format
// Borrowed the code from the PHP.net annoted manual, origanally written by: // Borrowed the code from the PHP.net annoted manual, origanally written by:
// Jesse (jesse@jess.on.ca) // Jesse (jesse@jess.on.ca)
if ( $avatar_dir_size >= 1048576 ) if ($avatar_dir_size >= 1048576)
{ {
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' MB'; $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' MB';
} }
else if ( $avatar_dir_size >= 1024 ) else if ($avatar_dir_size >= 1024)
{ {
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' KB'; $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' KB';
} }
@ -222,17 +234,17 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
$avatar_dir_size = $user->lang['Not_available']; $avatar_dir_size = $user->lang['Not_available'];
} }
if ( $posts_per_day > $total_posts ) if ($posts_per_day > $total_posts)
{ {
$posts_per_day = $total_posts; $posts_per_day = $total_posts;
} }
if ( $topics_per_day > $total_topics ) if ($topics_per_day > $total_topics)
{ {
$topics_per_day = $total_topics; $topics_per_day = $total_topics;
} }
if ( $users_per_day > $total_users ) if ($users_per_day > $total_users)
{ {
$users_per_day = $total_users; $users_per_day = $total_users;
} }
@ -240,30 +252,30 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
// DB size ... MySQL only // DB size ... MySQL only
// This code is heavily influenced by a similar routine // This code is heavily influenced by a similar routine
// in phpMyAdmin 2.2.0 // in phpMyAdmin 2.2.0
if ( preg_match('/^mysql/', SQL_LAYER) ) if (preg_match('/^mysql/', SQL_LAYER))
{ {
$result = $db->sql_query('SELECT VERSION() AS mysql_version'); $result = $db->sql_query('SELECT VERSION() AS mysql_version');
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
$version = $row['mysql_version']; $version = $row['mysql_version'];
if ( preg_match('/^(3\.23|4\.)/', $version) ) if (preg_match('/^(3\.23|4\.)/', $version))
{ {
$db_name = ( preg_match('/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)/', $version) ) ? "`$dbname`" : $dbname; $db_name = (preg_match('/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)/', $version)) ? "`$dbname`" : $dbname;
$sql = "SHOW TABLE STATUS $sql = "SHOW TABLE STATUS
FROM " . $db_name; FROM " . $db_name;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$dbsize = 0; $dbsize = 0;
while ( $row = $db->sql_fetchrow($result) ) while ($row = $db->sql_fetchrow($result))
{ {
if ( $row['Type'] != 'MRG_MyISAM' ) if ($row['Type'] != 'MRG_MyISAM')
{ {
if ( $table_prefix != '' ) if ($table_prefix != '')
{ {
if ( strstr($row['Name'], $table_prefix) ) if (strstr($row['Name'], $table_prefix))
{ {
$dbsize += $row['Data_length'] + $row['Index_length']; $dbsize += $row['Data_length'] + $row['Index_length'];
} }
@ -285,22 +297,22 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
$dbsize = $user->lang['Not_available']; $dbsize = $user->lang['Not_available'];
} }
} }
else if ( preg_match('/^mssql/', SQL_LAYER) ) else if (preg_match('/^mssql/', SQL_LAYER))
{ {
$sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
FROM sysfiles"; FROM sysfiles";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $user->lang['Not_available']; $dbsize = ($row = $db->sql_fetchrow($result)) ? intval($row['dbsize']) : $user->lang['Not_available'];
} }
else else
{ {
$dbsize = $user->lang['Not_available']; $dbsize = $user->lang['Not_available'];
} }
if ( is_int($dbsize) ) if (is_int($dbsize))
{ {
$dbsize = ( $dbsize >= 1048576 ) ? sprintf('%.2f MB', ( $dbsize / 1048576 )) : ( ( $dbsize >= 1024 ) ? sprintf('%.2f KB', ( $dbsize / 1024 )) : sprintf('%.2f Bytes', $dbsize) ); $dbsize = ($dbsize >= 1048576) ? sprintf('%.2f MB', ($dbsize / 1048576)) : (($dbsize >= 1024) ? sprintf('%.2f KB', ($dbsize / 1024)) : sprintf('%.2f Bytes', $dbsize));
} }
page_header($user->lang['Admin_Index']); page_header($user->lang['Admin_Index']);
@ -360,7 +372,7 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
<td class="row1" nowrap="nowrap"><?php echo $user->lang['Database_size']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['Database_size']; ?>:</td>
<td class="row2"><b><?php echo $dbsize; ?></b></td> <td class="row2"><b><?php echo $dbsize; ?></b></td>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['Gzip_compression']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['Gzip_compression']; ?>:</td>
<td class="row2"><b><?php echo ( $config['gzip_compress'] ) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td> <td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td>
</tr> </tr>
<!-- tr> <!-- tr>
<td class="row1" colspan="4"><?php echo sprintf($user->lang['Record_online_users'], $config['record_online_users'], $user->format_date($config['record_online_date'])); ?></td> <td class="row1" colspan="4"><?php echo sprintf($user->lang['Record_online_users'], $config['record_online_users'], $user->format_date($config['record_online_date'])); ?></td>
@ -384,7 +396,7 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
for($i = 0; $i < sizeof($log_data); $i++) for($i = 0; $i < sizeof($log_data); $i++)
{ {
$row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
<tr> <tr>
@ -397,6 +409,9 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
} }
if ($auth->acl_get('a_user'))
{
?> ?>
</table> </table>
@ -419,11 +434,11 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
ORDER BY user_regdate ASC"; ORDER BY user_regdate ASC";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
do do
{ {
$row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
<tr> <tr>
@ -434,7 +449,7 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
<?php <?php
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
?> ?>
<tr> <tr>
@ -465,6 +480,8 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' )
<?php <?php
}
page_footer(); page_footer();
} }

View file

@ -19,7 +19,7 @@
* *
***************************************************************************/ ***************************************************************************/
if ( !defined('IN_PHPBB') ) if (!defined('IN_PHPBB'))
{ {
die('Hacking attempt'); die('Hacking attempt');
} }
@ -53,9 +53,9 @@ function page_header($sub_title, $meta = '', $table_html = true)
define('HEADER_INC', true); define('HEADER_INC', true);
// gzip_compression // gzip_compression
if ( $config['gzip_compress'] ) if ($config['gzip_compress'])
{ {
if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() ) if (extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent())
{ {
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
} }
@ -87,7 +87,7 @@ td.cat { background-image: url('images/cellpic1.gif') }
<?php <?php
if ( $table_html ) if ($table_html)
{ {
?> ?>
@ -122,7 +122,7 @@ function page_footer($copyright_html = true)
</table> </table>
<?php <?php
if ( $copyright_html ) if ($copyright_html)
{ {
?> ?>
@ -144,7 +144,7 @@ function page_message($title, $message, $show_header = false)
{ {
global $phpEx, $SID, $user; global $phpEx, $SID, $user;
if ( $show_header ) if ($show_header)
{ {
?> ?>
@ -186,7 +186,7 @@ function add_admin_log()
$arguments = func_get_args(); $arguments = func_get_args();
$action = array_shift($arguments); $action = array_shift($arguments);
$data = ( !sizeof($arguments) ) ? '' : addslashes(serialize($arguments)); $data = (!sizeof($arguments)) ? '' : addslashes(serialize($arguments));
$sql = "INSERT INTO " . LOG_ADMIN_TABLE . " (user_id, log_ip, log_time, log_operation, log_data) $sql = "INSERT INTO " . LOG_ADMIN_TABLE . " (user_id, log_ip, log_time, log_operation, log_data)
VALUES (" . $user->data['user_id'] . ", '$user->ip', " . time() . ", '$action', '$data')"; VALUES (" . $user->data['user_id'] . ", '$user->ip', " . time() . ", '$action', '$data')";
@ -199,9 +199,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
{ {
global $db, $user, $phpEx, $SID; global $db, $user, $phpEx, $SID;
$table_sql = ( $mode == 'admin' ) ? LOG_ADMIN_TABLE : LOG_MOD_TABLE; $table_sql = ($mode == 'admin') ? LOG_ADMIN_TABLE : LOG_MOD_TABLE;
$forum_sql = ( $mode == 'mod' && $forum_id ) ? "AND l.forum_id = $forum_id" : ''; $forum_sql = ($mode == 'mod' && $forum_id) ? "AND l.forum_id = $forum_id" : '';
$limit_sql = ( $limit ) ? ( ( $offset ) ? "LIMIT $offset, $limit" : "LIMIT $limit" ) : ''; $limit_sql = ($limit) ? (($offset) ? "LIMIT $offset, $limit" : "LIMIT $limit") : '';
$sql = "SELECT l.log_id, l.user_id, l.log_ip, l.log_time, l.log_operation, l.log_data, u.username $sql = "SELECT l.log_id, l.user_id, l.log_ip, l.log_time, l.log_operation, l.log_data, u.username
FROM $table_sql l, " . USERS_TABLE . " u FROM $table_sql l, " . USERS_TABLE . " u
@ -213,7 +213,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$log = array(); $log = array();
if ( $row = $db->sql_fetchrow($result) ) if ($row = $db->sql_fetchrow($result))
{ {
$i = 0; $i = 0;
do do
@ -223,13 +223,13 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$log[$i]['ip'] = $row['log_ip']; $log[$i]['ip'] = $row['log_ip'];
$log[$i]['time'] = $row['log_time']; $log[$i]['time'] = $row['log_time'];
$log[$i]['action'] = ( !empty($user->lang[$row['log_operation']]) ) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation'])); $log[$i]['action'] = (!empty($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation']));
if ( !empty($row['log_data']) ) if (!empty($row['log_data']))
{ {
$log_data_ary = unserialize(stripslashes($row['log_data'])); $log_data_ary = unserialize(stripslashes($row['log_data']));
foreach ( $log_data_ary as $log_data ) foreach ($log_data_ary as $log_data)
{ {
$log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1); $log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
} }
@ -237,7 +237,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$i++; $i++;
} }
while ( $row = $db->sql_fetchrow($result) ); while ($row = $db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -128,10 +128,23 @@ INSERT INTO phpbb_auth_options (auth_value, is_local, is_global) VALUES ('m_unra
INSERT INTO phpbb_auth_options (auth_value, is_local, is_global) VALUES ('m_auth', 1, 1); INSERT INTO phpbb_auth_options (auth_value, is_local, is_global) VALUES ('m_auth', 1, 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_general', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_server', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_defaults', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_board', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_cookies', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_clearlogs', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_words', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_icons', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_bbcode', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_attach', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_events', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_email', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_styles', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_user', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_user', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_useradd', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_useradd', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_userdel', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_userdel', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_ranks', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_ban', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_names', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_names', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_group', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_group', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_groupadd', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_groupadd', 1);
@ -139,17 +152,13 @@ INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_groupdel', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forum', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forum', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forumadd', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forumadd', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forumdel', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_forumdel', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_posts', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_prune', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_ban', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_auth', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_auth', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_authmods', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_authmods', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_authadmins', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_authadmins', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_email', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_styles', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_backup', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_backup', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_restore', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_restore', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_search', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_search', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('a_clearlogs', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_email', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_email', 1);
@ -186,11 +195,11 @@ INSERT INTO phpbb_ranks (rank_id, rank_title, rank_min, rank_special, rank_image
# -- Groups # -- Groups
INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (1, 'GUESTS', 0); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (1, 'GUESTS', 3);
INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (2, 'REGISTERED_INACTIVE', 0); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (2, 'INACTIVE', 3);
INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (3, 'REGISTERED', 0); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (3, 'REGISTERED', 3);
INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (4, 'SUPER_MODERATORS', 0); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (4, 'SUPER_MODERATORS', 3);
INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (5, 'ADMINISTRATORS', 0); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (5, 'ADMINISTRATORS', 3);
# -- User -> Group # -- User -> Group

View file

@ -21,7 +21,7 @@
$lang = array_merge($lang, array( $lang = array_merge($lang, array(
'Admin_title' => 'Administration Panel', 'Admin_title' => 'Administration Panel',
'No_admin' => 'You are not authorised to administer this board', 'NO_ADMIN' => 'You are not authorised to administer this board',
'No_frames' => 'Sorry, your browser does not support frames', 'No_frames' => 'Sorry, your browser does not support frames',
'Return_to' => 'Return to ...', 'Return_to' => 'Return to ...',
'DB_cat' => 'Database Admin', 'DB_cat' => 'Database Admin',
@ -39,7 +39,7 @@ $lang = array_merge($lang, array(
'Email_settings' => 'Email Settings', 'Email_settings' => 'Email Settings',
'Server_settings' => 'Server Settings', 'Server_settings' => 'Server Settings',
'Auth_settings' => 'Authentication', 'Auth_settings' => 'Authentication',
'Permissions' => 'Permissions', 'PERMISSIONS' => 'Permissions',
'Manage' => 'Manage', 'Manage' => 'Manage',
'Disallow' => 'Disallow names', 'Disallow' => 'Disallow names',
'Prune' => 'Pruning', 'Prune' => 'Pruning',
@ -57,7 +57,7 @@ $lang = array_merge($lang, array(
'DB_Backup' => 'DB Backup', 'DB_Backup' => 'DB Backup',
'DB_Restore' => 'DB Restore', 'DB_Restore' => 'DB Restore',
'Basic_Config' => 'Basic Configuration', 'Basic_Config' => 'Basic Configuration',
'Administrators' => 'Administrators', 'ADMINISTRATORS' => 'Administrators',
'Admin_logs' => 'Admin Log', 'Admin_logs' => 'Admin Log',
'Mod_logs' => 'Moderator Log', 'Mod_logs' => 'Moderator Log',
'Users' => 'Users', 'Users' => 'Users',
@ -97,6 +97,7 @@ $lang = array_merge($lang, array(
'log_prune_user_deac' => '<b>Users Deactivated</b> => %s', 'log_prune_user_deac' => '<b>Users Deactivated</b> => %s',
'log_prune_user_del_del' => '<b>Users Pruned and Posts Deleted</b> => %s', 'log_prune_user_del_del' => '<b>Users Pruned and Posts Deleted</b> => %s',
'log_prune_user_del_anon' => '<b>Users Pruned and Posts Retained</b> => %s', 'log_prune_user_del_anon' => '<b>Users Pruned and Posts Retained</b> => %s',
'Admin_logs_explain' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', 'Admin_logs_explain' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.',
'Mod_logs_explain' => 'This lists the actions carried out by board moderators, select a forum from the drop down list. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', 'Mod_logs_explain' => 'This lists the actions carried out by board moderators, select a forum from the drop down list. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.',
'Display_log' => 'Display entries from previous', 'Display_log' => 'Display entries from previous',
@ -168,13 +169,13 @@ $lang = array_merge($lang, array(
'Restore_Error_filename' => 'The file you uploaded had an unsupported extension.', 'Restore_Error_filename' => 'The file you uploaded had an unsupported extension.',
'Compress_unsupported' => 'The version of PHP installed on this server does not support the type of compression used for your backup. Please use a compression method listed on the previous page.', 'Compress_unsupported' => 'The version of PHP installed on this server does not support the type of compression used for your backup. Please use a compression method listed on the previous page.',
'Restore_Error_no_file' => 'No file was uploaded', 'Restore_Error_no_file' => 'No file was uploaded',
'ACL_explain' => 'Permissions are based on an ALLOW / INHERIT / DENY system with all options being denied by default. The precedent is DENY &gt; ALLOW &gt; INHERIT for any combination of user or group settings. The INHERIT setting causes permissions granted elsewhere for the option being used in place of a specific ALLOW / DENY setting here.', 'ACL_EXPLAIN' => 'Permissions are based on an ALLOW / INHERIT / DENY system with all options being denied by default. The precedent is DENY &gt; ALLOW &gt; INHERIT for any combination of user or group settings. The INHERIT setting causes permissions granted elsewhere for the option being used in place of a specific ALLOW / DENY setting here.',
'Permissions_explain' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page (see left hand side menu).', 'PERMISSIONS_EXPLAIN' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page (see left hand side menu).',
'Moderators' => 'Moderators', 'MODERATORS' => 'Moderators',
'Moderators_explain' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define super moderators or administrators please use the appropriate page (see left hand side menu).', 'MODERATORS_EXPLAIN' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define super moderators or administrators please use the appropriate page (see left hand side menu).',
'Super_Moderators' => 'Super Moderators', 'SUPER_MODERATORS' => 'Super Moderators',
'Super_Moderators_explain' => 'Here you can assign users and groups as super moderators. Super Moderators are like ordinary moderators accept they have access to every forum on your board. To assign users access to forums or define administrators please use the appropriate page (see left hand side menu).', 'SUPER_MODERATORS_EXPLAIN' => 'Here you can assign users and groups as super moderators. Super Moderators are like ordinary moderators accept they have access to every forum on your board. To assign users access to forums or define administrators please use the appropriate page (see left hand side menu).',
'Administrators_explain' => 'Here you can assign administrator rights to users or groups. All users with admin permissions can view the administration panel.', 'ADMINISTRATORS_EXPLAIN' => 'Here you can assign administrator rights to users or groups. All users with admin permissions can view the administration panel.',
'Manage_users' => 'Manage Users', 'Manage_users' => 'Manage Users',
'Add_users' => 'Add Users', 'Add_users' => 'Add Users',
'Manage_groups' => 'Manage Groups', 'Manage_groups' => 'Manage Groups',
@ -201,26 +202,49 @@ $lang = array_merge($lang, array(
'All_Inherit' => 'All Inherit', 'All_Inherit' => 'All Inherit',
'Inheritance' => 'Inheritance', 'Inheritance' => 'Inheritance',
'Inheritance_explain' => 'Select the subforums you want to inherit these permissions', 'Inheritance_explain' => 'Select the subforums you want to inherit these permissions',
'acl_a_general' => 'General Settings',
'acl_a_user' => 'Users', 'acl_a_server' => 'Alter Server/Email Settings',
'acl_a_group' => 'Groups', 'acl_a_defaults' => 'Alter Board Defaults',
'acl_a_forum' => 'Forums', 'acl_a_board' => 'Alter Board Settings',
'acl_a_post' => 'Posts', 'acl_a_cookies' => 'Alter Cookie Settings',
'acl_a_ban' => 'Banning', 'acl_a_names' => 'Alter Disallowed Names',
'acl_a_auth' => 'Permissions', 'acl_a_words' => 'Alter Word Censors',
'acl_a_email' => 'Email', 'acl_a_icons' => 'Alter Topic Icons/Emoticons',
'acl_a_styles' => 'Styles', 'acl_a_search' => 'Re-index Search Tables',
'acl_a_backup' => 'Backups', 'acl_a_prune' => 'Prune Forums',
'acl_a_clearlogs' => 'Clear Admin Log', 'acl_a_bbcode' => 'Define BBCode Tags',
'acl_m__edit' => 'Edit posts', 'acl_a_attach' => 'Manage Attachments',
'acl_m__delete' => 'Delete posts', 'acl_a_events' => 'Manage User/Group Events',
'acl_m__move' => 'Move posts', 'acl_a_ranks' => 'Manage User Ranks',
'acl_m__lock' => 'Lock topics', 'acl_a_user' => 'Manage Users',
'acl_m__split' => 'Split topics', 'acl_a_userdel' => 'Delete/Prune Users',
'acl_m__merge' => 'Merge topics', 'acl_a_useradd' => 'Add New Users',
'acl_m__approve' => 'Approve posts', 'acl_a_group' => 'Manage Groups',
'acl_m__unrate' => 'Un-rate topics', 'acl_a_groupdel' => 'Delete Groups',
'acl_m__auth' => 'Set permissions', 'acl_a_groupadd' => 'Add New Groups',
'acl_a_forum' => 'Manage Forums',
'acl_a_forumdel' => 'Delete Forums',
'acl_a_forumadd' => 'Add New Forums',
'acl_a_ban' => 'Manage Bans',
'acl_a_auth' => 'Alter Forum Permissions',
'acl_a_authmods' => 'Alter Moderator Permissions',
'acl_a_authadmins' => 'Alter Admin Permissions',
'acl_a_email' => 'Mass Email',
'acl_a_styles' => 'Manage Styles',
'acl_a_backup' => 'Backup Database',
'acl_a_restore' => 'Restore Database',
'acl_a_clearlogs' => 'Clear Admin/Mod Logs',
'acl_m_edit' => 'Edit posts',
'acl_m_delete' => 'Delete posts',
'acl_m_move' => 'Move posts',
'acl_m_lock' => 'Lock topics',
'acl_m_split' => 'Split topics',
'acl_m_merge' => 'Merge topics',
'acl_m_approve' => 'Approve posts',
'acl_m_unrate' => 'Un-rate topics',
'acl_m_auth' => 'Set permissions',
'acl_f_list' => 'See forum', 'acl_f_list' => 'See forum',
'acl_f_read' => 'Read forum', 'acl_f_read' => 'Read forum',
'acl_f_post' => 'Post in forum', 'acl_f_post' => 'Post in forum',
@ -245,6 +269,7 @@ $lang = array_merge($lang, array(
'acl_f_print' => 'Print topics', 'acl_f_print' => 'Print topics',
'acl_f_ignoreflood' => 'Ignore flood limit', 'acl_f_ignoreflood' => 'Ignore flood limit',
'acl_f_ignorequeue' => 'Ignore mod queue', 'acl_f_ignorequeue' => 'Ignore mod queue',
'Auth_updated' => 'Permissions have been updated', 'Auth_updated' => 'Permissions have been updated',
'Prune_users' => 'Prune Users', 'Prune_users' => 'Prune Users',
'Prune_users_explain' => 'Here you can delete (or deactivate) users from you board. This can be done in a variety of ways; by post count, last activity, etc. Each of these criteria can be combined, i.e. you can prune users last active before 2002-01-01 with fewer than 10 posts. Alternatively you can enter a list of users directly into the text box, any criteria entered will be ignored. Take care with this facility! Once a user is deleted there is no way back.', 'Prune_users_explain' => 'Here you can delete (or deactivate) users from you board. This can be done in a variety of ways; by post count, last activity, etc. Each of these criteria can be combined, i.e. you can prune users last active before 2002-01-01 with fewer than 10 posts. Alternatively you can enter a list of users directly into the text box, any criteria entered will be ignored. Take care with this facility! Once a user is deleted there is no way back.',