function action_update_var($blob) { log_write("debug", "file_storage", "Executing action_update_var(BLOB)"); /* Create temp file */ $temp_file = file_generate_tmpfile(); /* Write blob to disk */ if (!($fhandle = fopen($temp_file, "w"))) { log_write("error", "file_storage", "Unable to open output file '{$temp_file}' for writing."); return 0; } // write all blob data fwrite($fhandle, $blob); // close the output file fclose($fhandle); /* Process with action_update_file */ if ($this->action_update_file($temp_file)) { // clean up temp file unlink($temp_file); return $this->id; } else { unlink($temp_file); return 0; } }
admin/db_backup-process.php Access: admin only Performs export of the MySQL database, by executing mysqldump, creating temp files and then outputting the file for download. */ // includes include_once "../include/config.php"; include_once "../include/amberphplib/main.php"; if (user_permissions_get("admin")) { /* Create temp files for download */ $file_config = file_generate_tmpfile(); $file_export = file_generate_tmpfile(); /* Write authentication information into temp config file this allows us to prevent the exposure of the DB password on the CLI */ $fh = fopen($file_config, "w"); fwrite($fh, "[mysqldump]\n"); fwrite($fh, "host=" . $config["db_host"] . "\n"); fwrite($fh, "user="******"db_user"] . "\n"); fwrite($fh, "password="******"db_pass"] . "\n"); fclose($fh); /* Export Database */ $dbname = sql_get_singlevalue("SELECT DATABASE() as value"); $app_mysqldump = sql_get_singlevalue("SELECT value FROM config WHERE name='APP_MYSQL_DUMP'");