Duplicate entries will not be overwritten but the default setting and other options will be updated. The file must end with either '.xml' or '.xml.gz'
" ,
$this->ipsclass->adskin->form_upload( )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "OR enter the filename of the XML settings file
The file must be uploaded into the forum's root folder
" ,
$this->ipsclass->adskin->form_input( 'file_location', 'resources/settings.xml' )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Tool To Run
";
}
$this->ipsclass->admin->output();
}
//-----------------------------------------
// Settings Update
//-----------------------------------------
function setting_update( $donothing="" )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$bounceback = str_replace( '&', '&', $this->ipsclass->input['bounceback'] );
$load_modules = array();
$db_fields = array();
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $this->ipsclass->input['id'] and ! $this->ipsclass->input['search'] )
{
$this->ipsclass->main_msg = "No ID was passed, please try again";
$this->setting_start();
}
//-----------------------------------------
// Reorder?
//-----------------------------------------
if ( isset($this->ipsclass->input['reorder']) AND $this->ipsclass->input['reorder'] )
{
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^cp_(\d+)$/", $key, $match ) )
{
if ( isset( $this->ipsclass->input[$match[0]]) )
{
$this->ipsclass->DB->do_update( 'conf_settings', array( 'conf_position' => $this->ipsclass->input[$match[0]] ), 'conf_id='.intval($match[1]) );
}
}
}
$this->ipsclass->main_msg = "Settings reordered";
$this->ipsclass->input['conf_group'] = $this->ipsclass->input['id'];
$this->setting_view();
}
//-----------------------------------------
// check...
//-----------------------------------------
$fields = explode(",", trim($this->ipsclass->input['settings_save']) );
if ( ! count($fields ) )
{
$this->ipsclass->main_msg = "No fields were passed to be saved";
$this->ipsclass->settings_view();
}
//-----------------------------------------
// Get info from DB
//-----------------------------------------
$this->ipsclass->DB->build_query( array( 'select' => 's.*',
'from' => array( 'conf_settings' => 's' ),
'where' => "conf_key IN ('".implode( "','", $fields )."')",
'add_join' => array( 0 => array( 'select' => 'c.*',
'from' => array( 'conf_settings_titles' => 'c' ),
'where' => 'c.conf_title_id=s.conf_group',
'type' => 'inner' ) ) ) );
$this->ipsclass->DB->exec_query();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
if ( $r['conf_title_module'] )
{
$load_modules[ $r['conf_title_module'] ] = $r['conf_title_module'];
}
$r['_value'] = $_POST[ $r['conf_key'] ];
$db_fields[ $r['conf_id'] ] = $r;
}
//-----------------------------------------
// Post-parse...
//-----------------------------------------
if ( is_array( $load_modules ) AND count( $load_modules ) )
{
foreach( $load_modules as $_module )
{
$_module = $this->ipsclass->txt_filename_clean( $_module );
$_name = 'setting_' . str_replace( '.php', '', $_module );
$_file = ROOT_PATH . 'sources/components_acp/setting_plugins/'.$_module;
if ( file_exists( $_file ) )
{
require_once( $_file );
$_plugin = new $_name;
$_plugin->ipsclass =& $this->ipsclass;
$db_fields = $_plugin->settings_post_parse( $db_fields );
}
}
//-----------------------------------------
// Got any errors?
//-----------------------------------------
$_error = 0;
foreach( $db_fields as $_id => $data )
{
if ( $data['_error'] )
{
$_error = 1;
break;
}
}
if ( $_error )
{
$this->setting_view( $db_fields );
return;
}
}
//-----------------------------------------
// Continue
//-----------------------------------------
foreach( $db_fields as $id => $data )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$key = $data['conf_key'];
//-----------------------------------------
// Evil eval
//-----------------------------------------
if ( $data['conf_evalphp'] )
{
if ( $this->ipsclass->hax_check_for_executable_code( $data['conf_evalphp'] ) === TRUE )
{
$this->ipsclass->main_msg = "Setting PHP code not evaluated. EVAL code contains PHP command keywords.";
}
else
{
$value = $data['_value'];
$show = 0;
$save = 1;
eval( $data['conf_evalphp'] );
$data['_value'] = $_POST[ $key ];
}
}
if ( $data['conf_type'] == 'editor' )
{
if ( ! $this->editor_loaded )
{
//-----------------------------------------
// Load and config the std/rte editors
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_editor.php" );
$this->han_editor = new han_editor();
$this->han_editor->ipsclass =& $this->ipsclass;
$this->han_editor->from_acp = 1;
$this->han_editor->init();
//-----------------------------------------
// Load and config the post parser
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$this->parser = new parse_bbcode();
$this->parser->ipsclass =& $this->ipsclass;
$this->parser->allow_update_caches = 1;
$this->parser->bypass_badwords = 1;
$this->editor_loaded = 1;
}
$data['_value'] = $this->han_editor->process_raw_post( $key );
$this->parser->parse_smilies = 1;
$this->parser->parse_html = 1;
$this->parser->parse_bbcode = 1;
$data['_value'] = $this->parser->pre_display_parse( $this->parser->pre_db_parse( $data['_value'] ) );
}
$data['_value'] = $this->ipsclass->txt_stripslashes( str_replace( "\r", "", $data['_value'] ) );
if ( ($data['_value'] != $data['conf_default']) )
{
$value = str_replace( "'", "'", $this->ipsclass->txt_stripslashes($data['_value']) );
$this->ipsclass->DB->do_update( 'conf_settings', array( 'conf_value' => $value ), 'conf_id='.$data['conf_id'] );
}
else if ( $this->ipsclass->input[ $key ] != "" and ( $this->ipsclass->input[ $key ] == $data['conf_default'] ) and $data['conf_value'] != '' )
{
$this->ipsclass->DB->do_update( 'conf_settings', array( 'conf_value' => '' ), 'conf_id='.$data['conf_id'] );
}
else if ( isset($this->ipsclass->input[ $key ]) AND empty($this->ipsclass->input[ $key ]) )
{
$this->ipsclass->DB->do_update( 'conf_settings', array( 'conf_value' => '' ), 'conf_id='.$data['conf_id'] );
}
}
$this->ipsclass->input['conf_group'] = $this->ipsclass->input['id'];
$this->ipsclass->main_msg = "Settings updated";
$this->setting_rebuildcache();
//-----------------------------------------
// We're bouncing back (Boing boing)
//-----------------------------------------
if ( $bounceback )
{
$this->ipsclass->admin->redirect_noscreen( $this->ipsclass->base_url.'&'.$bounceback );
}
//-----------------------------------------
// Still here?
//-----------------------------------------
if ( ! $donothing )
{
$this->setting_view();
}
}
//-----------------------------------------
// Settings Save Form
//-----------------------------------------
function setting_save($type='add')
{
//-----------------------------------------
// What are we doing?
//-----------------------------------------
if ( $type == 'edit' )
{
if ( ! $this->ipsclass->input['id'] )
{
$this->ipsclass->main_msg = "No ID was passed, please try again";
$this->setting_form( $type );
}
}
//-----------------------------------------
// EVAL check
//-----------------------------------------
if ( $this->ipsclass->hax_check_for_executable_code( $_POST['conf_evalphp'] ) === TRUE )
{
$this->ipsclass->main_msg = "You cannot use executable PHP function keywords such as (include, require, include_once, require_once, exec, system and passthru).";
$this->setting_form( $type );
}
//-----------------------------------------
// check...
//-----------------------------------------
$conf_group = ( isset($this->ipsclass->input['conf_newgroup']) ANd $this->ipsclass->input['conf_newgroup'] ) ? $this->ipsclass->input['conf_newgroup'] : $this->ipsclass->input['conf_group'];
$array = array( 'conf_title' => $this->ipsclass->input['conf_title'],
'conf_description' => $this->ipsclass->txt_stripslashes( $_POST['conf_description'] ),
'conf_group' => $this->ipsclass->input['conf_group'],
'conf_type' => $this->ipsclass->input['conf_type'],
'conf_key' => $this->ipsclass->input['conf_key'],
'conf_value' => $this->ipsclass->txt_stripslashes( $this->ipsclass->txt_UNhtmlspecialchars($_POST['conf_value']) ),
'conf_default' => $this->ipsclass->txt_stripslashes( $this->ipsclass->txt_UNhtmlspecialchars($_POST['conf_default']) ),
'conf_extra' => $this->ipsclass->txt_stripslashes( $_POST['conf_extra'] ),
'conf_evalphp' => ($this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group'] ) ? $this->ipsclass->txt_stripslashes( $_POST['conf_evalphp'] ) : '',
'conf_protected' => intval( $this->ipsclass->input['conf_protected'] ),
'conf_position' => intval( $this->ipsclass->input['conf_position'] ),
'conf_start_group' => $this->ipsclass->input['conf_start_group'],
'conf_end_group' => $this->ipsclass->input['conf_end_group'],
'conf_add_cache' => intval( $this->ipsclass->input['conf_add_cache'] ),
);
if ( $type == 'add' )
{
$this->ipsclass->DB->do_insert( 'conf_settings', $array );
$this->ipsclass->main_msg = 'New Setting Added';
$this->ipsclass->DB->simple_exec_query( array( 'update' => 'conf_settings_titles', 'set' => 'conf_title_count=conf_title_count+1', 'where' => 'conf_title_id='.$this->ipsclass->input['conf_group'] ) );
}
else
{
$this->ipsclass->DB->do_update( 'conf_settings', $array, 'conf_id='.intval($this->ipsclass->input['id']) );
$this->ipsclass->main_msg = 'Setting Edited';
}
$this->setting_rebuildcache();
$this->setting_view();
}
//-----------------------------------------
// Settings Revert
//-----------------------------------------
function setting_revert()
{
$this->ipsclass->input['id'] = intval($this->ipsclass->input['id']);
if ( ! $this->ipsclass->input['id'] )
{
$this->ipsclass->main_msg = "No ID was passed, please try again";
$this->setting_form();
}
$conf = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'conf_settings', 'where' => 'conf_id='.$this->ipsclass->input['id'] ) );
//-----------------------------------------
// Revert...
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'update' => 'conf_settings', 'set' => "conf_value=''", 'where' => 'conf_id='.$this->ipsclass->input['id'] ) );
$this->ipsclass->main_msg = "Configuration setting reverted back to default.";
$this->setting_rebuildcache();
$this->setting_view();
}
//-----------------------------------------
// Settings Delete
//-----------------------------------------
function setting_delete()
{
if ( ! $this->ipsclass->input['id'] )
{
$this->ipsclass->main_msg = "No ID was passed, please try again";
$this->setting_form();
}
$conf = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'conf_settings', 'where' => 'conf_id='.intval($this->ipsclass->input['id']) ) );
//-----------------------------------------
// Delete...
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'conf_settings', 'where' => 'conf_id='.intval($this->ipsclass->input['id']) ) );
$this->ipsclass->DB->simple_exec_query( array( 'update' => 'conf_settings_titles', 'set' => 'conf_title_count=conf_title_count-1', 'where' => 'conf_title_id='.$conf['conf_group'] ) );
$this->ipsclass->main_msg = "Configuration Setting Deleted";
$this->setting_rebuildcache();
$this->ipsclass->input['conf_group'] = $conf['conf_group'];
$this->setting_view();
}
//-----------------------------------------
// BBCODE Rebuild Cache
//-----------------------------------------
function setting_rebuildcache()
{
$this->ipsclass->cache['settings'] = array();
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings', 'where' => 'conf_add_cache=1' ) );
$info = $this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row($info) )
{
$value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
if ( $value == '{blank}' )
{
$value = '';
}
$this->ipsclass->cache['settings'][ $r['conf_key'] ] = $this->ipsclass->txt_stripslashes($value);
$this->ipsclass->vars[ $r['conf_key'] ] = $this->ipsclass->cache['settings'][ $r['conf_key'] ];
}
$this->ipsclass->update_cache( array( 'name' => 'settings', 'array' => 1, 'deletefirst' => 1 ) );
}
//-----------------------------------------
// Setting get cache
//-----------------------------------------
function setting_get_groups()
{
$this->setting_groups = array();
if ( IN_DEV )
{
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings_titles', 'order' => 'conf_title_title' ) );
$this->ipsclass->DB->simple_exec();
}
else
{
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings_titles', 'where' => 'conf_title_noshow=0', 'order' => 'conf_title_title' ) );
$this->ipsclass->DB->simple_exec();
}
while( $r = $this->ipsclass->DB->fetch_row() )
{
$this->setting_groups[ $r['conf_title_id'] ] = $r;
$this->setting_groups_by_key[ $r['conf_title_keyword'] ] = $r;
}
}
//-----------------------------------------
// Make drop down of available titles
//-----------------------------------------
function setting_make_dropdown()
{
if ( ! is_array( $this->setting_groups ) )
{
$this->setting_get_groups();
}
$ret = "";
}
//-----------------------------------------
// Save full text options
//-----------------------------------------
function do_fulltext()
{
$this->ipsclass->admin-> get_mysql_version();
if ( $this->ipsclass->DB->sql_can_fulltext() )
{
// How many posts do we have?
$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(*) as cnt', 'from' => 'posts' ) );
$this->ipsclass->DB->simple_exec();
$result = $this->ipsclass->DB->fetch_row();
// If over 15,000 posts...
if ( $result['cnt'] > 15000 )
{
// Explain how, why and what to do..
$this->ipsclass->admin->page_detail = "";
$this->ipsclass->admin->page_title = "Unable to continue";
$this->ipsclass->html .= $this->return_sql_no_no_cant_do_it_sorry_text();
$this->ipsclass->admin->output();
}
else
{
// Index away!
$this->ipsclass->DB->sql_add_fulltext_index( 'topics', 'title' );
$this->ipsclass->DB->sql_add_fulltext_index( 'posts' , 'post' );
}
}
else
{
$this->ipsclass->admin->error("Sorry, the version of MySQL that you are using is unable to use FULLTEXT searches");
}
$this->ipsclass->admin->save_log("Full Text Options Updated");
$query = urlencode( 'Type of search to use' );
$this->ipsclass->admin->done_screen("Full Text Indexes Rebuilt", "Full Text Settings", "{$this->ipsclass->form_code}&code=setting_view&search={$query}", "redirect" );
}
/*-------------------------------------------------------------------------*/
// Checks all the settings titles to ensure they have a key associated.
/*-------------------------------------------------------------------------*/
function setting_titles_check()
{
//-----------------------------------------
// Get 'em
//-----------------------------------------
$this->ipsclass->DB->build_query( array( 'select' => '*', 'from' => 'conf_settings_titles' ) );
$outer = $this->ipsclass->DB->exec_query();
while( $row = $this->ipsclass->DB->fetch_row( $outer ) )
{
if ( ! $row['conf_title_keyword'] )
{
$new_keyword = strtolower( preg_replace( "#[^\d\w]#", "", $row['conf_title_title'] ) );
$this->ipsclass->DB->do_update( 'conf_settings_titles', array( 'conf_title_keyword' => $new_keyword ), 'conf_title_id='.$row['conf_title_id'] );
}
}
}
//-----------------------------------------
//
// Save config. Does the hard work, so you don't have to.
//
//-----------------------------------------
/**
* @deprecated
*/
function save_config( $new )
{
$master = array();
if ( is_array($new) )
{
if ( count($new) > 0 )
{
foreach( $new as $field )
{
// Handle special..
if ($field == 'img_ext' or $field == 'avatar_ext' or $field == 'photo_ext')
{
$_POST[ $field ] = preg_replace( "/[\.\s]/", "" , $_POST[ $field ] );
$_POST[ $field ] = str_replace('|', "|", $_POST[ $field ]);
$_POST[ $field ] = preg_replace( "/,/" , '|', $_POST[ $field ] );
}
else if ($field == 'coppa_address')
{
$_POST[ $field ] = nl2br( $_POST[ $field ] );
}
if ( $field == 'gd_font' OR $field == 'html_dir' OR $field == 'upload_dir')
{
$_POST[ $field ] = str_replace( "'", "'", $_POST[ $field ] );
}
else
{
$_POST[ $field ] = str_replace( "'", "'", stripslashes($_POST[ $field ]) );
}
$master[ $field ] = stripslashes($_POST[ $field ]);
}
$this->ipsclass->admin->rebuild_config($master);
}
}
$this->ipsclass->admin->save_log("Board Settings Updated, Back Up Written");
$this->ipsclass->admin->done_screen("Forum Configurations updated", "Administration CP Home", "act=index" );
}
function return_sql_no_no_cant_do_it_sorry_text()
{
return "
Unable to automatically create the FULLTEXT indexes
You have too many posts for an automatic FULLTEXT index creation. It is more than likely that PHP will
time out before the indexes are complete which could cause some index corruption.
Creating FULLTEXT indexes is a relatively slow process but it's one that's worth doing as it will save you
a lot of time and CPU power when your members search.
On average, a normal webserver is capable of indexing about 80,000 posts an hour but it is a relatively intense process. If you
are using MySQL 4.0.12+ then this time is reduced substaintially.
How to manually create the indexes
If you have shell (SSH / Telnet) access to mysql, the process is very straightforward. If you do not have access to shell, then you will
have to contact your webhost and ask them to do this for you.
Step 1: Initiate mysql
In shell type:
mysql -u{your_sql_user_name} -p{your_sql_password}
Your MySQL username and password can be found in your conf_global.php file
Step 2: Select your database
In mysql type:
use {your_database_name_here};
Make sure you use a trailing semi-colon. Your MySQL database name can be found in conf_global.php
Step 3: Indexing the topics table
In mysql type:
alter table " . SQL_PREFIX . "topics add fulltext(title);
This query can take a while depending on the number of topics you have.
Step 4: Indexing the posts table
In mysql type:
alter table " . SQL_PREFIX . "posts add fulltext(post);
This query can take a while depending on the number of posts you have. On average MySQL can index 80,000 posts an hour. If you are using MySQL 4, the time is greatly reduced.