1
1
<?php
2
2
/*
3
- +--------------------------------------------------------------------------+
4
- | phpMyBackupPro |
5
- +--------------------------------------------------------------------------+
6
- | Copyright (c) 2004-2015 by Dirk Randhahn |
7
- | http://www.phpMyBackupPro.net |
8
- | version information can be found in definitions.php. |
9
- | |
10
- | This program is free software; you can redistribute it and/or |
11
- | modify it under the terms of the GNU General Public License |
12
- | as published by the Free Software Foundation; either version 2 |
13
- | of the License, or (at your option) any later version. |
14
- | |
15
- | This program is distributed in the hope that it will be useful, |
16
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
- | GNU General Public License for more details. |
19
- | |
20
- | You should have received a copy of the GNU General Public License |
21
- | along with this program; if not, write to the Free Software |
22
- | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
23
- +--------------------------------------------------------------------------+
24
- */
3
+ +--------------------------------------------------------------------------+
4
+ | phpMyBackupPro |
5
+ +--------------------------------------------------------------------------+
6
+ | Copyright (c) 2004-2015 by Dirk Randhahn |
7
+ | http://www.phpMyBackupPro.net |
8
+ | version information can be found in definitions.php. |
9
+ | |
10
+ | This program is free software; you can redistribute it and/or |
11
+ | modify it under the terms of the GNU General Public License |
12
+ | as published by the Free Software Foundation; either version 2 |
13
+ | of the License, or (at your option) any later version. |
14
+ | |
15
+ | This program is distributed in the hope that it will be useful, |
16
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
+ | GNU General Public License for more details. |
19
+ | |
20
+ | You should have received a copy of the GNU General Public License |
21
+ | along with this program; if not, write to the Free Software |
22
+ | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
23
+ +--------------------------------------------------------------------------+
24
+ */
25
25
26
26
// This code is derived from BigDump ver. 0.21b from 2005-02-08
27
- // Author: Alexey Ozerov (alexey at ozerov dot de)
27
+ // Author: Alexey Ozerov (alexey at ozerov dot de)
28
28
// More Infos: http://www.ozerov.de/bigdump
29
29
// License: GNU General Public License 2
30
30
31
- require_once ( "login.php " ) ;
31
+ require_once "login.php " ;
32
32
@session_start ();
33
33
34
34
// print html header
35
35
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN \"
36
36
\"http://www.w3.org/TR/html4/loose.dtd \">
37
- <html ". ARABIC_HTML . ">
37
+ <html " . ARABIC_HTML . ">
38
38
<head>
39
39
<meta http-equiv= \"Content-Type \" content= \"text/html;charset=utf-8 \">
40
- <link rel= \"stylesheet \" href= \"". PMBP_STYLESHEET_DIR . $ CONF ['stylesheet ' ]. ".css \" type= \"text/css \">
41
- <title>phpMyBackupPro - ". INF_INFO . "</title>
40
+ <link rel= \"stylesheet \" href= \"" . PMBP_STYLESHEET_DIR . $ CONF ['stylesheet ' ] . ".css \" type= \"text/css \">
41
+ <title>phpMyBackupPro - " . INF_INFO . "</title>
42
42
</head>
43
43
<body>
44
44
<table border= \"0 \" cellspacing= \"2 \" cellpadding= \"0 \" width= \"100% \"> \n
45
45
<tr><th colspan= \"2 \" class= \"active \"> \n" ;
46
- echo PMBP_image_tag ("logo.png " ,"phpMyBackupPro PMBP_WEBSITE " ,PMBP_WEBSITE );
46
+ echo PMBP_image_tag ("logo.png " , "phpMyBackupPro PMBP_WEBSITE " , PMBP_WEBSITE );
47
47
echo "\n</th></tr> \n" ;
48
48
49
49
@set_time_limit ($ CONF ['timelimit ' ]);
50
50
51
51
// set parameters
52
- $ linespersession= 10000 ;
52
+ $ linespersession = 10000 ;
53
53
54
54
// set some basic values on start up
55
- $ error =false ;
56
- if (!isset ($ _GET ['sn ' ])) $ _GET ['sn ' ]=0 ; else $ _GET ['sn ' ]++;
57
- if (!isset ($ _GET ['totalqueries ' ])) $ _GET ['totalqueries ' ]=0 ;
58
- if (!isset ($ _GET ['dbn ' ])) $ _GET ['dbn ' ]=" " ;
59
- if (!isset ($ _GET ['delete ' ])) $ _GET ['delete ' ]=false ;
55
+ $ error = false ;
56
+ if (!isset ($ _GET ['sn ' ])) {
57
+ $ _GET ['sn ' ] = 0 ;
58
+ } else {
59
+ $ _GET ['sn ' ]++;
60
+ }
61
+
62
+ if (!isset ($ _GET ['totalqueries ' ])) {
63
+ $ _GET ['totalqueries ' ] = 0 ;
64
+ }
65
+
66
+ if (!isset ($ _GET ['dbn ' ])) {
67
+ $ _GET ['dbn ' ] = " " ;
68
+ }
69
+
70
+ if (!isset ($ _GET ['delete ' ])) {
71
+ $ _GET ['delete ' ] = false ;
72
+ }
73
+
60
74
if (!isset ($ _GET ['start ' ]) || !isset ($ _GET ['foffset ' ])) {
61
- $ _GET ['start ' ]= $ _GET ['foffset ' ]= 0 ;
62
- $ firstSession= TRUE ;
63
- $ linenumber= 0 ;
64
- $ foffset= 0 ;
65
- $ totalqueries= 0 ;
75
+ $ _GET ['start ' ] = $ _GET ['foffset ' ] = 0 ;
76
+ $ firstSession = true ;
77
+ $ linenumber = 0 ;
78
+ $ foffset = 0 ;
79
+ $ totalqueries = 0 ;
66
80
}
67
81
68
82
// connect to the database
69
83
if (!isset ($ firstSession )) {
70
- $ con =PMBP_mysql_connect ();
71
- if (!$ con ) $ error =C_WRONG_SQL ;
72
- if (!$ error ) $ db =@mysql_select_db ($ _GET ['dbn ' ]);
73
- if (!$ db ) $ error =C_WRONG_DB ." ( " .$ _GET ['dbn ' ].") " ;
84
+ $ con = PMBP_mysql_connect ();
85
+ if (!$ con ) {
86
+ $ error = C_WRONG_SQL ;
87
+ }
88
+
89
+ if (!$ error ) {
90
+ $ db = @mysqli_select_db ($ _GET ['dbn ' ]);
91
+ }
92
+
93
+ if (!$ db ) {
94
+ $ error = C_WRONG_DB . " ( " . $ _GET ['dbn ' ] . ") " ;
95
+ }
96
+
74
97
}
75
98
76
99
// open the file
77
100
if (!$ error && !isset ($ firstSession )) {
78
101
// gzopen can be used for plain text too!
79
-
102
+
80
103
// extract zip file
81
- if (PMBP_file_info ("comp " ,$ _GET ["fn " ])=="zip " ) {
82
- include_once ("pclzip.lib.php " );
83
- $ pclzip = new PclZip ($ _GET ["fn " ]);
84
- $ extracted_file =$ pclzip ->extractByIndex (0 ,PMBP_EXPORT_DIR ,"" );
85
- if ($ pclzip ->error_code !=0 ) $ error ="plczip: " .$ pclzip ->error_string ."<br> " .BI_BROKEN_ZIP ."! " ;
86
- $ _GET ["fn " ]=substr ($ _GET ["fn " ],0 ,strlen ($ _GET ["fn " ])-4 );
87
- unset($ pclzip );
104
+ if (PMBP_file_info ("comp " , $ _GET ["fn " ]) == "zip " ) {
105
+ include_once "pclzip.lib.php " ;
106
+ $ pclzip = new PclZip ($ _GET ["fn " ]);
107
+ $ extracted_file = $ pclzip ->extractByIndex (0 , PMBP_EXPORT_DIR , "" );
108
+ if ($ pclzip ->error_code != 0 ) {
109
+ $ error = "plczip: " . $ pclzip ->error_string . "<br> " . BI_BROKEN_ZIP . "! " ;
110
+ }
111
+
112
+ $ _GET ["fn " ] = substr ($ _GET ["fn " ], 0 , strlen ($ _GET ["fn " ]) - 4 );
113
+ unset($ pclzip );
114
+ }
115
+
116
+ if (!$ error && !$ file = @gzopen ($ _GET ["fn " ], "r " )) {
117
+ $ error = C_OPEN . " " . $ _GET ["fn " ];
88
118
}
89
119
90
- if (!$ error && !$ file =@gzopen ($ _GET ["fn " ],"r " )) $ error =C_OPEN ." " .$ _GET ["fn " ];
91
120
}
92
121
93
122
if (!$ error ) {
94
123
// get start time to calculate duration
95
124
if (function_exists ("microtime " )) {
96
- $ microtime= explode (" " ,microtime ());
97
- $ starttime= ($ microtime [0 ]+ $ microtime [1 ]);
125
+ $ microtime = explode (" " , microtime ());
126
+ $ starttime = ($ microtime [0 ] + $ microtime [1 ]);
98
127
} else {
99
- $ starttime= time ();
100
- }
128
+ $ starttime = time ();
129
+ }
101
130
102
- if (file_exists ($ _GET ["fn " ].".zip " )) echo "<tr><td><div class= \"bold_left \"> " .BI_IMPORTING_FILE .":</div></td><td> " .basename ($ _GET ["fn " ]).".zip</td></tr> \n" ;
103
- else echo "<tr><td><div class= \"bold_left \"> " .BI_IMPORTING_FILE .":</div></td><td> " .basename ($ _GET ["fn " ])."</td></tr> \n" ;
104
- echo "<tr><td><div class= \"bold_left \"> " .BI_INTO_DB .":</div></td><td> " .$ _GET ["dbn " ]."</td></tr> \n" ;
105
- echo "<tr><td><div class= \"bold_left \"> " .BI_SESSION_NO .":</div></td><td> " .$ _GET ["sn " ]."</td></tr> \n" ;
106
- echo "<tr><td><div class= \"bold_left \"> " .BI_STARTING_LINE .":</div></td><td> " .$ _GET ["start " ]."</td></tr> \n" ;
131
+ if (file_exists ($ _GET ["fn " ] . ".zip " )) {
132
+ echo "<tr><td><div class= \"bold_left \"> " . BI_IMPORTING_FILE . ":</div></td><td> " . basename ($ _GET ["fn " ]) . ".zip</td></tr> \n" ;
133
+ } else {
134
+ echo "<tr><td><div class= \"bold_left \"> " . BI_IMPORTING_FILE . ":</div></td><td> " . basename ($ _GET ["fn " ]) . "</td></tr> \n" ;
135
+ }
136
+
137
+ echo "<tr><td><div class= \"bold_left \"> " . BI_INTO_DB . ":</div></td><td> " . $ _GET ["dbn " ] . "</td></tr> \n" ;
138
+ echo "<tr><td><div class= \"bold_left \"> " . BI_SESSION_NO . ":</div></td><td> " . $ _GET ["sn " ] . "</td></tr> \n" ;
139
+ echo "<tr><td><div class= \"bold_left \"> " . BI_STARTING_LINE . ":</div></td><td> " . $ _GET ["start " ] . "</td></tr> \n" ;
107
140
108
141
// start or continue the import process
109
142
if (!isset ($ firstSession )) {
110
- if (gzseek ($ file , $ _GET ["foffset " ])!=0 ) $ error ="UNEXPECTED ERROR: Can't set gzip file pointer to offset: " .$ _GET ["foffset " ];
143
+ if (gzseek ($ file , $ _GET ["foffset " ]) != 0 ) {
144
+ $ error = "UNEXPECTED ERROR: Can't set gzip file pointer to offset: " . $ _GET ["foffset " ];
145
+ }
111
146
112
- // execute sql queries
147
+ // execute sql queries
113
148
if (!$ error ) {
114
- extract (PMBP_exec_sql ($ file ,$ con ,$ linespersession ), EXTR_OVERWRITE );
115
- }
149
+ extract (PMBP_exec_sql ($ file , $ con , $ linespersession), EXTR_OVERWRITE );
150
+ }
116
151
117
152
// get the current file position
118
153
if (!$ error ) {
119
- $ foffset =gztell ($ file );
120
- if ($ foffset ===false ) $ error ="UNEXPECTED ERROR: Can't read the file pointer offset " ;
154
+ $ foffset = gztell ($ file );
155
+ if ($ foffset === false ) {
156
+ $ error = "UNEXPECTED ERROR: Can't read the file pointer offset " ;
157
+ }
158
+
121
159
}
122
160
}
123
161
124
162
// clean up
125
163
if (!isset ($ firstSession )) {
126
- if ($ con ) @mysql_close ();
164
+ if ($ con ) {
165
+ @mysqli_close ();
166
+ }
167
+
127
168
@gzclose ($ file );
128
169
}
129
-
170
+
130
171
if (!$ error || isset ($ firstSession )) {
131
172
// calculate execution duration of this session
132
173
if (function_exists ("microtime " )) {
133
- $ microtime= explode (" " ,microtime ());
134
- $ endtime= ($ microtime [0 ]+ $ microtime [1 ]);
174
+ $ microtime = explode (" " , microtime ());
175
+ $ endtime = ($ microtime [0 ] + $ microtime [1 ]);
135
176
} else {
136
- $ endtime= time ();
177
+ $ endtime = time ();
137
178
}
138
179
139
180
if (!isset ($ firstSession )) {
140
- // print information table
141
- echo "<tr><td><div class= \"bold_left \"> " . BI_STOPPING_LINE . ":</div></td><td> " . ($ linenumber- 1 ). "</td></tr> \n" ;
142
- echo "<tr><td><div class= \"bold_left \"> " . BI_QUERY_NO . "<br>( " . BI_THIS_LAST . "):</div></td><td> " . $ queries. "/ " . $ totalqueries. "</td></tr> \n" ;
143
- echo "<tr><td><div class= \"bold_left \"> " . BI_BYTE_NO . ":</div></td><td> " . round ($ foffset/ 1024 ). " KB</td></tr> \n" ;
144
- echo "<tr><td><div class= \"bold_left \"> " . BI_DURATION . ":</div></td><td> " . number_format ($ endtime- $ starttime ,3 ). " " . F_SECONDS . "</td></tr> \n" ;
181
+ // print information table
182
+ echo "<tr><td><div class= \"bold_left \"> " . BI_STOPPING_LINE . ":</div></td><td> " . ($ linenumber - 1 ) . "</td></tr> \n" ;
183
+ echo "<tr><td><div class= \"bold_left \"> " . BI_QUERY_NO . "<br>( " . BI_THIS_LAST . "):</div></td><td> " . $ queries . "/ " . $ totalqueries . "</td></tr> \n" ;
184
+ echo "<tr><td><div class= \"bold_left \"> " . BI_BYTE_NO . ":</div></td><td> " . round ($ foffset / 1024 ) . " KB</td></tr> \n" ;
185
+ echo "<tr><td><div class= \"bold_left \"> " . BI_DURATION . ":</div></td><td> " . number_format ($ endtime - $ starttime , 3 ) . " " . F_SECONDS . "</td></tr> \n" ;
145
186
}
146
-
147
- if ($ linenumber <$ _GET ["start " ]+$ linespersession && !isset ($ firstSession )) {
148
- // delete extracted zip file
149
- if (file_exists ($ _GET ["fn " ].".zip " )) @unlink ($ _GET ["fn " ]);
187
+
188
+ if ($ linenumber < $ _GET ["start " ] + $ linespersession && !isset ($ firstSession )) {
189
+ // delete extracted zip file
190
+ if (file_exists ($ _GET ["fn " ] . ".zip " )) {
191
+ @unlink ($ _GET ["fn " ]);
192
+ }
193
+
150
194
// all sql queries executed
151
195
echo "<tr><td colspan= \"2 \"> </td></tr> \n" ;
152
- echo "<tr><td colspan= \"2 \" class= \"active \"> " . PMBP_addOutput (BI_END ,"green_left " );
153
- // delete the temporary created file
196
+ echo "<tr><td colspan= \"2 \" class= \"active \"> " . PMBP_addOutput (BI_END , "green_left " );
197
+ // delete the temporary created file
154
198
if (!$ _GET ['delete ' ]) {
155
- if (file_exists ($ _GET ["fn " ].".zip " )) echo "<br>(<a href= \"" .$ _SERVER ["PHP_SELF " ]."?fn= " .$ _GET ["fn " ].".zip&dbn= " .$ _GET ['dbn ' ]."\"> " .BI_RESTART ."" .basename ($ _GET ['fn ' ]).".zip</a>)</td></tr> \n" ;
156
- else echo "<br>(<a href= \"" .$ _SERVER ["PHP_SELF " ]."?fn= " .$ _GET ["fn " ]."&dbn= " .$ _GET ['dbn ' ]."\"> " .BI_RESTART ."" .basename ($ _GET ['fn ' ])."</a>)</td></tr> \n" ;
199
+ if (file_exists ($ _GET ["fn " ] . ".zip " )) {
200
+ echo "<br>(<a href= \"" . $ _SERVER ["PHP_SELF " ] . "?fn= " . $ _GET ["fn " ] . ".zip&dbn= " . $ _GET ['dbn ' ] . "\"> " . BI_RESTART . "" . basename ($ _GET ['fn ' ]) . ".zip</a>)</td></tr> \n" ;
201
+ } else {
202
+ echo "<br>(<a href= \"" . $ _SERVER ["PHP_SELF " ] . "?fn= " . $ _GET ["fn " ] . "&dbn= " . $ _GET ['dbn ' ] . "\"> " . BI_RESTART . "" . basename ($ _GET ['fn ' ]) . "</a>)</td></tr> \n" ;
203
+ }
204
+
157
205
}
158
206
echo "</table> \n" ;
159
207
} else {
160
208
// restart script to execute next queries
161
209
echo "<tr><td colspan= \"2 \"> </td></tr> \n" ;
162
- echo "<tr><td colspan= \"2 \" class= \"active \"> " . PMBP_addOutput (BI_SCRIPT_RUNNING ,"red_left " ). "</td></tr> \n" ;
210
+ echo "<tr><td colspan= \"2 \" class= \"active \"> " . PMBP_addOutput (BI_SCRIPT_RUNNING , "red_left " ) . "</td></tr> \n" ;
163
211
echo "</table> \n" ;
164
- echo "<script language= \"JavaScript \" type= \"text/javascript \">window.setTimeout('location.href= \"" . $ _SERVER ["PHP_SELF " ]. "?fn= " . $ _GET ["fn " ];
165
- echo "&dbn= " . $ _GET ['dbn ' ]. "&delete= " . $ _GET ['delete ' ]. "&start= " . $ linenumber. "&foffset= " . $ foffset. "&totalqueries= " . $ totalqueries. "&sn= " . $ _GET ['sn ' ]. "\";',500);</script> \n" ;
212
+ echo "<script language= \"JavaScript \" type= \"text/javascript \">window.setTimeout('location.href= \"" . $ _SERVER ["PHP_SELF " ] . "?fn= " . $ _GET ["fn " ];
213
+ echo "&dbn= " . $ _GET ['dbn ' ] . "&delete= " . $ _GET ['delete ' ] . "&start= " . $ linenumber . "&foffset= " . $ foffset . "&totalqueries= " . $ totalqueries . "&sn= " . $ _GET ['sn ' ] . "\";',500);</script> \n" ;
166
214
echo "<noscript> \n" ;
167
- $ link = $ _SERVER ["PHP_SELF " ]. "?delete= " . $ _GET ['delete ' ]. "&start= " . $ linenumber. "&fn= " . $ _GET ["fn " ]. "&foffset= " . $ foffset. "&dbn= " . $ _GET ['dbn ' ]. "&totalqueries= " . $ totalqueries. "&sn= " . $ _GET ['sn ' ];
168
- echo PMBP_addOutput ("<a href= \"" . $ link. "\"> " . BI_CONTINUE . " " . $ linenumber. "</a> ( " . BI_ENABLE_JS . "!) " ,"red_left " );
215
+ $ link = $ _SERVER ["PHP_SELF " ] . "?delete= " . $ _GET ['delete ' ] . "&start= " . $ linenumber . "&fn= " . $ _GET ["fn " ] . "&foffset= " . $ foffset . "&dbn= " . $ _GET ['dbn ' ] . "&totalqueries= " . $ totalqueries . "&sn= " . $ _GET ['sn ' ];
216
+ echo PMBP_addOutput ("<a href= \"" . $ link . "\"> " . BI_CONTINUE . " " . $ linenumber . "</a> ( " . BI_ENABLE_JS . "!) " , "red_left " );
169
217
echo "</noscript> \n" ;
170
218
}
171
- }
219
+ }
220
+ }
221
+
222
+ if ($ error ) {
223
+ echo "<tr><td colspan= \"2 \"> " . PMBP_addOutput ($ error , "red_left " ) . "</td></tr> " ;
172
224
}
173
225
174
- if ($ error ) echo "<tr><td colspan= \"2 \"> " .PMBP_addOutput ($ error ,"red_left " )."</td></tr> " ;
175
226
echo "</table></body> \n</html> " ;
176
- ?>
0 commit comments