wordmove 1.3.0.pre2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.mdown +5 -0
- data/Rakefile +2 -4
- data/assets/images/wordmove.png +0 -0
- data/bin/console +10 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +7 -0
- data/exe/wordmove +6 -0
- data/lib/wordmove.rb +25 -0
- data/lib/wordmove/assets/dump.php.erb +202 -165
- data/lib/wordmove/assets/import.php.erb +1179 -1080
- data/lib/wordmove/cli.rb +18 -18
- data/lib/wordmove/deployer/base.rb +30 -32
- data/lib/wordmove/deployer/ftp.rb +3 -7
- data/lib/wordmove/deployer/ssh.rb +3 -5
- data/lib/wordmove/exceptions.rb +6 -0
- data/lib/wordmove/generators/movefile.rb +0 -3
- data/lib/wordmove/generators/movefile_adapter.rb +3 -4
- data/lib/wordmove/logger.rb +0 -5
- data/lib/wordmove/version.rb +1 -1
- data/wordmove.gemspec +34 -38
- metadata +91 -75
- data/bin/wordmove +0 -6
- data/lib/wordmove/core_ext.rb +0 -11
- data/spec/deployer/base_spec.rb +0 -85
- data/spec/features/movefile_spec.rb +0 -59
- data/spec/fixtures/Movefile +0 -23
- data/spec/fixtures/wp-config.php +0 -90
- data/spec/spec_helper.rb +0 -22
- data/spec/sql_adapter_spec.rb +0 -163
@@ -1,1080 +1,1179 @@
|
|
1
|
-
<?php
|
2
|
-
|
3
|
-
$shared_key = '<%= password %>';
|
4
|
-
if ($_GET['shared_key'] != $shared_key) {
|
5
|
-
die();
|
6
|
-
}
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
//
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
//
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
//
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
//
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
//
|
43
|
-
//
|
44
|
-
|
45
|
-
|
46
|
-
//
|
47
|
-
|
48
|
-
//
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
$
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
//
|
68
|
-
//
|
69
|
-
//
|
70
|
-
|
71
|
-
if
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
{
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
}
|
201
|
-
|
202
|
-
|
203
|
-
{
|
204
|
-
text-align:
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
$
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
}
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
$
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
$error=true;
|
489
|
-
}
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
$
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
if (
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
$
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
//
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
//
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
if (!$
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
if ($
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
// DIAGNOSTIC
|
703
|
-
// echo ("<p>
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
$
|
715
|
-
$
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
</
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
echo "<
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
echo
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1
|
+
<?php
|
2
|
+
|
3
|
+
$shared_key = '<%= password %>';
|
4
|
+
if ($_GET['shared_key'] != $shared_key) {
|
5
|
+
die();
|
6
|
+
}
|
7
|
+
|
8
|
+
error_reporting(E_ALL);
|
9
|
+
|
10
|
+
// BigDump ver. 0.35b from 2012-12-26
|
11
|
+
// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump)
|
12
|
+
// Even through the webservers with hard runtime limit and those in safe mode
|
13
|
+
// Works fine with Internet Explorer 7.0 and Firefox 2.x
|
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-2013
|
18
|
+
// More Infos: http://www.ozerov.de/bigdump
|
19
|
+
|
20
|
+
// This program is free software; you can redistribute it and/or modify it under the
|
21
|
+
// terms of the GNU General Public License as published by the Free Software Foundation;
|
22
|
+
// either version 2 of the License, or (at your option) any later version.
|
23
|
+
|
24
|
+
// THIS SCRIPT IS PROVIDED AS IS, WITHOUT ANY WARRANTY OR GUARANTEE OF ANY KIND
|
25
|
+
|
26
|
+
// USAGE
|
27
|
+
|
28
|
+
// 1. Adjust the database configuration and charset in this file
|
29
|
+
// 2. Remove the old tables on the target database if your dump doesn't contain "DROP TABLE"
|
30
|
+
// 3. Create the working directory (e.g. dump) on your web server
|
31
|
+
// 4. Upload bigdump.php and your dump files (.sql, .gz) via FTP to the working directory
|
32
|
+
// 5. Run the bigdump.php from your browser via URL like http://www.yourdomain.com/dump/bigdump.php
|
33
|
+
// 6. BigDump can start the next import session automatically if you enable the JavaScript
|
34
|
+
// 7. Wait for the script to finish, do not close the browser window
|
35
|
+
// 8. IMPORTANT: Remove bigdump.php and your dump files from the web server
|
36
|
+
|
37
|
+
// If Timeout errors still occure you may need to adjust the $linepersession setting in this file
|
38
|
+
|
39
|
+
// LAST CHANGES
|
40
|
+
|
41
|
+
// *** First ideas about adding plugin interface
|
42
|
+
// *** Fix // delimiter bug
|
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
|
47
|
+
|
48
|
+
// Database configuration
|
49
|
+
|
50
|
+
$db_port = '<%= db[:port] %>';
|
51
|
+
if (!$db_port) {
|
52
|
+
$db_port = ini_get("mysqli.default_port");
|
53
|
+
}
|
54
|
+
$db_server = '<%= escape_php db[:host] %>:' . $db_port;
|
55
|
+
$db_username = '<%= escape_php db[:user] %>';
|
56
|
+
$db_password = '<%= escape_php db[:password] %>';
|
57
|
+
$db_name = '<%= escape_php db[:name] %>';
|
58
|
+
|
59
|
+
// Connection charset should be the same as the dump file charset (utf8, latin1, cp1251, koi8r etc.)
|
60
|
+
// See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html for the full list
|
61
|
+
// Change this if you have problems with non-latin letters
|
62
|
+
|
63
|
+
$db_connection_charset = '<%= db[:charset] || 'utf8' %>';
|
64
|
+
|
65
|
+
// OPTIONAL SETTINGS
|
66
|
+
|
67
|
+
$filename = ''; // Specify the dump filename to suppress the file selection dialog
|
68
|
+
$ajax = true; // AJAX mode: import will be done without refreshing the website
|
69
|
+
$linespersession = 3000; // Lines to be executed per one import session
|
70
|
+
$delaypersession = 0; // You can specify a sleep time in milliseconds after each session
|
71
|
+
// Works only if JavaScript is activated. Use to reduce server overrun
|
72
|
+
|
73
|
+
// CSV related settings (only if you use a CSV dump)
|
74
|
+
|
75
|
+
$csv_insert_table = ''; // Destination table for CSV files
|
76
|
+
$csv_preempty_table = false; // true: delete all entries from table specified in $csv_insert_table before processing
|
77
|
+
$csv_delimiter = ','; // Field delimiter in CSV file
|
78
|
+
$csv_add_quotes = true; // If your CSV data already have quotes around each field set it to false
|
79
|
+
$csv_add_slashes = true; // If your CSV data already have slashes in front of ' and " set it to false
|
80
|
+
|
81
|
+
// Allowed comment markers: lines starting with these strings will be ignored by BigDump
|
82
|
+
|
83
|
+
$comment[]='#'; // Standard comment lines are dropped by default
|
84
|
+
$comment[]='-- ';
|
85
|
+
$comment[]='DELIMITER'; // Ignore DELIMITER switch as it's not a valid SQL statement
|
86
|
+
// $comment[]='---'; // Uncomment this line if using proprietary dump created by outdated mysqldump
|
87
|
+
// $comment[]='CREATE DATABASE'; // Uncomment this line if your dump contains create database queries in order to ignore them
|
88
|
+
$comment[]='/*!'; // Or add your own string to leave out other proprietary things
|
89
|
+
|
90
|
+
// Pre-queries: SQL queries to be executed at the beginning of each import session
|
91
|
+
|
92
|
+
// $pre_query[]='SET foreign_key_checks = 0';
|
93
|
+
// $pre_query[]='Add additional queries if you want here';
|
94
|
+
|
95
|
+
// Default query delimiter: this character at the line end tells Bigdump where a SQL statement ends
|
96
|
+
// Can be changed by DELIMITER statement in the dump file (normally used when defining procedures/functions)
|
97
|
+
|
98
|
+
$delimiter = ';';
|
99
|
+
|
100
|
+
// String quotes character
|
101
|
+
|
102
|
+
$string_quotes = '\''; // Change to '"' if your dump file uses double qoutes for strings
|
103
|
+
|
104
|
+
// How many lines may be considered to be one query (except text lines)
|
105
|
+
|
106
|
+
$max_query_lines = 300;
|
107
|
+
|
108
|
+
// Where to put the upload files into (default: bigdump folder)
|
109
|
+
|
110
|
+
$upload_dir = dirname(__FILE__);
|
111
|
+
|
112
|
+
// *******************************************************************************************
|
113
|
+
// If not familiar with PHP please don't change anything below this line
|
114
|
+
// *******************************************************************************************
|
115
|
+
|
116
|
+
if ($ajax)
|
117
|
+
ob_start();
|
118
|
+
|
119
|
+
define ('VERSION','0.35b');
|
120
|
+
define ('DATA_CHUNK_LENGTH',16384); // How many chars are read per time
|
121
|
+
define ('TESTMODE',false); // Set to true to process the file without actually accessing the database
|
122
|
+
define ('BIGDUMP_DIR',dirname(__FILE__));
|
123
|
+
define ('PLUGIN_DIR',BIGDUMP_DIR.'/plugins/');
|
124
|
+
|
125
|
+
header("Expires: Mon, 1 Dec 2003 01:00:00 GMT");
|
126
|
+
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
127
|
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
128
|
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
129
|
+
header("Pragma: no-cache");
|
130
|
+
|
131
|
+
@ini_set('auto_detect_line_endings', true);
|
132
|
+
@set_time_limit(0);
|
133
|
+
|
134
|
+
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get"))
|
135
|
+
@date_default_timezone_set(@date_default_timezone_get());
|
136
|
+
|
137
|
+
// Clean and strip anything we don't want from user's input [0.27b]
|
138
|
+
|
139
|
+
foreach ($_REQUEST as $key => $val)
|
140
|
+
{
|
141
|
+
$val = preg_replace("/[^_A-Za-z0-9-\.&= ;\$]/i",'', $val);
|
142
|
+
$_REQUEST[$key] = $val;
|
143
|
+
}
|
144
|
+
|
145
|
+
// Plugin handling is still EXPERIMENTAL and DISABLED
|
146
|
+
// Register plugins by including plugin_name.php from each ./plugins/plugin_name
|
147
|
+
/*
|
148
|
+
if (is_dir(PLUGIN_DIR))
|
149
|
+
{ if ($dh = opendir(PLUGIN_DIR))
|
150
|
+
{
|
151
|
+
while (($file = readdir($dh)) !== false)
|
152
|
+
{ if (is_dir(PLUGIN_DIR.$file) && $file!='.' && $file!='..' && file_exists(PLUGIN_DIR.$file.'/'.$file.'.php'))
|
153
|
+
include (PLUGIN_DIR.$file.'/'.$file.'.php');
|
154
|
+
}
|
155
|
+
closedir($dh);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
*/
|
159
|
+
|
160
|
+
do_action('header');
|
161
|
+
|
162
|
+
?>
|
163
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
164
|
+
<html>
|
165
|
+
<head>
|
166
|
+
<title>BigDump ver. <?php echo (VERSION); ?></title>
|
167
|
+
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-1"/>
|
168
|
+
<meta http-equiv="CONTENT-LANGUAGE" content="EN"/>
|
169
|
+
|
170
|
+
<meta http-equiv="Cache-Control" content="no-cache/"/>
|
171
|
+
<meta http-equiv="Pragma" content="no-cache"/>
|
172
|
+
<meta http-equiv="Expires" content="-1"/>
|
173
|
+
<meta name="robots" content="noindex, nofollow">
|
174
|
+
|
175
|
+
<?php do_action('head_meta'); ?>
|
176
|
+
|
177
|
+
<style type="text/css">
|
178
|
+
<!--
|
179
|
+
|
180
|
+
body
|
181
|
+
{ background-color:#FFFFF0;
|
182
|
+
}
|
183
|
+
|
184
|
+
h1
|
185
|
+
{ font-size:20px;
|
186
|
+
line-height:24px;
|
187
|
+
font-family:Arial,Helvetica,sans-serif;
|
188
|
+
margin-top:5px;
|
189
|
+
margin-bottom:5px;
|
190
|
+
}
|
191
|
+
|
192
|
+
p,td,th
|
193
|
+
{ font-size:14px;
|
194
|
+
line-height:18px;
|
195
|
+
font-family:Arial,Helvetica,sans-serif;
|
196
|
+
margin-top:5px;
|
197
|
+
margin-bottom:5px;
|
198
|
+
text-align:justify;
|
199
|
+
vertical-align:top;
|
200
|
+
}
|
201
|
+
|
202
|
+
p.centr
|
203
|
+
{
|
204
|
+
text-align:center;
|
205
|
+
}
|
206
|
+
|
207
|
+
p.smlcentr
|
208
|
+
{ font-size:10px;
|
209
|
+
line-height:14px;
|
210
|
+
text-align:center;
|
211
|
+
}
|
212
|
+
|
213
|
+
p.error
|
214
|
+
{ color:#FF0000;
|
215
|
+
font-weight:bold;
|
216
|
+
}
|
217
|
+
|
218
|
+
p.success
|
219
|
+
{ color:#00DD00;
|
220
|
+
font-weight:bold;
|
221
|
+
}
|
222
|
+
|
223
|
+
p.successcentr
|
224
|
+
{ color:#00DD00;
|
225
|
+
background-color:#DDDDFF;
|
226
|
+
font-weight:bold;
|
227
|
+
text-align:center;
|
228
|
+
}
|
229
|
+
|
230
|
+
td
|
231
|
+
{ background-color:#F8F8F8;
|
232
|
+
text-align:left;
|
233
|
+
}
|
234
|
+
|
235
|
+
td.transparent
|
236
|
+
{ background-color:#FFFFF0;
|
237
|
+
}
|
238
|
+
|
239
|
+
th
|
240
|
+
{ font-weight:bold;
|
241
|
+
color:#FFFFFF;
|
242
|
+
background-color:#AAAAEE;
|
243
|
+
text-align:left;
|
244
|
+
}
|
245
|
+
|
246
|
+
td.right
|
247
|
+
{ text-align:right;
|
248
|
+
}
|
249
|
+
|
250
|
+
form
|
251
|
+
{ margin-top:5px;
|
252
|
+
margin-bottom:5px;
|
253
|
+
}
|
254
|
+
|
255
|
+
div.skin1
|
256
|
+
{
|
257
|
+
border-color:#3333EE;
|
258
|
+
border-width:5px;
|
259
|
+
border-style:solid;
|
260
|
+
background-color:#AAAAEE;
|
261
|
+
text-align:center;
|
262
|
+
vertical-align:middle;
|
263
|
+
padding:3px;
|
264
|
+
margin:1px;
|
265
|
+
}
|
266
|
+
|
267
|
+
td.bg3
|
268
|
+
{ background-color:#EEEE99;
|
269
|
+
text-align:left;
|
270
|
+
vertical-align:top;
|
271
|
+
width:20%;
|
272
|
+
}
|
273
|
+
|
274
|
+
th.bg4
|
275
|
+
{ background-color:#EEAA55;
|
276
|
+
text-align:left;
|
277
|
+
vertical-align:top;
|
278
|
+
width:20%;
|
279
|
+
}
|
280
|
+
|
281
|
+
td.bgpctbar
|
282
|
+
{ background-color:#EEEEAA;
|
283
|
+
text-align:left;
|
284
|
+
vertical-align:middle;
|
285
|
+
width:80%;
|
286
|
+
}
|
287
|
+
|
288
|
+
<?php do_action('head_style'); ?>
|
289
|
+
|
290
|
+
-->
|
291
|
+
</style>
|
292
|
+
|
293
|
+
</head>
|
294
|
+
|
295
|
+
<body>
|
296
|
+
|
297
|
+
<center>
|
298
|
+
|
299
|
+
<table width="780" cellspacing="0" cellpadding="0">
|
300
|
+
<tr><td class="transparent">
|
301
|
+
|
302
|
+
<!-- <h1>BigDump: Staggered MySQL Dump Importer ver. <?php echo (VERSION); ?></h1> -->
|
303
|
+
|
304
|
+
<?php
|
305
|
+
|
306
|
+
function skin_open()
|
307
|
+
{
|
308
|
+
echo ('<div class="skin1">');
|
309
|
+
}
|
310
|
+
|
311
|
+
function skin_close()
|
312
|
+
{
|
313
|
+
echo ('</div>');
|
314
|
+
}
|
315
|
+
|
316
|
+
skin_open();
|
317
|
+
echo ('<h1>BigDump: Staggered MySQL Dump Importer v'.VERSION.'</h1>');
|
318
|
+
skin_close();
|
319
|
+
|
320
|
+
do_action('after_headline');
|
321
|
+
|
322
|
+
$error = false;
|
323
|
+
$file = false;
|
324
|
+
|
325
|
+
// Check PHP version
|
326
|
+
|
327
|
+
if (!$error && !function_exists('version_compare'))
|
328
|
+
{ echo ("<p class=\"error\">PHP version 4.1.0 is required for BigDump to proceed. You have PHP ".phpversion()." installed. Sorry!</p>\n");
|
329
|
+
$error=true;
|
330
|
+
}
|
331
|
+
|
332
|
+
// Check if mysql extension is available
|
333
|
+
|
334
|
+
if (!$error && !function_exists('mysql_connect'))
|
335
|
+
{ echo ("<p class=\"error\">There is no mySQL extension available in your PHP installation. Sorry!</p>\n");
|
336
|
+
$error=true;
|
337
|
+
}
|
338
|
+
|
339
|
+
// Calculate PHP max upload size (handle settings like 10M or 100K)
|
340
|
+
|
341
|
+
if (!$error)
|
342
|
+
{ $upload_max_filesize=ini_get("upload_max_filesize");
|
343
|
+
if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
|
344
|
+
if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
|
345
|
+
if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024;
|
346
|
+
}
|
347
|
+
|
348
|
+
// Get the current directory
|
349
|
+
/*
|
350
|
+
if (isset($_SERVER["CGIA"]))
|
351
|
+
$upload_dir=dirname($_SERVER["CGIA"]);
|
352
|
+
else if (isset($_SERVER["ORIG_PATH_TRANSLATED"]))
|
353
|
+
$upload_dir=dirname($_SERVER["ORIG_PATH_TRANSLATED"]);
|
354
|
+
else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"]))
|
355
|
+
$upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]);
|
356
|
+
else if (isset($_SERVER["PATH_TRANSLATED"]))
|
357
|
+
$upload_dir=dirname($_SERVER["PATH_TRANSLATED"]);
|
358
|
+
else
|
359
|
+
$upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
|
360
|
+
*/
|
361
|
+
|
362
|
+
do_action ('script_runs');
|
363
|
+
|
364
|
+
// Handle file upload
|
365
|
+
|
366
|
+
if (!$error && isset($_REQUEST["uploadbutton"]))
|
367
|
+
{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
|
368
|
+
{
|
369
|
+
$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
|
370
|
+
$uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
|
371
|
+
$uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
|
372
|
+
|
373
|
+
do_action('file_uploaded');
|
374
|
+
|
375
|
+
if (file_exists($uploaded_filename))
|
376
|
+
{ echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
|
377
|
+
}
|
378
|
+
else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
|
379
|
+
{ echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
|
380
|
+
}
|
381
|
+
else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
|
382
|
+
{ echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
|
383
|
+
echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
|
384
|
+
}
|
385
|
+
else
|
386
|
+
{ echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
|
387
|
+
}
|
388
|
+
}
|
389
|
+
else
|
390
|
+
{ echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
// Handle file deletion (delete only in the current directory for security reasons)
|
396
|
+
|
397
|
+
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"]))
|
399
|
+
echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
|
400
|
+
else
|
401
|
+
echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
|
402
|
+
}
|
403
|
+
|
404
|
+
// Connect to the database, set charset and execute pre-queries
|
405
|
+
|
406
|
+
if (!$error && !TESTMODE)
|
407
|
+
{ $dbconnection = @mysql_connect($db_server,$db_username,$db_password);
|
408
|
+
if ($dbconnection)
|
409
|
+
$db = mysql_select_db($db_name);
|
410
|
+
if (!$dbconnection || !$db)
|
411
|
+
{ echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n");
|
412
|
+
echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
|
413
|
+
$error=true;
|
414
|
+
}
|
415
|
+
if (!$error && $db_connection_charset!=='')
|
416
|
+
@mysql_query("SET NAMES $db_connection_charset", $dbconnection);
|
417
|
+
|
418
|
+
if (!$error && isset ($pre_query) && sizeof ($pre_query)>0)
|
419
|
+
{ reset($pre_query);
|
420
|
+
foreach ($pre_query as $pre_query_value)
|
421
|
+
{ if (!@mysql_query($pre_query_value, $dbconnection))
|
422
|
+
{ echo ("<p class=\"error\">Error with pre-query.</p>\n");
|
423
|
+
echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n");
|
424
|
+
echo ("<p>MySQL: ".mysql_error()."</p>\n");
|
425
|
+
$error=true;
|
426
|
+
break;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
else
|
432
|
+
{ $dbconnection = false;
|
433
|
+
}
|
434
|
+
|
435
|
+
do_action('database_connected');
|
436
|
+
|
437
|
+
// DIAGNOSTIC
|
438
|
+
// echo("<h1>Checkpoint!</h1>");
|
439
|
+
|
440
|
+
// List uploaded files in multifile mode
|
441
|
+
|
442
|
+
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
443
|
+
{ if ($dirhandle = opendir($upload_dir))
|
444
|
+
{
|
445
|
+
$files=array();
|
446
|
+
while (false !== ($files[] = readdir($dirhandle)));
|
447
|
+
closedir($dirhandle);
|
448
|
+
$dirhead=false;
|
449
|
+
|
450
|
+
if (sizeof($files)>0)
|
451
|
+
{
|
452
|
+
sort($files);
|
453
|
+
foreach ($files as $dirfile)
|
454
|
+
{
|
455
|
+
if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile))
|
456
|
+
{ if (!$dirhead)
|
457
|
+
{ echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
|
458
|
+
echo ("<tr><th>Filename</th><th>Size</th><th>Date&Time</th><th>Type</th><th> </th><th> </th>\n");
|
459
|
+
$dirhead=true;
|
460
|
+
}
|
461
|
+
echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($upload_dir.'/'.$dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($upload_dir.'/'.$dirfile))."</td>");
|
462
|
+
|
463
|
+
if (preg_match("/\.sql$/i",$dirfile))
|
464
|
+
echo ("<td>SQL</td>");
|
465
|
+
elseif (preg_match("/\.gz$/i",$dirfile))
|
466
|
+
echo ("<td>GZip</td>");
|
467
|
+
elseif (preg_match("/\.csv$/i",$dirfile))
|
468
|
+
echo ("<td>CSV</td>");
|
469
|
+
else
|
470
|
+
echo ("<td>Misc</td>");
|
471
|
+
|
472
|
+
if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile))
|
473
|
+
echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=".urlencode($dirfile)."&foffset=0&totalqueries=0&delimiter=".urlencode($delimiter)."\">Start Import</a> into $db_name at $db_server</td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
|
474
|
+
// TODO: echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=".urlencode($dirfile)."&foffset=0&totalqueries=0&delimiter=".urlencode($delimiter)."\">Start Import</a></td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
|
475
|
+
else
|
476
|
+
echo ("<td> </td>\n <td> </td></tr>\n");
|
477
|
+
}
|
478
|
+
}
|
479
|
+
}
|
480
|
+
|
481
|
+
if ($dirhead)
|
482
|
+
echo ("</table>\n");
|
483
|
+
else
|
484
|
+
echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
|
485
|
+
}
|
486
|
+
else
|
487
|
+
{ echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
|
488
|
+
$error=true;
|
489
|
+
}
|
490
|
+
}
|
491
|
+
|
492
|
+
|
493
|
+
// Single file mode
|
494
|
+
|
495
|
+
if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
|
496
|
+
{ echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=".urlencode($filename)."&foffset=0&totalqueries=0\">Start Import</a> from $filename into $db_name at $db_server</p>\n");
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
// File Upload Form
|
501
|
+
|
502
|
+
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
503
|
+
{
|
504
|
+
|
505
|
+
// Test permissions on working directory
|
506
|
+
|
507
|
+
do { $tempfilename=$upload_dir.'/'.time().".tmp"; } while (file_exists($tempfilename));
|
508
|
+
if (!($tempfile=@fopen($tempfilename,"w")))
|
509
|
+
{ 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
|
+
echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
|
511
|
+
}
|
512
|
+
else
|
513
|
+
{ fclose($tempfile);
|
514
|
+
unlink ($tempfilename);
|
515
|
+
|
516
|
+
echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) ");
|
517
|
+
echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
|
518
|
+
?>
|
519
|
+
<form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
|
520
|
+
<input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize">
|
521
|
+
<p>Dump file: <input type="file" name="dumpfile" accept="*/*" size=60"></p>
|
522
|
+
<p><input type="submit" name="uploadbutton" value="Upload"></p>
|
523
|
+
</form>
|
524
|
+
<?php
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
// Print the current mySQL connection charset
|
529
|
+
|
530
|
+
if (!$error && !TESTMODE && !isset($_REQUEST["fn"]))
|
531
|
+
{
|
532
|
+
$result = mysql_query("SHOW VARIABLES LIKE 'character_set_connection';");
|
533
|
+
$row = mysql_fetch_assoc($result);
|
534
|
+
if ($row)
|
535
|
+
{ $charset = $row['Value'];
|
536
|
+
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");
|
537
|
+
}
|
538
|
+
}
|
539
|
+
|
540
|
+
// Open the file
|
541
|
+
|
542
|
+
if (!$error && isset($_REQUEST["start"]))
|
543
|
+
{
|
544
|
+
|
545
|
+
// Set current filename ($filename overrides $_REQUEST["fn"] if set)
|
546
|
+
|
547
|
+
if ($filename!="")
|
548
|
+
$curfilename=$filename;
|
549
|
+
else if (isset($_REQUEST["fn"]))
|
550
|
+
$curfilename=urldecode($_REQUEST["fn"]);
|
551
|
+
else
|
552
|
+
$curfilename="";
|
553
|
+
|
554
|
+
// Recognize GZip filename
|
555
|
+
|
556
|
+
if (preg_match("/\.gz$/i",$curfilename))
|
557
|
+
$gzipmode=true;
|
558
|
+
else
|
559
|
+
$gzipmode=false;
|
560
|
+
|
561
|
+
if ((!$gzipmode && !$file=@fopen($upload_dir.'/'.$curfilename,"r")) || ($gzipmode && !$file=@gzopen($upload_dir.'/'.$curfilename,"r")))
|
562
|
+
{ echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n");
|
563
|
+
echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.".
|
564
|
+
"<br>Or, specify \$filename in bigdump.php with the full filename. ".
|
565
|
+
"<br>Or, you have to upload the $curfilename to the server first.</p>\n");
|
566
|
+
$error=true;
|
567
|
+
}
|
568
|
+
|
569
|
+
// Get the file size (can't do it fast on gzipped files, no idea how)
|
570
|
+
|
571
|
+
else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0))
|
572
|
+
{ if (!$gzipmode) $filesize = ftell($file);
|
573
|
+
else $filesize = gztell($file); // Always zero, ignore
|
574
|
+
}
|
575
|
+
else
|
576
|
+
{ echo ("<p class=\"error\">I can't seek into $curfilename</p>\n");
|
577
|
+
$error=true;
|
578
|
+
}
|
579
|
+
|
580
|
+
// Stop if csv file is used, but $csv_insert_table is not set
|
581
|
+
|
582
|
+
if (!$error && ($csv_insert_table == "") && (preg_match("/(\.csv)$/i",$curfilename)))
|
583
|
+
{ echo ("<p class=\"error\">You have to specify \$csv_insert_table when using a CSV file. </p>\n");
|
584
|
+
$error=true;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
|
588
|
+
|
589
|
+
// *******************************************************************************************
|
590
|
+
// START IMPORT SESSION HERE
|
591
|
+
// *******************************************************************************************
|
592
|
+
|
593
|
+
if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_match("/(\.(sql|gz|csv))$/i",$curfilename))
|
594
|
+
{
|
595
|
+
|
596
|
+
do_action('session_start');
|
597
|
+
|
598
|
+
// Check start and foffset are numeric values
|
599
|
+
|
600
|
+
if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
|
601
|
+
{ echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
|
602
|
+
$error=true;
|
603
|
+
}
|
604
|
+
else
|
605
|
+
{ $_REQUEST["start"] = floor($_REQUEST["start"]);
|
606
|
+
$_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
|
607
|
+
}
|
608
|
+
|
609
|
+
// Set the current delimiter if defined
|
610
|
+
|
611
|
+
if (isset($_REQUEST["delimiter"]))
|
612
|
+
$delimiter = $_REQUEST["delimiter"];
|
613
|
+
|
614
|
+
// Empty CSV table if requested
|
615
|
+
|
616
|
+
if (!$error && $_REQUEST["start"]==1 && $csv_insert_table != "" && $csv_preempty_table)
|
617
|
+
{
|
618
|
+
$query = "DELETE FROM `$csv_insert_table`";
|
619
|
+
if (!TESTMODE && !mysql_query(trim($query), $dbconnection))
|
620
|
+
{ echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n");
|
621
|
+
echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
622
|
+
echo ("<p>MySQL: ".mysql_error()."</p>\n");
|
623
|
+
$error=true;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
// Print start message
|
628
|
+
|
629
|
+
if (!$error)
|
630
|
+
{ skin_open();
|
631
|
+
if (TESTMODE)
|
632
|
+
echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
|
633
|
+
echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
|
634
|
+
echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");
|
635
|
+
skin_close();
|
636
|
+
}
|
637
|
+
|
638
|
+
// Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files)
|
639
|
+
|
640
|
+
if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize)
|
641
|
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n");
|
642
|
+
$error=true;
|
643
|
+
}
|
644
|
+
|
645
|
+
// Set file pointer to $_REQUEST["foffset"]
|
646
|
+
|
647
|
+
if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0)))
|
648
|
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n");
|
649
|
+
$error=true;
|
650
|
+
}
|
651
|
+
|
652
|
+
// Start processing queries from $file
|
653
|
+
|
654
|
+
if (!$error)
|
655
|
+
{ $query="";
|
656
|
+
$queries=0;
|
657
|
+
$totalqueries=$_REQUEST["totalqueries"];
|
658
|
+
$linenumber=$_REQUEST["start"];
|
659
|
+
$querylines=0;
|
660
|
+
$inparents=false;
|
661
|
+
|
662
|
+
// Stay processing as long as the $linespersession is not reached or the query is still incomplete
|
663
|
+
|
664
|
+
while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
|
665
|
+
{
|
666
|
+
|
667
|
+
// Read the whole next line
|
668
|
+
|
669
|
+
$dumpline = "";
|
670
|
+
while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r")
|
671
|
+
{ if (!$gzipmode)
|
672
|
+
$dumpline .= fgets($file, DATA_CHUNK_LENGTH);
|
673
|
+
else
|
674
|
+
$dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
|
675
|
+
}
|
676
|
+
if ($dumpline==="") break;
|
677
|
+
|
678
|
+
// Remove UTF8 Byte Order Mark at the file beginning if any
|
679
|
+
|
680
|
+
if ($_REQUEST["foffset"]==0)
|
681
|
+
$dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
|
682
|
+
|
683
|
+
// Create an SQL query from CSV line
|
684
|
+
|
685
|
+
if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename)))
|
686
|
+
{
|
687
|
+
if ($csv_add_slashes)
|
688
|
+
$dumpline = addslashes($dumpline);
|
689
|
+
$dumpline = explode($csv_delimiter,$dumpline);
|
690
|
+
if ($csv_add_quotes)
|
691
|
+
$dumpline = "'".implode("','",$dumpline)."'";
|
692
|
+
else
|
693
|
+
$dumpline = implode(",",$dumpline);
|
694
|
+
$dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
|
695
|
+
}
|
696
|
+
|
697
|
+
// Handle DOS and Mac encoded linebreaks (I don't know if it really works on Win32 or Mac Servers)
|
698
|
+
|
699
|
+
$dumpline=str_replace("\r\n", "\n", $dumpline);
|
700
|
+
$dumpline=str_replace("\r", "\n", $dumpline);
|
701
|
+
|
702
|
+
// DIAGNOSTIC
|
703
|
+
// echo ("<p>Line $linenumber: $dumpline</p>\n");
|
704
|
+
|
705
|
+
// Recognize delimiter statement
|
706
|
+
|
707
|
+
if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0)
|
708
|
+
$delimiter = str_replace ("DELIMITER ","",trim($dumpline));
|
709
|
+
|
710
|
+
// Skip comments and blank lines only if NOT in parents
|
711
|
+
|
712
|
+
if (!$inparents)
|
713
|
+
{ $skipline=false;
|
714
|
+
reset($comment);
|
715
|
+
foreach ($comment as $comment_value)
|
716
|
+
{
|
717
|
+
|
718
|
+
// DIAGNOSTIC
|
719
|
+
// echo ($comment_value);
|
720
|
+
if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0)
|
721
|
+
{ $skipline=true;
|
722
|
+
break;
|
723
|
+
}
|
724
|
+
}
|
725
|
+
if ($skipline)
|
726
|
+
{ $linenumber++;
|
727
|
+
|
728
|
+
// DIAGNOSTIC
|
729
|
+
// echo ("<p>Comment line skipped</p>\n");
|
730
|
+
|
731
|
+
continue;
|
732
|
+
}
|
733
|
+
}
|
734
|
+
|
735
|
+
// Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
|
736
|
+
|
737
|
+
$dumpline_deslashed = str_replace ("\\\\","",$dumpline);
|
738
|
+
|
739
|
+
// Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter
|
740
|
+
|
741
|
+
$parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes");
|
742
|
+
if ($parents % 2 != 0)
|
743
|
+
$inparents=!$inparents;
|
744
|
+
|
745
|
+
// Add the line to query
|
746
|
+
|
747
|
+
$query .= $dumpline;
|
748
|
+
|
749
|
+
// Don't count the line if in parents (text fields may include unlimited linebreaks)
|
750
|
+
|
751
|
+
if (!$inparents)
|
752
|
+
$querylines++;
|
753
|
+
|
754
|
+
// Stop if query contains more lines as defined by $max_query_lines
|
755
|
+
|
756
|
+
if ($querylines>$max_query_lines)
|
757
|
+
{
|
758
|
+
echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
|
759
|
+
echo ("<p>At this place the current query includes more than ".$max_query_lines." dump lines. That can happen if your dump file was ");
|
760
|
+
echo ("created by some tool which doesn't place a semicolon followed by a linebreak at the end of each query, or if your dump contains ");
|
761
|
+
echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> ");
|
762
|
+
echo ("for more infos. Ask for our support services ");
|
763
|
+
echo ("in order to handle dump files containing extended inserts.</p>\n");
|
764
|
+
$error=true;
|
765
|
+
break;
|
766
|
+
}
|
767
|
+
|
768
|
+
// Execute query if end of query detected ($delimiter as last character) AND NOT in parents
|
769
|
+
|
770
|
+
// DIAGNOSTIC
|
771
|
+
// echo ("<p>Regex: ".'/'.preg_quote($delimiter).'$/'."</p>\n");
|
772
|
+
// echo ("<p>In Parents: ".($inparents?"true":"false")."</p>\n");
|
773
|
+
// echo ("<p>Line: $dumpline</p>\n");
|
774
|
+
|
775
|
+
if ((preg_match('/'.preg_quote($delimiter,'/').'$/',trim($dumpline)) || $delimiter=='') && !$inparents)
|
776
|
+
{
|
777
|
+
|
778
|
+
// Cut off delimiter of the end of the query
|
779
|
+
|
780
|
+
$query = substr(trim($query),0,-1*strlen($delimiter));
|
781
|
+
|
782
|
+
// DIAGNOSTIC
|
783
|
+
// echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
784
|
+
|
785
|
+
if (!TESTMODE && !mysql_query($query, $dbconnection))
|
786
|
+
{ echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
|
787
|
+
echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
788
|
+
echo ("<p>MySQL: ".mysql_error()."</p>\n");
|
789
|
+
$error=true;
|
790
|
+
break;
|
791
|
+
}
|
792
|
+
$totalqueries++;
|
793
|
+
$queries++;
|
794
|
+
$query="";
|
795
|
+
$querylines=0;
|
796
|
+
}
|
797
|
+
$linenumber++;
|
798
|
+
}
|
799
|
+
}
|
800
|
+
|
801
|
+
// Get the current file position
|
802
|
+
|
803
|
+
if (!$error)
|
804
|
+
{ if (!$gzipmode)
|
805
|
+
$foffset = ftell($file);
|
806
|
+
else
|
807
|
+
$foffset = gztell($file);
|
808
|
+
if (!$foffset)
|
809
|
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
|
810
|
+
$error=true;
|
811
|
+
}
|
812
|
+
}
|
813
|
+
|
814
|
+
// Print statistics
|
815
|
+
|
816
|
+
skin_open();
|
817
|
+
|
818
|
+
// echo ("<p class=\"centr\"><b>Statistics</b></p>\n");
|
819
|
+
|
820
|
+
if (!$error)
|
821
|
+
{
|
822
|
+
$lines_this = $linenumber-$_REQUEST["start"];
|
823
|
+
$lines_done = $linenumber-1;
|
824
|
+
$lines_togo = ' ? ';
|
825
|
+
$lines_tota = ' ? ';
|
826
|
+
|
827
|
+
$queries_this = $queries;
|
828
|
+
$queries_done = $totalqueries;
|
829
|
+
$queries_togo = ' ? ';
|
830
|
+
$queries_tota = ' ? ';
|
831
|
+
|
832
|
+
$bytes_this = $foffset-$_REQUEST["foffset"];
|
833
|
+
$bytes_done = $foffset;
|
834
|
+
$kbytes_this = round($bytes_this/1024,2);
|
835
|
+
$kbytes_done = round($bytes_done/1024,2);
|
836
|
+
$mbytes_this = round($kbytes_this/1024,2);
|
837
|
+
$mbytes_done = round($kbytes_done/1024,2);
|
838
|
+
|
839
|
+
if (!$gzipmode)
|
840
|
+
{
|
841
|
+
$bytes_togo = $filesize-$foffset;
|
842
|
+
$bytes_tota = $filesize;
|
843
|
+
$kbytes_togo = round($bytes_togo/1024,2);
|
844
|
+
$kbytes_tota = round($bytes_tota/1024,2);
|
845
|
+
$mbytes_togo = round($kbytes_togo/1024,2);
|
846
|
+
$mbytes_tota = round($kbytes_tota/1024,2);
|
847
|
+
|
848
|
+
$pct_this = ceil($bytes_this/$filesize*100);
|
849
|
+
$pct_done = ceil($foffset/$filesize*100);
|
850
|
+
$pct_togo = 100 - $pct_done;
|
851
|
+
$pct_tota = 100;
|
852
|
+
|
853
|
+
if ($bytes_togo==0)
|
854
|
+
{ $lines_togo = '0';
|
855
|
+
$lines_tota = $linenumber-1;
|
856
|
+
$queries_togo = '0';
|
857
|
+
$queries_tota = $totalqueries;
|
858
|
+
}
|
859
|
+
|
860
|
+
$pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
|
861
|
+
}
|
862
|
+
else
|
863
|
+
{
|
864
|
+
$bytes_togo = ' ? ';
|
865
|
+
$bytes_tota = ' ? ';
|
866
|
+
$kbytes_togo = ' ? ';
|
867
|
+
$kbytes_tota = ' ? ';
|
868
|
+
$mbytes_togo = ' ? ';
|
869
|
+
$mbytes_tota = ' ? ';
|
870
|
+
|
871
|
+
$pct_this = ' ? ';
|
872
|
+
$pct_done = ' ? ';
|
873
|
+
$pct_togo = ' ? ';
|
874
|
+
$pct_tota = 100;
|
875
|
+
$pct_bar = str_replace(' ',' ','<tt>[ Not available for gzipped files ]</tt>');
|
876
|
+
}
|
877
|
+
|
878
|
+
echo ("
|
879
|
+
<center>
|
880
|
+
<table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
|
881
|
+
<tr><th class=\"bg4\"> </th><th class=\"bg4\">Session</th><th class=\"bg4\">Done</th><th class=\"bg4\">To go</th><th class=\"bg4\">Total</th></tr>
|
882
|
+
<tr><th class=\"bg4\">Lines</th><td class=\"bg3\">$lines_this</td><td class=\"bg3\">$lines_done</td><td class=\"bg3\">$lines_togo</td><td class=\"bg3\">$lines_tota</td></tr>
|
883
|
+
<tr><th class=\"bg4\">Queries</th><td class=\"bg3\">$queries_this</td><td class=\"bg3\">$queries_done</td><td class=\"bg3\">$queries_togo</td><td class=\"bg3\">$queries_tota</td></tr>
|
884
|
+
<tr><th class=\"bg4\">Bytes</th><td class=\"bg3\">$bytes_this</td><td class=\"bg3\">$bytes_done</td><td class=\"bg3\">$bytes_togo</td><td class=\"bg3\">$bytes_tota</td></tr>
|
885
|
+
<tr><th class=\"bg4\">KB</th><td class=\"bg3\">$kbytes_this</td><td class=\"bg3\">$kbytes_done</td><td class=\"bg3\">$kbytes_togo</td><td class=\"bg3\">$kbytes_tota</td></tr>
|
886
|
+
<tr><th class=\"bg4\">MB</th><td class=\"bg3\">$mbytes_this</td><td class=\"bg3\">$mbytes_done</td><td class=\"bg3\">$mbytes_togo</td><td class=\"bg3\">$mbytes_tota</td></tr>
|
887
|
+
<tr><th class=\"bg4\">%</th><td class=\"bg3\">$pct_this</td><td class=\"bg3\">$pct_done</td><td class=\"bg3\">$pct_togo</td><td class=\"bg3\">$pct_tota</td></tr>
|
888
|
+
<tr><th class=\"bg4\">% bar</th><td class=\"bgpctbar\" colspan=\"4\">$pct_bar</td></tr>
|
889
|
+
</table>
|
890
|
+
</center>
|
891
|
+
\n");
|
892
|
+
|
893
|
+
// Finish message and restart the script
|
894
|
+
|
895
|
+
if ($linenumber<$_REQUEST["start"]+$linespersession)
|
896
|
+
{ echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
|
897
|
+
echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n");
|
898
|
+
echo ("<p class=\"centr\">Thank you for using this tool! Please rate <a href=\"http://www.hotscripts.com/listing/bigdump/?RID=403\" target=\"_blank\">Bigdump at Hotscripts.com</a></p>\n");
|
899
|
+
echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation via PayPal. Thank you!</p>\n");
|
900
|
+
?>
|
901
|
+
|
902
|
+
<!-- Start Paypal donation code -->
|
903
|
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
904
|
+
<input type="hidden" name="cmd" value="_xclick" />
|
905
|
+
<input type="hidden" name="business" value="alexey@ozerov.de" />
|
906
|
+
<input type="hidden" name="item_name" value="BigDump Donation" />
|
907
|
+
<input type="hidden" name="no_shipping" value="1" />
|
908
|
+
<input type="hidden" name="no_note" value="0" />
|
909
|
+
<input type="hidden" name="tax" value="0" />
|
910
|
+
<input type="hidden" name="bn" value="PP-DonationsBF" />
|
911
|
+
<input type="hidden" name="lc" value="US" />
|
912
|
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
|
913
|
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
|
914
|
+
</form>
|
915
|
+
<!-- End Paypal donation code -->
|
916
|
+
|
917
|
+
<?php
|
918
|
+
do_action('script_finished');
|
919
|
+
$error=true; // This is a semi-error telling the script is finished
|
920
|
+
}
|
921
|
+
else
|
922
|
+
{ if ($delaypersession!=0)
|
923
|
+
echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
|
924
|
+
if (!$ajax)
|
925
|
+
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
|
+
|
927
|
+
echo ("<noscript>\n");
|
928
|
+
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
|
+
echo ("</noscript>\n");
|
930
|
+
|
931
|
+
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
|
+
}
|
933
|
+
}
|
934
|
+
else
|
935
|
+
echo ("<p class=\"error\">Stopped on error</p>\n");
|
936
|
+
|
937
|
+
skin_close();
|
938
|
+
|
939
|
+
}
|
940
|
+
|
941
|
+
if ($error)
|
942
|
+
echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
|
943
|
+
|
944
|
+
if ($dbconnection) mysql_close($dbconnection);
|
945
|
+
if ($file && !$gzipmode) fclose($file);
|
946
|
+
else if ($file && $gzipmode) gzclose($file);
|
947
|
+
|
948
|
+
?>
|
949
|
+
|
950
|
+
<p class="centr">© 2003-2013 <a href="mailto:alexey@ozerov.de">Alexey Ozerov</a></p>
|
951
|
+
|
952
|
+
</td></tr></table>
|
953
|
+
|
954
|
+
</center>
|
955
|
+
<?php do_action('end_of_body'); ?>
|
956
|
+
</body>
|
957
|
+
</html>
|
958
|
+
|
959
|
+
<?php
|
960
|
+
|
961
|
+
// If error or finished put out the whole output from above and stop
|
962
|
+
|
963
|
+
if ($error)
|
964
|
+
{
|
965
|
+
$out1 = ob_get_contents();
|
966
|
+
ob_end_clean();
|
967
|
+
echo $out1;
|
968
|
+
die;
|
969
|
+
}
|
970
|
+
|
971
|
+
// If Ajax enabled and in import progress creates responses (XML response or script for the initial page)
|
972
|
+
|
973
|
+
if ($ajax && isset($_REQUEST['start']))
|
974
|
+
{
|
975
|
+
if (isset($_REQUEST['ajaxrequest']))
|
976
|
+
{ ob_end_clean();
|
977
|
+
create_xml_response();
|
978
|
+
die;
|
979
|
+
}
|
980
|
+
else
|
981
|
+
create_ajax_script();
|
982
|
+
}
|
983
|
+
|
984
|
+
// Anyway put out the output from above
|
985
|
+
|
986
|
+
ob_flush();
|
987
|
+
|
988
|
+
// THE MAIN SCRIPT ENDS HERE
|
989
|
+
|
990
|
+
// *******************************************************************************************
|
991
|
+
// Plugin handling (EXPERIMENTAL)
|
992
|
+
// *******************************************************************************************
|
993
|
+
|
994
|
+
function do_action($tag)
|
995
|
+
{ global $plugin_actions;
|
996
|
+
|
997
|
+
if (isset($plugin_actions[$tag]))
|
998
|
+
{ reset ($plugin_actions[$tag]);
|
999
|
+
foreach ($plugin_actions[$tag] as $action)
|
1000
|
+
call_user_func_array($action, array());
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
function add_action($tag, $function)
|
1005
|
+
{
|
1006
|
+
global $plugin_actions;
|
1007
|
+
$plugin_actions[$tag][] = $function;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
// *******************************************************************************************
|
1011
|
+
// AJAX utilities
|
1012
|
+
// *******************************************************************************************
|
1013
|
+
|
1014
|
+
function create_xml_response()
|
1015
|
+
{
|
1016
|
+
global $linenumber, $foffset, $totalqueries, $curfilename, $delimiter,
|
1017
|
+
$lines_this, $lines_done, $lines_togo, $lines_tota,
|
1018
|
+
$queries_this, $queries_done, $queries_togo, $queries_tota,
|
1019
|
+
$bytes_this, $bytes_done, $bytes_togo, $bytes_tota,
|
1020
|
+
$kbytes_this, $kbytes_done, $kbytes_togo, $kbytes_tota,
|
1021
|
+
$mbytes_this, $mbytes_done, $mbytes_togo, $mbytes_tota,
|
1022
|
+
$pct_this, $pct_done, $pct_togo, $pct_tota,$pct_bar;
|
1023
|
+
|
1024
|
+
header('Content-Type: application/xml');
|
1025
|
+
header('Cache-Control: no-cache');
|
1026
|
+
|
1027
|
+
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
|
1028
|
+
echo "<root>";
|
1029
|
+
|
1030
|
+
// data - for calculations
|
1031
|
+
|
1032
|
+
echo "<linenumber>$linenumber</linenumber>";
|
1033
|
+
echo "<foffset>$foffset</foffset>";
|
1034
|
+
echo "<fn>$curfilename</fn>";
|
1035
|
+
echo "<totalqueries>$totalqueries</totalqueries>";
|
1036
|
+
echo "<delimiter>$delimiter</delimiter>";
|
1037
|
+
|
1038
|
+
// results - for page update
|
1039
|
+
|
1040
|
+
echo "<elem1>$lines_this</elem1>";
|
1041
|
+
echo "<elem2>$lines_done</elem2>";
|
1042
|
+
echo "<elem3>$lines_togo</elem3>";
|
1043
|
+
echo "<elem4>$lines_tota</elem4>";
|
1044
|
+
|
1045
|
+
echo "<elem5>$queries_this</elem5>";
|
1046
|
+
echo "<elem6>$queries_done</elem6>";
|
1047
|
+
echo "<elem7>$queries_togo</elem7>";
|
1048
|
+
echo "<elem8>$queries_tota</elem8>";
|
1049
|
+
|
1050
|
+
echo "<elem9>$bytes_this</elem9>";
|
1051
|
+
echo "<elem10>$bytes_done</elem10>";
|
1052
|
+
echo "<elem11>$bytes_togo</elem11>";
|
1053
|
+
echo "<elem12>$bytes_tota</elem12>";
|
1054
|
+
|
1055
|
+
echo "<elem13>$kbytes_this</elem13>";
|
1056
|
+
echo "<elem14>$kbytes_done</elem14>";
|
1057
|
+
echo "<elem15>$kbytes_togo</elem15>";
|
1058
|
+
echo "<elem16>$kbytes_tota</elem16>";
|
1059
|
+
|
1060
|
+
echo "<elem17>$mbytes_this</elem17>";
|
1061
|
+
echo "<elem18>$mbytes_done</elem18>";
|
1062
|
+
echo "<elem19>$mbytes_togo</elem19>";
|
1063
|
+
echo "<elem20>$mbytes_tota</elem20>";
|
1064
|
+
|
1065
|
+
echo "<elem21>$pct_this</elem21>";
|
1066
|
+
echo "<elem22>$pct_done</elem22>";
|
1067
|
+
echo "<elem23>$pct_togo</elem23>";
|
1068
|
+
echo "<elem24>$pct_tota</elem24>";
|
1069
|
+
echo "<elem_bar>".htmlentities($pct_bar)."</elem_bar>";
|
1070
|
+
|
1071
|
+
echo "</root>";
|
1072
|
+
}
|
1073
|
+
|
1074
|
+
|
1075
|
+
function create_ajax_script()
|
1076
|
+
{
|
1077
|
+
global $linenumber, $foffset, $totalqueries, $delaypersession, $curfilename, $delimiter;
|
1078
|
+
?>
|
1079
|
+
|
1080
|
+
<script type="text/javascript" language="javascript">
|
1081
|
+
|
1082
|
+
// creates next action url (upload page, or XML response)
|
1083
|
+
function get_url(linenumber,fn,foffset,totalqueries,delimiter) {
|
1084
|
+
return "<?php echo $_SERVER['PHP_SELF'] ?>?start="+linenumber+"&fn="+fn+"&foffset="+foffset+"&totalqueries="+totalqueries+"&delimiter="+delimiter+"&ajaxrequest=true";
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
// extracts text from XML element (itemname must be unique)
|
1088
|
+
function get_xml_data(itemname,xmld) {
|
1089
|
+
return xmld.getElementsByTagName(itemname).item(0).firstChild.data;
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
function makeRequest(url) {
|
1093
|
+
http_request = false;
|
1094
|
+
if (window.XMLHttpRequest) {
|
1095
|
+
// Mozilla etc.
|
1096
|
+
http_request = new XMLHttpRequest();
|
1097
|
+
if (http_request.overrideMimeType) {
|
1098
|
+
http_request.overrideMimeType("text/xml");
|
1099
|
+
}
|
1100
|
+
} else if (window.ActiveXObject) {
|
1101
|
+
// IE
|
1102
|
+
try {
|
1103
|
+
http_request = new ActiveXObject("Msxml2.XMLHTTP");
|
1104
|
+
} catch(e) {
|
1105
|
+
try {
|
1106
|
+
http_request = new ActiveXObject("Microsoft.XMLHTTP");
|
1107
|
+
} catch(e) {}
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
if (!http_request) {
|
1111
|
+
alert("Cannot create an XMLHTTP instance");
|
1112
|
+
return false;
|
1113
|
+
}
|
1114
|
+
http_request.onreadystatechange = server_response;
|
1115
|
+
http_request.open("GET", url, true);
|
1116
|
+
http_request.send(null);
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
function server_response()
|
1120
|
+
{
|
1121
|
+
|
1122
|
+
// waiting for correct response
|
1123
|
+
if (http_request.readyState != 4)
|
1124
|
+
return;
|
1125
|
+
|
1126
|
+
if (http_request.status != 200)
|
1127
|
+
{
|
1128
|
+
alert("Page unavailable, or wrong url!")
|
1129
|
+
return;
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
// r = xml response
|
1133
|
+
var r = http_request.responseXML;
|
1134
|
+
|
1135
|
+
//if received not XML but HTML with new page to show
|
1136
|
+
if (!r || r.getElementsByTagName('root').length == 0)
|
1137
|
+
{ var text = http_request.responseText;
|
1138
|
+
document.open();
|
1139
|
+
document.write(text);
|
1140
|
+
document.close();
|
1141
|
+
return;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
// update "Starting from line: "
|
1145
|
+
document.getElementsByTagName('p').item(1).innerHTML =
|
1146
|
+
"Starting from line: " +
|
1147
|
+
r.getElementsByTagName('linenumber').item(0).firstChild.nodeValue;
|
1148
|
+
|
1149
|
+
// update table with new values
|
1150
|
+
for(i = 1; i <= 24; i++)
|
1151
|
+
document.getElementsByTagName('td').item(i).firstChild.data = get_xml_data('elem'+i,r);
|
1152
|
+
|
1153
|
+
// update color bar
|
1154
|
+
document.getElementsByTagName('td').item(25).innerHTML =
|
1155
|
+
r.getElementsByTagName('elem_bar').item(0).firstChild.nodeValue;
|
1156
|
+
|
1157
|
+
// action url (XML response)
|
1158
|
+
url_request = get_url(
|
1159
|
+
get_xml_data('linenumber',r),
|
1160
|
+
get_xml_data('fn',r),
|
1161
|
+
get_xml_data('foffset',r),
|
1162
|
+
get_xml_data('totalqueries',r),
|
1163
|
+
get_xml_data('delimiter',r));
|
1164
|
+
|
1165
|
+
// ask for XML response
|
1166
|
+
window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
// First Ajax request from initial page
|
1170
|
+
|
1171
|
+
var http_request = false;
|
1172
|
+
var url_request = get_url(<?php echo ($linenumber.',"'.urlencode($curfilename).'",'.$foffset.','.$totalqueries.',"'.urlencode($delimiter).'"') ;?>);
|
1173
|
+
window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
|
1174
|
+
</script>
|
1175
|
+
|
1176
|
+
<?php
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
?>
|