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.

182 lines
5.5 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/class_db.php');
  15. include('./includes/class_error.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./includes/sessions.php');
  19. include('./includes/class_user.php');
  20. include('./common.php');
  21. include('./includes/class_overall.php');
  22. include('./includes/class_topic.php');
  23. include('./includes/classes/secure.php');
  24. include('./lngs/'.Over::DefaultLang().'/main.php');
  25. sess_del_invalid($_SESSION['uid']);
  26. sess_register($_SESSION['uid']);
  27. sess_delete_old();
  28. $start = Over::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 = Over::TimeGeneration();
  43. $default_skin = Over::ViewSkinName();
  44. $gid = intval($_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. $sql = "SELECT `g_id`, `name`, `desc`, `m_id` FROM `".GROUPS_TABLE."` WHERE `g_id`='$gid'";
  71. $group = mysql_fetch_array(DataBase::sql_query($sql, 'GENERAL', 'Could not obtain groups information.'));
  72. if ($group['g_id']=='')
  73. {
  74. message_forum($lng['no_group'], 'index.php');
  75. }
  76. unset($tmp);
  77. $skin = Over::generate_header($lng['showgroup'].': '.$group['name'], '</a>&gt; <a href="groups.php?mode=view&amp;id='.$group['g_id'].'" class="navigator">'.$lng['showgroup'].': '.$group['name']);
  78. include('./skins/'.$default_skin.'/overall_header.tpl');
  79. $skin = array(
  80. 'moderate'=>Over::IfModGroup($group['m_id']),
  81. 'name'=>$group['name'],
  82. 'desc'=>$group['desc'],
  83. 'lregdate'=>$lng['luregister'],
  84. 'llastvisit'=>$lng['lulastvisit'],
  85. 'lposts'=>$lng['posts'],
  86. 'luname'=>$lng['user_name'],
  87. 'g_id'=>$group['g_id']
  88. );
  89. include('./skins/'.$default_skin.'/group_view_head_body.tpl');
  90. $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'";
  91. $query = DataBase::sql_query($sql, 'GENERAL', 'Could not obtain users in groups information.');
  92. $amout = @mysql_num_rows($query);
  93. if ($amout>0)
  94. {
  95. while($result = mysql_fetch_array($query))
  96. {
  97. $skin = array(
  98. 'id'=>$result['u_id'],
  99. 'uname'=>Topic::UserName($result['nick'], $result['rank']),
  100. 'regdate'=>date('d-m-Y, G:i',$result['regdate']),
  101. 'lastvisit'=>($result['lastvisit']>0) ? date('d-m-Y, G:i',$result['lastvisit']) : $lng['never'],
  102. 'posts'=>$result['posts']
  103. );
  104. include('./skins/'.$default_skin.'/users_item_add_body.tpl');
  105. }
  106. }
  107. else
  108. {
  109. echo '<tr><td width="100%" colspan="8" height="19" class="fitem"><p class="fstandard" align="center">'.$lng['no_elements'].'!</p></td></tr>';
  110. }
  111. if ($_SESSION['uid']>0)
  112. {
  113. if(RANK=='2')
  114. {
  115. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  116. }
  117. else
  118. {
  119. $skin['pa_link']='';
  120. }
  121. }
  122. else
  123. {
  124. $skin['pa_link']='';
  125. }
  126. echo '</table>';
  127. $stop = Over::TimeGeneration();
  128. $skin['queries'] = Over::ShowQueries($start, $stop);
  129. include('./skins/'.$default_skin.'/overall_footer.tpl');
  130. break;
  131. }
  132. default:
  133. {
  134. message_forum($lng['invalidmode'],'groups.php');
  135. }
  136. }
  137. }
  138. else
  139. {
  140. $default_skin = Over::ViewSkinName();
  141. $skin = Over::generate_header($lng['lgroups'], '</a>&gt; <a href="groups.php" class="navigator">'.$lng['lgroups']);
  142. include('./skins/'.$default_skin.'/overall_header.tpl');
  143. $sql = "SELECT `g_id`, `name`, `desc` FROM `".GROUPS_TABLE."` ORDER BY `sort`";
  144. $query = DataBase::sql_query($sql, 'GENERAL', 'Could not obtain groups information.');
  145. if (@mysql_num_rows($query)>0)
  146. {
  147. while($item = mysql_fetch_array($query))
  148. {
  149. $skin = array(
  150. 'g_id'=>$item['g_id'],
  151. 'name'=>$item['name'],
  152. 'desc'=>$item['desc']
  153. );
  154. include('./skins/'.$default_skin.'/group_add_body.tpl');
  155. }
  156. }
  157. else
  158. {
  159. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8"
  160. height="19" class="fitem"><p class="fstandard" align="center">'.$lng['no_groups'].'!</p></td></tr></table>';
  161. }
  162. if ($_SESSION['uid']>0)
  163. {
  164. if(RANK=='2')
  165. {
  166. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  167. }
  168. else
  169. {
  170. $skin['pa_link']='';
  171. }
  172. }
  173. else
  174. {
  175. $skin['pa_link']='';
  176. }
  177. $stop = Over::TimeGeneration();
  178. $skin['queries'] = Over::ShowQueries($start, $stop);
  179. include('./skins/'.$default_skin.'/overall_footer.tpl');
  180. }
  181. ?>