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.

220 lines
6.3 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file groups.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. include('./config.php');
  13. include('./includes/constants.php');
  14. include('./includes/db.php');
  15. include('./includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./includes/sessions.php');
  19. include('./includes/classes/class_user.php');
  20. include('./common.php');
  21. include('./includes/misc_functions.php');
  22. include('./includes/classes/class_topic.php');
  23. include('./includes/classes/secure.php');
  24. include('./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>&gt; <a href="groups.php?mode=view&amp;id='.$group['g_id'].'" class="navigator">'.$lng['showgroup'].': '.$group['name']);
  92. include('./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. include('./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. include('./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. if ($_SESSION['uid']>0)
  134. {
  135. if(RANK=='2')
  136. {
  137. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  138. }
  139. else
  140. {
  141. $skin['pa_link']='';
  142. }
  143. }
  144. else
  145. {
  146. $skin['pa_link']='';
  147. }
  148. echo '</table>';
  149. $stop = TimeGeneration();
  150. $skin['queries'] = ShowQueries($start, $stop);
  151. include('./skins/'.$default_skin.'/overall_footer.tpl');
  152. break;
  153. }
  154. default:
  155. {
  156. message_forum($lng['invalidmode'],'groups.php');
  157. }
  158. }
  159. }
  160. else
  161. {
  162. $default_skin = ViewSkinName();
  163. $skin = GenerateHeader($lng['lgroups'], '</a>&gt; <a href="groups.php" class="navigator">'.$lng['lgroups']);
  164. include('./skins/'.$default_skin.'/overall_header.tpl');
  165. $special_groups[] = array('admins', $lng['admins'], $lng['admins_desc']);
  166. $special_groups[] = array('mods', $lng['mods'], $lng['mods_desc']);
  167. $i = 0;
  168. while($i<2)
  169. {
  170. $skin = array (
  171. 'g_id'=>$special_groups[$i][0],
  172. 'name' => $special_groups[$i][1],
  173. 'desc' =>$special_groups[$i][2]
  174. );
  175. include('./skins/'.$default_skin.'/group_add_body.tpl');
  176. $i++;
  177. }
  178. echo '<br />';
  179. $sql = "SELECT `g_id`, `name`, `desc` FROM `".GROUPS_TABLE."` ORDER BY `sort`";
  180. $query = DataBase::sql_query($sql, GENERAL, 'Could not obtain groups information.');
  181. if (DataBase::num_rows($query)>0)
  182. {
  183. while($item = DataBase::fetch($query))
  184. {
  185. $skin = array(
  186. 'g_id'=>$item['g_id'],
  187. 'name'=>$item['name'],
  188. 'desc'=>$item['desc']
  189. );
  190. include('./skins/'.$default_skin.'/group_add_body.tpl');
  191. }
  192. }
  193. else
  194. {
  195. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8"
  196. height="19" class="fitem"><p class="fstandard" align="center">'.$lng['no_groups'].'!</p></td></tr></table>';
  197. }
  198. if ($_SESSION['uid']>0)
  199. {
  200. if(RANK=='2')
  201. {
  202. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  203. }
  204. else
  205. {
  206. $skin['pa_link']='';
  207. }
  208. }
  209. else
  210. {
  211. $skin['pa_link']='';
  212. }
  213. $stop = TimeGeneration();
  214. $skin['queries'] = ShowQueries($start, $stop);
  215. include('./skins/'.$default_skin.'/overall_footer.tpl');
  216. }
  217. ?>