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.

212 lines
6.7 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/censorlist.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. include('./../includes/classes/class_pms.php');
  17. //connect to database
  18. DataBase::db_connect();
  19. include('./../includes/sessions.php');
  20. include('./../includes/classes/class_user.php');
  21. include('./../common.php');
  22. include('./../includes/admin/class_main.php');
  23. include('./../includes/classes/class_forum.php');
  24. include('./../includes/admin/class_forum.php');
  25. include('./../includes/classes/secure.php');
  26. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  27. SessDelInvalid();
  28. SessRegister();
  29. SessDeleteOld();
  30. if (User::UserInformation($_SESSION['uid'],'rank')!=2)
  31. {
  32. admin_message_forum($lng['yournotadmin'],'../index.php');
  33. }
  34. if (!isset($_GET['mode']))
  35. {
  36. header('Location: censorlist.php?mode=main');
  37. }
  38. switch($_GET['mode'])
  39. {
  40. case 'addfile':
  41. {
  42. if (isset($_FILES['file']))
  43. {
  44. $catalog = '../tmp/';
  45. if(!move_uploaded_file($_FILES['file']['tmp_name'], $catalog.$_FILES['file']['name']))
  46. {
  47. message_die(GENERAL,'Could not upload file.','');
  48. }
  49. $open = fopen($catalog.$_FILES['file']['name'],'r');
  50. $file = fread($open, filesize($catalog.$_FILES['file']['name']));
  51. $item = @explode(',',$file);
  52. $sql = "SELECT `w_id` FROM ".CENSORLIST_TABLE." ORDER BY `w_id` DESC";
  53. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last word id'));
  54. $last = $last['w_id'];
  55. $last= $last +1;
  56. for($i=0;$i<count($item);$i++)
  57. {
  58. $word = $item[$i];
  59. DataBase::sql_query("INSERT INTO ".CENSORLIST_TABLE." VALUES ('$last','$word','[censored]')",GENERAL,'Could not add censored word.');
  60. $last = $last +1;
  61. }
  62. admin_message_forum($lng['words_added'],'censorlist.php');
  63. }
  64. else
  65. {
  66. $skin = array(
  67. 'L.main_beam'=>$lng['add_from_file'],
  68. 'L.file_name'=>$lng['file_name'],
  69. 'L.save'=>$lng['submit'],
  70. 'L.reset'=>$lng['reset'],
  71. 'L.censorlist'=>$lng['admin_censorlist']
  72. );
  73. Admin_Over::GenerateHeader();
  74. include('./template/censorlist_upload_body.tpl');
  75. include('./template/overall_footer.tpl');
  76. }
  77. break;
  78. }
  79. case 'delete':
  80. {
  81. $wid = intval($_GET['w']);
  82. $sql = "DELETE FROM ".CENSORLIST_TABLE." WHERE `w_id`='$wid'";
  83. DataBase::sql_query($sql,GENERAL,'Could not delete word.');
  84. admin_message_forum($lng['word_deleted'],'censorlist.php?mode=view');
  85. break;
  86. }
  87. case 'addword':
  88. {
  89. if (isset($_POST['word']))
  90. {
  91. $word = strip_tags($_POST['word']);
  92. $replace = (strlen($_POST['replace']) > 0) ? $_POST['replace'] : '[censored]';
  93. $sql = "SELECT `w_id` FROM ".CENSORLIST_TABLE." ORDER BY `w_id` DESC";
  94. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last word id'));
  95. $last = $last['w_id'];
  96. $last= $last +1;
  97. DataBase::sql_query("INSERT INTO ".CENSORLIST_TABLE." VALUES ('$last','$word','$replace')",GENERAL,'Could not add censored word.');
  98. admin_message_forum($lng['word_added'],'censorlist.php');
  99. }
  100. else
  101. {
  102. $_POST['word']='';
  103. $_POST['replace']='';
  104. $skin = array(
  105. 'action'=>'censorlist.php?mode=addword',
  106. 'L.main_beam'=>$lng['add_word'],
  107. 'L.word_name'=>$lng['word_name'],
  108. 'L.replace_to'=>$lng['replace_to'],
  109. 'L.save'=>$lng['submit'],
  110. 'L.reset'=>$lng['reset'],
  111. 'L.censorlist'=>$lng['admin_censorlist']
  112. );
  113. Admin_Over::GenerateHeader();
  114. include('./template/censorlist_add_edit_body.tpl');
  115. include('./template/overall_footer.tpl');
  116. }
  117. break;
  118. }
  119. case 'edit':
  120. {
  121. if (isset($_POST['word'],$_GET['w']))
  122. {
  123. $word = strip_tags(trim($_POST['word']));
  124. $wid = intval($_GET['w']);
  125. $replace = $_POST['replace'];
  126. DataBase::sql_query("UPDATE ".CENSORLIST_TABLE." SET `word`='$word', `replace`='$replace' WHERE `w_id`='$wid'",GENERAL,'Could not update censored word.');
  127. admin_message_forum($lng['word_edited'],'censorlist.php?mode=view');
  128. }
  129. else
  130. {
  131. $wid = intval($_GET['w']);
  132. $sql = "SELECT * FROM ".CENSORLIST_TABLE." WHERE `w_id`='$wid'";
  133. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain censorlist words');
  134. $result = DataBase::fetch($query);
  135. $_POST['word']=$result['word'];
  136. $_POST['replace']=$result['replace'];
  137. $skin = array(
  138. 'action'=>'censorlist.php?mode=edit&w='.$wid,
  139. 'L.main_beam'=>$lng['edit_word'],
  140. 'L.word_name'=>$lng['word_name'],
  141. 'L.replace_to'=>$lng['replace_to'],
  142. 'L.save'=>$lng['submit'],
  143. 'L.reset'=>$lng['reset'],
  144. 'L.censorlist'=>$lng['admin_censorlist']
  145. );
  146. Admin_Over::GenerateHeader();
  147. include('./template/censorlist_add_edit_body.tpl');
  148. include('./template/overall_footer.tpl');
  149. }
  150. break;
  151. }
  152. case 'deleteall':
  153. {
  154. DataBase::sql_query("TRUNCATE TABLE ".CENSORLIST_TABLE,GENERAL,'Could not empty censorlist table.');
  155. admin_message_forum($lng['table_cleanout'],'censorlist.php');
  156. break;
  157. }
  158. case 'view':
  159. {
  160. $sql = "SELECT * FROM ".CENSORLIST_TABLE." ORDER BY `word`";
  161. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain censorlist words');
  162. $skin = array(
  163. 'L.censorlist'=>$lng['admin_censorlist'],
  164. 'L.view_all_words'=>$lng['view_all_words']
  165. );
  166. Admin_Over::GenerateHeader();
  167. include('./template/censorlist_view_body.tpl');
  168. if (DataBase::num_rows($query)<1)
  169. {
  170. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8" height="19"
  171. class="fitem"><p class="fstandard" align="center">'.$lng['no_words'].'!</p></td></tr></table>';
  172. }
  173. else
  174. {
  175. while($item = DataBase::fetch($query))
  176. {
  177. $skin = array(
  178. 'L.word_name'=>$item['word'],
  179. 'L.word_replacement'=>$item['replace'],
  180. 'w_id'=>$item['w_id'],
  181. 'L.delete'=>$lng['delete'],
  182. 'L.edit'=>$lng['edit'],
  183. );
  184. include('./template/censorlist_list_word.tpl');
  185. }
  186. }
  187. include('./template/overall_footer.tpl');
  188. break;
  189. }
  190. case 'main':
  191. {
  192. $skin = array(
  193. 'L.show_all_words' => $lng['show_all_words'],
  194. 'L.what_do_you_want'=> $lng['what_do_you_want'],
  195. 'L.delete_all_words' => $lng['delete_all_words'],
  196. 'L.add_from_file' => $lng['add_from_file'],
  197. 'L.add_word' => $lng['add_word'],
  198. 'L.censorlist'=>$lng['admin_censorlist']
  199. );
  200. Admin_Over::GenerateHeader();
  201. include('./template/censorlist_main_body.tpl');
  202. include('./template/overall_footer.tpl');
  203. break;
  204. }
  205. default:
  206. {
  207. header('Location: censorlist.php?mode=main');
  208. break;
  209. }
  210. }
  211. ?>