Browse code

Fixed/improved backup, added with and without UTF-8

Rainer Volkrodt authored on 2016/05/18 08:52:49
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,85 +0,0 @@
1
-<?php
2
-// ----------------------------------------------------------------------
3
-// eFiction 3.0
4
-// Copyright (c) 2007 by Tammy Keefer
5
-// Valid HTML 4.01 Transitional
6
-// Based on eFiction 1.1
7
-// Copyright (C) 2003 by Rebecca Smallwood.
8
-// http://efiction.sourceforge.net/
9
-//
10
-// Size fix / UTF-8 feature 2016-05-18
11
-// ----------------------------------------------------------------------
12
-// LICENSE
13
-//
14
-// This program is free software; you can redistribute it and/or
15
-// modify it under the terms of the GNU General Public License (GPL)
16
-// as published by the Free Software Foundation; either version 2
17
-// of the License, or (at your option) any later version.
18
-//
19
-// This program is distributed in the hope that it will be useful,
20
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
21
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
-// GNU General Public License for more details.
23
-//
24
-// To read the license please visit http://www.gnu.org/copyleft/gpl.html
25
-// ----------------------------------------------------------------------
26
-
27
-define("_BASEDIR", "../");
28
-include("../config.php");
29
-
30
-$settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
31
-$settings = dbassoc($settingsresults);
32
-foreach($settings as $var => $val) {
33
-	$$var = stripslashes($val);
34
-	$settings[$var] = htmlspecialchars($val);
35
-}
36
-if(!defined("SITEKEY")) define("SITEKEY", $settings['sitekey']);
37
-unset($settings['sitekey']);
38
-if(!defined("TABLEPREFIX")) define("TABLEPREFIX", $settings['tableprefix']);
39
-unset($settings['tableprefix']);
40
-$debug = 0;
41
-include("../languages/".$language.".php");
42
-include("../languages/".$language."_admin.php");
43
-$file_name = str_replace(" ", "_", $sitename).date("m-d-Y").".sql";
44
-header("Content-Type: text/html; charset=utf-8");
45
-Header("Content-type: application/octet-stream");
46
-Header("Content-Disposition: attachment; filename='$file_name'");
47
-
48
-session_start( );
49
-require_once("../includes/queries.php");
50
-require_once("../includes/get_session_vars.php");
51
-$debug = false;  // Because we don't want debug info mucking up our backup.
52
-
53
-if(!isADMIN) die( );
54
-
55
-// Database backup
56
-function datadump ($table) {
57
-    echo "# Dump of $table \r\n";
58
-    echo "# Dump DATE : " . date("d-M-Y") ."\r\n\r\n";
59
-
60
-    $tabledata = dbquery("SELECT * FROM $table");
61
-
62
-	while($t = dbassoc($tabledata)) {
63
-		echo "INSERT INTO ".$table." ";
64
-		$row = array( );
65
-		foreach($t AS $field => $value) {			
66
-			$value = utf8_encode (escapestring($value) );
67
-			$value = str_replace("\n","\\n",$value);
68
-			if (isset($value)) $row[$field] = "\"$value\"";
69
-			else $row[$field] = "\"\"";
70
-		}   
71
-		echo "VALUES(".implode(", ", $row).");\r\n";
72
-	}
73
-	echo "\r\n\r\n\r\n";
74
-}
75
-
76
-	$alltables = dbquery("SHOW TABLES");
77
-
78
-	while ($table = dbassoc($alltables)) {
79
-			datadump(current($table));
80
-	}
81
-
82
- 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM')");
83
-	exit( );
84
-
85
-?>
86 0
\ No newline at end of file
Browse code

Fixed/improved backup, added as mk2

Rainer Volkrodt authored on 2016/05/18 08:49:47
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,85 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+//
10
+// Size fix / UTF-8 feature 2016-05-18
11
+// ----------------------------------------------------------------------
12
+// LICENSE
13
+//
14
+// This program is free software; you can redistribute it and/or
15
+// modify it under the terms of the GNU General Public License (GPL)
16
+// as published by the Free Software Foundation; either version 2
17
+// of the License, or (at your option) any later version.
18
+//
19
+// This program is distributed in the hope that it will be useful,
20
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+// GNU General Public License for more details.
23
+//
24
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
25
+// ----------------------------------------------------------------------
26
+
27
+define("_BASEDIR", "../");
28
+include("../config.php");
29
+
30
+$settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
31
+$settings = dbassoc($settingsresults);
32
+foreach($settings as $var => $val) {
33
+	$$var = stripslashes($val);
34
+	$settings[$var] = htmlspecialchars($val);
35
+}
36
+if(!defined("SITEKEY")) define("SITEKEY", $settings['sitekey']);
37
+unset($settings['sitekey']);
38
+if(!defined("TABLEPREFIX")) define("TABLEPREFIX", $settings['tableprefix']);
39
+unset($settings['tableprefix']);
40
+$debug = 0;
41
+include("../languages/".$language.".php");
42
+include("../languages/".$language."_admin.php");
43
+$file_name = str_replace(" ", "_", $sitename).date("m-d-Y").".sql";
44
+header("Content-Type: text/html; charset=utf-8");
45
+Header("Content-type: application/octet-stream");
46
+Header("Content-Disposition: attachment; filename='$file_name'");
47
+
48
+session_start( );
49
+require_once("../includes/queries.php");
50
+require_once("../includes/get_session_vars.php");
51
+$debug = false;  // Because we don't want debug info mucking up our backup.
52
+
53
+if(!isADMIN) die( );
54
+
55
+// Database backup
56
+function datadump ($table) {
57
+    echo "# Dump of $table \r\n";
58
+    echo "# Dump DATE : " . date("d-M-Y") ."\r\n\r\n";
59
+
60
+    $tabledata = dbquery("SELECT * FROM $table");
61
+
62
+	while($t = dbassoc($tabledata)) {
63
+		echo "INSERT INTO ".$table." ";
64
+		$row = array( );
65
+		foreach($t AS $field => $value) {			
66
+			$value = utf8_encode (escapestring($value) );
67
+			$value = str_replace("\n","\\n",$value);
68
+			if (isset($value)) $row[$field] = "\"$value\"";
69
+			else $row[$field] = "\"\"";
70
+		}   
71
+		echo "VALUES(".implode(", ", $row).");\r\n";
72
+	}
73
+	echo "\r\n\r\n\r\n";
74
+}
75
+
76
+	$alltables = dbquery("SHOW TABLES");
77
+
78
+	while ($table = dbassoc($alltables)) {
79
+			datadump(current($table));
80
+	}
81
+
82
+ 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM')");
83
+	exit( );
84
+
85
+?>
0 86
\ No newline at end of file