A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
 
 
 
 
 
 

415 lines
13 KiB

<?php
/**
* @package µForum
* @file admin/admin_scripts.php
* @version 1.0.x, 06-07-2007, 14:59
* @copyright 2008(c) PioDer <pioder@wp.pl>
* @link http://pioder.gim2przemysl.int.pl/dsf.html
* @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');
//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('./../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');
}
function AddSkins()
{
global $forum_config;
$all='';
$query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
while($t = @mysql_fetch_array($query))
{
if ($t['s_id']==$forum_config['defaultskin'])
{
$all .= '<option value="'.$t['s_id'].'" selected="selected">'.$t['name'].'</option>';
}
else
{
$all .= '<option value="'.$t['s_id'].'">'.$t['name'].'</option>';
}
}
return $all;
unset($t, $all);
}
function AddPages2($page)//for admin script, not used in limit!
{
$content = '';
for ($i=1;$i<=50;$i++)
{
if ($i==$page)
{
$content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
}
else
{
$content .= '<option value="'.$i.'">'.$i.'</option>';
}
}
return $content;
unset($content);
}
function AddLangs()
{
global $forum_config;
$result='';
$rep=opendir('./../lngs');
while ($file = readdir($rep))
{
if($file != '..' && $file !='.' && $file !='')
{
if (is_dir('./../lngs/'.$file)){
if ($file==$forum_config['defaultlang'])
{
$result .='<option value="'.$file.'" selected="selected">'.$file.'</option>';
}
else
{
$result .='<option value="'.$file.'">'.$file.'</option>';
}
}
}
}
return $result;
unset($rep, $file, $result);
}
$errors = true;
if (isset($_POST['forum_path']))
{
if (!$_POST['forum_path'])
{
$message = $lng['no_path'];
$ERROR = './template/in_error_body.tpl';
}
else
{
if ((strlen(trim($_POST['forum_name']))<3) or (strlen(trim($_POST['forum_name']))>30))
{
$message = $lng['invalid_forum_name'];
$ERROR = './template/in_error_body.tpl';
}
else
{
if ($_POST['default_skin']!='-1')
{
if ($_POST['default_lang']!='-1')
{
if($_POST['limit_tpid']!='-1')
{
if($_POST['limit_ftid']!='-1')
{
if($_POST['limit_users']!='-1')
{
if((strlen($_POST['forum_desc'])>3) or (strlen($_POST['forum_desc'])<30))
{
$errors = false;
}
else
{
$message = $lng['invalid_forum_desc'];
$ERROR = './template/in_error_body.tpl';
}
}
else
{
$message = $lng['no_limit_users'];
$ERROR = './template/in_error_body.tpl';
}
}
else
{
$message = $lng['no_limit_ftid'];
$ERROR = './template/in_error_body.tpl';
}
}
else
{
$message = $lng['no_limit_tpid'];
$ERROR = './template/in_error_body.tpl';
}
}
else
{
$message = $lng['no_lang'];
$ERROR = './template/in_error_body.tpl';
}
}
else
{
$message = $lng['no_skin'];
$ERROR = './template/in_error_body.tpl';
}
}
}
if (!$errors)
{
$name = array();
$value = array();
/* forum name */
$name[] = 'forumname';
$value[] = strip_tags($_POST['forum_name']);
/* forum description */
$name[] = 'forumdesc';
$value[] = strip_tags($_POST['forum_desc']);
/* forum path */
$name[] = 'forumpatch';
$value[] = strip_tags($_POST['forum_path']);
/* forum disabled */
$name[] = 'disable_forum';
$value[] = strip_tags($_POST['forum_disabled']);
/* default_skin */
$name[] = 'defaultskin';
$value[] = $_POST['default_skin'];
/* default lang */
$name[] = 'defaultlang';
$value[] = $_POST['default_lang'];
/* limit users */
$name[] = 'limit_users';
$value[] = $_POST['limit_users'];
/* limit posts in topic */
$name[] = 'limit_tpid';
$value[] = $_POST['limit_tpid'];
/* limit topics in forum*/
$name[] = 'limit_ftid';
$value[] = $_POST['limit_ftid'];
/* meta keywords */
$name[] = 'meta_keywords';
$value[] = strip_tags($_POST['meta_keywords']);
/* meta description */
$name[] = 'meta_description';
$value[] = strip_tags($_POST['meta_description']);
/* show queries */
$name[] = 'show_time_generation';
$value[] = (!isset($_POST['allow_time_generation'])) ? 0 : 1;
/* enable_confirms */
$name[] = 'enable_confirms';
$value[] = (!isset($_POST['enable_confirms'])) ? 0 : 1;
/* enable_confirms */
$name[] = 'ip_post_for_mod';
$value[] = (!isset($_POST['allow_ip_for_mods'])) ? 0 : 1;
/* use censorlist */
$name[] = 'use_censorlist';
$value[] = (!isset($_POST['enable_censorlist'])) ? 0 : 1;
/* enable warns */
$name[] = 'allow_warns';
$value[] = (!isset($_POST['enable_warnings'])) ? 0 : 1;
/* warns in topic */
$name[] = 'warns_in_topic';
$value[] = (!isset($_POST['warnings_in_topic'])) ? 0 : 1;
//allow_email
$name[] = 'allow_send_email';
$value[] = (!isset($_POST['enable_send_email'])) ? 0 : 1;
//allow_upload_avatars
$name[] = 'allow_upload_avatars';
$value[] = (!isset($_POST['allow_upload_avatars'])) ? 0 : 1;
/* allow shoutbox */
$name[] = 'view_shoutbox';
$value[] = (!isset($_POST['allow_shoutbox'])) ? 0 : 1;
/* shoutbox max time*/
$name[] = 'shoutbox_max_time';
$value[] = (!is_numeric($_POST['shoutbox_max_time'])) ? '14400' : $_POST['shoutbox_max_time'];
/* color mod */
$name[] = 'color_mod';
$value[] = ($_POST['color_mod']=='') ? 'green' : strip_tags($_POST['color_mod']);
/* color admin */
$name[] = 'color_admin';
$value[] = ($_POST['color_admin']=='') ? 'red' : strip_tags($_POST['color_admin']);
/* av max x */
$name[] = 'max_av_x';
$value[] = (!is_numeric($_POST['max_av_x'])) ? '150' : $_POST['max_av_x'];
/* av max y */
$name[] = 'max_av_y';
$value[] = (!is_numeric($_POST['max_av_y'])) ? '150' : $_POST['max_av_y'];
/* av max filesize */
$name[] = 'max_av_filesize';
$value[] = (!is_numeric($_POST['max_av_filesize'])) ? '102400' : ($_POST['max_av_filesize'] * 1024);
/* sig len */
$name[] = 'sig_len';
$value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
/* antiflood time */
$name[] = 'time_antiflood';
$value[] = (!is_numeric($_POST['time_antiflood'])) ? '30' : $_POST['time_antiflood'];
/* tables width */
$name[] = 'tables_width';
$value[] = (!is_numeric($_POST['tables_width'])) ? '900' : $_POST['tables_width'];
/* sig len */
$name[] = 'sig_len';
$value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
/* new password len */
$name[] = 'newpasswd_len';
$value[] = (!is_numeric($_POST['newpasswd_len'])) ? '6' : $_POST['newpasswd_len'];
/* shoutbox_max_msgs */
$name[] = 'shoutbox_max';
$value[] = (!is_numeric($_POST['shoutbox_limit'])) ? '50' : $_POST['shoutbox_limit'];
$count_o = count($name);
for($i=0;$i<$count_o;$i++)
{
$sql = "UPDATE `".CONFIG_TABLE."` SET `value`='".$value[$i]."' WHERE `name`='".$name[$i]."'";
DataBase::sql_query($sql, 'GENERAL', 'Could not update script config');
}
//end...
unset($name, $value, $count_o, $sql);
admin_message_forum($lng['forum_config_modernized'],'admin_script.php');
}
}
else
{
$ERROR='./template/blank.tpl';
}
//add skin variables
$skin = array(
'main_beam'=>$lng['scriptconfig'],
'L.submit'=>$lng['submit'],
'L.reset'=>$lng['reset'],
'L.general_preferences'=>$lng['general_preferences'],
'L.positioning'=>$lng['positioning_preferences'],
'L.other'=>$lng['other'],
'L.users'=>$lng['users_preferences'],
'L.forum_path'=>$lng['forum_path'],
'L.forum_path.D'=>$lng['t_forum_path'],
'forum_path'=>$forum_config['forumpatch'],
'L.forum_name'=>$lng['forum_name'],
'L.forum_desc'=>$lng['forum_description'],
'forum_desc'=>$forum_config['forumdesc'],
'forum_name'=>$forum_config['forumname'],
'L.forum_disabled'=>$lng['forum_disabled'],
'L.forum_disabled.D'=>$lng['t_forum_disabled'],
'forum_disabled'=>$forum_config['disable_forum'],
'L.default_skin'=>$lng['default_skin'],
'L2.default_skin'=>$lng['select_skin'],
'OPTIONS.default_skin'=>AddSkins(),
'L.default_lang'=>$lng['default_lang'],
'L2.default_lang'=>$lng['select_lang'],
'OPTIONS.default_lang'=>AddLangs(),
'L.meta_keywords'=>$lng['meta_keywords'],
'meta_keywords'=>$forum_config['meta_keywords'],
'L.meta_description'=>$lng['meta_description'],
'meta_description'=>$forum_config['meta_description'],
'L.allow'=>$lng['allow'],
'L.time_generation'=>$lng['show_time_generation'],
'OPTION.time_generation'=>($forum_config['show_time_generation']) ? 'checked="checked"' : '',
'L.enable_censorlist'=>$lng['enable_censorlist'],
'OPTION.enable_censorlist'=>($forum_config['use_censorlist']) ? 'checked="checked"' : '',
'L.enable_warnings'=>$lng['warns_enabled'],
'OPTION.enable_warnings'=>($forum_config['allow_warns']) ? 'checked="checked"' : '',
'L.allow_ip_for_mods'=>$lng['allow_ip_for_mods'],
'OPTION.allow_ip_for_mods'=>($forum_config['ip_post_for_mod']) ? 'checked="checked"' : '',
'L.warnings_in_topic'=>$lng['warns_in_topic'],
'OPTION.warnings_in_topic'=>($forum_config['warns_in_topic']) ? 'checked="checked"' : '',
'L.enable_confirms'=>$lng['enable_confirms'],
'OPTION.enable_confirms'=>($forum_config['enable_confirms']) ? 'checked="checked"' : '',
'L.enable_send_email'=>$lng['enable_send_email'],
'OPTION.enable_send_email'=>($forum_config['allow_send_email']) ? 'checked="checked"' : '',
'L.allow_upload_avatars'=>$lng['allow_upload_avatars'],
'OPTION.allow_upload_avatars'=>($forum_config['allow_upload_avatars']) ? 'checked="checked"' : '',
'L.select_value'=>$lng['select_value'],
'L.limit_users'=>$lng['limit_users'],
'OPTIONS.limit_users'=>AddPages2($forum_config['limit_users']),
'L.posts_in_topic'=>$lng['limit_posts'],
'L.scriptoptions'=>$lng['scriptconfig'],
'OPTIONS.limit_tpid'=>AddPages2($forum_config['limit_tpid']),
'L.topics_in_forum'=>$lng['limit_topics'],
'OPTIONS.limit_ftid'=>AddPages2($forum_config['limit_ftid']),
'L.admin_mod'=>$lng['admin_mod_preferences'],
'L.shoutbox'=>$lng['shoutbox_preferences'],
'L.allow_shoutbox'=>$lng['allow_shoutbox'],
'OPTION.allow_shoutbox'=>($forum_config['view_shoutbox']) ? 'checked="checked"' : '',
'L.shoutbox_max_time'=>$lng['shoutbox_time_clear'],
'OPTION.shoutbox_max_time'=>$forum_config['shoutbox_max_time'],
'L.shoutbox_limit'=>$lng['shoutbox_max_view'],
'OPTION.shoutbox_limit'=>$forum_config['shoutbox_max'],
/* color mod */
'L.color_mod'=>$lng['color_mod'],
'OPTION.color_mod' => $forum_config['color_mod'],
/* color admin */
'L.color_admin'=>$lng['color_admin'],
'OPTION.color_admin' => $forum_config['color_admin'],
/* max avatar x */
'L.max_av_x'=>$lng['max_av_x'],
'OPTION.max_av_x' => $forum_config['max_av_x'],
/* max avatar y */
'L.max_av_y'=>$lng['max_av_y'],
'OPTION.max_av_y' => $forum_config['max_av_y'],
/* max avatar filesize */
'L.max_av_filesize'=>$lng['max_av_filesize'],
'OPTION.max_av_filesize' => ($forum_config['max_av_filesize'] / 1024),
/* signature len */
'L.sig_len'=>$lng['sig_len'],
'OPTION.sig_len' => $forum_config['sig_len'],
/* antiflood time */
'L.time_antiflood'=>$lng['time_antiflood'],
'OPTION.time_antiflood' => $forum_config['time_antiflood'],
/* tables width */
'L.tables_width'=>$lng['tables_width'],
'OPTION.tables_width' => $forum_config['tables_width'],
/* new password len */
'L.newpasswd_len'=>$lng['newpasswd_len'],
'OPTION.newpasswd_len' => $forum_config['newpasswd_len'],
/* sig len */
'L.sig_len'=>$lng['sig_len'],
'OPTION.sig_len'=>$forum_config['sig_len']
);
//do it!
Admin_Over::GenerateHeader();
include('./template/admin_script.tpl');
include('./template/overall_footer.tpl');
?>