@@ -18,7 +18,7 @@ |
||
18 | 18 | **/ |
19 | 19 | |
20 | 20 | if ( !include("../../mainfile.php") ) { |
21 | - die("XOOPS root path not defined"); |
|
21 | + die("XOOPS root path not defined"); |
|
22 | 22 | } |
23 | 23 | $module_dirname = basename( dirname( __FILE__ ) ) ; |
24 | 24 | if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) exit( _NOPERM ); |
@@ -21,7 +21,9 @@ |
||
21 | 21 | die("XOOPS root path not defined"); |
22 | 22 | } |
23 | 23 | $module_dirname = basename( dirname( __FILE__ ) ) ; |
24 | -if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) exit( _NOPERM ); |
|
24 | +if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|
25 | + exit( _NOPERM ); |
|
26 | +} |
|
25 | 27 | $xoopsOption["template_main"] = $module_dirname . "_index.html"; |
26 | 28 | |
27 | 29 | include(XOOPS_ROOT_PATH."/header.php"); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | **/ |
19 | 19 | // connect xoops database |
20 | 20 | if ( !include("../../mainfile.php") ) { |
21 | - die("XOOPS root path not defined"); |
|
21 | + die("XOOPS root path not defined"); |
|
22 | 22 | } |
23 | 23 | $module_dirname = basename( dirname( __FILE__ ) ) ; |
24 | 24 | include(XOOPS_ROOT_PATH."/header.php"); |
@@ -22,7 +22,9 @@ |
||
22 | 22 | } |
23 | 23 | $module_dirname = basename( dirname( __FILE__ ) ) ; |
24 | 24 | include(XOOPS_ROOT_PATH."/header.php"); |
25 | -if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) exit( _NOPERM ); |
|
25 | +if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|
26 | + exit( _NOPERM ); |
|
27 | +} |
|
26 | 28 | |
27 | 29 | function adminer_object() { |
28 | 30 | class AdminerKfr extends Adminer { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $ajax = true; // AJAX mode: import will be done without refreshing the website |
52 | 52 | $linespersession = 3000; // Lines to be executed per one import session |
53 | 53 | $delaypersession = 0; // You can specify a sleep time in milliseconds after each session |
54 | - // Works only if JavaScript is activated. Use to reduce server overrun |
|
54 | + // Works only if JavaScript is activated. Use to reduce server overrun |
|
55 | 55 | |
56 | 56 | // CSV related settings (only if you use a CSV dump) |
57 | 57 | |
@@ -319,23 +319,23 @@ discard block |
||
319 | 319 | if (!$error && isset($_REQUEST["uploadbutton"])) |
320 | 320 | { if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0) |
321 | 321 | { |
322 | - $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]); |
|
323 | - $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename); |
|
324 | - $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename); |
|
325 | - |
|
326 | - if (file_exists($uploaded_filename)) |
|
327 | - { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n"); |
|
328 | - } |
|
329 | - else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename)) |
|
330 | - { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n"); |
|
331 | - } |
|
332 | - else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath)) |
|
333 | - { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n"); |
|
334 | - echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n"); |
|
335 | - } |
|
336 | - else |
|
337 | - { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n"); |
|
338 | - } |
|
322 | + $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]); |
|
323 | + $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename); |
|
324 | + $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename); |
|
325 | + |
|
326 | + if (file_exists($uploaded_filename)) |
|
327 | + { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n"); |
|
328 | + } |
|
329 | + else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename)) |
|
330 | + { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n"); |
|
331 | + } |
|
332 | + else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath)) |
|
333 | + { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n"); |
|
334 | + echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n"); |
|
335 | + } |
|
336 | + else |
|
337 | + { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n"); |
|
338 | + } |
|
339 | 339 | } |
340 | 340 | else |
341 | 341 | { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n"); |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | |
348 | 348 | if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"])) |
349 | 349 | { if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"]))) |
350 | - echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n"); |
|
350 | + echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n"); |
|
351 | 351 | else |
352 | - echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n"); |
|
352 | + echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n"); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | // Connect to the database, set charset and execute pre-queries |
@@ -357,26 +357,26 @@ discard block |
||
357 | 357 | if (!$error && !TESTMODE) |
358 | 358 | { $dbconnection = @mysql_connect($db_server,$db_username,$db_password); |
359 | 359 | if ($dbconnection) |
360 | - $db = mysql_select_db($db_name); |
|
360 | + $db = mysql_select_db($db_name); |
|
361 | 361 | if (!$dbconnection || !$db) |
362 | 362 | { echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n"); |
363 | - echo ("<p>Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider.</p>\n"); |
|
364 | - $error=true; |
|
363 | + echo ("<p>Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider.</p>\n"); |
|
364 | + $error=true; |
|
365 | 365 | } |
366 | 366 | if (!$error && $db_connection_charset!=='') |
367 | - @mysql_query("SET NAMES $db_connection_charset", $dbconnection); |
|
367 | + @mysql_query("SET NAMES $db_connection_charset", $dbconnection); |
|
368 | 368 | |
369 | 369 | if (!$error && isset ($pre_query) && sizeof ($pre_query)>0) |
370 | 370 | { reset($pre_query); |
371 | - foreach ($pre_query as $pre_query_value) |
|
372 | - { if (!@mysql_query($pre_query_value, $dbconnection)) |
|
373 | - { echo ("<p class=\"error\">Error with pre-query.</p>\n"); |
|
374 | - echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n"); |
|
375 | - echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
376 | - $error=true; |
|
377 | - break; |
|
378 | - } |
|
379 | - } |
|
371 | + foreach ($pre_query as $pre_query_value) |
|
372 | + { if (!@mysql_query($pre_query_value, $dbconnection)) |
|
373 | + { echo ("<p class=\"error\">Error with pre-query.</p>\n"); |
|
374 | + echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n"); |
|
375 | + echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
376 | + $error=true; |
|
377 | + break; |
|
378 | + } |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | else |
@@ -392,49 +392,49 @@ discard block |
||
392 | 392 | if (!$error && !isset($_REQUEST["fn"]) && $filename=="") |
393 | 393 | { if ($dirhandle = opendir($upload_dir)) |
394 | 394 | { |
395 | - $files=array(); |
|
396 | - while (false !== ($files[] = readdir($dirhandle))); |
|
397 | - closedir($dirhandle); |
|
398 | - $dirhead=false; |
|
399 | - |
|
400 | - if (sizeof($files)>0) |
|
401 | - { |
|
402 | - sort($files); |
|
403 | - foreach ($files as $dirfile) |
|
404 | - { |
|
405 | - if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile)) |
|
406 | - { if (!$dirhead) |
|
407 | - { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n"); |
|
408 | - echo ("<tr><th>Filename</th><th>Size</th><th>Date&Time</th><th>Type</th><th> </th><th> </th>\n"); |
|
409 | - $dirhead=true; |
|
410 | - } |
|
411 | - echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($dirfile))."</td>"); |
|
412 | - |
|
413 | - if (preg_match("/\.sql$/i",$dirfile)) |
|
414 | - echo ("<td>SQL</td>"); |
|
415 | - elseif (preg_match("/\.gz$/i",$dirfile)) |
|
416 | - echo ("<td>GZip</td>"); |
|
417 | - elseif (preg_match("/\.csv$/i",$dirfile)) |
|
418 | - echo ("<td>CSV</td>"); |
|
419 | - else |
|
420 | - echo ("<td>Misc</td>"); |
|
421 | - |
|
422 | - if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile)) |
|
423 | - 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"); |
|
424 | - else |
|
425 | - echo ("<td> </td>\n <td> </td></tr>\n"); |
|
426 | - } |
|
427 | - } |
|
428 | - } |
|
429 | - |
|
430 | - if ($dirhead) |
|
431 | - echo ("</table>\n"); |
|
432 | - else |
|
433 | - echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n"); |
|
395 | + $files=array(); |
|
396 | + while (false !== ($files[] = readdir($dirhandle))); |
|
397 | + closedir($dirhandle); |
|
398 | + $dirhead=false; |
|
399 | + |
|
400 | + if (sizeof($files)>0) |
|
401 | + { |
|
402 | + sort($files); |
|
403 | + foreach ($files as $dirfile) |
|
404 | + { |
|
405 | + if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile)) |
|
406 | + { if (!$dirhead) |
|
407 | + { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n"); |
|
408 | + echo ("<tr><th>Filename</th><th>Size</th><th>Date&Time</th><th>Type</th><th> </th><th> </th>\n"); |
|
409 | + $dirhead=true; |
|
410 | + } |
|
411 | + echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($dirfile))."</td>"); |
|
412 | + |
|
413 | + if (preg_match("/\.sql$/i",$dirfile)) |
|
414 | + echo ("<td>SQL</td>"); |
|
415 | + elseif (preg_match("/\.gz$/i",$dirfile)) |
|
416 | + echo ("<td>GZip</td>"); |
|
417 | + elseif (preg_match("/\.csv$/i",$dirfile)) |
|
418 | + echo ("<td>CSV</td>"); |
|
419 | + else |
|
420 | + echo ("<td>Misc</td>"); |
|
421 | + |
|
422 | + if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile)) |
|
423 | + 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"); |
|
424 | + else |
|
425 | + echo ("<td> </td>\n <td> </td></tr>\n"); |
|
426 | + } |
|
427 | + } |
|
428 | + } |
|
429 | + |
|
430 | + if ($dirhead) |
|
431 | + echo ("</table>\n"); |
|
432 | + else |
|
433 | + echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n"); |
|
434 | 434 | } |
435 | 435 | else |
436 | 436 | { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n"); |
437 | - $error=true; |
|
437 | + $error=true; |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | do { $tempfilename=time().".tmp"; } while (file_exists($tempfilename)); |
457 | 457 | if (!($tempfile=@fopen($tempfilename,"w"))) |
458 | 458 | { 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 "); |
459 | - echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n"); |
|
459 | + echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n"); |
|
460 | 460 | } |
461 | 461 | else |
462 | 462 | { fclose($tempfile); |
463 | - unlink ($tempfilename); |
|
463 | + unlink ($tempfilename); |
|
464 | 464 | |
465 | - echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) "); |
|
466 | - echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n"); |
|
465 | + echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) "); |
|
466 | + echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n"); |
|
467 | 467 | ?> |
468 | 468 | <form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data"> |
469 | 469 | <input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize"> |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | $row = mysql_fetch_assoc($result); |
483 | 483 | if ($row) |
484 | 484 | { $charset = $row['Value']; |
485 | - 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"); |
|
485 | + 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"); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
@@ -494,36 +494,36 @@ discard block |
||
494 | 494 | // Set current filename ($filename overrides $_REQUEST["fn"] if set) |
495 | 495 | |
496 | 496 | if ($filename!="") |
497 | - $curfilename=$filename; |
|
497 | + $curfilename=$filename; |
|
498 | 498 | else if (isset($_REQUEST["fn"])) |
499 | - $curfilename=urldecode($_REQUEST["fn"]); |
|
499 | + $curfilename=urldecode($_REQUEST["fn"]); |
|
500 | 500 | else |
501 | - $curfilename=""; |
|
501 | + $curfilename=""; |
|
502 | 502 | |
503 | 503 | // Recognize GZip filename |
504 | 504 | |
505 | 505 | if (preg_match("/\.gz$/i",$curfilename)) |
506 | - $gzipmode=true; |
|
506 | + $gzipmode=true; |
|
507 | 507 | else |
508 | - $gzipmode=false; |
|
508 | + $gzipmode=false; |
|
509 | 509 | |
510 | 510 | if ((!$gzipmode && !$file=@fopen($curfilename,"r")) || ($gzipmode && !$file=@gzopen($curfilename,"r"))) |
511 | 511 | { echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n"); |
512 | - echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.". |
|
513 | - "<br>Or, specify \$filename in bigdump.php with the full filename. ". |
|
514 | - "<br>Or, you have to upload the $curfilename to the server first.</p>\n"); |
|
515 | - $error=true; |
|
512 | + echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.". |
|
513 | + "<br>Or, specify \$filename in bigdump.php with the full filename. ". |
|
514 | + "<br>Or, you have to upload the $curfilename to the server first.</p>\n"); |
|
515 | + $error=true; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | // Get the file size (can't do it fast on gzipped files, no idea how) |
519 | 519 | |
520 | 520 | else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0)) |
521 | 521 | { if (!$gzipmode) $filesize = ftell($file); |
522 | - else $filesize = gztell($file); // Always zero, ignore |
|
522 | + else $filesize = gztell($file); // Always zero, ignore |
|
523 | 523 | } |
524 | 524 | else |
525 | 525 | { echo ("<p class=\"error\">I can't seek into $curfilename</p>\n"); |
526 | - $error=true; |
|
526 | + $error=true; |
|
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
@@ -546,171 +546,171 @@ discard block |
||
546 | 546 | |
547 | 547 | if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"])) |
548 | 548 | { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n"); |
549 | - $error=true; |
|
549 | + $error=true; |
|
550 | 550 | } |
551 | 551 | else |
552 | 552 | { $_REQUEST["start"] = floor($_REQUEST["start"]); |
553 | - $_REQUEST["foffset"] = floor($_REQUEST["foffset"]); |
|
553 | + $_REQUEST["foffset"] = floor($_REQUEST["foffset"]); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | // Set the current delimiter if defined |
557 | 557 | |
558 | 558 | if (isset($_REQUEST["delimiter"])) |
559 | - $delimiter = $_REQUEST["delimiter"]; |
|
559 | + $delimiter = $_REQUEST["delimiter"]; |
|
560 | 560 | |
561 | 561 | // Empty CSV table if requested |
562 | 562 | |
563 | 563 | if (!$error && $_REQUEST["start"]==1 && $csv_insert_table != "" && $csv_preempty_table) |
564 | 564 | { |
565 | - $query = "DELETE FROM $csv_insert_table"; |
|
566 | - if (!TESTMODE && !mysql_query(trim($query), $dbconnection)) |
|
567 | - { echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n"); |
|
568 | - echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n"); |
|
569 | - echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
570 | - $error=true; |
|
571 | - } |
|
565 | + $query = "DELETE FROM $csv_insert_table"; |
|
566 | + if (!TESTMODE && !mysql_query(trim($query), $dbconnection)) |
|
567 | + { echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n"); |
|
568 | + echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n"); |
|
569 | + echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
570 | + $error=true; |
|
571 | + } |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | // Print start message |
575 | 575 | |
576 | 576 | if (!$error) |
577 | 577 | { skin_open(); |
578 | - if (TESTMODE) |
|
579 | - echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n"); |
|
580 | - echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n"); |
|
581 | - echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n"); |
|
582 | - skin_close(); |
|
578 | + if (TESTMODE) |
|
579 | + echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n"); |
|
580 | + echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n"); |
|
581 | + echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n"); |
|
582 | + skin_close(); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files) |
586 | 586 | |
587 | 587 | if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize) |
588 | 588 | { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n"); |
589 | - $error=true; |
|
589 | + $error=true; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // Set file pointer to $_REQUEST["foffset"] |
593 | 593 | |
594 | 594 | if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0))) |
595 | 595 | { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n"); |
596 | - $error=true; |
|
596 | + $error=true; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // Start processing queries from $file |
600 | 600 | |
601 | 601 | if (!$error) |
602 | 602 | { $query=""; |
603 | - $queries=0; |
|
604 | - $totalqueries=$_REQUEST["totalqueries"]; |
|
605 | - $linenumber=$_REQUEST["start"]; |
|
606 | - $querylines=0; |
|
607 | - $inparents=false; |
|
603 | + $queries=0; |
|
604 | + $totalqueries=$_REQUEST["totalqueries"]; |
|
605 | + $linenumber=$_REQUEST["start"]; |
|
606 | + $querylines=0; |
|
607 | + $inparents=false; |
|
608 | 608 | |
609 | 609 | // Stay processing as long as the $linespersession is not reached or the query is still incomplete |
610 | 610 | |
611 | - while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="") |
|
612 | - { |
|
611 | + while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="") |
|
612 | + { |
|
613 | 613 | |
614 | 614 | // Read the whole next line |
615 | 615 | |
616 | - $dumpline = ""; |
|
617 | - while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r") |
|
618 | - { if (!$gzipmode) |
|
619 | - $dumpline .= fgets($file, DATA_CHUNK_LENGTH); |
|
620 | - else |
|
621 | - $dumpline .= gzgets($file, DATA_CHUNK_LENGTH); |
|
622 | - } |
|
623 | - if ($dumpline==="") break; |
|
616 | + $dumpline = ""; |
|
617 | + while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r") |
|
618 | + { if (!$gzipmode) |
|
619 | + $dumpline .= fgets($file, DATA_CHUNK_LENGTH); |
|
620 | + else |
|
621 | + $dumpline .= gzgets($file, DATA_CHUNK_LENGTH); |
|
622 | + } |
|
623 | + if ($dumpline==="") break; |
|
624 | 624 | |
625 | 625 | // Remove UTF8 Byte Order Mark at the file beginning if any |
626 | 626 | |
627 | - if ($_REQUEST["foffset"]==0) |
|
628 | - $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline); |
|
627 | + if ($_REQUEST["foffset"]==0) |
|
628 | + $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline); |
|
629 | 629 | |
630 | 630 | // Create an SQL query from CSV line |
631 | 631 | |
632 | - if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename))) |
|
633 | - { |
|
634 | - if ($csv_add_slashes) |
|
635 | - $dumpline = addslashes($dumpline); |
|
636 | - $dumpline = explode($csv_delimiter,$dumpline); |
|
637 | - if ($csv_add_quotes) |
|
638 | - $dumpline = "'".implode("','",$dumpline)."'"; |
|
639 | - else |
|
640 | - $dumpline = implode(",",$dumpline); |
|
641 | - $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');'; |
|
642 | - } |
|
632 | + if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename))) |
|
633 | + { |
|
634 | + if ($csv_add_slashes) |
|
635 | + $dumpline = addslashes($dumpline); |
|
636 | + $dumpline = explode($csv_delimiter,$dumpline); |
|
637 | + if ($csv_add_quotes) |
|
638 | + $dumpline = "'".implode("','",$dumpline)."'"; |
|
639 | + else |
|
640 | + $dumpline = implode(",",$dumpline); |
|
641 | + $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');'; |
|
642 | + } |
|
643 | 643 | |
644 | 644 | // Handle DOS and Mac encoded linebreaks (I don't know if it really works on Win32 or Mac Servers) |
645 | 645 | |
646 | - $dumpline=str_replace("\r\n", "\n", $dumpline); |
|
647 | - $dumpline=str_replace("\r", "\n", $dumpline); |
|
646 | + $dumpline=str_replace("\r\n", "\n", $dumpline); |
|
647 | + $dumpline=str_replace("\r", "\n", $dumpline); |
|
648 | 648 | |
649 | 649 | // DIAGNOSTIC |
650 | 650 | // echo ("<p>Line $linenumber: $dumpline</p>\n"); |
651 | 651 | |
652 | 652 | // Recognize delimiter statement |
653 | 653 | |
654 | - if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0) |
|
655 | - $delimiter = str_replace ("DELIMITER ","",trim($dumpline)); |
|
654 | + if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0) |
|
655 | + $delimiter = str_replace ("DELIMITER ","",trim($dumpline)); |
|
656 | 656 | |
657 | 657 | // Skip comments and blank lines only if NOT in parents |
658 | 658 | |
659 | - if (!$inparents) |
|
660 | - { $skipline=false; |
|
661 | - reset($comment); |
|
662 | - foreach ($comment as $comment_value) |
|
663 | - { |
|
659 | + if (!$inparents) |
|
660 | + { $skipline=false; |
|
661 | + reset($comment); |
|
662 | + foreach ($comment as $comment_value) |
|
663 | + { |
|
664 | 664 | |
665 | 665 | // DIAGNOSTIC |
666 | 666 | // echo ($comment_value); |
667 | - if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0) |
|
668 | - { $skipline=true; |
|
669 | - break; |
|
670 | - } |
|
671 | - } |
|
672 | - if ($skipline) |
|
673 | - { $linenumber++; |
|
667 | + if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0) |
|
668 | + { $skipline=true; |
|
669 | + break; |
|
670 | + } |
|
671 | + } |
|
672 | + if ($skipline) |
|
673 | + { $linenumber++; |
|
674 | 674 | |
675 | 675 | // DIAGNOSTIC |
676 | 676 | // echo ("<p>Comment line skipped</p>\n"); |
677 | 677 | |
678 | - continue; |
|
679 | - } |
|
680 | - } |
|
678 | + continue; |
|
679 | + } |
|
680 | + } |
|
681 | 681 | |
682 | 682 | // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings) |
683 | 683 | |
684 | - $dumpline_deslashed = str_replace ("\\\\","",$dumpline); |
|
684 | + $dumpline_deslashed = str_replace ("\\\\","",$dumpline); |
|
685 | 685 | |
686 | 686 | // Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter |
687 | 687 | |
688 | - $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes"); |
|
689 | - if ($parents % 2 != 0) |
|
690 | - $inparents=!$inparents; |
|
688 | + $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes"); |
|
689 | + if ($parents % 2 != 0) |
|
690 | + $inparents=!$inparents; |
|
691 | 691 | |
692 | 692 | // Add the line to query |
693 | 693 | |
694 | - $query .= $dumpline; |
|
694 | + $query .= $dumpline; |
|
695 | 695 | |
696 | 696 | // Don't count the line if in parents (text fields may include unlimited linebreaks) |
697 | 697 | |
698 | - if (!$inparents) |
|
699 | - $querylines++; |
|
698 | + if (!$inparents) |
|
699 | + $querylines++; |
|
700 | 700 | |
701 | 701 | // Stop if query contains more lines as defined by MAX_QUERY_LINES |
702 | 702 | |
703 | - if ($querylines>MAX_QUERY_LINES) |
|
704 | - { |
|
705 | - echo ("<p class=\"error\">Stopped at the line $linenumber. </p>"); |
|
706 | - echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was "); |
|
707 | - 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 "); |
|
708 | - echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> "); |
|
709 | - echo ("for more infos. Ask for our support services "); |
|
710 | - echo ("in order to handle dump files containing extended inserts.</p>\n"); |
|
711 | - $error=true; |
|
712 | - break; |
|
713 | - } |
|
703 | + if ($querylines>MAX_QUERY_LINES) |
|
704 | + { |
|
705 | + echo ("<p class=\"error\">Stopped at the line $linenumber. </p>"); |
|
706 | + echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was "); |
|
707 | + 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 "); |
|
708 | + echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> "); |
|
709 | + echo ("for more infos. Ask for our support services "); |
|
710 | + echo ("in order to handle dump files containing extended inserts.</p>\n"); |
|
711 | + $error=true; |
|
712 | + break; |
|
713 | + } |
|
714 | 714 | |
715 | 715 | // Execute query if end of query detected ($delimiter as last character) AND NOT in parents |
716 | 716 | |
@@ -719,43 +719,43 @@ discard block |
||
719 | 719 | // echo ("<p>In Parents: ".($inparents?"true":"false")."</p>\n"); |
720 | 720 | // echo ("<p>Line: $dumpline</p>\n"); |
721 | 721 | |
722 | - if (preg_match('/'.preg_quote($delimiter).'$/',trim($dumpline)) && !$inparents) |
|
723 | - { |
|
722 | + if (preg_match('/'.preg_quote($delimiter).'$/',trim($dumpline)) && !$inparents) |
|
723 | + { |
|
724 | 724 | |
725 | 725 | // Cut off delimiter of the end of the query |
726 | 726 | |
727 | - $query = substr(trim($query),0,-1*strlen($delimiter)); |
|
727 | + $query = substr(trim($query),0,-1*strlen($delimiter)); |
|
728 | 728 | |
729 | 729 | // DIAGNOSTIC |
730 | 730 | // echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n"); |
731 | 731 | |
732 | - if (!TESTMODE && !mysql_query($query, $dbconnection)) |
|
733 | - { echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n"); |
|
734 | - echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n"); |
|
735 | - echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
736 | - $error=true; |
|
737 | - break; |
|
738 | - } |
|
739 | - $totalqueries++; |
|
740 | - $queries++; |
|
741 | - $query=""; |
|
742 | - $querylines=0; |
|
743 | - } |
|
744 | - $linenumber++; |
|
745 | - } |
|
732 | + if (!TESTMODE && !mysql_query($query, $dbconnection)) |
|
733 | + { echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n"); |
|
734 | + echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n"); |
|
735 | + echo ("<p>MySQL: ".mysql_error()."</p>\n"); |
|
736 | + $error=true; |
|
737 | + break; |
|
738 | + } |
|
739 | + $totalqueries++; |
|
740 | + $queries++; |
|
741 | + $query=""; |
|
742 | + $querylines=0; |
|
743 | + } |
|
744 | + $linenumber++; |
|
745 | + } |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | // Get the current file position |
749 | 749 | |
750 | 750 | if (!$error) |
751 | 751 | { if (!$gzipmode) |
752 | - $foffset = ftell($file); |
|
753 | - else |
|
754 | - $foffset = gztell($file); |
|
755 | - if (!$foffset) |
|
756 | - { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"); |
|
757 | - $error=true; |
|
758 | - } |
|
752 | + $foffset = ftell($file); |
|
753 | + else |
|
754 | + $foffset = gztell($file); |
|
755 | + if (!$foffset) |
|
756 | + { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"); |
|
757 | + $error=true; |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | // Print statistics |
@@ -766,63 +766,63 @@ discard block |
||
766 | 766 | |
767 | 767 | if (!$error) |
768 | 768 | { |
769 | - $lines_this = $linenumber-$_REQUEST["start"]; |
|
770 | - $lines_done = $linenumber-1; |
|
771 | - $lines_togo = ' ? '; |
|
772 | - $lines_tota = ' ? '; |
|
769 | + $lines_this = $linenumber-$_REQUEST["start"]; |
|
770 | + $lines_done = $linenumber-1; |
|
771 | + $lines_togo = ' ? '; |
|
772 | + $lines_tota = ' ? '; |
|
773 | 773 | |
774 | - $queries_this = $queries; |
|
775 | - $queries_done = $totalqueries; |
|
776 | - $queries_togo = ' ? '; |
|
777 | - $queries_tota = ' ? '; |
|
778 | - |
|
779 | - $bytes_this = $foffset-$_REQUEST["foffset"]; |
|
780 | - $bytes_done = $foffset; |
|
781 | - $kbytes_this = round($bytes_this/1024,2); |
|
782 | - $kbytes_done = round($bytes_done/1024,2); |
|
783 | - $mbytes_this = round($kbytes_this/1024,2); |
|
784 | - $mbytes_done = round($kbytes_done/1024,2); |
|
774 | + $queries_this = $queries; |
|
775 | + $queries_done = $totalqueries; |
|
776 | + $queries_togo = ' ? '; |
|
777 | + $queries_tota = ' ? '; |
|
778 | + |
|
779 | + $bytes_this = $foffset-$_REQUEST["foffset"]; |
|
780 | + $bytes_done = $foffset; |
|
781 | + $kbytes_this = round($bytes_this/1024,2); |
|
782 | + $kbytes_done = round($bytes_done/1024,2); |
|
783 | + $mbytes_this = round($kbytes_this/1024,2); |
|
784 | + $mbytes_done = round($kbytes_done/1024,2); |
|
785 | 785 | |
786 | - if (!$gzipmode) |
|
787 | - { |
|
788 | - $bytes_togo = $filesize-$foffset; |
|
789 | - $bytes_tota = $filesize; |
|
790 | - $kbytes_togo = round($bytes_togo/1024,2); |
|
791 | - $kbytes_tota = round($bytes_tota/1024,2); |
|
792 | - $mbytes_togo = round($kbytes_togo/1024,2); |
|
793 | - $mbytes_tota = round($kbytes_tota/1024,2); |
|
786 | + if (!$gzipmode) |
|
787 | + { |
|
788 | + $bytes_togo = $filesize-$foffset; |
|
789 | + $bytes_tota = $filesize; |
|
790 | + $kbytes_togo = round($bytes_togo/1024,2); |
|
791 | + $kbytes_tota = round($bytes_tota/1024,2); |
|
792 | + $mbytes_togo = round($kbytes_togo/1024,2); |
|
793 | + $mbytes_tota = round($kbytes_tota/1024,2); |
|
794 | 794 | |
795 | - $pct_this = ceil($bytes_this/$filesize*100); |
|
796 | - $pct_done = ceil($foffset/$filesize*100); |
|
797 | - $pct_togo = 100 - $pct_done; |
|
798 | - $pct_tota = 100; |
|
799 | - |
|
800 | - if ($bytes_togo==0) |
|
801 | - { $lines_togo = '0'; |
|
802 | - $lines_tota = $linenumber-1; |
|
803 | - $queries_togo = '0'; |
|
804 | - $queries_tota = $totalqueries; |
|
805 | - } |
|
806 | - |
|
807 | - $pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>"; |
|
808 | - } |
|
809 | - else |
|
810 | - { |
|
811 | - $bytes_togo = ' ? '; |
|
812 | - $bytes_tota = ' ? '; |
|
813 | - $kbytes_togo = ' ? '; |
|
814 | - $kbytes_tota = ' ? '; |
|
815 | - $mbytes_togo = ' ? '; |
|
816 | - $mbytes_tota = ' ? '; |
|
795 | + $pct_this = ceil($bytes_this/$filesize*100); |
|
796 | + $pct_done = ceil($foffset/$filesize*100); |
|
797 | + $pct_togo = 100 - $pct_done; |
|
798 | + $pct_tota = 100; |
|
799 | + |
|
800 | + if ($bytes_togo==0) |
|
801 | + { $lines_togo = '0'; |
|
802 | + $lines_tota = $linenumber-1; |
|
803 | + $queries_togo = '0'; |
|
804 | + $queries_tota = $totalqueries; |
|
805 | + } |
|
806 | + |
|
807 | + $pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>"; |
|
808 | + } |
|
809 | + else |
|
810 | + { |
|
811 | + $bytes_togo = ' ? '; |
|
812 | + $bytes_tota = ' ? '; |
|
813 | + $kbytes_togo = ' ? '; |
|
814 | + $kbytes_tota = ' ? '; |
|
815 | + $mbytes_togo = ' ? '; |
|
816 | + $mbytes_tota = ' ? '; |
|
817 | 817 | |
818 | - $pct_this = ' ? '; |
|
819 | - $pct_done = ' ? '; |
|
820 | - $pct_togo = ' ? '; |
|
821 | - $pct_tota = 100; |
|
822 | - $pct_bar = str_replace(' ',' ','<tt>[ Not available for gzipped files ]</tt>'); |
|
823 | - } |
|
818 | + $pct_this = ' ? '; |
|
819 | + $pct_done = ' ? '; |
|
820 | + $pct_togo = ' ? '; |
|
821 | + $pct_tota = 100; |
|
822 | + $pct_bar = str_replace(' ',' ','<tt>[ Not available for gzipped files ]</tt>'); |
|
823 | + } |
|
824 | 824 | |
825 | - echo (" |
|
825 | + echo (" |
|
826 | 826 | <center> |
827 | 827 | <table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\"> |
828 | 828 | <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> |
@@ -839,11 +839,11 @@ discard block |
||
839 | 839 | |
840 | 840 | // Finish message and restart the script |
841 | 841 | |
842 | - if ($linenumber<$_REQUEST["start"]+$linespersession) |
|
843 | - { echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n"); |
|
844 | - echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n"); |
|
845 | - 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"); |
|
846 | - echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation via PayPal. Thank you!</p>\n"); |
|
842 | + if ($linenumber<$_REQUEST["start"]+$linespersession) |
|
843 | + { echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n"); |
|
844 | + echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n"); |
|
845 | + 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"); |
|
846 | + echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation via PayPal. Thank you!</p>\n"); |
|
847 | 847 | ?> |
848 | 848 | |
849 | 849 | <!-- Start Paypal donation code --> |
@@ -863,23 +863,23 @@ discard block |
||
863 | 863 | |
864 | 864 | <?php |
865 | 865 | |
866 | - $error=true; // This is a semi-error telling the script is finished |
|
867 | - } |
|
868 | - else |
|
869 | - { if ($delaypersession!=0) |
|
870 | - echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); |
|
871 | - if (!$ajax) |
|
872 | - 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"); |
|
873 | - |
|
874 | - echo ("<noscript>\n"); |
|
875 | - 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"); |
|
876 | - echo ("</noscript>\n"); |
|
866 | + $error=true; // This is a semi-error telling the script is finished |
|
867 | + } |
|
868 | + else |
|
869 | + { if ($delaypersession!=0) |
|
870 | + echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); |
|
871 | + if (!$ajax) |
|
872 | + 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"); |
|
873 | + |
|
874 | + echo ("<noscript>\n"); |
|
875 | + 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"); |
|
876 | + echo ("</noscript>\n"); |
|
877 | 877 | |
878 | - echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n"); |
|
879 | - } |
|
878 | + echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n"); |
|
879 | + } |
|
880 | 880 | } |
881 | 881 | else |
882 | - echo ("<p class=\"error\">Stopped on error</p>\n"); |
|
882 | + echo ("<p class=\"error\">Stopped on error</p>\n"); |
|
883 | 883 | |
884 | 884 | skin_close(); |
885 | 885 | |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | die; |
926 | 926 | } |
927 | 927 | else |
928 | - create_ajax_script(); |
|
928 | + create_ajax_script(); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | // Anyway put out the output from above |
@@ -95,8 +95,9 @@ discard block |
||
95 | 95 | // If not familiar with PHP please don't change anything below this line |
96 | 96 | // ******************************************************************************************* |
97 | 97 | |
98 | -if ($ajax) |
|
98 | +if ($ajax) { |
|
99 | 99 | ob_start(); |
100 | +} |
|
100 | 101 | |
101 | 102 | define ('VERSION','0.34b'); |
102 | 103 | define ('DATA_CHUNK_LENGTH',16384); // How many chars are read per time |
@@ -112,8 +113,9 @@ discard block |
||
112 | 113 | @ini_set('auto_detect_line_endings', true); |
113 | 114 | @set_time_limit(0); |
114 | 115 | |
115 | -if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) |
|
116 | +if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) { |
|
116 | 117 | @date_default_timezone_set(@date_default_timezone_get()); |
118 | +} |
|
117 | 119 | |
118 | 120 | // Clean and strip anything we don't want from user's input [0.27b] |
119 | 121 | |
@@ -296,23 +298,30 @@ discard block |
||
296 | 298 | |
297 | 299 | if (!$error) |
298 | 300 | { $upload_max_filesize=ini_get("upload_max_filesize"); |
299 | - if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024; |
|
300 | - if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024; |
|
301 | - if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024; |
|
302 | -} |
|
301 | + if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) { |
|
302 | + $upload_max_filesize=$tempregs[1]*1024; |
|
303 | + } |
|
304 | + if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) { |
|
305 | + $upload_max_filesize=$tempregs[1]*1024*1024; |
|
306 | + } |
|
307 | + if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) { |
|
308 | + $upload_max_filesize=$tempregs[1]*1024*1024*1024; |
|
309 | + } |
|
310 | + } |
|
303 | 311 | |
304 | 312 | // Get the current directory |
305 | 313 | |
306 | -if (isset($_SERVER["CGIA"])) |
|
314 | +if (isset($_SERVER["CGIA"])) { |
|
307 | 315 | $upload_dir=dirname($_SERVER["CGIA"]); |
308 | -else if (isset($_SERVER["ORIG_PATH_TRANSLATED"])) |
|
316 | +} else if (isset($_SERVER["ORIG_PATH_TRANSLATED"])) { |
|
309 | 317 | $upload_dir=dirname($_SERVER["ORIG_PATH_TRANSLATED"]); |
310 | -else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"])) |
|
318 | +} else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"])) { |
|
311 | 319 | $upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]); |
312 | -else if (isset($_SERVER["PATH_TRANSLATED"])) |
|
320 | +} else if (isset($_SERVER["PATH_TRANSLATED"])) { |
|
313 | 321 | $upload_dir=dirname($_SERVER["PATH_TRANSLATED"]); |
314 | -else |
|
322 | +} else { |
|
315 | 323 | $upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]); |
324 | +} |
|
316 | 325 | |
317 | 326 | // Handle file upload |
318 | 327 | |
@@ -325,19 +334,15 @@ discard block |
||
325 | 334 | |
326 | 335 | if (file_exists($uploaded_filename)) |
327 | 336 | { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n"); |
328 | - } |
|
329 | - else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename)) |
|
337 | + } else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename)) |
|
330 | 338 | { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n"); |
331 | - } |
|
332 | - else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath)) |
|
339 | + } else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath)) |
|
333 | 340 | { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n"); |
334 | 341 | echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n"); |
335 | - } |
|
336 | - else |
|
342 | + } else |
|
337 | 343 | { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n"); |
338 | 344 | } |
339 | - } |
|
340 | - else |
|
345 | + } else |
|
341 | 346 | { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n"); |
342 | 347 | } |
343 | 348 | } |
@@ -346,25 +351,28 @@ discard block |
||
346 | 351 | // Handle file deletion (delete only in the current directory for security reasons) |
347 | 352 | |
348 | 353 | if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"])) |
349 | -{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"]))) |
|
354 | +{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"]))) { |
|
350 | 355 | echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n"); |
351 | - else |
|
352 | - echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n"); |
|
353 | -} |
|
356 | +} else { |
|
357 | + echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n"); |
|
358 | + } |
|
359 | + } |
|
354 | 360 | |
355 | 361 | // Connect to the database, set charset and execute pre-queries |
356 | 362 | |
357 | 363 | if (!$error && !TESTMODE) |
358 | 364 | { $dbconnection = @mysql_connect($db_server,$db_username,$db_password); |
359 | - if ($dbconnection) |
|
360 | - $db = mysql_select_db($db_name); |
|
365 | + if ($dbconnection) { |
|
366 | + $db = mysql_select_db($db_name); |
|
367 | + } |
|
361 | 368 | if (!$dbconnection || !$db) |
362 | 369 | { echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n"); |
363 | 370 | echo ("<p>Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider.</p>\n"); |
364 | 371 | $error=true; |
365 | 372 | } |
366 | - if (!$error && $db_connection_charset!=='') |
|
367 | - @mysql_query("SET NAMES $db_connection_charset", $dbconnection); |
|
373 | + if (!$error && $db_connection_charset!=='') { |
|
374 | + @mysql_query("SET NAMES $db_connection_charset", $dbconnection); |
|
375 | + } |
|
368 | 376 | |
369 | 377 | if (!$error && isset ($pre_query) && sizeof ($pre_query)>0) |
370 | 378 | { reset($pre_query); |
@@ -378,8 +386,7 @@ discard block |
||
378 | 386 | } |
379 | 387 | } |
380 | 388 | } |
381 | -} |
|
382 | -else |
|
389 | +} else |
|
383 | 390 | { $dbconnection = false; |
384 | 391 | } |
385 | 392 | |
@@ -410,29 +417,31 @@ discard block |
||
410 | 417 | } |
411 | 418 | echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($dirfile))."</td>"); |
412 | 419 | |
413 | - if (preg_match("/\.sql$/i",$dirfile)) |
|
414 | - echo ("<td>SQL</td>"); |
|
415 | - elseif (preg_match("/\.gz$/i",$dirfile)) |
|
416 | - echo ("<td>GZip</td>"); |
|
417 | - elseif (preg_match("/\.csv$/i",$dirfile)) |
|
418 | - echo ("<td>CSV</td>"); |
|
419 | - else |
|
420 | - echo ("<td>Misc</td>"); |
|
421 | - |
|
422 | - if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile)) |
|
423 | - 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"); |
|
424 | - else |
|
425 | - echo ("<td> </td>\n <td> </td></tr>\n"); |
|
420 | + if (preg_match("/\.sql$/i",$dirfile)) { |
|
421 | + echo ("<td>SQL</td>"); |
|
422 | + } elseif (preg_match("/\.gz$/i",$dirfile)) { |
|
423 | + echo ("<td>GZip</td>"); |
|
424 | + } elseif (preg_match("/\.csv$/i",$dirfile)) { |
|
425 | + echo ("<td>CSV</td>"); |
|
426 | + } else { |
|
427 | + echo ("<td>Misc</td>"); |
|
428 | + } |
|
429 | + |
|
430 | + if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile)) { |
|
431 | + 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"); |
|
432 | + } else { |
|
433 | + echo ("<td> </td>\n <td> </td></tr>\n"); |
|
434 | + } |
|
426 | 435 | } |
427 | 436 | } |
428 | 437 | } |
429 | 438 | |
430 | - if ($dirhead) |
|
431 | - echo ("</table>\n"); |
|
432 | - else |
|
433 | - echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n"); |
|
434 | - } |
|
435 | - else |
|
439 | + if ($dirhead) { |
|
440 | + echo ("</table>\n"); |
|
441 | + } else { |
|
442 | + echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n"); |
|
443 | + } |
|
444 | + } else |
|
436 | 445 | { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n"); |
437 | 446 | $error=true; |
438 | 447 | } |
@@ -457,8 +466,7 @@ discard block |
||
457 | 466 | if (!($tempfile=@fopen($tempfilename,"w"))) |
458 | 467 | { 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 "); |
459 | 468 | echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n"); |
460 | - } |
|
461 | - else |
|
469 | + } else |
|
462 | 470 | { fclose($tempfile); |
463 | 471 | unlink ($tempfilename); |
464 | 472 | |
@@ -493,19 +501,21 @@ discard block |
||
493 | 501 | |
494 | 502 | // Set current filename ($filename overrides $_REQUEST["fn"] if set) |
495 | 503 | |
496 | - if ($filename!="") |
|
497 | - $curfilename=$filename; |
|
498 | - else if (isset($_REQUEST["fn"])) |
|
499 | - $curfilename=urldecode($_REQUEST["fn"]); |
|
500 | - else |
|
501 | - $curfilename=""; |
|
504 | + if ($filename!="") { |
|
505 | + $curfilename=$filename; |
|
506 | + } else if (isset($_REQUEST["fn"])) { |
|
507 | + $curfilename=urldecode($_REQUEST["fn"]); |
|
508 | + } else { |
|
509 | + $curfilename=""; |
|
510 | + } |
|
502 | 511 | |
503 | 512 | // Recognize GZip filename |
504 | 513 | |
505 | - if (preg_match("/\.gz$/i",$curfilename)) |
|
506 | - $gzipmode=true; |
|
507 | - else |
|
508 | - $gzipmode=false; |
|
514 | + if (preg_match("/\.gz$/i",$curfilename)) { |
|
515 | + $gzipmode=true; |
|
516 | + } else { |
|
517 | + $gzipmode=false; |
|
518 | + } |
|
509 | 519 | |
510 | 520 | if ((!$gzipmode && !$file=@fopen($curfilename,"r")) || ($gzipmode && !$file=@gzopen($curfilename,"r"))) |
511 | 521 | { echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n"); |
@@ -518,10 +528,13 @@ discard block |
||
518 | 528 | // Get the file size (can't do it fast on gzipped files, no idea how) |
519 | 529 | |
520 | 530 | else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0)) |
521 | - { if (!$gzipmode) $filesize = ftell($file); |
|
522 | - else $filesize = gztell($file); // Always zero, ignore |
|
523 | - } |
|
524 | - else |
|
531 | + { if (!$gzipmode) { |
|
532 | + $filesize = ftell($file); |
|
533 | + } else { |
|
534 | + $filesize = gztell($file); |
|
535 | + } |
|
536 | + // Always zero, ignore |
|
537 | + } else |
|
525 | 538 | { echo ("<p class=\"error\">I can't seek into $curfilename</p>\n"); |
526 | 539 | $error=true; |
527 | 540 | } |
@@ -547,16 +560,16 @@ discard block |
||
547 | 560 | if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"])) |
548 | 561 | { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n"); |
549 | 562 | $error=true; |
550 | - } |
|
551 | - else |
|
563 | + } else |
|
552 | 564 | { $_REQUEST["start"] = floor($_REQUEST["start"]); |
553 | 565 | $_REQUEST["foffset"] = floor($_REQUEST["foffset"]); |
554 | 566 | } |
555 | 567 | |
556 | 568 | // Set the current delimiter if defined |
557 | 569 | |
558 | - if (isset($_REQUEST["delimiter"])) |
|
559 | - $delimiter = $_REQUEST["delimiter"]; |
|
570 | + if (isset($_REQUEST["delimiter"])) { |
|
571 | + $delimiter = $_REQUEST["delimiter"]; |
|
572 | + } |
|
560 | 573 | |
561 | 574 | // Empty CSV table if requested |
562 | 575 | |
@@ -575,8 +588,9 @@ discard block |
||
575 | 588 | |
576 | 589 | if (!$error) |
577 | 590 | { skin_open(); |
578 | - if (TESTMODE) |
|
579 | - echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n"); |
|
591 | + if (TESTMODE) { |
|
592 | + echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n"); |
|
593 | + } |
|
580 | 594 | echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n"); |
581 | 595 | echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n"); |
582 | 596 | skin_close(); |
@@ -615,29 +629,35 @@ discard block |
||
615 | 629 | |
616 | 630 | $dumpline = ""; |
617 | 631 | while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r") |
618 | - { if (!$gzipmode) |
|
619 | - $dumpline .= fgets($file, DATA_CHUNK_LENGTH); |
|
620 | - else |
|
621 | - $dumpline .= gzgets($file, DATA_CHUNK_LENGTH); |
|
632 | + { if (!$gzipmode) { |
|
633 | + $dumpline .= fgets($file, DATA_CHUNK_LENGTH); |
|
634 | + } else { |
|
635 | + $dumpline .= gzgets($file, DATA_CHUNK_LENGTH); |
|
636 | + } |
|
637 | + } |
|
638 | + if ($dumpline==="") { |
|
639 | + break; |
|
622 | 640 | } |
623 | - if ($dumpline==="") break; |
|
624 | 641 | |
625 | 642 | // Remove UTF8 Byte Order Mark at the file beginning if any |
626 | 643 | |
627 | - if ($_REQUEST["foffset"]==0) |
|
628 | - $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline); |
|
644 | + if ($_REQUEST["foffset"]==0) { |
|
645 | + $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline); |
|
646 | + } |
|
629 | 647 | |
630 | 648 | // Create an SQL query from CSV line |
631 | 649 | |
632 | 650 | if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename))) |
633 | 651 | { |
634 | - if ($csv_add_slashes) |
|
635 | - $dumpline = addslashes($dumpline); |
|
652 | + if ($csv_add_slashes) { |
|
653 | + $dumpline = addslashes($dumpline); |
|
654 | + } |
|
636 | 655 | $dumpline = explode($csv_delimiter,$dumpline); |
637 | - if ($csv_add_quotes) |
|
638 | - $dumpline = "'".implode("','",$dumpline)."'"; |
|
639 | - else |
|
640 | - $dumpline = implode(",",$dumpline); |
|
656 | + if ($csv_add_quotes) { |
|
657 | + $dumpline = "'".implode("','",$dumpline)."'"; |
|
658 | + } else { |
|
659 | + $dumpline = implode(",",$dumpline); |
|
660 | + } |
|
641 | 661 | $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');'; |
642 | 662 | } |
643 | 663 | |
@@ -651,8 +671,9 @@ discard block |
||
651 | 671 | |
652 | 672 | // Recognize delimiter statement |
653 | 673 | |
654 | - if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0) |
|
655 | - $delimiter = str_replace ("DELIMITER ","",trim($dumpline)); |
|
674 | + if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0) { |
|
675 | + $delimiter = str_replace ("DELIMITER ","",trim($dumpline)); |
|
676 | + } |
|
656 | 677 | |
657 | 678 | // Skip comments and blank lines only if NOT in parents |
658 | 679 | |
@@ -686,8 +707,9 @@ discard block |
||
686 | 707 | // Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter |
687 | 708 | |
688 | 709 | $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes"); |
689 | - if ($parents % 2 != 0) |
|
690 | - $inparents=!$inparents; |
|
710 | + if ($parents % 2 != 0) { |
|
711 | + $inparents=!$inparents; |
|
712 | + } |
|
691 | 713 | |
692 | 714 | // Add the line to query |
693 | 715 | |
@@ -695,8 +717,9 @@ discard block |
||
695 | 717 | |
696 | 718 | // Don't count the line if in parents (text fields may include unlimited linebreaks) |
697 | 719 | |
698 | - if (!$inparents) |
|
699 | - $querylines++; |
|
720 | + if (!$inparents) { |
|
721 | + $querylines++; |
|
722 | + } |
|
700 | 723 | |
701 | 724 | // Stop if query contains more lines as defined by MAX_QUERY_LINES |
702 | 725 | |
@@ -748,10 +771,11 @@ discard block |
||
748 | 771 | // Get the current file position |
749 | 772 | |
750 | 773 | if (!$error) |
751 | - { if (!$gzipmode) |
|
752 | - $foffset = ftell($file); |
|
753 | - else |
|
754 | - $foffset = gztell($file); |
|
774 | + { if (!$gzipmode) { |
|
775 | + $foffset = ftell($file); |
|
776 | + } else { |
|
777 | + $foffset = gztell($file); |
|
778 | + } |
|
755 | 779 | if (!$foffset) |
756 | 780 | { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"); |
757 | 781 | $error=true; |
@@ -805,8 +829,7 @@ discard block |
||
805 | 829 | } |
806 | 830 | |
807 | 831 | $pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>"; |
808 | - } |
|
809 | - else |
|
832 | + } else |
|
810 | 833 | { |
811 | 834 | $bytes_togo = ' ? '; |
812 | 835 | $bytes_tota = ' ? '; |
@@ -864,12 +887,13 @@ discard block |
||
864 | 887 | <?php |
865 | 888 | |
866 | 889 | $error=true; // This is a semi-error telling the script is finished |
890 | + } else |
|
891 | + { if ($delaypersession!=0) { |
|
892 | + echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); |
|
867 | 893 | } |
868 | - else |
|
869 | - { if ($delaypersession!=0) |
|
870 | - echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); |
|
871 | - if (!$ajax) |
|
872 | - 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"); |
|
894 | + if (!$ajax) { |
|
895 | + 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"); |
|
896 | + } |
|
873 | 897 | |
874 | 898 | echo ("<noscript>\n"); |
875 | 899 | 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"); |
@@ -877,20 +901,26 @@ discard block |
||
877 | 901 | |
878 | 902 | echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n"); |
879 | 903 | } |
904 | + } else { |
|
905 | + echo ("<p class=\"error\">Stopped on error</p>\n"); |
|
880 | 906 | } |
881 | - else |
|
882 | - echo ("<p class=\"error\">Stopped on error</p>\n"); |
|
883 | 907 | |
884 | 908 | skin_close(); |
885 | 909 | |
886 | 910 | } |
887 | 911 | |
888 | -if ($error) |
|
912 | +if ($error) { |
|
889 | 913 | echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n"); |
914 | +} |
|
890 | 915 | |
891 | -if ($dbconnection) mysql_close($dbconnection); |
|
892 | -if ($file && !$gzipmode) fclose($file); |
|
893 | -else if ($file && $gzipmode) gzclose($file); |
|
916 | +if ($dbconnection) { |
|
917 | + mysql_close($dbconnection); |
|
918 | +} |
|
919 | +if ($file && !$gzipmode) { |
|
920 | + fclose($file); |
|
921 | +} else if ($file && $gzipmode) { |
|
922 | + gzclose($file); |
|
923 | +} |
|
894 | 924 | |
895 | 925 | ?> |
896 | 926 | |
@@ -923,10 +953,10 @@ discard block |
||
923 | 953 | { ob_end_clean(); |
924 | 954 | create_xml_response(); |
925 | 955 | die; |
926 | - } |
|
927 | - else |
|
928 | - create_ajax_script(); |
|
929 | -} |
|
956 | + } else { |
|
957 | + create_ajax_script(); |
|
958 | + } |
|
959 | + } |
|
930 | 960 | |
931 | 961 | // Anyway put out the output from above |
932 | 962 |
@@ -9,8 +9,8 @@ |
||
9 | 9 | var $sameOrigin; |
10 | 10 | |
11 | 11 | /** |
12 | - * @param bool allow running from the same origin only |
|
13 | - */ |
|
12 | + * @param bool allow running from the same origin only |
|
13 | + */ |
|
14 | 14 | function AdminerFrames($sameOrigin = false) { |
15 | 15 | $this->sameOrigin = $sameOrigin; |
16 | 16 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | var $plugins; |
10 | 10 | |
11 | 11 | /** |
12 | - * @param array |
|
13 | - */ |
|
12 | + * @param array |
|
13 | + */ |
|
14 | 14 | function AdminerPlugin($plugins) { |
15 | 15 | $this->plugins = $plugins; |
16 | 16 | // it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once |
@@ -10,8 +10,8 @@ |
||
10 | 10 | var $path; |
11 | 11 | |
12 | 12 | /** |
13 | - * @param string |
|
14 | - */ |
|
13 | + * @param string |
|
14 | + */ |
|
15 | 15 | function AdminerTinymce($path = "tiny_mce/tiny_mce.js") { |
16 | 16 | $this->path = $path; |
17 | 17 | } |
@@ -18,8 +18,8 @@ |
||
18 | 18 | var $database; |
19 | 19 | |
20 | 20 | /** Set database of login table |
21 | - * @param string |
|
22 | - */ |
|
21 | + * @param string |
|
22 | + */ |
|
23 | 23 | function AdminerLoginTable($database) { |
24 | 24 | $this->database = $database; |
25 | 25 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | var $uploadPath, $displayPath; |
10 | 10 | |
11 | 11 | /** |
12 | - * @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields) |
|
13 | - * @param string prefix for displaying data, null stands for $uploadPath |
|
14 | - */ |
|
12 | + * @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields) |
|
13 | + * @param string prefix for displaying data, null stands for $uploadPath |
|
14 | + */ |
|
15 | 15 | function AdminerFileUpload($uploadPath = "../static/data/", $displayPath = null) { |
16 | 16 | $this->uploadPath = $uploadPath; |
17 | 17 | $this->displayPath = (isset($displayPath) ? $displayPath : $uploadPath); |
@@ -9,9 +9,9 @@ |
||
9 | 9 | var $from, $to; |
10 | 10 | |
11 | 11 | /** |
12 | - * @param string find these characters ... |
|
13 | - * @param string ... and replace them by these |
|
14 | - */ |
|
12 | + * @param string find these characters ... |
|
13 | + * @param string ... and replace them by these |
|
14 | + */ |
|
15 | 15 | function AdminerSlugify($from = 'áčďéěíňóřšťúůýž', $to = 'acdeeinorstuuyz') { |
16 | 16 | $this->from = $from; |
17 | 17 | $this->to = $to; |