- <?php
- /**
- * @package uForum
- * @file admin/censorlist.php
- * @version $Id$
- * @copyright 2009(c) PioDer <pioder@wp.pl>
- * @link http://pioder.gim2przemysl.int.pl/
- * @license GNU GPL v3
- **/
- define('IN_uF', true);
- //include files
- include('./../config.php');
- include('./../includes/constants.php');
- include('./../includes/db.php');
- include('./../includes/errors.php');
- include('./../includes/classes/class_pms.php');
- //connect to database
- DataBase::db_connect();
- include('./../includes/sessions.php');
- include('./../includes/classes/class_user.php');
- include('./../common.php');
- include('./../includes/admin/class_main.php');
- include('./../includes/classes/class_forum.php');
- include('./../includes/admin/class_forum.php');
- include('./../includes/classes/secure.php');
- include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
- SessDelInvalid();
- SessRegister();
- SessDeleteOld();
- if (User::UserInformation($_SESSION['uid'],'rank')!=2)
- {
- admin_message_forum($lng['yournotadmin'],'../index.php');
- }
-
- if (!isset($_GET['mode']))
- {
- header('Location: censorlist.php?mode=main');
- }
- switch($_GET['mode'])
- {
- case 'addfile':
- {
- if (isset($_FILES['file']))
- {
- $catalog = '../tmp/';
- if(!move_uploaded_file($_FILES['file']['tmp_name'], $catalog.$_FILES['file']['name']))
- {
- message_die(GENERAL,'Could not upload file.','');
- }
- $open = fopen($catalog.$_FILES['file']['name'],'r');
- $file = fread($open, filesize($catalog.$_FILES['file']['name']));
- $item = @explode(',',$file);
- $sql = "SELECT `w_id` FROM ".CENSORLIST_TABLE." ORDER BY `w_id` DESC";
- $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last word id'));
- $last = $last['w_id'];
- $last= $last +1;
- for($i=0;$i<count($item);$i++)
- {
- $word = $item[$i];
- DataBase::sql_query("INSERT INTO ".CENSORLIST_TABLE." VALUES ('$last','$word')",GENERAL,'Could not add censored word.');
- $last = $last +1;
- }
- admin_message_forum($lng['words_added'],'censorlist.php');
- }
- else
- {
- $skin = array(
- 'L.main_beam'=>$lng['add_from_file'],
- 'L.file_name'=>$lng['file_name'],
- 'L.save'=>$lng['submit'],
- 'L.reset'=>$lng['reset'],
- 'L.censorlist'=>$lng['admin_censorlist']
- );
- Admin_Over::GenerateHeader();
- include('./template/censorlist_upload_body.tpl');
- include('./template/overall_footer.tpl');
- }
- break;
- }
- case 'delete':
- {
- $wid = intval($_GET['w']);
- $sql = "DELETE FROM ".CENSORLIST_TABLE." WHERE `w_id`='$wid'";
- DataBase::sql_query($sql,GENERAL,'Could not delete word.');
- admin_message_forum($lng['word_deleted'],'censorlist.php?mode=view');
- break;
- }
- case 'addword':
- {
- if (isset($_POST['word']))
- {
- $word = strip_tags($_POST['word']);
- $sql = "SELECT `w_id` FROM ".CENSORLIST_TABLE." ORDER BY `w_id` DESC";
- $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last word id'));
- $last = $last['w_id'];
- $last= $last +1;
- DataBase::sql_query("INSERT INTO ".CENSORLIST_TABLE." VALUES ('$last','$word')",GENERAL,'Could not add censored word.');
- admin_message_forum($lng['word_added'],'censorlist.php');
- }
- else
- {
- $_POST['word']='';
- $skin = array(
- 'action'=>'censorlist.php?mode=addword',
- 'L.main_beam'=>$lng['add_word'],
- 'L.word_name'=>$lng['word_name'],
- 'L.save'=>$lng['submit'],
- 'L.reset'=>$lng['reset'],
- 'L.censorlist'=>$lng['admin_censorlist']
- );
- Admin_Over::GenerateHeader();
- include('./template/censorlist_add_edit_body.tpl');
- include('./template/overall_footer.tpl');
- }
- break;
- }
- case 'edit':
- {
- if (isset($_POST['word'],$_GET['w']))
- {
- $word = strip_tags(trim($_POST['word']));
- $wid = intval($_GET['w']);
- DataBase::sql_query("UPDATE ".CENSORLIST_TABLE." SET `word`='$word' WHERE `w_id`='$wid'",GENERAL,'Could not update censored word.');
- admin_message_forum($lng['word_edited'],'censorlist.php?mode=view');
- }
- else
- {
- $wid = intval($_GET['w']);
- $sql = "SELECT * FROM ".CENSORLIST_TABLE." WHERE `w_id`='$wid'";
- $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain censorlist words');
- $result = DataBase::fetch($query);
- $_POST['word']=$result['word'];
- $skin = array(
- 'action'=>'censorlist.php?mode=edit&w='.$wid,
- 'L.main_beam'=>$lng['edit_word'],
- 'L.word_name'=>$lng['word_name'],
- 'L.save'=>$lng['submit'],
- 'L.reset'=>$lng['reset'],
- 'L.censorlist'=>$lng['admin_censorlist']
- );
- Admin_Over::GenerateHeader();
- include('./template/censorlist_add_edit_body.tpl');
- include('./template/overall_footer.tpl');
- }
- break;
- }
- case 'deleteall':
- {
- DataBase::sql_query("TRUNCATE TABLE ".CENSORLIST_TABLE,GENERAL,'Could not empty censorlist table.');
- admin_message_forum($lng['table_cleanout'],'censorlist.php');
- break;
- }
- case 'view':
- {
- $sql = "SELECT * FROM ".CENSORLIST_TABLE." ORDER BY `word`";
- $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain censorlist words');
- $skin = array(
- 'L.censorlist'=>$lng['admin_censorlist'],
- 'L.view_all_words'=>$lng['view_all_words']
- );
- Admin_Over::GenerateHeader();
- include('./template/censorlist_view_body.tpl');
- if (DataBase::num_rows($query)<1)
- {
- echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8" height="19"
- class="fitem"><p class="fstandard" align="center">'.$lng['no_words'].'!</p></td></tr></table>';
- }
- else
- {
- while($item = DataBase::fetch($query))
- {
- $skin = array(
- 'L.word_name'=>$item['word'],
- 'w_id'=>$item['w_id'],
- 'L.delete'=>$lng['delete'],
- 'L.edit'=>$lng['edit'],
- );
- include('./template/censorlist_word_add.tpl');
- }
- }
- include('./template/overall_footer.tpl');
- break;
- }
- case 'main':
- {
- $skin = array(
- 'L.show_all_words' => $lng['show_all_words'],
- 'L.what_do_you_want'=> $lng['what_do_you_want'],
- 'L.delete_all_words' => $lng['delete_all_words'],
- 'L.add_from_file' => $lng['add_from_file'],
- 'L.add_word' => $lng['add_word'],
- 'L.censorlist'=>$lng['admin_censorlist']
- );
- Admin_Over::GenerateHeader();
- include('./template/censorlist_main_body.tpl');
- include('./template/overall_footer.tpl');
- break;
- }
- default:
- {
- header('Location: censorlist.php?mode=main');
- break;
- }
- }
- ?>
|