* @link http://www.pioder.pl/ * @license see LICENSE.txt **/ define('IN_uF', true); //include files require('./../config.php'); require('./../includes/constants.php'); require('./../includes/db.php'); require('./../includes/errors.php'); require('./../includes/classes/class_pms.php'); //connect to database DataBase::db_connect(); require('./../includes/sessions.php'); require('./../includes/classes/class_user.php'); require('./../common.php'); require('./../includes/admin/class_main.php'); require('./../includes/classes/class_forum.php'); require('./../includes/admin/class_forum.php'); require('./../includes/classes/secure.php'); require('./../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$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(); require('./template/censorlist_upload_body.tpl'); require('./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']); $replace = (strlen($_POST['replace']) > 0) ? $_POST['replace'] : '[censored]'; $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','$replace')",GENERAL,'Could not add censored word.'); admin_message_forum($lng['word_added'],'censorlist.php'); } else { $_POST['word']=''; $_POST['replace']=''; $skin = array( 'action'=>'censorlist.php?mode=addword', 'L.main_beam'=>$lng['add_word'], 'L.word_name'=>$lng['word_name'], 'L.replace_to'=>$lng['replace_to'], 'L.save'=>$lng['submit'], 'L.reset'=>$lng['reset'], 'L.censorlist'=>$lng['admin_censorlist'] ); Admin_Over::GenerateHeader(); require('./template/censorlist_add_edit_body.tpl'); require('./template/overall_footer.tpl'); } break; } case 'edit': { if (isset($_POST['word'],$_GET['w'])) { $word = strip_tags(trim($_POST['word'])); $wid = intval($_GET['w']); $replace = $_POST['replace']; DataBase::sql_query("UPDATE ".CENSORLIST_TABLE." SET `word`='$word', `replace`='$replace' 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']; $_POST['replace']=$result['replace']; $skin = array( 'action'=>'censorlist.php?mode=edit&w='.$wid, 'L.main_beam'=>$lng['edit_word'], 'L.word_name'=>$lng['word_name'], 'L.replace_to'=>$lng['replace_to'], 'L.save'=>$lng['submit'], 'L.reset'=>$lng['reset'], 'L.censorlist'=>$lng['admin_censorlist'] ); Admin_Over::GenerateHeader(); require('./template/censorlist_add_edit_body.tpl'); require('./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(); require('./template/censorlist_view_body.tpl'); if (DataBase::num_rows($query)<1) { echo '

'.$lng['no_words'].'!

'; } else { while($item = DataBase::fetch($query)) { $skin = array( 'L.word_name'=>$item['word'], 'L.word_replacement'=>$item['replace'], 'w_id'=>$item['w_id'], 'L.delete'=>$lng['delete'], 'L.edit'=>$lng['edit'], ); require('./template/censorlist_list_word.tpl'); } } require('./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(); require('./template/censorlist_main_body.tpl'); require('./template/overall_footer.tpl'); break; } default: { header('Location: censorlist.php?mode=main'); break; } } ?>