plugins/admin/GroupManager.php
changeset 1227 bdac73ed481e
parent 1081 745200a9cc2a
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    13 
    13 
    14 // Usergroup editor
    14 // Usergroup editor
    15 
    15 
    16 function page_Admin_GroupManager()
    16 function page_Admin_GroupManager()
    17 {
    17 {
    18   global $db, $session, $paths, $template, $plugins; // Common objects
    18 	global $db, $session, $paths, $template, $plugins; // Common objects
    19   global $lang;
    19 	global $lang;
    20   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    20 	if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    21   {
    21 	{
    22     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    22 		$login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    23     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    23 		echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    24     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    24 		echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    25     return;
    25 		return;
    26   }
    26 	}
    27   
    27 	
    28   if(isset($_POST['do_create_stage1']))
    28 	if(isset($_POST['do_create_stage1']))
    29   {
    29 	{
    30     if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
    30 		if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
    31     {
    31 		{
    32       echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
    32 			echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
    33       return;
    33 			return;
    34     }
    34 		}
    35     echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
    35 		echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
    36     echo '<div class="tblholder">
    36 		echo '<div class="tblholder">
    37           <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
    37 					<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
    38           <tr><th colspan="2">' . $lang->get('acpug_heading_creating_group') . ' '.htmlspecialchars($_POST['create_group_name']).'</th></tr>
    38 					<tr><th colspan="2">' . $lang->get('acpug_heading_creating_group') . ' '.htmlspecialchars($_POST['create_group_name']).'</th></tr>
    39           <tr>
    39 					<tr>
    40             <td class="row1">' . $lang->get('acpug_field_group_mod') . '</td><td class="row1">' . $template->username_field('group_mod') . '</td>
    40 						<td class="row1">' . $lang->get('acpug_field_group_mod') . '</td><td class="row1">' . $template->username_field('group_mod') . '</td>
    41           </tr>
    41 					</tr>
    42           <tr><td class="row2">' . $lang->get('acpug_field_group_type') . '</td><td class="row2">
    42 					<tr><td class="row2">' . $lang->get('acpug_field_group_type') . '</td><td class="row2">
    43             <label><input type="radio" name="group_status" value="'.GROUP_CLOSED.'" checked="checked" /> ' . $lang->get('groupcp_type_hidden') . '</label><br />
    43 						<label><input type="radio" name="group_status" value="'.GROUP_CLOSED.'" checked="checked" /> ' . $lang->get('groupcp_type_hidden') . '</label><br />
    44             <label><input type="radio" name="group_status" value="'.GROUP_REQUEST.'" /> ' . $lang->get('groupcp_type_closed') . '</label><br />
    44 						<label><input type="radio" name="group_status" value="'.GROUP_REQUEST.'" /> ' . $lang->get('groupcp_type_closed') . '</label><br />
    45             <label><input type="radio" name="group_status" value="'.GROUP_OPEN.'" /> ' . $lang->get('groupcp_type_request') . '</label><br />
    45 						<label><input type="radio" name="group_status" value="'.GROUP_OPEN.'" /> ' . $lang->get('groupcp_type_request') . '</label><br />
    46             <label><input type="radio" name="group_status" value="'.GROUP_HIDDEN.'" /> ' . $lang->get('groupcp_type_open') . '</label>
    46 						<label><input type="radio" name="group_status" value="'.GROUP_HIDDEN.'" /> ' . $lang->get('groupcp_type_open') . '</label>
    47           </td></tr>
    47 					</td></tr>
    48           <tr>
    48 					<tr>
    49             <th class="subhead" colspan="2">
    49 						<th class="subhead" colspan="2">
    50               <input type="hidden" name="create_group_name" value="'.htmlspecialchars($_POST['create_group_name']).'" />
    50 							<input type="hidden" name="create_group_name" value="'.htmlspecialchars($_POST['create_group_name']).'" />
    51               <input type="submit" name="do_create_stage2" value="' . $lang->get('acpug_btn_create_stage2') . '" />
    51 							<input type="submit" name="do_create_stage2" value="' . $lang->get('acpug_btn_create_stage2') . '" />
    52             </th>
    52 						</th>
    53           </tr>
    53 					</tr>
    54           </table>
    54 					</table>
    55           </div>';
    55 					</div>';
    56     echo '</form>';
    56 		echo '</form>';
    57     return;
    57 		return;
    58   }
    58 	}
    59   elseif(isset($_POST['do_create_stage2']))
    59 	elseif(isset($_POST['do_create_stage2']))
    60   {
    60 	{
    61     if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
    61 		if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
    62     {
    62 		{
    63       echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
    63 			echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
    64       return;
    64 			return;
    65     }
    65 		}
    66     if(!in_array(intval($_POST['group_status']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
    66 		if(!in_array(intval($_POST['group_status']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
    67     {
    67 		{
    68       echo '<p>Hacking attempt</p>';
    68 			echo '<p>Hacking attempt</p>';
    69       return;
    69 			return;
    70     }
    70 		}
    71     $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
    71 		$e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
    72     if(!$e)
    72 		if(!$e)
    73     {
    73 		{
    74       echo $db->get_error();
    74 			echo $db->get_error();
    75       return;
    75 			return;
    76     }
    76 		}
    77     if($db->numrows() > 0)
    77 		if($db->numrows() > 0)
    78     {
    78 		{
    79       echo '<p>' . $lang->get('acpug_err_already_exist') . '</p>';
    79 			echo '<p>' . $lang->get('acpug_err_already_exist') . '</p>';
    80       return;
    80 			return;
    81     }
    81 		}
    82     $db->free_result();
    82 		$db->free_result();
    83     $q = $db->sql_query('INSERT INTO '.table_prefix.'groups(group_name,group_type) VALUES( \''.$db->escape($_POST['create_group_name']).'\', ' . intval($_POST['group_status']) . ' )');
    83 		$q = $db->sql_query('INSERT INTO '.table_prefix.'groups(group_name,group_type) VALUES( \''.$db->escape($_POST['create_group_name']).'\', ' . intval($_POST['group_status']) . ' )');
    84     if(!$q)
    84 		if(!$q)
    85     {
    85 		{
    86       echo $db->get_error();
    86 			echo $db->get_error();
    87       return;
    87 			return;
    88     }
    88 		}
    89     $e = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['group_mod']).'\';');
    89 		$e = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['group_mod']).'\';');
    90     if(!$e)
    90 		if(!$e)
    91     {
    91 		{
    92       echo $db->get_error();
    92 			echo $db->get_error();
    93       return;
    93 			return;
    94     }
    94 		}
    95     if($db->numrows() < 1)
    95 		if($db->numrows() < 1)
    96     {
    96 		{
    97       echo '<p>' . $lang->get('acpug_err_bad_username') . '</p>';
    97 			echo '<p>' . $lang->get('acpug_err_bad_username') . '</p>';
    98       return;
    98 			return;
    99     }
    99 		}
   100     $row = $db->fetchrow();
   100 		$row = $db->fetchrow();
   101     $id = $row['user_id'];
   101 		$id = $row['user_id'];
   102     $db->free_result();
   102 		$db->free_result();
   103     $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
   103 		$e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
   104     if(!$e)
   104 		if(!$e)
   105     {
   105 		{
   106       echo $db->get_error();
   106 			echo $db->get_error();
   107       return;
   107 			return;
   108     }
   108 		}
   109     if($db->numrows() < 1)
   109 		if($db->numrows() < 1)
   110     {
   110 		{
   111       echo '<p>' . $lang->get('acpug_err_bad_insert_id') . '</p>';
   111 			echo '<p>' . $lang->get('acpug_err_bad_insert_id') . '</p>';
   112       return;
   112 			return;
   113     }
   113 		}
   114     $row = $db->fetchrow();
   114 		$row = $db->fetchrow();
   115     $gid = $row['group_id'];
   115 		$gid = $row['group_id'];
   116     $db->free_result();
   116 		$db->free_result();
   117     $e = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.$gid.', '.$id.', 1);');
   117 		$e = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.$gid.', '.$id.', 1);');
   118     if(!$e)
   118 		if(!$e)
   119     {
   119 		{
   120       echo $db->get_error();
   120 			echo $db->get_error();
   121       return;
   121 			return;
   122     }
   122 		}
   123     $g_name = htmlspecialchars($_POST['create_group_name']);
   123 		$g_name = htmlspecialchars($_POST['create_group_name']);
   124     echo "<div class='info-box'>
   124 		echo "<div class='info-box'>
   125             <b>" . $lang->get('acpug_heading_info') . "</b><br />
   125 						<b>" . $lang->get('acpug_heading_info') . "</b><br />
   126             " . $lang->get('acpug_msg_create_success', array('g_name' => $g_name)) . "
   126 						" . $lang->get('acpug_msg_create_success', array('g_name' => $g_name)) . "
   127           </div>";
   127 					</div>";
   128   }
   128 	}
   129   if(isset($_POST['do_edit']) || isset($_POST['edit_do']))
   129 	if(isset($_POST['do_edit']) || isset($_POST['edit_do']))
   130   {
   130 	{
   131     // Fetch the group name
   131 		// Fetch the group name
   132     $q = $db->sql_query('SELECT group_name,system_group,group_rank FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
   132 		$q = $db->sql_query('SELECT group_name,system_group,group_rank FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
   133     if(!$q)
   133 		if(!$q)
   134     {
   134 		{
   135       echo $db->get_error();
   135 			echo $db->get_error();
   136       return;
   136 			return;
   137     }
   137 		}
   138     if($db->numrows() < 1)
   138 		if($db->numrows() < 1)
   139     {
   139 		{
   140       echo '<p>Error: couldn\'t look up group name</p>';
   140 			echo '<p>Error: couldn\'t look up group name</p>';
   141     }
   141 		}
   142     $row = $db->fetchrow();
   142 		$row = $db->fetchrow();
   143     $name = htmlspecialchars($row['group_name']);
   143 		$name = htmlspecialchars($row['group_name']);
   144     $db->free_result();
   144 		$db->free_result();
   145     if(isset($_POST['edit_do']))
   145 		if(isset($_POST['edit_do']))
   146     {
   146 		{
   147       if(isset($_POST['edit_do']['del_group']))
   147 			if(isset($_POST['edit_do']['del_group']))
   148       {
   148 			{
   149         if ( $row['system_group'] == 1 )
   149 				if ( $row['system_group'] == 1 )
   150         {
   150 				{
   151           echo '<div class="error-box">' . $lang->get('acpug_err_nodelete_system_group', array('g_name' => $name)) . '</div>';
   151 					echo '<div class="error-box">' . $lang->get('acpug_err_nodelete_system_group', array('g_name' => $name)) . '</div>';
   152         }
   152 				}
   153         else
   153 				else
   154         {
   154 				{
   155           $q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE group_id='.intval($_POST['group_edit_id']).';');
   155 					$q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE group_id='.intval($_POST['group_edit_id']).';');
   156           if(!$q)
   156 					if(!$q)
   157           {
   157 					{
   158             echo $db->get_error();
   158 						echo $db->get_error();
   159             return;
   159 						return;
   160           }
   160 					}
   161           $q = $db->sql_query('DELETE FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
   161 					$q = $db->sql_query('DELETE FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
   162           if(!$q)
   162 					if(!$q)
   163           {
   163 					{
   164             echo $db->get_error();
   164 						echo $db->get_error();
   165             return;
   165 						return;
   166           }
   166 					}
   167           echo '<div class="info-box">' . $lang->get('acpug_msg_delete_success', array('g_name' => $name, 'a_flags' => 'href="javascript:ajaxPage(\'' . $paths->nslist['Admin'] . 'GroupManager\');"')) . '</div>';
   167 					echo '<div class="info-box">' . $lang->get('acpug_msg_delete_success', array('g_name' => $name, 'a_flags' => 'href="javascript:ajaxPage(\'' . $paths->nslist['Admin'] . 'GroupManager\');"')) . '</div>';
   168           return;
   168 					return;
   169         }
   169 				}
   170       }
   170 			}
   171       if(isset($_POST['edit_do']['save_name']))
   171 			if(isset($_POST['edit_do']['save_name']))
   172       {
   172 			{
   173         if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['group_name']))
   173 				if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['group_name']))
   174         {
   174 				{
   175           echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
   175 					echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
   176           return;
   176 					return;
   177         }
   177 				}
   178         // determine rank
   178 				// determine rank
   179         $group_rank =& $_POST['group_rank'];
   179 				$group_rank =& $_POST['group_rank'];
   180         if ( $_POST['group_rank'] !== 'NULL' )
   180 				if ( $_POST['group_rank'] !== 'NULL' )
   181         {
   181 				{
   182           $group_rank = intval($group_rank);
   182 					$group_rank = intval($group_rank);
   183           if ( empty($group_rank) )
   183 					if ( empty($group_rank) )
   184           {
   184 					{
   185             echo '<p>Hacked rank ID</p>';
   185 						echo '<p>Hacked rank ID</p>';
   186             return;
   186 						return;
   187           }
   187 					}
   188         }
   188 				}
   189         $row['group_rank'] = $group_rank;
   189 				$row['group_rank'] = $group_rank;
   190         $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\',group_rank = ' . $group_rank . '
   190 				$q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\',group_rank = ' . $group_rank . '
   191             WHERE group_id='.intval($_POST['group_edit_id']).';');
   191 						WHERE group_id='.intval($_POST['group_edit_id']).';');
   192         if(!$q)
   192 				if(!$q)
   193         {
   193 				{
   194           echo $db->get_error();
   194 					echo $db->get_error();
   195           return;
   195 					return;
   196         }
   196 				}
   197         else
   197 				else
   198         {
   198 				{
   199           echo '<div class="info-box" style="margin: 0 0 10px 0;"">
   199 					echo '<div class="info-box" style="margin: 0 0 10px 0;"">
   200                   ' . $lang->get('acpug_msg_name_update_success') . '
   200 									' . $lang->get('acpug_msg_name_update_success') . '
   201                 </div>';
   201 								</div>';
   202         }
   202 				}
   203         $name = htmlspecialchars($_POST['group_name']);
   203 				$name = htmlspecialchars($_POST['group_name']);
   204         
   204 				
   205       }
   205 			}
   206       $q = $db->sql_query('SELECT member_id FROM '.table_prefix.'group_members
   206 			$q = $db->sql_query('SELECT member_id FROM '.table_prefix.'group_members
   207                              WHERE group_id='.intval($_POST['group_edit_id']).';');
   207  														WHERE group_id='.intval($_POST['group_edit_id']).';');
   208       if(!$q)
   208 			if(!$q)
   209       {
   209 			{
   210         echo $db->get_error();
   210 				echo $db->get_error();
   211         return;
   211 				return;
   212       }
   212 			}
   213       if($db->numrows() > 0)
   213 			if($db->numrows() > 0)
   214       {
   214 			{
   215         while($delrow = $db->fetchrow($q))
   215 				while($delrow = $db->fetchrow($q))
   216         {
   216 				{
   217           if(isset($_POST['edit_do']['del_' . $delrow['member_id']]))
   217 					if(isset($_POST['edit_do']['del_' . $delrow['member_id']]))
   218           {
   218 					{
   219             $e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$delrow['member_id']);
   219 						$e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$delrow['member_id']);
   220             if(!$e)
   220 						if(!$e)
   221             {
   221 						{
   222               echo $db->get_error();
   222 							echo $db->get_error();
   223               return;
   223 							return;
   224             }
   224 						}
   225           }
   225 					}
   226         }
   226 				}
   227       }
   227 			}
   228       $db->free_result();
   228 			$db->free_result();
   229       if(isset($_POST['edit_do']['add_member']))
   229 			if(isset($_POST['edit_do']['add_member']))
   230       {
   230 			{
   231         $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['edit_add_username']).'\';');
   231 				$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['edit_add_username']).'\';');
   232         if(!$q)
   232 				if(!$q)
   233         {
   233 				{
   234           echo $db->get_error();
   234 					echo $db->get_error();
   235           return;
   235 					return;
   236         }
   236 				}
   237         if($db->numrows() > 0)
   237 				if($db->numrows() > 0)
   238         {
   238 				{
   239           $row = $db->fetchrow();
   239 					$row = $db->fetchrow();
   240           $user_id = $row['user_id'];
   240 					$user_id = $row['user_id'];
   241           $is_mod = ( isset( $_POST['add_mod'] ) ) ? '1' : '0';
   241 					$is_mod = ( isset( $_POST['add_mod'] ) ) ? '1' : '0';
   242           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.intval($_POST['group_edit_id']).','.$user_id.','.$is_mod.');');
   242 					$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.intval($_POST['group_edit_id']).','.$user_id.','.$is_mod.');');
   243           if(!$q)
   243 					if(!$q)
   244           {
   244 					{
   245             echo $db->get_error();
   245 						echo $db->get_error();
   246             return;
   246 						return;
   247           }
   247 					}
   248           else
   248 					else
   249           {
   249 					{
   250             
   250 						
   251             echo '<div class="info-box" style="margin: 0 0 10px 0;"">
   251 						echo '<div class="info-box" style="margin: 0 0 10px 0;"">
   252                     ' . $lang->get('acpug_msg_user_added', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '
   252 										' . $lang->get('acpug_msg_user_added', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '
   253                   </div>';
   253 									</div>';
   254           }
   254 					}
   255         }
   255 				}
   256         else
   256 				else
   257           echo '<div class="warning-box">' . $lang->get('acpug_err_username_not_exist', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '</div>';
   257 					echo '<div class="warning-box">' . $lang->get('acpug_err_username_not_exist', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '</div>';
   258       }
   258 			}
   259       generate_cache_userranks();
   259 			generate_cache_userranks();
   260     }
   260 		}
   261     $sg_disabled = ( $row['system_group'] == 1 ) ?
   261 		$sg_disabled = ( $row['system_group'] == 1 ) ?
   262              ' value="' . $lang->get('acpug_btn_cant_delete') . '" disabled="disabled" style="color: #FF9773" ' :
   262  						' value="' . $lang->get('acpug_btn_cant_delete') . '" disabled="disabled" style="color: #FF9773" ' :
   263              ' value="' . $lang->get('acpug_btn_delete_group') . '" style="color: #FF3713" ';
   263  						' value="' . $lang->get('acpug_btn_delete_group') . '" style="color: #FF3713" ';
   264     
   264 		
   265     // build rank list
   265 		// build rank list
   266     $q = $db->sql_query('SELECT rank_id, rank_title FROM ' . table_prefix . 'ranks');
   266 		$q = $db->sql_query('SELECT rank_id, rank_title FROM ' . table_prefix . 'ranks');
   267     if ( !$q )
   267 		if ( !$q )
   268       $db->_die();
   268 			$db->_die();
   269     $rank_list = '<option value="NULL"' . ( $row['group_rank'] === NULL ? ' selected="selected"' : '' ) . '>--</option>' . "\n";
   269 		$rank_list = '<option value="NULL"' . ( $row['group_rank'] === NULL ? ' selected="selected"' : '' ) . '>--</option>' . "\n";
   270     while ( $rank_row = $db->fetchrow() )
   270 		while ( $rank_row = $db->fetchrow() )
   271     {
   271 		{
   272       $rank_list .= '<option value="' . $rank_row['rank_id'] . '"' . ( $rank_row['rank_id'] == $row['group_rank'] ? ' selected="selected"' : '' ) . '>' . htmlspecialchars($lang->get($rank_row['rank_title'])) . '</option>' . "\n";
   272 			$rank_list .= '<option value="' . $rank_row['rank_id'] . '"' . ( $rank_row['rank_id'] == $row['group_rank'] ? ' selected="selected"' : '' ) . '>' . htmlspecialchars($lang->get($rank_row['rank_title'])) . '</option>' . "\n";
   273     }
   273 		}
   274              
   274  						
   275     echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   275 		echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   276     echo '<div class="tblholder">
   276 		echo '<div class="tblholder">
   277           <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   277 					<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   278           <tr><th>' . $lang->get('acpug_heading_edit_name') . '</th></tr>
   278 					<tr><th>' . $lang->get('acpug_heading_edit_name') . '</th></tr>
   279           <tr>
   279 					<tr>
   280             <td class="row1">
   280 						<td class="row1">
   281               ' . $lang->get('acpug_field_group_name') . ' <input type="text" name="group_name" value="'.$name.'" />
   281 							' . $lang->get('acpug_field_group_name') . ' <input type="text" name="group_name" value="'.$name.'" />
   282             </td>
   282 						</td>
   283           </tr>
   283 					</tr>
   284           <tr>
   284 					<tr>
   285             <td class="row1">
   285 						<td class="row1">
   286               ' . $lang->get('acpug_field_group_rank') . ' <select name="group_rank" />' . $rank_list . '</select>
   286 							' . $lang->get('acpug_field_group_rank') . ' <select name="group_rank" />' . $rank_list . '</select>
   287             </td>
   287 						</td>
   288           </tr>
   288 					</tr>
   289           <tr>
   289 					<tr>
   290             <th class="subhead">
   290 						<th class="subhead">
   291               <input type="submit" name="edit_do[save_name]" value="' . $lang->get('acpug_btn_save_name') . '" />
   291 							<input type="submit" name="edit_do[save_name]" value="' . $lang->get('acpug_btn_save_name') . '" />
   292               <input type="submit" name="edit_do[del_group]" '.$sg_disabled.' />
   292 							<input type="submit" name="edit_do[del_group]" '.$sg_disabled.' />
   293             </th>
   293 						</th>
   294           </tr>
   294 					</tr>
   295           </table>
   295 					</table>
   296           </div>
   296 					</div>
   297           <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   297 					<input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   298     echo '</form>';
   298 		echo '</form>';
   299     echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   299 		echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   300     echo '<div class="tblholder">
   300 		echo '<div class="tblholder">
   301           <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   301 					<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   302           <tr><th colspan="3">' . $lang->get('acpug_heading_edit_members') . '</th></tr>';
   302 					<tr><th colspan="3">' . $lang->get('acpug_heading_edit_members') . '</th></tr>';
   303     $q = $db->sql_query('SELECT m.member_id,m.is_mod,u.username FROM '.table_prefix.'group_members AS m
   303 		$q = $db->sql_query('SELECT m.member_id,m.is_mod,u.username FROM '.table_prefix.'group_members AS m
   304                            LEFT JOIN '.table_prefix.'users AS u
   304  													LEFT JOIN '.table_prefix.'users AS u
   305                              ON u.user_id=m.user_id
   305  														ON u.user_id=m.user_id
   306                              WHERE m.group_id='.intval($_POST['group_edit_id']).'
   306  														WHERE m.group_id='.intval($_POST['group_edit_id']).'
   307                            ORDER BY m.is_mod DESC, u.username ASC;');
   307  													ORDER BY m.is_mod DESC, u.username ASC;');
   308     if(!$q)
   308 		if(!$q)
   309     {
   309 		{
   310       echo $db->get_error();
   310 			echo $db->get_error();
   311       return;
   311 			return;
   312     }
   312 		}
   313     if($db->numrows() < 1)
   313 		if($db->numrows() < 1)
   314     {
   314 		{
   315       echo '<tr><td colspan="3" class="row1">' . $lang->get('acpug_msg_no_members') . '</td></tr>';
   315 			echo '<tr><td colspan="3" class="row1">' . $lang->get('acpug_msg_no_members') . '</td></tr>';
   316     }
   316 		}
   317     else
   317 		else
   318     {
   318 		{
   319       $cls = 'row2';
   319 			$cls = 'row2';
   320       while($row = $db->fetchrow())
   320 			while($row = $db->fetchrow())
   321       {
   321 			{
   322         $cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
   322 				$cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
   323         $mod = ( $row['is_mod'] == 1 ) ? $lang->get('acpug_lbl_member_mod') : '';
   323 				$mod = ( $row['is_mod'] == 1 ) ? $lang->get('acpug_lbl_member_mod') : '';
   324         echo '<tr>
   324 				echo '<tr>
   325                 <td class="'.$cls.'" style="width: 100%;">
   325 								<td class="'.$cls.'" style="width: 100%;">
   326                   ' . $row['username'] . '
   326 									' . $row['username'] . '
   327                 </td>
   327 								</td>
   328                 <td class="'.$cls.'">
   328 								<td class="'.$cls.'">
   329                   '.$mod.'
   329 									'.$mod.'
   330                 </td>
   330 								</td>
   331                 <td class="'.$cls.'">
   331 								<td class="'.$cls.'">
   332                   <input type="submit" name="edit_do[del_'.$row['member_id'].']" value="' . $lang->get('acpug_btn_remove_member') . '" />
   332 									<input type="submit" name="edit_do[del_'.$row['member_id'].']" value="' . $lang->get('acpug_btn_remove_member') . '" />
   333                 </td>
   333 								</td>
   334               </tr>';
   334 							</tr>';
   335       }
   335 			}
   336     }
   336 		}
   337     $db->free_result();
   337 		$db->free_result();
   338     echo '</table>
   338 		echo '</table>
   339           </div>
   339 					</div>
   340           <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   340 					<input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   341     echo '</form>';
   341 		echo '</form>';
   342     echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   342 		echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   343     echo '<div class="tblholder">
   343 		echo '<div class="tblholder">
   344           <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   344 					<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
   345             <tr>
   345 						<tr>
   346               <th>' . $lang->get('acpug_heading_add_member') . '</th>
   346 							<th>' . $lang->get('acpug_heading_add_member') . '</th>
   347             </tr>
   347 						</tr>
   348             <tr>
   348 						<tr>
   349               <td class="row1">
   349 							<td class="row1">
   350                 ' . $lang->get('acpug_field_username') . ' ' . $template->username_field('edit_add_username') . '
   350 								' . $lang->get('acpug_field_username') . ' ' . $template->username_field('edit_add_username') . '
   351               </td>
   351 							</td>
   352             </tr>
   352 						</tr>
   353             <tr>
   353 						<tr>
   354               <td class="row2">
   354 							<td class="row2">
   355                 <label><input type="checkbox" name="add_mod" /> ' . $lang->get('acpug_field_make_mod') . '</label>
   355 								<label><input type="checkbox" name="add_mod" /> ' . $lang->get('acpug_field_make_mod') . '</label>
   356                 ' . $lang->get('acpug_field_make_mod_hint') . '
   356 								' . $lang->get('acpug_field_make_mod_hint') . '
   357               </td>
   357 							</td>
   358             </tr>
   358 						</tr>
   359             <tr>
   359 						<tr>
   360               <th class="subhead">
   360 							<th class="subhead">
   361                 <input type="submit" name="edit_do[add_member]" value="' . $lang->get('acpug_btn_add_user') . '" />
   361 								<input type="submit" name="edit_do[add_member]" value="' . $lang->get('acpug_btn_add_user') . '" />
   362               </th>
   362 							</th>
   363             </tr>
   363 						</tr>
   364           </table>
   364 					</table>
   365           </div>
   365 					</div>
   366           <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   366 					<input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
   367     echo '</form>';
   367 		echo '</form>';
   368     return;
   368 		return;
   369   }
   369 	}
   370   echo '<h3>' . $lang->get('acpug_heading_main') . '</h3>';
   370 	echo '<h3>' . $lang->get('acpug_heading_main') . '</h3>';
   371   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   371 	echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   372   $q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups ORDER BY group_name ASC;');
   372 	$q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups ORDER BY group_name ASC;');
   373   if(!$q)
   373 	if(!$q)
   374   {
   374 	{
   375     echo $db->get_error();
   375 		echo $db->get_error();
   376   }
   376 	}
   377   else
   377 	else
   378   {
   378 	{
   379     echo '<div class="tblholder">
   379 		echo '<div class="tblholder">
   380           <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   380 					<table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   381           <tr>
   381 					<tr>
   382           <th>' . $lang->get('acpug_heading_edit_existing') . '</th>
   382 					<th>' . $lang->get('acpug_heading_edit_existing') . '</th>
   383           </tr>';
   383 					</tr>';
   384     echo '<tr><td class="row2"><select name="group_edit_id">';
   384 		echo '<tr><td class="row2"><select name="group_edit_id">';
   385     while ( $row = $db->fetchrow() )
   385 		while ( $row = $db->fetchrow() )
   386     {
   386 		{
   387       if ( $row['group_name'] != 'Everyone' )
   387 			if ( $row['group_name'] != 'Everyone' )
   388       {
   388 			{
   389         echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars( $row['group_name'] ) . '</option>';
   389 				echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars( $row['group_name'] ) . '</option>';
   390       }
   390 			}
   391     }
   391 		}
   392     $db->free_result();
   392 		$db->free_result();
   393     echo '</select></td></tr>';
   393 		echo '</select></td></tr>';
   394     echo '<tr><td class="row1" style="text-align: center;"><input type="submit" name="do_edit" value="' . $lang->get('acpug_btn_edit_stage1') . '" /></td></tr>
   394 		echo '<tr><td class="row1" style="text-align: center;"><input type="submit" name="do_edit" value="' . $lang->get('acpug_btn_edit_stage1') . '" /></td></tr>
   395           </table>
   395 					</table>
   396           </div>
   396 					</div>
   397           </form><br />';
   397 					</form><br />';
   398   }
   398 	}
   399   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   399 	echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   400   echo '<div class="tblholder">
   400 	echo '<div class="tblholder">
   401         <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   401 				<table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   402         <tr>
   402 				<tr>
   403         <th colspan="2">' . $lang->get('acpug_heading_create_new') . '</th>
   403 				<th colspan="2">' . $lang->get('acpug_heading_create_new') . '</th>
   404         </tr>';
   404 				</tr>';
   405   echo '<tr><td class="row2">' . $lang->get('acpug_field_group_name') . '</td><td class="row2"><input type="text" name="create_group_name" /></td></tr>';
   405 	echo '<tr><td class="row2">' . $lang->get('acpug_field_group_name') . '</td><td class="row2"><input type="text" name="create_group_name" /></td></tr>';
   406   echo '<tr><td colspan="2" class="row1" style="text-align: center;"><input type="submit" name="do_create_stage1" value="' . $lang->get('acpug_btn_create_stage1') . ' &raquo;" /></td></tr>
   406 	echo '<tr><td colspan="2" class="row1" style="text-align: center;"><input type="submit" name="do_create_stage1" value="' . $lang->get('acpug_btn_create_stage1') . ' &raquo;" /></td></tr>
   407         </table>
   407 				</table>
   408         </div>';
   408 				</div>';
   409   echo '</form>';
   409 	echo '</form>';
   410 }
   410 }
   411 
   411 
   412 ?>
   412 ?>