Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit 07e11fc

Browse files
committed
Added compatibility for PHP 7.x
1 parent 139580e commit 07e11fc

13 files changed

+3133
-2207
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/files
1+
/files
2+
schedule_backup.php

big_import.php

Lines changed: 143 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,226 @@
11
<?php
22
/*
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+
*/
2525

2626
// 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)
2828
// More Infos: http://www.ozerov.de/bigdump
2929
// License: GNU General Public License 2
3030

31-
require_once("login.php");
31+
require_once "login.php";
3232
@session_start();
3333

3434
// print html header
3535
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
3636
\"http://www.w3.org/TR/html4/loose.dtd\">
37-
<html".ARABIC_HTML.">
37+
<html" . ARABIC_HTML . ">
3838
<head>
3939
<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>
4242
</head>
4343
<body>
4444
<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n
4545
<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);
4747
echo "\n</th></tr>\n";
4848

4949
@set_time_limit($CONF['timelimit']);
5050

5151
// set parameters
52-
$linespersession=10000;
52+
$linespersession = 10000;
5353

5454
// 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+
6074
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;
6680
}
6781

6882
// connect to the database
6983
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+
7497
}
7598

7699
// open the file
77100
if (!$error && !isset($firstSession)) {
78101
// gzopen can be used for plain text too!
79-
102+
80103
// 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"];
88118
}
89119

90-
if(!$error && !$file=@gzopen($_GET["fn"],"r")) $error=C_OPEN." ".$_GET["fn"];
91120
}
92121

93122
if (!$error) {
94123
// get start time to calculate duration
95124
if (function_exists("microtime")) {
96-
$microtime=explode(" ",microtime());
97-
$starttime=($microtime[0]+$microtime[1]);
125+
$microtime = explode(" ", microtime());
126+
$starttime = ($microtime[0] + $microtime[1]);
98127
} else {
99-
$starttime=time();
100-
}
128+
$starttime = time();
129+
}
101130

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";
107140

108141
// start or continue the import process
109142
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+
}
111146

112-
// execute sql queries
147+
// execute sql queries
113148
if (!$error) {
114-
extract(PMBP_exec_sql($file,$con,$linespersession ),EXTR_OVERWRITE);
115-
}
149+
extract(PMBP_exec_sql($file, $con, $linespersession), EXTR_OVERWRITE);
150+
}
116151

117152
// get the current file position
118153
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+
121159
}
122160
}
123161

124162
// clean up
125163
if (!isset($firstSession)) {
126-
if ($con) @mysql_close();
164+
if ($con) {
165+
@mysqli_close();
166+
}
167+
127168
@gzclose($file);
128169
}
129-
170+
130171
if (!$error || isset($firstSession)) {
131172
// calculate execution duration of this session
132173
if (function_exists("microtime")) {
133-
$microtime=explode(" ",microtime());
134-
$endtime=($microtime[0]+$microtime[1]);
174+
$microtime = explode(" ", microtime());
175+
$endtime = ($microtime[0] + $microtime[1]);
135176
} else {
136-
$endtime=time();
177+
$endtime = time();
137178
}
138179

139180
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";
145186
}
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+
150194
// all sql queries executed
151195
echo "<tr><td colspan=\"2\">&nbsp;</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
154198
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+
157205
}
158206
echo "</table>\n";
159207
} else {
160208
// restart script to execute next queries
161209
echo "<tr><td colspan=\"2\">&nbsp;</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";
163211
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";
166214
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");
169217
echo "</noscript>\n";
170218
}
171-
}
219+
}
220+
}
221+
222+
if ($error) {
223+
echo "<tr><td colspan=\"2\">" . PMBP_addOutput($error, "red_left") . "</td></tr>";
172224
}
173225

174-
if ($error) echo "<tr><td colspan=\"2\">".PMBP_addOutput($error,"red_left")."</td></tr>";
175226
echo "</table></body>\n</html>";
176-
?>

0 commit comments

Comments
 (0)