$this->show_msg_error(__('The plugin has detected that it cannot write to the wp-config.php file. This feature can only be used if the plugin can successfully write to the wp-config.php file.','all-in-one-wp-security-and-firewall'));
}
else
{
if(isset($_POST['aiowps_enable_random_prefix']))
{//User has elected to generate a random DB prefix
echo'<p>'.__('Your WordPress DB is the most important asset of your website because it contains a lot of your site\'s precious information.','all-in-one-wp-security-and-firewall').'
$info_msg='<p><strong>'.sprintf(__('It is recommended that you perform a %s before using this feature','all-in-one-wp-security-and-firewall'),$backup_tab_link).'</strong></p>';
<spanclass="description"><?php_e('Check this if you want the plugin to generate a random 6 character string for the table prefix','all-in-one-wp-security-and-firewall');?></span>
<spanclass="description"><?php_e('Choose your own DB prefix by specifying a string which contains letters and/or numbers and/or underscores. Example: xyz_','all-in-one-wp-security-and-firewall');?></span>
</td>
</tr>
</table>
<inputtype="submit"name="aiowps_db_prefix_change"value="<?php _e('Change DB Prefix', 'all-in-one-wp-security-and-firewall')?>"class="button-primary"/>
_e('DB Backup was successfully completed! You will receive the backup file via email if you have enabled "Send Backup File Via Email", otherwise you can retrieve it via FTP from the following directory:','all-in-one-wp-security-and-firewall');
$error.='<br />'.__('You entered a non numeric value for the "backup time interval" field. It has been set to the default value.','all-in-one-wp-security-and-firewall');
$backup_frequency='4';//Set it to the default value for this field
$error.='<br />'.__('You entered a non numeric value for the "number of backup files to keep" field. It has been set to the default value.','all-in-one-wp-security-and-firewall');
$files_to_keep='2';//Set it to the default value for this field
$error.='<br />'.__('You have entered an incorrect email address format. It has been set to your WordPress admin email as default.','all-in-one-wp-security-and-firewall');
$email_address=get_bloginfo('admin_email');//Set the default value to the blog admin email
<spanclass="description"><?php_e('Check this if you want the system to automatically generate backups periodically based on the settings below','all-in-one-wp-security-and-firewall');?></span>
</td>
</tr>
<trvalign="top">
<thscope="row"><?php_e('Backup Time Interval','all-in-one-wp-security-and-firewall')?>:</th>
<spanclass="description"><?php_e('Set the value for how often you would like an automated backup to occur','all-in-one-wp-security-and-firewall');?></span>
</td>
</tr>
<trvalign="top">
<thscope="row"><?php_e('Number of Backup Files To Keep','all-in-one-wp-security-and-firewall')?>:</th>
<spanclass="description"><?php_e('Thie field allows you to choose the number of backup files you would like to keep in the backup directory','all-in-one-wp-security-and-firewall');?></span>
</td>
</tr>
<trvalign="top">
<thscope="row"><?php_e('Send Backup File Via Email','all-in-one-wp-security-and-firewall')?>:</th>
<spanclass="description"><?php_e('Check this if you want the system to email you the backup file after a DB backup has been performed','all-in-one-wp-security-and-firewall');?></span>
$result=$this->get_mysql_tables(DB_NAME);//Fix for deprecated php mysql_list_tables function
//Count the number of tables
if(is_array($result)&&count($result)>0){
$num_rows=count($result);
}else{
echo'<div class="aio_red_box"><p>'.__('Error - Could not get tables or no tables found!','all-in-one-wp-security-and-firewall').'</p></div>';
return;
}
$table_count=0;
$info_msg_string='<p class="aio_info_with_icon">'.__('Starting DB prefix change operations.....','all-in-one-wp-security-and-firewall').'</p>';
$info_msg_string.='<p class="aio_info_with_icon">'.sprintf(__('Your WordPress system has a total of %s tables and your new DB prefix will be: %s','all-in-one-wp-security-and-firewall'),'<strong>'.$num_rows.'</strong>','<strong>'.$table_new_prefix.'</strong>').'</p>';
echo'<div class="aio_red_box"><p>'.__('Failed to make a backup of the wp-config.php file. This operation will not go ahead.','all-in-one-wp-security-and-firewall').'</p></div>';
return;
}
else{
echo'<p class="aio_success_with_icon">'.__('A backup copy of your wp-config.php file was created successfully!','all-in-one-wp-security-and-firewall').'</p>';
$sql="RENAME TABLE `".$table_old_name."` TO `".$table_new_name."`";
//$sql = "RENAME TABLE %s TO %s";
//Execute the query
if(false===$wpdb->query($sql))
{
$error=1;
echo'<p class="aio_error_with_icon">'.sprintf(__('%s table name update failed','all-in-one-wp-security-and-firewall'),'<strong>'.$table_old_name.'</strong>').'</p>';
$aio_wp_security->debug_logger->log_debug("DB Security Feature - Unable to change prefix of table ".$table_old_name,4);
}else{
$table_count++;
}
}else
{
continue;
}
}
if($error==1)
{
echo'<p class="aio_error_with_icon">'.sprintf(__('Please change the prefix manually for the above tables to: %s','all-in-one-wp-security-and-firewall'),'<strong>'.$table_new_prefix.'</strong>').'</p>';
}else
{
echo'<p class="aio_success_with_icon">'.sprintf(__('%s tables had their prefix updated successfully!','all-in-one-wp-security-and-firewall'),'<strong>'.$table_count.'</strong>').'</p>';
echo'<p class="aio_error_with_icon">'.sprintf(__('Update of table %s failed: unable to change %s to %s','all-in-one-wp-security-and-firewall'),$table_new_prefix.'options',$table_old_prefix.'user_roles',$table_new_prefix.'user_roles').'</p>';
$aio_wp_security->debug_logger->log_debug("DB Security Feature - Error when updating the options table",4);//Log the highly unlikely event of DB error
}else
{
echo'<p class="aio_success_with_icon">'.sprintf(__('The options table records which had references to the old DB prefix were updated successfully!','all-in-one-wp-security-and-firewall')).'</p>';
}
//Now let's update the options tables for the multisite subsites if applicable
echo'<p class="aio_error_with_icon">'.sprintf(__('Update of table %s failed: unable to change %s to %s','all-in-one-wp-security-and-firewall'),$new_pref_and_site_id.'options',$old_pref_and_site_id.'user_roles',$new_pref_and_site_id.'user_roles').'</p>';
$aio_wp_security->debug_logger->log_debug("DB change prefix feature - Error when updating the subsite options table: ".$new_pref_and_site_id.'options',4);//Log the highly unlikely event of DB error
}else
{
echo'<p class="aio_success_with_icon">'.sprintf(__('The %s table records which had references to the old DB prefix were updated successfully!','all-in-one-wp-security-and-firewall'),$new_pref_and_site_id.'options').'</p>';
}
}
}
}
//Now let's update the user meta table
$custom_sql="SELECT user_id, meta_key
FROM" . $table_new_prefix . "usermeta
WHEREmeta_key
LIKE'" . $table_old_prefix . "%'";
$meta_keys=$wpdb->get_results($custom_sql);
$error_update_usermeta='';
//Update all meta_key field values which have the old table prefix in user_meta table
$error_update_usermeta.='<p class="aio_error_with_icon">'.sprintf(__('Error updating user_meta table where new meta_key = %s, old meta_key = %s and user_id = %s.','all-in-one-wp-security-and-firewall'),$new_meta_key,$meta_key->meta_key,$meta_key->user_id).'</p>';
echo$error_update_usermeta;
$aio_wp_security->debug_logger->log_debug("DB Security Feature - Error updating user_meta table where new meta_key = ".$new_meta_key." old meta_key = ".$meta_key->meta_key." and user_id = ".$meta_key->user_id,4);//Log the highly unlikely event of DB error
}
}
echo'<p class="aio_success_with_icon">'.__('The usermeta table records which had references to the old DB prefix were updated successfully!','all-in-one-wp-security-and-firewall').'</p>';
//Display tasks finished message
$tasks_finished_msg_string='<p class="aio_info_with_icon">'.__('DB prefix change tasks have been completed.','all-in-one-wp-security-and-firewall').'</p>';
$new_def_no_bt=str_replace("`","",$new_def);//remove any backticks because these will cause the "ALTER" command used later to fail
$view_name=$item->TABLE_NAME;
$chg_view_sql="ALTER VIEW $view_name AS $new_def_no_bt";//Note: cannot use $wpdb->prepare because it adds single quotes which cause the ALTER query to fail
$view_res=$wpdb->query($chg_view_sql);
if($view_res===false){
echo'<p class="aio_error_with_icon">'.sprintf(__('Update of the following MySQL view definition failed: %s','all-in-one-wp-security-and-firewall'),$old_def).'</p>';
$aio_wp_security->debug_logger->log_debug("Update of the following MySQL view definition failed: ".$old_def,4);//Log the highly unlikely event of DB error
}else{
$view_count++;
}
}
if($view_count>0){
echo'<p class="aio_success_with_icon">'.sprintf(__('%s view definitions were updated successfully!','all-in-one-wp-security-and-firewall'),'<strong>'.$view_count.'</strong>').'</p>';