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.

192 lines
5.9 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file warns.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/class_posting.php');
  24. include('./includes/class_forum.php');
  25. include('./includes/classes/secure.php');
  26. include('./lngs/'.Over::DefaultLang().'/main.php');
  27. $start = Over::TimeGeneration();
  28. sess_del_invalid($_SESSION['uid']);
  29. sess_register($_SESSION['uid']);
  30. sess_delete_old();
  31. foreach ($_POST as $name => $value)
  32. {
  33. if ($forum_config['use_censorlist'])
  34. {
  35. $_POST[$name] = Secure::UseCensorlist($value);
  36. }
  37. }
  38. if (!$forum_config['allow_warns'])
  39. {
  40. message_forum($lng['warns_disabled'],'index.php');
  41. }
  42. $default_skin = Over::ViewSkinName();
  43. switch(trim($_GET['mode']))
  44. {
  45. case 'add':
  46. {
  47. $uid = intval($_GET['id']);
  48. if (User::RankAdminMod($_SESSION['uid'])=='0')
  49. {
  50. message_forum($lng['is_no_mod'],'warns.php?mode=view&amp;id='.$uid);
  51. }
  52. $msg ='./skins/'.$default_skin.'/blank.tpl';
  53. if ((isset($_POST['textedit'])) and (isset($_POST['value'])))
  54. {
  55. if (($_POST['textedit'] !="" ) and (strlen($_POST['textedit'])>10))
  56. {
  57. if ((strpos($_POST['value'],'+')!==false) or (strpos($_POST['value'],'-')!==false))
  58. {
  59. $_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
  60. User::UserAddWarn($_GET['id'],$_POST['value'] ,addslashes(strip_tags($_POST['textedit'])));
  61. $stop = Over::TimeGeneration();
  62. message_forum($lng['warn_is_added'],'warns.php?mode=view&amp;id='.$_GET['id']);
  63. }
  64. else
  65. {
  66. $message = $lng['werror_1'];
  67. $msg = './skins/'.$default_skin.'/post_error_body.tpl';
  68. }
  69. }
  70. else
  71. {
  72. $message = $lng['perror_1'];
  73. $msg = './skins/'.$default_skin.'/post_error_body.tpl';
  74. }
  75. }
  76. else
  77. {
  78. $_POST['textedit']='';
  79. $_POST['value']='';
  80. }
  81. $nick_name = User::UserInformation($_GET['id'],'nick');
  82. if($nick_name=='')
  83. {
  84. message_forum($lng['no_user'],'index.php');
  85. }
  86. //add skin variables
  87. $skin = array(
  88. 'f_id'=>$_GET['id'],
  89. 'smiles'=>Post::SmilesShow(),
  90. 'action'=>'warns.php?mode=add&amp;id='.$_GET['id'],
  91. //labels
  92. 'lsmiles'=>$lng['smiles'],
  93. 'lmsg'=>$lng['motive'],
  94. 'ladd'=>$lng['add'],
  95. 'ldelete'=>$lng['delete'],
  96. 'lsave'=>$lng['save'],
  97. 'lvalue'=>$lng['value'],
  98. 'lreset'=>$lng['reset'],
  99. 'lwarn'=>$lng['warn'],
  100. 'lall_warns'=>$lng['all_warns'],
  101. 'queries'=>Over::ShowQueries($start, Over::TimeGeneration())
  102. );
  103. $skin = array_push_associative($skin, Over::generate_header($lng['add_warn'].': '.$nick_name,'</a>&gt; <a href="warns.php?mode=add&amp;id='.$uid.'" class="navigator">'.$lng['add_warn'].': '.$nick_name));
  104. if(User::UserInformation($_SESSION['uid'],'rank')=='2')
  105. {
  106. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  107. }
  108. else
  109. {
  110. $skin['pa_link']='';
  111. }
  112. include('./skins/'.$default_skin.'/overall_header.tpl');
  113. include('./skins/'.$default_skin.'/warns_add_body.tpl');
  114. include('./skins/'.$default_skin.'/overall_footer.tpl');
  115. break;
  116. }
  117. case 'view':
  118. {
  119. $uid = $_GET['id'];
  120. $sql = "SELECT `u_id`, `nick` FROM `".USERS_TABLE."` WHERE `u_id`='$uid'";
  121. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information');
  122. $user = @mysql_fetch_array($query);
  123. if ($user['u_id']=='')
  124. {
  125. message_forum($lng['no_user'],'index.php');
  126. }
  127. //add skin variables
  128. $skin = array(
  129. 'lvalue' => $lng['value'],
  130. 'lmotive' => $lng['motive']
  131. );
  132. $skin = array_push_associative($skin, Over::generate_header($lng['show_warns'].': '.$user['nick'],'</a>&gt; <a href="warns.php?mode=view&amp;id='.$uid.'" class="navigator">'.$lng['show_warns'].': '.$user['nick']));
  133. include('./skins/'.$default_skin.'/overall_header.tpl');
  134. include('./skins/'.$default_skin.'/warns_view_body.tpl');
  135. $sql = "SELECT * FROM `".WARNINGS_TABLE."` WHERE `u_id`='$uid'";
  136. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user warns information');
  137. $result = mysql_num_rows($query);
  138. $warns_count = 0;
  139. while($item = mysql_fetch_array($query))
  140. {
  141. $skin = array(
  142. 'value'=>$item['value'],
  143. 'motive'=>$item['motive']
  144. );
  145. include('./skins/'.$default_skin.'/warns_view_item_body.tpl');
  146. $warns_count = ($item['value']=='+') ? $warns_count + 1 : $warns_count -1;
  147. }
  148. $stop = Over::TimeGeneration();
  149. $skin = array(
  150. 'lall_warns'=>$lng['all_warns'],
  151. 'all_warns'=>($warns_count>0) ? '<span class="fstandard" style="color: "red"><b>'.($warns_count*10).'%</b></span>' : '<span class="fstandard" style="color: green"><b>'.$warns_count.'%</b></span>',
  152. 'queries'=>Over::ShowQueries($start, $stop)
  153. );
  154. $user_rank = ($_SESSION['uid']>0) ? RANK : 0;
  155. if ($user_rank>0)
  156. {
  157. $skin['add']='<td width="128"><a href="warns.php?mode=add&amp;id='.$uid.'" class="fstandard"><b><u>'.$lng['add_warn'].'</u></b></a></td>';
  158. }
  159. else
  160. {
  161. $skin['add']='';
  162. }
  163. if ($result>0)
  164. {
  165. $skin['no_elements']='';
  166. }
  167. else
  168. {
  169. $skin['no_elements']='<tr><td width="748" colspan="2" class="fitem"><p class="fstandard" align="center">'.$lng['no_elements'].'!</p></td></tr>';
  170. }
  171. if($user_rank=='2')
  172. {
  173. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  174. }
  175. else
  176. {
  177. $skin['pa_link']='';
  178. }
  179. include('./skins/'.$default_skin.'/warns_view_end_body.tpl');
  180. include('./skins/'.$default_skin.'/overall_footer.tpl');
  181. break;
  182. }
  183. default:
  184. {
  185. $stop = Over::TimeGeneration();
  186. message_forum($lng['invalidmode'],'index.php');
  187. break;
  188. }
  189. }
  190. ?>