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.

229 lines
6.4 KiB

  1. <?php
  2. /**
  3. * @package Dynamic Script Forum
  4. * @file users.php
  5. * @version 1.0.x, 11-07-2007, 10:32
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  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_topic.php');
  22. include('./includes/class_overall.php');
  23. include('./includes/class_forum.php');
  24. $start = Over::TimeGeneration();
  25. include('./lngs/'.Over::DefaultLang().'/main.php');
  26. sess_del_invalid($_SESSION['uid']);
  27. sess_register($_SESSION['uid']);
  28. sess_delete_old();
  29. $default_skin = Over::ViewSkinName();
  30. //
  31. //generate output pages
  32. //
  33. if ($_SESSION['uid']>0)
  34. {
  35. $limiter = User::UserInformation($_SESSION['uid'], 'limit_users');
  36. }
  37. else
  38. {
  39. $limiter = $forum_config['limit_users'];
  40. }
  41. if (isset($_GET['page'])&&($_GET['page']!=1))
  42. {
  43. if (!is_numeric($_GET['page']))
  44. {
  45. die('Hacking attempt');
  46. }
  47. $value = ($_GET['page']-1)*$limiter;
  48. $limit = 'LIMIT '.$value . ', '.$limiter;
  49. $page = $_GET['page'];
  50. }
  51. else
  52. {
  53. $limit = 'LIMIT 0, '.$limiter;
  54. $page=1;
  55. }
  56. $count = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`u_id`) as `u_id`
  57. FROM ".USERS_TABLE,'GENERAL','Could not obtain count amout of users'));
  58. $count = $count['u_id'] -1;
  59. $count = ceil($count / $limiter);
  60. if(isset($_GET['page']) && ($_GET['page']>$count))
  61. {
  62. message_forum($lng['invalidpage'],'index.php');
  63. }
  64. //
  65. //end generating pages
  66. //
  67. if (isset($_COOKIE['users_desc'], $_POST['desc']))
  68. {
  69. unset($_COOKIE['users_desc']);
  70. }
  71. if (isset($_POST['sort'],$_COOKIE['users_sort']))
  72. {
  73. unset($_COOKIE['users_sort']);
  74. }
  75. if (!isset($_COOKIE['users_desc']))
  76. {
  77. if (isset($_POST['desc']))
  78. {
  79. switch($_POST['desc'])
  80. {
  81. case 'yes':
  82. {
  83. @setcookie('users_desc','desc',time()+3600);
  84. $_COOKIE['users_desc'] = 'desc';
  85. $desc = 'DESC';
  86. break;
  87. }
  88. case 'no':
  89. {
  90. @setcookie('users_desc','no',time()+3600);
  91. $_COOKIE['users_desc'] = 'no';
  92. $desc = '';
  93. break;
  94. }
  95. }
  96. }
  97. else
  98. {
  99. @setcookie('users_desc','no',time()+3600);
  100. $_COOKIE['users_desc'] = 'no';
  101. $desc = '';
  102. }
  103. }
  104. else
  105. {
  106. $desc = ($_COOKIE['users_desc']=='desc') ? 'DESC' : '';
  107. }
  108. if (!isset($_COOKIE['users_sort']))
  109. {
  110. if (isset($_POST['sort']))
  111. {
  112. switch($_POST['sort'])
  113. {
  114. case 'regdate':
  115. {
  116. @setcookie('users_sort','regdate',time()+3600);
  117. $_COOKIE['users_sort'] = 'regdate';
  118. break;
  119. }
  120. case 'lastvisit':
  121. {
  122. @setcookie('users_sort','lastvisit',time()+3600);
  123. $_COOKIE['users_sort'] = 'lastvisit';
  124. break;
  125. }
  126. case 'uname':
  127. {
  128. @setcookie('users_sort','uname',time()+3600);
  129. $_COOKIE['users_sort'] = 'uname';
  130. break;
  131. }
  132. case 'posts':
  133. {
  134. @setcookie('users_sort','posts',time()+3600);
  135. $_COOKIE['users_sort'] = 'posts';
  136. break;
  137. }
  138. }
  139. }
  140. else
  141. {
  142. @setcookie('users_sort','regdate',time()+3600);
  143. $_COOKIE['users_sort'] = 'regdate';
  144. }
  145. }
  146. //add skin variables
  147. $skin = array(
  148. 'ldesc' => $lng['desc'],
  149. 'desc_yes_option'=>(($_COOKIE['users_desc']=='desc') || ((isset ($_POST['desc'])) && ($_POST['desc']=='yes'))) ? 'selected="selected"' : '',
  150. 'desc_no_option'=>(($_COOKIE['users_desc']=='no') || ((isset ($_POST['desc'])) && ($_POST['desc']=='no'))) ? 'selected="selected"' : '',
  151. 'regdate_option'=>(($_COOKIE['users_sort']=='regdate') || ((isset ($_POST['sort'])) && ($_POST['sort']=='posts'))) ? 'selected="selected"' : '',
  152. 'lastvisit_option'=>(($_COOKIE['users_sort']=='lastvisit') || ((isset ($_POST['sort'])) && ($_POST['sort']=='lastvisit'))) ? 'selected="selected"' : '',
  153. 'posts_option'=>(($_COOKIE['users_sort']=='posts') || ((isset ($_POST['sort'])) && ($_POST['sort']=='posts'))) ? 'selected="selected"' : '',
  154. 'uname_option'=>(($_COOKIE['users_sort']=='uname') || ((isset ($_POST['sort'])) && ($_POST['sort']=='uname'))) ? 'selected="selected"' : '',
  155. 'lselectusers'=>$lng['sort_u_by'],
  156. 'ltitle'=>$lng['lusers'],
  157. 'lyes'=>$lng['yes'],
  158. 'lno'=>$lng['no'],
  159. 'lregdate'=>$lng['luregister'],
  160. 'llastvisit'=>$lng['lulastvisit'],
  161. 'lposts'=>$lng['posts'],
  162. 'luname'=>$lng['user_name'],
  163. 'lgo'=>$lng['lgo']
  164. );
  165. $skin = array_push_associative($skin, Over::generate_header($lng['lusers'],'</a>&gt; <a href="users.php" class="navigator">'.$lng['lusers']));
  166. //do it!
  167. include('./skins/'.$default_skin.'/overall_header.tpl');
  168. include('./skins/'.$default_skin.'/users_body.tpl');
  169. switch($_COOKIE['users_sort'])
  170. {
  171. case 'regdate':
  172. {
  173. $sql = "SELECT `u_id`,`nick`, `rank`, `regdate`, `lastvisit`, `posts` FROM `".USERS_TABLE."` WHERE `u_id`>0 ORDER BY `regdate` $desc $limit;";
  174. break;
  175. }
  176. case 'lastvisit':
  177. {
  178. $sql = "SELECT `u_id`,`nick`, `rank`, `regdate`, `lastvisit`, `posts` FROM `".USERS_TABLE."` WHERE `u_id`>0 ORDER BY `lastvisit` $desc $limit;";
  179. break;
  180. }
  181. case 'uname':
  182. {
  183. $sql = "SELECT `u_id`,`nick`, `rank`, `regdate`, `lastvisit`, `posts` FROM `".USERS_TABLE."` WHERE `u_id`>0 ORDER BY `nick` $desc $limit;";
  184. break;
  185. }
  186. case 'posts':
  187. {
  188. $sql = "SELECT `u_id`,`nick`, `rank`, `regdate`, `lastvisit`, `posts` FROM `".USERS_TABLE."` WHERE `u_id`>0 ORDER BY `posts` $desc $limit;";
  189. break;
  190. }
  191. }
  192. $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain user information.');
  193. while($result = mysql_fetch_array($query))
  194. {
  195. $skin = array(
  196. 'id'=>$result['u_id'],
  197. 'uname'=>Topic::UserName($result['nick'], $result['rank']),
  198. 'regdate'=>date('d-m-Y, G:i',$result['regdate']),
  199. 'lastvisit'=>($result['lastvisit']!='0') ? date('d-m-Y, G:i',$result['lastvisit']) : $lng['never'],
  200. 'posts'=>$result['posts']
  201. );
  202. include('./skins/'.$default_skin.'/users_item_add_body.tpl');
  203. }
  204. $skin = array(
  205. 'option_pages'=>Over::AddPages(),
  206. 'lwith'=>$lng['with'],
  207. 'lpage'=>$lng['page'],
  208. 'lpages'=>$count
  209. );
  210. include('./skins/'.$default_skin.'/users_end_body.tpl');
  211. if($_SESSION['uid']>0)
  212. {
  213. if(RANK==2)
  214. {
  215. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  216. }
  217. else
  218. {
  219. $skin['pa_link']='';
  220. }
  221. }
  222. else
  223. {
  224. $skin['pa_link']='';
  225. }
  226. $stop = Over::TimeGeneration();
  227. $skin['queries'] = Over::ShowQueries($start, $stop);
  228. include('./skins/'.$default_skin.'/overall_footer.tpl');
  229. ?>