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
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/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/class_posting.php');
  24. include('./includes/classes/class_forum.php');
  25. include('./includes/classes/secure.php');
  26. include('./lngs/'.DefaultLang().'/main.php');
  27. $start = TimeGeneration();
  28. SessDelInvalid();
  29. SessRegister();
  30. SessDeleteOld();
  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 = 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. if ($_POST['value'] == '+')
  60. {
  61. if (User::UserInformation($_GET['id'],'rank')>0)
  62. {
  63. message_forum($lng['cannot_add_warn_am'],'warns.php?mode=view&amp;id='.$_GET['id']);
  64. }
  65. }
  66. $_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
  67. User::UserAddWarn($_GET['id'],$_POST['value'] ,addslashes(strip_tags($_POST['textedit'])));
  68. $stop = TimeGeneration();
  69. message_forum($lng['warn_is_added'],'warns.php?mode=view&amp;id='.$_GET['id']);
  70. }
  71. else
  72. {
  73. $message = $lng['werror_1'];
  74. $msg = './skins/'.$default_skin.'/post_error_body.tpl';
  75. }
  76. }
  77. else
  78. {
  79. $message = $lng['perror_1'];
  80. $msg = './skins/'.$default_skin.'/post_error_body.tpl';
  81. }
  82. }
  83. else
  84. {
  85. $_POST['textedit']='';
  86. $_POST['value']='';
  87. }
  88. $nick_name = User::UserInformation($_GET['id'],'nick');
  89. if($nick_name=='')
  90. {
  91. message_forum($lng['no_user'],'index.php');
  92. }
  93. //add skin variables
  94. $skin = array(
  95. 'f_id'=>$_GET['id'],
  96. 'smiles'=>Post::SmilesShow(),
  97. 'action'=>'warns.php?mode=add&amp;id='.$_GET['id'],
  98. //labels
  99. 'lsmiles'=>$lng['smiles'],
  100. 'lmsg'=>$lng['motive'],
  101. 'ladd'=>$lng['add'],
  102. 'ldelete'=>$lng['delete'],
  103. 'lsave'=>$lng['save'],
  104. 'lvalue'=>$lng['value'],
  105. 'lreset'=>$lng['reset'],
  106. 'lwarn'=>$lng['warn'],
  107. 'lall_warns'=>$lng['all_warns'],
  108. 'queries'=>ShowQueries($start, TimeGeneration())
  109. );
  110. $skin = array_push_assoc($skin, GenerateHeader($lng['add_warn'].': '.$nick_name,'</a>&gt; <a href="warns.php?mode=add&amp;id='.$uid.'" class="navigator">'.$lng['add_warn'].': '.$nick_name));
  111. if(User::UserInformation($_SESSION['uid'],'rank')=='2')
  112. {
  113. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  114. }
  115. else
  116. {
  117. $skin['pa_link']='';
  118. }
  119. include('./skins/'.$default_skin.'/overall_header.tpl');
  120. include('./skins/'.$default_skin.'/warns_add_body.tpl');
  121. include('./skins/'.$default_skin.'/overall_footer.tpl');
  122. break;
  123. }
  124. case 'view':
  125. {
  126. $uid = $_GET['id'];
  127. $sql = "SELECT `u_id`, `nick` FROM `".USERS_TABLE."` WHERE `u_id`='$uid'";
  128. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain user information');
  129. $user = DataBase::fetch($query);
  130. if ($user['u_id']=='')
  131. {
  132. message_forum($lng['no_user'],'index.php');
  133. }
  134. //add skin variables
  135. $skin = array(
  136. 'lvalue' => $lng['value'],
  137. 'lmotive' => $lng['motive']
  138. );
  139. $skin = array_push_assoc($skin, GenerateHeader($lng['show_warns'].': '.$user['nick'],'</a>&gt; <a href="warns.php?mode=view&amp;id='.$uid.'" class="navigator">'.$lng['show_warns'].': '.$user['nick']));
  140. include('./skins/'.$default_skin.'/overall_header.tpl');
  141. include('./skins/'.$default_skin.'/warns_view_body.tpl');
  142. $sql = "SELECT * FROM `".WARNINGS_TABLE."` WHERE `u_id`='$uid'";
  143. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain user warns information');
  144. $result = DataBase::num_rows($query);
  145. $warns_count = 0;
  146. while($item = DataBase::fetch($query))
  147. {
  148. $skin = array(
  149. 'value'=>$item['value'],
  150. 'motive'=>$item['motive']
  151. );
  152. include('./skins/'.$default_skin.'/warns_view_item_body.tpl');
  153. $warns_count = ($item['value']=='+') ? $warns_count + 1 : $warns_count -1;
  154. }
  155. $stop = TimeGeneration();
  156. $skin = array(
  157. 'lall_warns'=>$lng['all_warns'],
  158. '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>',
  159. 'queries'=>ShowQueries($start, $stop)
  160. );
  161. $user_rank = ($_SESSION['uid']>0) ? RANK : 0;
  162. if ($user_rank>0)
  163. {
  164. $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>';
  165. }
  166. else
  167. {
  168. $skin['add']='';
  169. }
  170. if ($result>0)
  171. {
  172. $skin['no_elements']='';
  173. }
  174. else
  175. {
  176. $skin['no_elements']='<tr><td width="748" colspan="2" class="fitem"><p class="fstandard" align="center">'.$lng['no_elements'].'!</p></td></tr>';
  177. }
  178. include('./skins/'.$default_skin.'/warns_view_end_body.tpl');
  179. include('./skins/'.$default_skin.'/overall_footer.tpl');
  180. break;
  181. }
  182. default:
  183. {
  184. $stop = TimeGeneration();
  185. message_forum($lng['invalidmode'],'index.php');
  186. break;
  187. }
  188. }
  189. ?>