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.

205 lines
6.4 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/class_db.php');
  15. include('./../includes/class_error.php');
  16. include('./../includes/classes/class_pms.php');
  17. //connect to database
  18. DataBase::db_connect();
  19. include('./../includes/sessions.php');
  20. include('./../includes/class_user.php');
  21. include('./../common.php');
  22. include('./../includes/admin/class_main.php');
  23. include('./../includes/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. sess_del_invalid($_SESSION['uid']);
  28. sess_register($_SESSION['uid']);
  29. sess_delete_old();
  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 = @mysql_fetch_array(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')",'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. $sql = "SELECT `w_id` FROM ".CENSORLIST_TABLE." ORDER BY `w_id` DESC";
  93. $last = @mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain last word id'));
  94. $last = $last['w_id'];
  95. $last= $last +1;
  96. DataBase::sql_query("INSERT INTO ".CENSORLIST_TABLE." VALUES ('$last','$word')",'GENERAL','Could not add censored word.');
  97. admin_message_forum($lng['word_added'],'censorlist.php');
  98. }
  99. else
  100. {
  101. $_POST['word']='';
  102. $skin = array(
  103. 'action'=>'censorlist.php?mode=addword',
  104. 'L.main_beam'=>$lng['add_word'],
  105. 'L.word_name'=>$lng['word_name'],
  106. 'L.save'=>$lng['submit'],
  107. 'L.reset'=>$lng['reset'],
  108. 'L.censorlist'=>$lng['admin_censorlist']
  109. );
  110. Admin_Over::GenerateHeader();
  111. include('./template/censorlist_add_edit_body.tpl');
  112. include('./template/overall_footer.tpl');
  113. }
  114. break;
  115. }
  116. case 'edit':
  117. {
  118. if (isset($_POST['word'],$_GET['w']))
  119. {
  120. $word = strip_tags(trim($_POST['word']));
  121. $wid = intval($_GET['w']);
  122. DataBase::sql_query("UPDATE ".CENSORLIST_TABLE." SET `word`='$word' WHERE `w_id`='$wid'",'GENERAL','Could not update censored word.');
  123. admin_message_forum($lng['word_edited'],'censorlist.php?mode=view');
  124. }
  125. else
  126. {
  127. $wid = intval($_GET['w']);
  128. $sql = "SELECT * FROM ".CENSORLIST_TABLE." WHERE `w_id`='$wid'";
  129. $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain censorlist words');
  130. $result = @mysql_fetch_array($query);
  131. $_POST['word']=$result['word'];
  132. $skin = array(
  133. 'action'=>'censorlist.php?mode=edit&w='.$wid,
  134. 'L.main_beam'=>$lng['edit_word'],
  135. 'L.word_name'=>$lng['word_name'],
  136. 'L.save'=>$lng['submit'],
  137. 'L.reset'=>$lng['reset'],
  138. 'L.censorlist'=>$lng['admin_censorlist']
  139. );
  140. Admin_Over::GenerateHeader();
  141. include('./template/censorlist_add_edit_body.tpl');
  142. include('./template/overall_footer.tpl');
  143. }
  144. break;
  145. }
  146. case 'deleteall':
  147. {
  148. DataBase::sql_query("TRUNCATE TABLE ".CENSORLIST_TABLE,'GENERAL','Could not empty censorlist table.');
  149. admin_message_forum($lng['table_cleanout'],'censorlist.php');
  150. break;
  151. }
  152. case 'view':
  153. {
  154. $sql = "SELECT * FROM ".CENSORLIST_TABLE." ORDER BY `word`";
  155. $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain censorlist words');
  156. $skin = array(
  157. 'L.censorlist'=>$lng['admin_censorlist'],
  158. 'L.view_all_words'=>$lng['view_all_words']
  159. );
  160. Admin_Over::GenerateHeader();
  161. include('./template/censorlist_view_body.tpl');
  162. if (@mysql_num_rows($query)<1)
  163. {
  164. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8" height="19"
  165. class="fitem"><p class="fstandard" align="center">'.$lng['no_words'].'!</p></td></tr></table>';
  166. }
  167. else
  168. {
  169. while($item = @mysql_fetch_array($query))
  170. {
  171. $skin = array(
  172. 'L.word_name'=>$item['word'],
  173. 'w_id'=>$item['w_id'],
  174. 'L.delete'=>$lng['delete'],
  175. 'L.edit'=>$lng['edit'],
  176. );
  177. include('./template/censorlist_word_add.tpl');
  178. }
  179. }
  180. include('./template/overall_footer.tpl');
  181. break;
  182. }
  183. case 'main':
  184. {
  185. $skin = array(
  186. 'L.show_all_words' => $lng['show_all_words'],
  187. 'L.what_do_you_want'=> $lng['what_do_you_want'],
  188. 'L.delete_all_words' => $lng['delete_all_words'],
  189. 'L.add_from_file' => $lng['add_from_file'],
  190. 'L.add_word' => $lng['add_word'],
  191. 'L.censorlist'=>$lng['admin_censorlist']
  192. );
  193. Admin_Over::GenerateHeader();
  194. include('./template/censorlist_main_body.tpl');
  195. include('./template/overall_footer.tpl');
  196. break;
  197. }
  198. default:
  199. {
  200. header('Location: censorlist.php?mode=main');
  201. break;
  202. }
  203. }
  204. ?>