<?php
// +----------------------------------------------------------------------+
// | Fantastic File Database |
// +----------------------------------------------------------------------+
// | By Tony Baird |
// | Copyright (c) 2003 Fantastic Scripts |
// | http://fscripts.com |
// +----------------------------------------------------------------------+
// | Fantastic File Database Can be modified freely as long as copyright |
// | is intact and this is left at the top of every source file |
// +----------------------------------------------------------------------+
// | settings.php |
// | Date Started: March 15, 2003 |
// | Last Modified: March 15, 2003 |
// +----------------------------------------------------------------------+
Class Settings {
//*************************************************/
// Just seing what we are doing
//*************************************************/
function Settings() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin,$admin_skin;
if ($_REQUEST['action']=="change_settings") {
$this->ChangeSettings();
}elseif (isset($_REQUEST['update_settings'])) {
$this->UpdateSettings();
}
}
//*************************************************/
// Change Settings Page
//*************************************************/
function ChangeSettings() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin;
$settings_values=Array (
'mysql_username'=>$CONFIG['mysql_username'],
'mysql_password'=>$CONFIG['mysql_password'],
'mysql_db'=>$CONFIG['mysql_db'],
'mysql_host'=>$CONFIG['mysql_host'],
'archive_name'=>$CONFIG['archive_name'],
'script_url'=>$CONFIG['script_url'],
'time_offset'=>$CONFIG['time_offset'],
'date_format'=>$CONFIG['date_format'],
'files_per_page'=>$CONFIG['files_per_page'],
'files_path'=>$CONFIG['files_path'],
'files_url'=>$CONFIG['files_url'],
'images_path'=>$CONFIG['images_path'],
'images_url'=>$CONFIG['images_url'],
'online_time'=>$CONFIG['online_time'],
'default_skin'=>$CONFIG['default_skin'],
'user_selectable_skins'=>$CONFIG['user_selectable_skins'],
'guest_id'=>$CONFIG['guest_id'],
'default_user_title'=>$CONFIG['default_user_title'],
'cookie_time'=>$CONFIG['cookie_time'],
'email'=>$CONFIG['email'],
'allow_email'=>$CONFIG['allow_email'],
'mail_method'=>$CONFIG['mail_method'],
'script_dir'=>$CONFIG['script_dir'],
'flood_time'=>$CONFIG['flood_time'],
'members_per_page'=>$CONFIG['members_per_page'],
'memberlist_date_format'=>$CONFIG['memberlist_date_format'],
'templates_path'=>$CONFIG['templates_path']
);
// The name of the setting
$settings_names=Array (
'mysql_username'=>"MySQL Username",
'mysql_password'=>"MySQL Password",
'mysql_db'=>"MySQL Database",
'mysql_host'=>"MySQL Host",
'archive_name'=>"Archive Name",
'script_url'=>"Script Url",
'time_offset'=>"Time Offset",
'date_format'=>"Date Format",
'files_per_page'=>"Files Per Page",
'files_path'=>"Files Path",
'files_url'=>"Files Url",
'images_path'=>"Images Path",
'images_url'=>"Images Url",
'online_time'=>"Online Time",
'default_skin'=>"Default Skin",
'user_selectable_skins'=>"User Selectable Skins",
'guest_id'=>"Guest ID",
'default_user_title'=>"Default User Title",
'cookie_time'=>"Cookie Time",
'email'=>"Mailer Email",
'allow_email'=>"Allow Emails",
'mail_method'=>"Mail Method",
'script_dir'=>"Script Directory",
'flood_time'=>"Flood Time",
'members_per_page'=>"Members Per Page",
'memberlist_date_format'=>"Memberlist Date Format",
'templates_path'=>"Templates Path"
);
// Explanation for each setting
$settings_explanation=Array (
'mysql_username'=>"Username for your MySQL Database",
'mysql_password'=>"Password for the username for your MySQL Database",
'mysql_db'=>"MySQL Database where all FFDB data is stored",
'mysql_host'=>"MySQL Host which is usually localhost",
'archive_name'=>"Name of your files archive",
'script_url'=>"Url to the script for example http://mysite.com/ffdb/",
'time_offset'=>"Offset time compared to your server's time",
'date_format'=>"Format for dates in FFDB",
'files_per_page'=>"Number of files per page",
'files_path'=>"Path where files that are uploaded are stored",
'files_url'=>"Url to the files that are uploaded",
'images_path'=>"Path where images that are uploaded are stored",
'images_url'=>"Url to the images that are uploaded",
'online_time'=>"How long a user will stay on the online list",
'default_skin'=>"Default skin if the user is a guest or the member hasn't selected their own skin this is based on skin id #",
'user_selectable_skins'=>"If set to yes the user can use any skins you have added to FFDB",
'guest_id'=>"Guest ID# only edit this if you are an advance user for the most part the id# is 1",
'default_user_title'=>"The default user title users are given if they leave it blank",
'cookie_time'=>"Time until a users cookie expires",
'email'=>"The email that sends out all mailings from FFDB",
'allow_email'=>"Allow users to use the mailing features of FFDB",
'mail_method'=>"Method in which you want to send your emails. Currently only sendmail is supported",
'script_dir'=>"Directory where the script resides",
'flood_time'=>"The time a user must wait until they can post another comment",
'members_per_page'=>"Number of members that will be listed per page on the members list page",
'memberlist_date_format'=>"Memberlists date format",
'templates_path'=>"Path to where the templates directory is"
);
// Setting up our settings template
$tpl->LoadTemplate("settings_list","Admin/templates/$admin_skin/settings_list.tpl");
// Sets up a nice looking page for the settings
foreach ($settings_names as $k => $v) {
$settings_list_array=Array(
'setting_name'=>$v,
'setting_value'=>$settings_values[$k],
'setting_explanation'=>$settings_explanation[$k],
'setting_form_name'=>$k
);
$tpl->ParseTemplate("settings_list",$settings_list_array,"Yes");
}
$tpl->LoadTemplate("settings_list_top","Admin/templates/$admin_skin/settings_list_top.tpl");
$tpl->ParseTemplate("settings_list_top",$settings_list_top_array,"No");
$tpl->PrintTemplate("settings_list_top");
$tpl->PrintTemplate("settings_list");
$tpl->LoadTemplate("settings_list_bottom","Admin/templates/$admin_skin/settings_list_bottom.tpl");
$tpl->ParseTemplate("settings_list_bottom",$settings_list_bottom_array,"No");
$tpl->PrintTemplate("settings_list_bottom");
}
function UpdateSettings() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
$settings_values=Array (
'mysql_username'=>$_POST['mysql_username'],
'mysql_password'=>$_POST['mysql_password'],
'mysql_db'=>$_POST['mysql_db'],
'mysql_host'=>$_POST['mysql_host'],
'archive_name'=>$_POST['archive_name'],
'script_url'=>$_POST['script_url'],
'time_offset'=>$_POST['time_offset'],
'date_format'=>$_POST['date_format'],
'files_per_page'=>$_POST['files_per_page'],
'files_path'=>$_POST['files_path'],
'files_url'=>$_POST['files_url'],
'images_path'=>$_POST['images_path'],
'images_url'=>$_POST['images_url'],
'online_time'=>$_POST['online_time'],
'default_skin'=>$_POST['default_skin'],
'user_selectable_skins'=>$_POST['user_selectable_skins'],
'guest_id'=>$_POST['guest_id'],
'default_user_title'=>$_POST['default_user_title'],
'cookie_time'=>$_POST['cookie_time'],
'email'=>$_POST['email'],
'allow_email'=>$_POST['allow_email'],
'mail_method'=>$_POST['mail_method'],
'script_dir'=>$_POST['script_dir'],
'flood_time'=>$_POST['flood_time'],
'members_per_page'=>$_POST['members_per_page'],
'memberlist_date_format'=>$_POST['memberlist_date_format'],
'templates_path'=>$_POST['templates_path']
);
$ffdb->strip_array($settings_values);
$this->WriteConfig($settings_values);
$admin->Success("Config File Written to Successfully");
}
//*************************************************/
// Writes to Config File
//*************************************************/
function WriteConfig($array) {
// My nice big copyright thing :)
$new_settings ="<?php\n// +----------------------------------------------------------------------+\n// | Fantastic File Database |\n// +----------------------------------------------------------------------+\n// | By Tony Baird |\n// | Copyright (c) 2003 Fantastic Scripts |\n// | http://fscripts.com |\n// +----------------------------------------------------------------------+\n// | Fantastic File Database Can be modified freely as long as copyright |\n// | is intact and this is left at the top of every source file |\n// +----------------------------------------------------------------------+\n// | config.php |\n// | Date Started: February 18, 2003 |\n// | Last Modified: February 28, 2003 |\n// +----------------------------------------------------------------------+\n";
// Making the config files nice list thing
foreach ($array as $k => $v) {
$new_settings .='$CONFIG[\''.$k."']=\"".$v."\";\n";
}
$new_settings .="\n?>";
if ($config_file=fopen("config.php","w+")) {
if(!fwrite($config_file,$new_settings)) {
$admin->Error("Failed to write to config file");
}
} else {
$admin->Error("Failed to open config file");
}
}
}
?>