function write_backup($gzdata, $backup_file_name) { $fp = fopen(LOCATION . "../backups/" . $backup_file_name, "w"); fwrite($fp, $gzdata); fclose($fp); //check folder is protected - stop HTTP access if (!file_exists(LOCATION . "../backups/.htaccess")) { $fp = fopen(LOCATION . "../backups/.htaccess", "w"); fwrite($fp, "deny from all"); fclose($fp); } delete_old_backups(); }
//change AI passwords daily. Wouldn't do to have someone get access to them. $p_pass = md5(create_rand_string(50)); dbn("update user_accounts set passwd = '{$p_pass}' where login_id = '2' || login_id = 3 || login_id = 4 || login_id = 5"); $final_str .= "\n<br />Special accounts pass changed...<br />"; //delete user history older than 3 weeks. dbn("delete from user_history where timestamp < " . time() . "-1814400"); $final_str .= "\n<br />" . mysql_affected_rows() . " old rows from the user_history deleted...<br />"; //delete posts to the central forum that are older than 3 weeks. dbn("delete from se_central_messages where timestamp < " . time() . "-1814400"); $final_str .= "\n<br />" . mysql_affected_rows() . " messages from the central forum were deleted...<br />"; print_time(); //backup the DB if requested. & delete old files if ($make_database_backups == 1) { backup_db(); print_time(); delete_old_backups($max_num_db_backups, "_db_backup"); print_time(); } //build a new index of the stylesheets directory. build_ss_index(); print_time(); dbn("update se_central_table set last_ran_s_maint = '" . time() . "'"); //print that maint was run, and how long it took. $end_time = explode(" ", microtime()); $end_time = $end_time[1] + $end_time[0]; $total_time = $end_time - $maint_time; $final_str .= "\n<p>... All done in {$total_time} seconds.<br />\n"; return 1; /******************************* Functions *********************************/ //This function will create a backup of the entire database. //it will try to compress the resulting file if it can.
$comp = true; } else { //unable to compress $ext = ".html"; $comp = false; } //open the file for outputting $fp = fopen("../{$directories['backups']}/" . DATABASE . "_maint_logs-" . date("M.d.Y") . $ext, "a+b"); if ($comp) { //compress before writing if possible $final_str = gzencode($final_str . "\n\n"); } fwrite($fp, $final_str); fclose($fp); //delete old maint logs. delete_old_backups($max_num_maint_logs, "_maint_logs"); } exit; /**************************** Functions ***********************/ /********************** * Database Functions ***********************/ //send a query to the database. function db_m($string) { global $db_maint_func_query, $database_link; $db_maint_func_query = mysql_query($string, $database_link) or mysql_die($string); } //returns associated array function db_mr() {