* @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/class_db.php'); include('./../includes/class_error.php'); include('./../includes/classes/class_pms.php'); //connect to database DataBase::db_connect(); include('./../includes/sessions.php'); include('./../includes/class_user.php'); include('./../common.php'); include('./../includes/admin/class_main.php'); include('./../includes/class_forum.php'); include('./../includes/admin/class_forum.php'); include('./../includes/classes/secure.php'); include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php'); sess_del_invalid($_SESSION['uid']); sess_register($_SESSION['uid']); sess_delete_old(); if (User::UserInformation($_SESSION['uid'],'rank')!=2) { admin_message_forum($lng['yournotadmin'],'../index.php'); } if (!isset($_GET['mode'])) { header('Location: smilelist.php?mode=view'); } switch($_GET['mode']) { case 'add': { switch($_GET['submode']) { //add one smile case 'one': { if (isset($_POST['word'],$_POST['url'])) { $sql = "SELECT * FROM ".SMILES_TABLE." ORDER BY `s_id` DESC LIMIT 1"; $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain smilelist item information'); $result = @mysql_fetch_array($query); $smile_id = $result['s_id']; $smile_id = $smile_id +1; $smile_word = strip_tags($_POST['word']); $smile_url = strip_tags($_POST['url']); $sql = "INSERT INTO ".SMILES_TABLE." VALUES('$smile_id','$smile_word','$smile_url')"; DataBase::sql_query($sql,'GENERAL','Could not add smile.'); admin_message_forum($lng['smile_added'],'smilelist.php?mode=view'); } else { $_POST['word']=''; $_POST['url'] = ''; $skin = array( 'L.smilelist'=>$lng['admin_smilelist'], 'action'=>'smilelist.php?mode=add&submode=one', 'L.edit_smile'=>$lng['smilelist_add'], 'L.smile'=>$lng['smile'], 'L.url' => $lng['url'], 'L.save'=>$lng['submit'], 'L.clear'=>$lng['reset'] ); Admin_Over::GenerateHeader(); include('./template/smilelist_edit_body.tpl'); include('./template/overall_footer.tpl'); } break; } //add smiles with file case 'file': { if (isset($_FILES['file'],$_POST['motive'])) { $ban_uid = '-2'; $ban_motive = strip_tags($_POST['motive']); $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("\n",$file); $bid = $bid = @mysql_fetch_array(DataBase::sql_query("SELECT `s_id` FROM ".SMILES_TABLE." ORDER BY `s_id` DESC",'GENERAL', 'Could not obtain last smile id')); $sid = $sid['s_id']; $sid = $sid +1; for($i=0;$i$lng['admin_smilelist'], 'action'=>'smilelist.php?mode=add&submode=file', 'L.add_file'=>$lng['smilelist_add_from_file'], 'L.file_name'=>$lng['file_name'], 'L.save'=>$lng['submit'], 'L.clear'=>$lng['reset'], 'L.file.HELP' => $lng['smilelist_info_1'] ); Admin_Over::GenerateHeader(); include('./template/smilelist_add_file_body.tpl'); include('./template/overall_footer.tpl'); } break; } } break; } case 'delete': { $sid = $_GET['id']; $sql = "DELETE FROM ".SMILES_TABLE." WHERE `s_id`='$sid'"; DataBase::sql_query($sql,'GENERAL','Could not delete smilelist item.'); admin_message_forum($lng['smile_deleted'],'smilelist.php?mode=view'); break; } case 'edit': { if (isset($_POST['word'],$_POST['url'],$_GET['id'])) { $smile_id = strip_tags($_GET['id']); $smile_word = strip_tags($_POST['word']); $smile_url = strip_tags($_POST['url']); $bid = $_GET['id']; $sql = "UPDATE ".SMILES_TABLE." SET `smile`='$smile_word', `url`='$smile_url' WHERE `s_id`='$smile_id'"; DataBase::sql_query($sql,'GENERAL','Could not update smile.'); admin_message_forum($lng['smile_edited'],'smilelist.php?mode=view'); } else { $sid = intval($_GET['id']); $sql = "SELECT * FROM ".SMILES_TABLE." WHERE `s_id`='$sid'"; $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain smilelist item information'); $result = @mysql_fetch_array($query); if ($result['s_id']=='') { admin_message_forum($lng['no_smile'],'smilelist.php?mode=view'); } $_POST['word']=$result['smile']; $_POST['url'] = $result['url']; $skin = array( 'L.smilelist'=>$lng['admin_smilelist'], 'action'=>'smilelist.php?mode=edit&id='.$sid, 'L.edit_smile'=>$lng['smilelist_edit'], 'L.smile'=>$lng['smile'], 'L.url' => $lng['url'], 'L.save'=>$lng['submit'], 'L.clear'=>$lng['reset'] ); Admin_Over::GenerateHeader(); include('./template/smilelist_edit_body.tpl'); include('./template/overall_footer.tpl'); } break; } case 'clear': { $sql = "TRUNCATE `".SMILES_TABLE."`"; DataBase::sql_query($sql, 'GENERAL','Could not empty smilelist'); admin_message_forum($lng['smilelist_cleanout'],'smilelist.php?mode=view'); } case 'view': { $sql = "SELECT * FROM ".SMILES_TABLE.""; $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain smilelist items'); $skin=array( 'L.smilelist'=>$lng['admin_smilelist'], 'L.select_mode'=>$lng['what_do_you_want'], 'L.add'=>$lng['smilelist_add'], 'L.add_file'=>$lng['smilelist_add_from_file'], 'L.clean_smilelist' => $lng['smilelist_clean'] ); Admin_Over::GenerateHeader(); include('./template/smilelist_view_body.tpl'); if (@mysql_num_rows($query)<1) { echo '

'.$lng['smilelist_no_items'].'!

'; } else { while($item = @mysql_fetch_array($query)) { $skin = array( 'smile_word'=>$item['smile'], 'addr'=> $item['url'], 'visual_smile' => $item['url'], 's_id'=>$item['s_id'], 'L.delete'=>$lng['delete'], 'L.edit'=>$lng['edit'] ); include('./template/smilelist_item_add.tpl'); } } include('./template/overall_footer.tpl'); break; } default: { header('Location: smilelist.php?mode=view'); break; } } ?>