<?php
|
|
/**
|
|
* @package uForum
|
|
* @file admin/smilelist.php
|
|
* @version $Id$
|
|
* @copyright 2007-2010 (c) PioDer <[email protected]>
|
|
* @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: 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 = DataBase::fetch($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();
|
|
require('./template/smilelist_edit_body.tpl');
|
|
require('./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 = DataBase::fetch(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<count($item);$i++)
|
|
{
|
|
$subitem = @explode(" :: ",$item[$i]);
|
|
$smile_word = $subitem[0];
|
|
$smile_url = $subitem[1];
|
|
$sql = "INSERT INTO ".SMILES_TABLE." VALUES ('$sid', '$smile_word', '$smile_url')";
|
|
DataBase::sql_query($sql,GENERAL,'Could not add smile.');
|
|
$sid = $bid +1;
|
|
}
|
|
admin_message_forum($lng['smiles_added'],'smilelist.php?mode=view');
|
|
}
|
|
else
|
|
{
|
|
$_POST['file'] = '';
|
|
$skin = array(
|
|
'L.smilelist'=>$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();
|
|
require('./template/smilelist_add_file_body.tpl');
|
|
require('./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 = DataBase::fetch($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();
|
|
require('./template/smilelist_edit_body.tpl');
|
|
require('./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();
|
|
require('./template/smilelist_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['smilelist_no_items'].'!</p></td></tr></table>';
|
|
}
|
|
else
|
|
{
|
|
while($item = DataBase::fetch($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']
|
|
);
|
|
require('./template/smilelist_item_add.tpl');
|
|
}
|
|
}
|
|
require('./template/overall_footer.tpl');
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
header('Location: smilelist.php?mode=view');
|
|
break;
|
|
}
|
|
}
|
|
?>
|