wordmove 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/.travis.yml +1 -4
- data/.vscode/launch.json +73 -0
- data/README.mdown +21 -5
- data/lib/wordmove/assets/import.php.erb +123 -125
- data/lib/wordmove/cli.rb +2 -2
- data/lib/wordmove/deployer/base.rb +22 -20
- data/lib/wordmove/deployer/ftp.rb +1 -1
- data/lib/wordmove/deployer/ssh/default_sql_adapter.rb +47 -0
- data/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb +54 -0
- data/lib/wordmove/deployer/ssh.rb +30 -34
- data/lib/wordmove/exceptions.rb +2 -0
- data/lib/wordmove/generators/Movefile +4 -1
- data/lib/wordmove/sql_adapter/default.rb +68 -0
- data/lib/wordmove/sql_adapter/wpcli.rb +21 -0
- data/lib/wordmove/version.rb +1 -1
- data/lib/wordmove.rb +4 -1
- data/wordmove.gemspec +7 -4
- metadata +14 -12
- data/lib/wordmove/sql_adapter.rb +0 -66
@@ -7,14 +7,14 @@ if ($_GET['shared_key'] != $shared_key) {
|
|
7
7
|
|
8
8
|
error_reporting(E_ALL);
|
9
9
|
|
10
|
-
// BigDump ver. 0.
|
10
|
+
// BigDump ver. 0.36b from 2015-04-30
|
11
11
|
// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump)
|
12
12
|
// Even through the webservers with hard runtime limit and those in safe mode
|
13
|
-
// Works fine with Internet Explorer
|
13
|
+
// Works fine with latest Chrome, Internet Explorer and Firefox
|
14
14
|
|
15
|
-
// Author: Alexey Ozerov (alexey at ozerov dot de)
|
16
|
-
// AJAX & CSV functionalities: Krzysiek Herod (kr81uni at wp dot pl)
|
17
|
-
// Copyright: GPL (C) 2003-
|
15
|
+
// Author: Alexey Ozerov (alexey at ozerov dot de)
|
16
|
+
// AJAX & CSV functionalities: Krzysiek Herod (kr81uni at wp dot pl)
|
17
|
+
// Copyright: GPL (C) 2003-2015
|
18
18
|
// More Infos: http://www.ozerov.de/bigdump
|
19
19
|
|
20
20
|
// This program is free software; you can redistribute it and/or modify it under the
|
@@ -38,12 +38,8 @@ error_reporting(E_ALL);
|
|
38
38
|
|
39
39
|
// LAST CHANGES
|
40
40
|
|
41
|
-
// ***
|
42
|
-
// ***
|
43
|
-
// *** Minor fix to avoid Undefined variable curfilename notice
|
44
|
-
// *** Handle empty delimiter setting
|
45
|
-
// *** New way to determine the upload directory
|
46
|
-
// *** Set UTF8 as default connection charset
|
41
|
+
// *** Fix a typo in HTML code
|
42
|
+
// *** Change from mySQL to mySQLi
|
47
43
|
|
48
44
|
// Database configuration
|
49
45
|
|
@@ -62,7 +58,7 @@ $db_name = '<%= escape_php db[:name] %>';
|
|
62
58
|
|
63
59
|
$db_connection_charset = '<%= db[:charset] || 'utf8' %>';
|
64
60
|
|
65
|
-
// OPTIONAL SETTINGS
|
61
|
+
// OPTIONAL SETTINGS
|
66
62
|
|
67
63
|
$filename = ''; // Specify the dump filename to suppress the file selection dialog
|
68
64
|
$ajax = true; // AJAX mode: import will be done without refreshing the website
|
@@ -116,7 +112,7 @@ $upload_dir = dirname(__FILE__);
|
|
116
112
|
if ($ajax)
|
117
113
|
ob_start();
|
118
114
|
|
119
|
-
define ('VERSION','0.
|
115
|
+
define ('VERSION','0.36b');
|
120
116
|
define ('DATA_CHUNK_LENGTH',16384); // How many chars are read per time
|
121
117
|
define ('TESTMODE',false); // Set to true to process the file without actually accessing the database
|
122
118
|
define ('BIGDUMP_DIR',dirname(__FILE__));
|
@@ -136,7 +132,7 @@ if (function_exists("date_default_timezone_set") && function_exists("date_defaul
|
|
136
132
|
|
137
133
|
// Clean and strip anything we don't want from user's input [0.27b]
|
138
134
|
|
139
|
-
foreach ($_REQUEST as $key => $val)
|
135
|
+
foreach ($_REQUEST as $key => $val)
|
140
136
|
{
|
141
137
|
$val = preg_replace("/[^_A-Za-z0-9-\.&= ;\$]/i",'', $val);
|
142
138
|
$_REQUEST[$key] = $val;
|
@@ -145,10 +141,10 @@ foreach ($_REQUEST as $key => $val)
|
|
145
141
|
// Plugin handling is still EXPERIMENTAL and DISABLED
|
146
142
|
// Register plugins by including plugin_name.php from each ./plugins/plugin_name
|
147
143
|
/*
|
148
|
-
if (is_dir(PLUGIN_DIR))
|
149
|
-
{ if ($dh = opendir(PLUGIN_DIR))
|
144
|
+
if (is_dir(PLUGIN_DIR))
|
145
|
+
{ if ($dh = opendir(PLUGIN_DIR))
|
150
146
|
{
|
151
|
-
while (($file = readdir($dh)) !== false)
|
147
|
+
while (($file = readdir($dh)) !== false)
|
152
148
|
{ if (is_dir(PLUGIN_DIR.$file) && $file!='.' && $file!='..' && file_exists(PLUGIN_DIR.$file.'/'.$file.'.php'))
|
153
149
|
include (PLUGIN_DIR.$file.'/'.$file.'.php');
|
154
150
|
}
|
@@ -181,7 +177,7 @@ body
|
|
181
177
|
{ background-color:#FFFFF0;
|
182
178
|
}
|
183
179
|
|
184
|
-
h1
|
180
|
+
h1
|
185
181
|
{ font-size:20px;
|
186
182
|
line-height:24px;
|
187
183
|
font-family:Arial,Helvetica,sans-serif;
|
@@ -200,7 +196,7 @@ p,td,th
|
|
200
196
|
}
|
201
197
|
|
202
198
|
p.centr
|
203
|
-
{
|
199
|
+
{
|
204
200
|
text-align:center;
|
205
201
|
}
|
206
202
|
|
@@ -303,12 +299,12 @@ td.bgpctbar
|
|
303
299
|
|
304
300
|
<?php
|
305
301
|
|
306
|
-
function skin_open()
|
302
|
+
function skin_open()
|
307
303
|
{
|
308
304
|
echo ('<div class="skin1">');
|
309
305
|
}
|
310
306
|
|
311
|
-
function skin_close()
|
307
|
+
function skin_close()
|
312
308
|
{
|
313
309
|
echo ('</div>');
|
314
310
|
}
|
@@ -331,8 +327,8 @@ if (!$error && !function_exists('version_compare'))
|
|
331
327
|
|
332
328
|
// Check if mysql extension is available
|
333
329
|
|
334
|
-
if (!$error && !function_exists('
|
335
|
-
{ echo ("<p class=\"error\">There is no
|
330
|
+
if (!$error && !function_exists('mysqli_connect'))
|
331
|
+
{ echo ("<p class=\"error\">There is no mySQLi extension found in your PHP installation. You can use an older Bigdump version if your PHP supports mySQL extension.</p>\n");
|
336
332
|
$error=true;
|
337
333
|
}
|
338
334
|
|
@@ -355,17 +351,17 @@ else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"]))
|
|
355
351
|
$upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]);
|
356
352
|
else if (isset($_SERVER["PATH_TRANSLATED"]))
|
357
353
|
$upload_dir=dirname($_SERVER["PATH_TRANSLATED"]);
|
358
|
-
else
|
354
|
+
else
|
359
355
|
$upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
|
360
356
|
*/
|
361
|
-
|
357
|
+
|
362
358
|
do_action ('script_runs');
|
363
359
|
|
364
360
|
// Handle file upload
|
365
361
|
|
366
362
|
if (!$error && isset($_REQUEST["uploadbutton"]))
|
367
363
|
{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
|
368
|
-
{
|
364
|
+
{
|
369
365
|
$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
|
370
366
|
$uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
|
371
367
|
$uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
|
@@ -395,7 +391,7 @@ if (!$error && isset($_REQUEST["uploadbutton"]))
|
|
395
391
|
// Handle file deletion (delete only in the current directory for security reasons)
|
396
392
|
|
397
393
|
if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
|
398
|
-
{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"]))
|
394
|
+
{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"]))
|
399
395
|
echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
|
400
396
|
else
|
401
397
|
echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
|
@@ -404,24 +400,23 @@ if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SER
|
|
404
400
|
// Connect to the database, set charset and execute pre-queries
|
405
401
|
|
406
402
|
if (!$error && !TESTMODE)
|
407
|
-
{ $
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
{ echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n");
|
403
|
+
{ $mysqli = new mysqli($db_server, $db_username, $db_password, $db_name);
|
404
|
+
|
405
|
+
if (mysqli_connect_error())
|
406
|
+
{ echo ("<p class=\"error\">Database connection failed due to ".mysqli_connect_error()."</p>\n");
|
412
407
|
echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
|
413
408
|
$error=true;
|
414
409
|
}
|
415
410
|
if (!$error && $db_connection_charset!=='')
|
416
|
-
|
411
|
+
$mysqli->query("SET NAMES $db_connection_charset");
|
417
412
|
|
418
413
|
if (!$error && isset ($pre_query) && sizeof ($pre_query)>0)
|
419
414
|
{ reset($pre_query);
|
420
415
|
foreach ($pre_query as $pre_query_value)
|
421
|
-
{ if (
|
416
|
+
{ if (!$mysqli->query($pre_query_value))
|
422
417
|
{ echo ("<p class=\"error\">Error with pre-query.</p>\n");
|
423
418
|
echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n");
|
424
|
-
echo ("<p>MySQL: ".
|
419
|
+
echo ("<p>MySQL: ".$mysqli->error."</p>\n");
|
425
420
|
$error=true;
|
426
421
|
break;
|
427
422
|
}
|
@@ -440,18 +435,18 @@ do_action('database_connected');
|
|
440
435
|
// List uploaded files in multifile mode
|
441
436
|
|
442
437
|
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
443
|
-
{ if ($dirhandle = opendir($upload_dir))
|
444
|
-
{
|
438
|
+
{ if ($dirhandle = opendir($upload_dir))
|
439
|
+
{
|
445
440
|
$files=array();
|
446
441
|
while (false !== ($files[] = readdir($dirhandle)));
|
447
442
|
closedir($dirhandle);
|
448
443
|
$dirhead=false;
|
449
444
|
|
450
445
|
if (sizeof($files)>0)
|
451
|
-
{
|
446
|
+
{
|
452
447
|
sort($files);
|
453
448
|
foreach ($files as $dirfile)
|
454
|
-
{
|
449
|
+
{
|
455
450
|
if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile))
|
456
451
|
{ if (!$dirhead)
|
457
452
|
{ echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
|
@@ -478,9 +473,9 @@ if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
|
478
473
|
}
|
479
474
|
}
|
480
475
|
|
481
|
-
if ($dirhead)
|
476
|
+
if ($dirhead)
|
482
477
|
echo ("</table>\n");
|
483
|
-
else
|
478
|
+
else
|
484
479
|
echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
|
485
480
|
}
|
486
481
|
else
|
@@ -500,11 +495,11 @@ if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
|
|
500
495
|
// File Upload Form
|
501
496
|
|
502
497
|
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
503
|
-
{
|
498
|
+
{
|
504
499
|
|
505
500
|
// Test permissions on working directory
|
506
501
|
|
507
|
-
do { $tempfilename=$upload_dir.'/'.time().".tmp"; } while (file_exists($tempfilename));
|
502
|
+
do { $tempfilename=$upload_dir.'/'.time().".tmp"; } while (file_exists($tempfilename));
|
508
503
|
if (!($tempfile=@fopen($tempfilename,"w")))
|
509
504
|
{ echo ("<p>Upload form disabled. Permissions for the working directory <i>$upload_dir</i> <b>must be set writable for the webserver</b> in order ");
|
510
505
|
echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
|
@@ -512,13 +507,13 @@ if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
|
512
507
|
else
|
513
508
|
{ fclose($tempfile);
|
514
509
|
unlink ($tempfilename);
|
515
|
-
|
510
|
+
|
516
511
|
echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) ");
|
517
512
|
echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
|
518
513
|
?>
|
519
514
|
<form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
|
520
515
|
<input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize">
|
521
|
-
<p>Dump file: <input type="file" name="dumpfile" accept="*/*" size=60"></p>
|
516
|
+
<p>Dump file: <input type="file" name="dumpfile" accept="*/*" size="60"></p>
|
522
517
|
<p><input type="submit" name="uploadbutton" value="Upload"></p>
|
523
518
|
</form>
|
524
519
|
<?php
|
@@ -528,19 +523,22 @@ if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
|
528
523
|
// Print the current mySQL connection charset
|
529
524
|
|
530
525
|
if (!$error && !TESTMODE && !isset($_REQUEST["fn"]))
|
531
|
-
{
|
532
|
-
$result =
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
526
|
+
{
|
527
|
+
$result = $mysqli->query("SHOW VARIABLES LIKE 'character_set_connection';");
|
528
|
+
if ($result)
|
529
|
+
{ $row = $result->fetch_assoc();
|
530
|
+
if ($row)
|
531
|
+
{ $charset = $row['Value'];
|
532
|
+
echo ("<p>Note: The current mySQL connection charset is <i>$charset</i>. Your dump file must be encoded in <i>$charset</i> in order to avoid problems with non-latin characters. You can change the connection charset using the \$db_connection_charset variable in bigdump.php</p>\n");
|
533
|
+
}
|
534
|
+
$result->free();
|
537
535
|
}
|
538
536
|
}
|
539
537
|
|
540
538
|
// Open the file
|
541
539
|
|
542
540
|
if (!$error && isset($_REQUEST["start"]))
|
543
|
-
{
|
541
|
+
{
|
544
542
|
|
545
543
|
// Set current filename ($filename overrides $_REQUEST["fn"] if set)
|
546
544
|
|
@@ -553,7 +551,7 @@ if (!$error && isset($_REQUEST["start"]))
|
|
553
551
|
|
554
552
|
// Recognize GZip filename
|
555
553
|
|
556
|
-
if (preg_match("/\.gz$/i",$curfilename))
|
554
|
+
if (preg_match("/\.gz$/i",$curfilename))
|
557
555
|
$gzipmode=true;
|
558
556
|
else
|
559
557
|
$gzipmode=false;
|
@@ -614,24 +612,24 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
614
612
|
// Empty CSV table if requested
|
615
613
|
|
616
614
|
if (!$error && $_REQUEST["start"]==1 && $csv_insert_table != "" && $csv_preempty_table)
|
617
|
-
{
|
615
|
+
{
|
618
616
|
$query = "DELETE FROM `$csv_insert_table`";
|
619
|
-
if (!TESTMODE &&
|
617
|
+
if (!TESTMODE && !$mysqli->query(trim($query)))
|
620
618
|
{ echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n");
|
621
619
|
echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
622
|
-
echo ("<p>MySQL: ".
|
620
|
+
echo ("<p>MySQL: ".$mysqli->error."</p>\n");
|
623
621
|
$error=true;
|
624
622
|
}
|
625
623
|
}
|
626
|
-
|
624
|
+
|
627
625
|
// Print start message
|
628
626
|
|
629
627
|
if (!$error)
|
630
628
|
{ skin_open();
|
631
|
-
if (TESTMODE)
|
629
|
+
if (TESTMODE)
|
632
630
|
echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
|
633
631
|
echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
|
634
|
-
echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");
|
632
|
+
echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");
|
635
633
|
skin_close();
|
636
634
|
}
|
637
635
|
|
@@ -698,7 +696,7 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
698
696
|
|
699
697
|
$dumpline=str_replace("\r\n", "\n", $dumpline);
|
700
698
|
$dumpline=str_replace("\r", "\n", $dumpline);
|
701
|
-
|
699
|
+
|
702
700
|
// DIAGNOSTIC
|
703
701
|
// echo ("<p>Line $linenumber: $dumpline</p>\n");
|
704
702
|
|
@@ -713,7 +711,7 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
713
711
|
{ $skipline=false;
|
714
712
|
reset($comment);
|
715
713
|
foreach ($comment as $comment_value)
|
716
|
-
{
|
714
|
+
{
|
717
715
|
|
718
716
|
// DIAGNOSTIC
|
719
717
|
// echo ($comment_value);
|
@@ -733,7 +731,7 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
733
731
|
}
|
734
732
|
|
735
733
|
// Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
|
736
|
-
|
734
|
+
|
737
735
|
$dumpline_deslashed = str_replace ("\\\\","",$dumpline);
|
738
736
|
|
739
737
|
// Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter
|
@@ -747,10 +745,10 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
747
745
|
$query .= $dumpline;
|
748
746
|
|
749
747
|
// Don't count the line if in parents (text fields may include unlimited linebreaks)
|
750
|
-
|
748
|
+
|
751
749
|
if (!$inparents)
|
752
750
|
$querylines++;
|
753
|
-
|
751
|
+
|
754
752
|
// Stop if query contains more lines as defined by $max_query_lines
|
755
753
|
|
756
754
|
if ($querylines>$max_query_lines)
|
@@ -773,7 +771,7 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
773
771
|
// echo ("<p>Line: $dumpline</p>\n");
|
774
772
|
|
775
773
|
if ((preg_match('/'.preg_quote($delimiter,'/').'$/',trim($dumpline)) || $delimiter=='') && !$inparents)
|
776
|
-
{
|
774
|
+
{
|
777
775
|
|
778
776
|
// Cut off delimiter of the end of the query
|
779
777
|
|
@@ -782,10 +780,10 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
782
780
|
// DIAGNOSTIC
|
783
781
|
// echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
784
782
|
|
785
|
-
if (!TESTMODE &&
|
783
|
+
if (!TESTMODE && !$mysqli->query($query))
|
786
784
|
{ echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
|
787
785
|
echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
788
|
-
echo ("<p>MySQL: ".
|
786
|
+
echo ("<p>MySQL: ".$mysqli->error."</p>\n");
|
789
787
|
$error=true;
|
790
788
|
break;
|
791
789
|
}
|
@@ -801,7 +799,7 @@ if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_
|
|
801
799
|
// Get the current file position
|
802
800
|
|
803
801
|
if (!$error)
|
804
|
-
{ if (!$gzipmode)
|
802
|
+
{ if (!$gzipmode)
|
805
803
|
$foffset = ftell($file);
|
806
804
|
else
|
807
805
|
$foffset = gztell($file);
|
@@ -818,12 +816,12 @@ skin_open();
|
|
818
816
|
// echo ("<p class=\"centr\"><b>Statistics</b></p>\n");
|
819
817
|
|
820
818
|
if (!$error)
|
821
|
-
{
|
819
|
+
{
|
822
820
|
$lines_this = $linenumber-$_REQUEST["start"];
|
823
821
|
$lines_done = $linenumber-1;
|
824
822
|
$lines_togo = ' ? ';
|
825
823
|
$lines_tota = ' ? ';
|
826
|
-
|
824
|
+
|
827
825
|
$queries_this = $queries;
|
828
826
|
$queries_done = $totalqueries;
|
829
827
|
$queries_togo = ' ? ';
|
@@ -835,7 +833,7 @@ skin_open();
|
|
835
833
|
$kbytes_done = round($bytes_done/1024,2);
|
836
834
|
$mbytes_this = round($kbytes_this/1024,2);
|
837
835
|
$mbytes_done = round($kbytes_done/1024,2);
|
838
|
-
|
836
|
+
|
839
837
|
if (!$gzipmode)
|
840
838
|
{
|
841
839
|
$bytes_togo = $filesize-$foffset;
|
@@ -844,17 +842,17 @@ skin_open();
|
|
844
842
|
$kbytes_tota = round($bytes_tota/1024,2);
|
845
843
|
$mbytes_togo = round($kbytes_togo/1024,2);
|
846
844
|
$mbytes_tota = round($kbytes_tota/1024,2);
|
847
|
-
|
845
|
+
|
848
846
|
$pct_this = ceil($bytes_this/$filesize*100);
|
849
847
|
$pct_done = ceil($foffset/$filesize*100);
|
850
848
|
$pct_togo = 100 - $pct_done;
|
851
849
|
$pct_tota = 100;
|
852
850
|
|
853
|
-
if ($bytes_togo==0)
|
854
|
-
{ $lines_togo = '0';
|
855
|
-
$lines_tota = $linenumber-1;
|
856
|
-
$queries_togo = '0';
|
857
|
-
$queries_tota = $totalqueries;
|
851
|
+
if ($bytes_togo==0)
|
852
|
+
{ $lines_togo = '0';
|
853
|
+
$lines_tota = $linenumber-1;
|
854
|
+
$queries_togo = '0';
|
855
|
+
$queries_tota = $totalqueries;
|
858
856
|
}
|
859
857
|
|
860
858
|
$pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
|
@@ -867,14 +865,14 @@ skin_open();
|
|
867
865
|
$kbytes_tota = ' ? ';
|
868
866
|
$mbytes_togo = ' ? ';
|
869
867
|
$mbytes_tota = ' ? ';
|
870
|
-
|
868
|
+
|
871
869
|
$pct_this = ' ? ';
|
872
870
|
$pct_done = ' ? ';
|
873
871
|
$pct_togo = ' ? ';
|
874
872
|
$pct_tota = 100;
|
875
873
|
$pct_bar = str_replace(' ',' ','<tt>[ Not available for gzipped files ]</tt>');
|
876
874
|
}
|
877
|
-
|
875
|
+
|
878
876
|
echo ("
|
879
877
|
<center>
|
880
878
|
<table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
|
@@ -914,24 +912,24 @@ skin_open();
|
|
914
912
|
</form>
|
915
913
|
<!-- End Paypal donation code -->
|
916
914
|
|
917
|
-
<?php
|
915
|
+
<?php
|
918
916
|
do_action('script_finished');
|
919
917
|
$error=true; // This is a semi-error telling the script is finished
|
920
918
|
}
|
921
919
|
else
|
922
920
|
{ if ($delaypersession!=0)
|
923
921
|
echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
|
924
|
-
if (!$ajax)
|
922
|
+
if (!$ajax)
|
925
923
|
echo ("<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".urlencode($curfilename)."&foffset=$foffset&totalqueries=$totalqueries&delimiter=".urlencode($delimiter)."\";',500+$delaypersession);</script>\n");
|
926
924
|
|
927
925
|
echo ("<noscript>\n");
|
928
926
|
echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".urlencode($curfilename)."&foffset=$foffset&totalqueries=$totalqueries&delimiter=".urlencode($delimiter)."\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
|
929
927
|
echo ("</noscript>\n");
|
930
|
-
|
928
|
+
|
931
929
|
echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
|
932
930
|
}
|
933
931
|
}
|
934
|
-
else
|
932
|
+
else
|
935
933
|
echo ("<p class=\"error\">Stopped on error</p>\n");
|
936
934
|
|
937
935
|
skin_close();
|
@@ -941,13 +939,13 @@ skin_close();
|
|
941
939
|
if ($error)
|
942
940
|
echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
|
943
941
|
|
944
|
-
if ($
|
942
|
+
if ($mysqli) $mysqli->close();
|
945
943
|
if ($file && !$gzipmode) fclose($file);
|
946
944
|
else if ($file && $gzipmode) gzclose($file);
|
947
945
|
|
948
946
|
?>
|
949
947
|
|
950
|
-
<p class="centr">© 2003-
|
948
|
+
<p class="centr">© 2003-2015 <a href="mailto:alexey@ozerov.de">Alexey Ozerov</a></p>
|
951
949
|
|
952
950
|
</td></tr></table>
|
953
951
|
|
@@ -960,7 +958,7 @@ else if ($file && $gzipmode) gzclose($file);
|
|
960
958
|
|
961
959
|
// If error or finished put out the whole output from above and stop
|
962
960
|
|
963
|
-
if ($error)
|
961
|
+
if ($error)
|
964
962
|
{
|
965
963
|
$out1 = ob_get_contents();
|
966
964
|
ob_end_clean();
|
@@ -972,13 +970,13 @@ if ($error)
|
|
972
970
|
|
973
971
|
if ($ajax && isset($_REQUEST['start']))
|
974
972
|
{
|
975
|
-
if (isset($_REQUEST['ajaxrequest']))
|
973
|
+
if (isset($_REQUEST['ajaxrequest']))
|
976
974
|
{ ob_end_clean();
|
977
975
|
create_xml_response();
|
978
976
|
die;
|
979
|
-
}
|
980
|
-
else
|
981
|
-
create_ajax_script();
|
977
|
+
}
|
978
|
+
else
|
979
|
+
create_ajax_script();
|
982
980
|
}
|
983
981
|
|
984
982
|
// Anyway put out the output from above
|
@@ -993,7 +991,7 @@ ob_flush();
|
|
993
991
|
|
994
992
|
function do_action($tag)
|
995
993
|
{ global $plugin_actions;
|
996
|
-
|
994
|
+
|
997
995
|
if (isset($plugin_actions[$tag]))
|
998
996
|
{ reset ($plugin_actions[$tag]);
|
999
997
|
foreach ($plugin_actions[$tag] as $action)
|
@@ -1011,7 +1009,7 @@ function add_action($tag, $function)
|
|
1011
1009
|
// AJAX utilities
|
1012
1010
|
// *******************************************************************************************
|
1013
1011
|
|
1014
|
-
function create_xml_response()
|
1012
|
+
function create_xml_response()
|
1015
1013
|
{
|
1016
1014
|
global $linenumber, $foffset, $totalqueries, $curfilename, $delimiter,
|
1017
1015
|
$lines_this, $lines_done, $lines_togo, $lines_tota,
|
@@ -1023,7 +1021,7 @@ function create_xml_response()
|
|
1023
1021
|
|
1024
1022
|
header('Content-Type: application/xml');
|
1025
1023
|
header('Cache-Control: no-cache');
|
1026
|
-
|
1024
|
+
|
1027
1025
|
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
|
1028
1026
|
echo "<root>";
|
1029
1027
|
|
@@ -1041,63 +1039,63 @@ function create_xml_response()
|
|
1041
1039
|
echo "<elem2>$lines_done</elem2>";
|
1042
1040
|
echo "<elem3>$lines_togo</elem3>";
|
1043
1041
|
echo "<elem4>$lines_tota</elem4>";
|
1044
|
-
|
1042
|
+
|
1045
1043
|
echo "<elem5>$queries_this</elem5>";
|
1046
1044
|
echo "<elem6>$queries_done</elem6>";
|
1047
1045
|
echo "<elem7>$queries_togo</elem7>";
|
1048
1046
|
echo "<elem8>$queries_tota</elem8>";
|
1049
|
-
|
1047
|
+
|
1050
1048
|
echo "<elem9>$bytes_this</elem9>";
|
1051
1049
|
echo "<elem10>$bytes_done</elem10>";
|
1052
1050
|
echo "<elem11>$bytes_togo</elem11>";
|
1053
1051
|
echo "<elem12>$bytes_tota</elem12>";
|
1054
|
-
|
1052
|
+
|
1055
1053
|
echo "<elem13>$kbytes_this</elem13>";
|
1056
1054
|
echo "<elem14>$kbytes_done</elem14>";
|
1057
1055
|
echo "<elem15>$kbytes_togo</elem15>";
|
1058
1056
|
echo "<elem16>$kbytes_tota</elem16>";
|
1059
|
-
|
1057
|
+
|
1060
1058
|
echo "<elem17>$mbytes_this</elem17>";
|
1061
1059
|
echo "<elem18>$mbytes_done</elem18>";
|
1062
1060
|
echo "<elem19>$mbytes_togo</elem19>";
|
1063
1061
|
echo "<elem20>$mbytes_tota</elem20>";
|
1064
|
-
|
1062
|
+
|
1065
1063
|
echo "<elem21>$pct_this</elem21>";
|
1066
1064
|
echo "<elem22>$pct_done</elem22>";
|
1067
1065
|
echo "<elem23>$pct_togo</elem23>";
|
1068
1066
|
echo "<elem24>$pct_tota</elem24>";
|
1069
1067
|
echo "<elem_bar>".htmlentities($pct_bar)."</elem_bar>";
|
1070
|
-
|
1071
|
-
echo "</root>";
|
1068
|
+
|
1069
|
+
echo "</root>";
|
1072
1070
|
}
|
1073
1071
|
|
1074
1072
|
|
1075
|
-
function create_ajax_script()
|
1073
|
+
function create_ajax_script()
|
1076
1074
|
{
|
1077
1075
|
global $linenumber, $foffset, $totalqueries, $delaypersession, $curfilename, $delimiter;
|
1078
1076
|
?>
|
1079
1077
|
|
1080
|
-
<script type="text/javascript" language="javascript">
|
1078
|
+
<script type="text/javascript" language="javascript">
|
1081
1079
|
|
1082
1080
|
// creates next action url (upload page, or XML response)
|
1083
1081
|
function get_url(linenumber,fn,foffset,totalqueries,delimiter) {
|
1084
1082
|
return "<?php echo $_SERVER['PHP_SELF'] ?>?start="+linenumber+"&fn="+fn+"&foffset="+foffset+"&totalqueries="+totalqueries+"&delimiter="+delimiter+"&ajaxrequest=true";
|
1085
1083
|
}
|
1086
|
-
|
1084
|
+
|
1087
1085
|
// extracts text from XML element (itemname must be unique)
|
1088
1086
|
function get_xml_data(itemname,xmld) {
|
1089
1087
|
return xmld.getElementsByTagName(itemname).item(0).firstChild.data;
|
1090
1088
|
}
|
1091
|
-
|
1089
|
+
|
1092
1090
|
function makeRequest(url) {
|
1093
1091
|
http_request = false;
|
1094
|
-
if (window.XMLHttpRequest) {
|
1092
|
+
if (window.XMLHttpRequest) {
|
1095
1093
|
// Mozilla etc.
|
1096
1094
|
http_request = new XMLHttpRequest();
|
1097
1095
|
if (http_request.overrideMimeType) {
|
1098
1096
|
http_request.overrideMimeType("text/xml");
|
1099
1097
|
}
|
1100
|
-
} else if (window.ActiveXObject) {
|
1098
|
+
} else if (window.ActiveXObject) {
|
1101
1099
|
// IE
|
1102
1100
|
try {
|
1103
1101
|
http_request = new ActiveXObject("Msxml2.XMLHTTP");
|
@@ -1115,54 +1113,54 @@ function create_ajax_script()
|
|
1115
1113
|
http_request.open("GET", url, true);
|
1116
1114
|
http_request.send(null);
|
1117
1115
|
}
|
1118
|
-
|
1119
|
-
function server_response()
|
1116
|
+
|
1117
|
+
function server_response()
|
1120
1118
|
{
|
1121
1119
|
|
1122
1120
|
// waiting for correct response
|
1123
1121
|
if (http_request.readyState != 4)
|
1124
1122
|
return;
|
1125
1123
|
|
1126
|
-
if (http_request.status != 200)
|
1124
|
+
if (http_request.status != 200)
|
1127
1125
|
{
|
1128
1126
|
alert("Page unavailable, or wrong url!")
|
1129
1127
|
return;
|
1130
1128
|
}
|
1131
|
-
|
1129
|
+
|
1132
1130
|
// r = xml response
|
1133
1131
|
var r = http_request.responseXML;
|
1134
|
-
|
1132
|
+
|
1135
1133
|
//if received not XML but HTML with new page to show
|
1136
|
-
if (!r || r.getElementsByTagName('root').length == 0)
|
1134
|
+
if (!r || r.getElementsByTagName('root').length == 0)
|
1137
1135
|
{ var text = http_request.responseText;
|
1138
1136
|
document.open();
|
1139
|
-
document.write(text);
|
1140
|
-
document.close();
|
1141
|
-
return;
|
1137
|
+
document.write(text);
|
1138
|
+
document.close();
|
1139
|
+
return;
|
1142
1140
|
}
|
1143
|
-
|
1141
|
+
|
1144
1142
|
// update "Starting from line: "
|
1145
|
-
document.getElementsByTagName('p').item(1).innerHTML =
|
1146
|
-
"Starting from line: " +
|
1143
|
+
document.getElementsByTagName('p').item(1).innerHTML =
|
1144
|
+
"Starting from line: " +
|
1147
1145
|
r.getElementsByTagName('linenumber').item(0).firstChild.nodeValue;
|
1148
|
-
|
1146
|
+
|
1149
1147
|
// update table with new values
|
1150
1148
|
for(i = 1; i <= 24; i++)
|
1151
1149
|
document.getElementsByTagName('td').item(i).firstChild.data = get_xml_data('elem'+i,r);
|
1152
|
-
|
1150
|
+
|
1153
1151
|
// update color bar
|
1154
|
-
document.getElementsByTagName('td').item(25).innerHTML =
|
1152
|
+
document.getElementsByTagName('td').item(25).innerHTML =
|
1155
1153
|
r.getElementsByTagName('elem_bar').item(0).firstChild.nodeValue;
|
1156
|
-
|
1157
|
-
// action url (XML response)
|
1154
|
+
|
1155
|
+
// action url (XML response)
|
1158
1156
|
url_request = get_url(
|
1159
1157
|
get_xml_data('linenumber',r),
|
1160
1158
|
get_xml_data('fn',r),
|
1161
1159
|
get_xml_data('foffset',r),
|
1162
1160
|
get_xml_data('totalqueries',r),
|
1163
1161
|
get_xml_data('delimiter',r));
|
1164
|
-
|
1165
|
-
// ask for XML response
|
1162
|
+
|
1163
|
+
// ask for XML response
|
1166
1164
|
window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
|
1167
1165
|
}
|
1168
1166
|
|