A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
6.0 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file groups.php
  5. * @version $Id$
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. require('./config.php');
  13. require('./includes/constants.php');
  14. require('./includes/db.php');
  15. require('./includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. require('./includes/sessions.php');
  19. require('./includes/classes/class_user.php');
  20. require('./common.php');
  21. require('./includes/misc_functions.php');
  22. require('./includes/classes/class_topic.php');
  23. require('./includes/classes/secure.php');
  24. require('./lngs/'.DefaultLang().'/main.php');
  25. SessDelInvalid();
  26. SessRegister();
  27. SessDeleteOld();
  28. $start = TimeGeneration();
  29. foreach ($_POST as $name => $value)
  30. {
  31. if ($forum_config['use_censorlist'])
  32. {
  33. $_POST[$name] = Secure::UseCensorlist($value);
  34. }
  35. }
  36. if(isset($_GET['mode']))
  37. {
  38. switch($_GET['mode'])
  39. {
  40. case 'view':
  41. {
  42. $start = TimeGeneration();
  43. $default_skin = ViewSkinName();
  44. $gid = addslashes(strip_tags($_GET['id']));
  45. if ((isset($_POST['nick']))and ($_POST['nick']!=''))
  46. {
  47. if($_POST['nick']!='')
  48. {
  49. $uid =User::UserIdByNick($_POST['nick']);
  50. Secure::user_exists($uid);
  51. User::AddToGroup($uid, $gid);
  52. message_forum($lng['useraddedtogroup'],'groups.php?mode=view&amp;id='.$gid);
  53. }
  54. else
  55. {
  56. }
  57. }
  58. elseif ((isset($_POST['delnick']))and ($_POST['delnick']!=''))
  59. {
  60. $uid =User::UserIdByNick($_POST['delnick']);
  61. Secure::user_exists($uid);
  62. User::DeleteFromGroup($uid, $gid);
  63. message_forum($lng['userdeletedforgroup'],'groups.php?mode=view&amp;id='.$gid);
  64. }
  65. else
  66. {
  67. $_POST['nick']='';
  68. $_POST['delnick']='';
  69. }
  70. $bool = ($gid == 'mods') ? true : ($gid == 'admins') ? true : false;
  71. if (!$bool)
  72. {
  73. $sql = "SELECT `g_id`, `name`, `desc`, `m_id` FROM `".GROUPS_TABLE."` WHERE `g_id`='$gid'";
  74. $group = DataBase::fetch(DataBase::sql_query($sql, GENERAL, 'Could not obtain groups information.'));
  75. if ($group['g_id']=='')
  76. {
  77. message_forum($lng['no_group'], 'groups.php');
  78. }
  79. }
  80. if ($gid == 'admins')
  81. {
  82. $group['name'] = $lng['admins'];
  83. $group['desc'] = $lng['admins_desc'];
  84. }
  85. if ($gid == 'mods')
  86. {
  87. $group['name'] = $lng['mods'];
  88. $group['desc'] = $lng['mods_desc'];
  89. }
  90. unset($tmp);
  91. $skin = GenerateHeader($lng['showgroup'].': '.$group['name'], '<a href="groups.php" class="navigator">'.$lng['lgroups'].' &raquo; <a href="groups.php?mode=view&amp;id='.$group['g_id'].'" class="navigator">'.$group['name']);
  92. require('./skins/'.$default_skin.'/overall_header.tpl');
  93. $skin = array(
  94. 'moderate'=>(is_numeric($gid)) ? IfModGroup($group['m_id']) : '',
  95. 'name'=>$group['name'],
  96. 'desc'=>$group['desc'],
  97. 'lregdate'=>$lng['luregister'],
  98. 'llastvisit'=>$lng['lulastvisit'],
  99. 'lposts'=>$lng['posts'],
  100. 'luname'=>$lng['user_name'],
  101. 'g_id'=>$group['g_id']
  102. );
  103. require('./skins/'.$default_skin.'/group_view_head_body.tpl');
  104. if ($gid == 'admins') { $rnk = 2; } else {$rnk = 1;}
  105. if (is_numeric($gid))
  106. {
  107. $sql = "SELECT ".USERS_GROUP_TABLE.".*, ".USERS_TABLE.".* FROM `".USERS_GROUP_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id =".USERS_GROUP_TABLE.".u_id WHERE `g_id`='$gid'";
  108. }
  109. else
  110. {
  111. $sql = "SELECT * FROM ".USERS_TABLE." WHERE `rank` = '$rnk'";
  112. }
  113. $query = DataBase::sql_query($sql, GENERAL, 'Could not obtain users in groups information.');
  114. $amout = DataBase::num_rows($query);
  115. if ($amout>0)
  116. {
  117. while($result = DataBase::fetch($query))
  118. {
  119. $skin = array(
  120. 'id'=>$result['u_id'],
  121. 'uname'=>Topic::UserName($result['nick'], $result['rank']),
  122. 'regdate'=>date('d-m-Y, G:i',$result['regdate']),
  123. 'lastvisit'=>($result['lastvisit']>0) ? date('d-m-Y, G:i',$result['lastvisit']) : $lng['never'],
  124. 'posts'=>$result['posts']
  125. );
  126. require('./skins/'.$default_skin.'/users_item_add_body.tpl');
  127. }
  128. }
  129. else
  130. {
  131. echo '<tr><td width="100%" colspan="8" height="19" class="fitem"><p class="fstandard" align="center">'.$lng['no_elements'].'!</p></td></tr>';
  132. }
  133. echo '</table>';
  134. $stop = TimeGeneration();
  135. $skin['queries'] = ShowQueries($start, $stop);
  136. require('./skins/'.$default_skin.'/overall_footer.tpl');
  137. break;
  138. }
  139. default:
  140. {
  141. message_forum($lng['invalidmode'],'groups.php');
  142. }
  143. }
  144. }
  145. else
  146. {
  147. $default_skin = ViewSkinName();
  148. $skin = GenerateHeader($lng['lgroups'], '<a href="groups.php" class="navigator">'.$lng['lgroups']);
  149. require('./skins/'.$default_skin.'/overall_header.tpl');
  150. $special_groups[] = array('admins', $lng['admins'], $lng['admins_desc']);
  151. $special_groups[] = array('mods', $lng['mods'], $lng['mods_desc']);
  152. $i = 0;
  153. while($i<2)
  154. {
  155. $color = ($i==0) ? $forum_config['color_admin'] : $forum_config['color_mod'];
  156. $skin = array (
  157. 'g_id'=>$special_groups[$i][0],
  158. 'name' => '<span style="color: '.$color.'">'.$special_groups[$i][1].'</span>',
  159. 'desc' =>$special_groups[$i][2]
  160. );
  161. require('./skins/'.$default_skin.'/group_add_body.tpl');
  162. $i++;
  163. }
  164. echo '<br />';
  165. $sql = "SELECT `g_id`, `name`, `desc` FROM `".GROUPS_TABLE."` ORDER BY `sort`";
  166. $query = DataBase::sql_query($sql, GENERAL, 'Could not obtain groups information.');
  167. if (DataBase::num_rows($query)>0)
  168. {
  169. while($item = DataBase::fetch($query))
  170. {
  171. $skin = array(
  172. 'g_id'=>$item['g_id'],
  173. 'name'=>$item['name'],
  174. 'desc'=>$item['desc']
  175. );
  176. require('./skins/'.$default_skin.'/group_add_body.tpl');
  177. }
  178. }
  179. else
  180. {
  181. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8"
  182. height="19" class="fitem"><p class="fstandard" align="center">'.$lng['no_groups'].'!</p></td></tr></table>';
  183. }
  184. $stop = TimeGeneration();
  185. $skin['queries'] = ShowQueries($start, $stop);
  186. require('./skins/'.$default_skin.'/overall_footer.tpl');
  187. }
  188. ?>