Completed
Branch master (0fc797)
by Michael
13:18 queued 09:16
created
mysql.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@
 block discarded – undo
22 22
 $moduleDirName = basename(__DIR__);
23 23
 include(XOOPS_ROOT_PATH . '/header.php');
24 24
 if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) {
25
-    exit(_NOPERM);
25
+	exit(_NOPERM);
26 26
 }
27 27
 
28 28
 function adminer_object()
29 29
 {
30
-    class AdminerKfr extends Adminer
31
-    {
32
-        public function name()
33
-        {
34
-            return 'XOOPS Admin';
35
-        }
30
+	class AdminerKfr extends Adminer
31
+	{
32
+		public function name()
33
+		{
34
+			return 'XOOPS Admin';
35
+		}
36 36
 
37
-        public function credentials()
38
-        {
39
-            return array(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
40
-        }
37
+		public function credentials()
38
+		{
39
+			return array(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
40
+		}
41 41
 
42
-        public function database()
43
-        {
44
-            return XOOPS_DB_NAME;
45
-        }
42
+		public function database()
43
+		{
44
+			return XOOPS_DB_NAME;
45
+		}
46 46
 
47
-        public function login($login, $password)
48
-        {
49
-            return ($login == XOOPS_DB_USER);
50
-        }
51
-    }
47
+		public function login($login, $password)
48
+		{
49
+			return ($login == XOOPS_DB_USER);
50
+		}
51
+	}
52 52
 
53
-    return new AdminerKfr;
53
+	return new AdminerKfr;
54 54
 }
55 55
 
56 56
 /*
Please login to merge, or discard this patch.
include/plugins/edit-calendar.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 	var $prepend, $langPath;
14 14
 
15 15
 	/**
16
-	* @param string text to append before first calendar usage
17
-	* @param string path to language file, %s stands for language code
18
-	*/
16
+	 * @param string text to append before first calendar usage
17
+	 * @param string path to language file, %s stands for language code
18
+	 */
19 19
 	function __construct($prepend = "<script type='text/javascript' src='jquery-ui/jquery.js'></script>\n<script type='text/javascript' src='jquery-ui/jquery-ui.js'></script>\n<script type='text/javascript' src='jquery-ui/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' type='text/css' href='jquery-ui/jquery-ui.css'>\n", $langPath = 'jquery-ui/i18n/jquery.ui.datepicker-%s.js'
20
-    ) {
20
+	) {
21 21
 		$this->prepend = $prepend;
22 22
 		$this->langPath = $langPath;
23 23
 	}
Please login to merge, or discard this patch.
include/plugins/FasterTablesFilter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
       tableDiv.appendChild(fragment);
52 52
     }
53 53
 
54
-    var tables = [<?php foreach($tables as $table => $type) { echo "'".urlencode($table) ."'" . ',';}?>];
54
+    var tables = [<?php foreach ($tables as $table => $type) { echo "'" . urlencode($table) . "'" . ','; }?>];
55 55
     var tempTables = tables;
56 56
     var hMe = "<?php echo h(ME) ?>";
57 57
     hMe = hMe.replace(/&amp;/g, '&');
58
-    var langSelect = "<?php echo lang('select');?>";
58
+    var langSelect = "<?php echo lang('select'); ?>";
59 59
 
60 60
 
61 61
     var filter = document.getElementById("filter-field");
@@ -82,4 +82,4 @@  discard block
 block discarded – undo
82 82
   }
83 83
   filterf();
84 84
 </script>
85
-<?php return true;}} ?>
85
+<?php return true; }} ?>
Please login to merge, or discard this patch.
include/plugins/foreign-system.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 				case 'tables_priv': return array(array('table' => 'user', 'source' => array('Host', 'User'), 'target' => array('Host', 'User')));
21 21
 				case 'time_zone_name': return array(array('table' => 'time_zone', 'source' => array('Time_zone_id'), 'target' => array('Time_zone_id')));
22 22
 				case 'time_zone_transition': return array(array('table' => 'time_zone', 'source' => array('Time_zone_id'), 'target' => array('Time_zone_id')), array(
23
-                    'table' => 'time_zone_transition_type', 'source' => array('Time_zone_id', 'Transition_type_id'), 'target' => array(
24
-                    'Time_zone_id',
25
-                    'Transition_type_id'
26
-                )));
23
+					'table' => 'time_zone_transition_type', 'source' => array('Time_zone_id', 'Transition_type_id'), 'target' => array(
24
+					'Time_zone_id',
25
+					'Transition_type_id'
26
+				)));
27 27
 				case 'time_zone_transition_type': return array(array('table' => 'time_zone', 'source' => array('Time_zone_id'), 'target' => array('Time_zone_id')));
28 28
 			}
29 29
 		} elseif (DB == 'information_schema') {
@@ -44,40 +44,40 @@  discard block
 block discarded – undo
44 44
 				case 'EVENTS': return array_merge(array(array('source' => array('EVENT_CATALOG', 'EVENT_SCHEMA')) + $schemata), $routine_charsets);
45 45
 				case 'FILES': return array($schemata, $tables);
46 46
 				case 'KEY_COLUMN_USAGE': return array(array('source' => array('CONSTRAINT_CATALOG', 'CONSTRAINT_SCHEMA')) + $schemata, $schemata, $tables, $columns, array('source' => array('TABLE_CATALOG', 'REFERENCED_TABLE_SCHEMA')) + $schemata, array(
47
-                                                                                                                                                                                                                                                           'source' => array(
48
-                                                         'TABLE_CATALOG',
49
-                                                         'REFERENCED_TABLE_SCHEMA',
50
-                                                         'REFERENCED_TABLE_NAME'
51
-                                                     )) + $tables, array(
52
-                                                                                                                                                                                                                                                                                                                                                                    'source' => array(
53
-                                                         'TABLE_CATALOG',
54
-                                                         'REFERENCED_TABLE_SCHEMA',
55
-                                                         'REFERENCED_TABLE_NAME',
56
-                                                         'REFERENCED_COLUMN_NAME'
57
-                                                     )) + $columns);
47
+																																																														   'source' => array(
48
+														 'TABLE_CATALOG',
49
+														 'REFERENCED_TABLE_SCHEMA',
50
+														 'REFERENCED_TABLE_NAME'
51
+													 )) + $tables, array(
52
+																																																																																									'source' => array(
53
+														 'TABLE_CATALOG',
54
+														 'REFERENCED_TABLE_SCHEMA',
55
+														 'REFERENCED_TABLE_NAME',
56
+														 'REFERENCED_COLUMN_NAME'
57
+													 )) + $columns);
58 58
 				case 'PARTITIONS': return array($schemata, $tables);
59 59
 				case 'REFERENTIAL_CONSTRAINTS': return array(array('source' => array('CONSTRAINT_CATALOG', 'CONSTRAINT_SCHEMA')) + $schemata, array('source' => array('UNIQUE_CONSTRAINT_CATALOG', 'UNIQUE_CONSTRAINT_SCHEMA')) + $schemata, array(
60
-                                                                                                                                                                                                                                                 'source' => array(
61
-                                                                'CONSTRAINT_CATALOG',
62
-                                                                'CONSTRAINT_SCHEMA',
63
-                                                                'TABLE_NAME'
64
-                                                            )) + $tables, array(
65
-                                                                                                                                                                                                                                                                                                                                              'source' => array(
66
-                                                                'CONSTRAINT_CATALOG',
67
-                                                                'CONSTRAINT_SCHEMA',
68
-                                                                'REFERENCED_TABLE_NAME'
69
-                                                            )) + $tables);
60
+																																																												 'source' => array(
61
+																'CONSTRAINT_CATALOG',
62
+																'CONSTRAINT_SCHEMA',
63
+																'TABLE_NAME'
64
+															)) + $tables, array(
65
+																																																																																			  'source' => array(
66
+																'CONSTRAINT_CATALOG',
67
+																'CONSTRAINT_SCHEMA',
68
+																'REFERENCED_TABLE_NAME'
69
+															)) + $tables);
70 70
 				case 'ROUTINES': return array_merge(array(array('source' => array('ROUTINE_CATALOG', 'ROUTINE_SCHEMA')) + $schemata), $routine_charsets);
71 71
 				case 'SCHEMA_PRIVILEGES': return array($schemata);
72 72
 				case 'STATISTICS': return array($schemata, $tables, $columns, array('source' => array('TABLE_CATALOG', 'INDEX_SCHEMA')) + $schemata);
73 73
 				case 'TABLE_CONSTRAINTS': return array(array('source' => array('CONSTRAINT_CATALOG', 'CONSTRAINT_SCHEMA')) + $schemata, array('source' => array('CONSTRAINT_CATALOG', 'TABLE_SCHEMA')) + $schemata, array('source' => array('CONSTRAINT_CATALOG', 'TABLE_SCHEMA', 'TABLE_NAME')) + $tables);
74 74
 				case 'TABLE_PRIVILEGES': return array($schemata, $tables);
75 75
 				case 'TRIGGERS': return array_merge(array(array('source' => array('TRIGGER_CATALOG', 'TRIGGER_SCHEMA')) + $schemata, array('source' => array('EVENT_OBJECT_CATALOG', 'EVENT_OBJECT_SCHEMA')) + $schemata, array(
76
-                                                                                                                                                                                                                              'source' => array(
77
-                                                             'EVENT_OBJECT_CATALOG',
78
-                                                             'EVENT_OBJECT_SCHEMA',
79
-                                                             'EVENT_OBJECT_TABLE'
80
-                                                         )) + $tables), $routine_charsets);
76
+																																																							  'source' => array(
77
+															 'EVENT_OBJECT_CATALOG',
78
+															 'EVENT_OBJECT_SCHEMA',
79
+															 'EVENT_OBJECT_TABLE'
80
+														 )) + $tables), $routine_charsets);
81 81
 				case 'VIEWS': return array($schemata);
82 82
 			}
83 83
 		}
Please login to merge, or discard this patch.
include/plugins/translation.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@
 block discarded – undo
39 39
 	}
40 40
 	
41 41
 	function tableName(&$tableStatus) {
42
-        $tableStatus['Comment'] = $this->_translate($tableStatus['Comment']);
42
+		$tableStatus['Comment'] = $this->_translate($tableStatus['Comment']);
43 43
 	}
44 44
 	
45 45
 	function fieldName(&$field, $order = 0) {
46
-        $field['comment'] = $this->_translate($field['comment']);
46
+		$field['comment'] = $this->_translate($field['comment']);
47 47
 	}
48 48
 	
49 49
 	function editVal(&$val, $field) {
Please login to merge, or discard this patch.
include/plugins/tinymce.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
include/plugins/login-servers.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
 	var $servers, $driver;
12 12
 	
13 13
 	/** Set supported servers
14
-	* @param array array($domain) or array($domain => $description) or array($category => array())
15
-	* @param string
16
-	*/
14
+	 * @param array array($domain) or array($domain => $description) or array($category => array())
15
+	 * @param string
16
+	 */
17 17
 	function __construct($servers, $driver = 'server') {
18 18
 		$this->servers = $servers;
19 19
 		$this->driver = $driver;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		?>
40 40
 <table cellspacing="0">
41 41
 <tr><th><?php echo lang('Server'); ?><td><input type="hidden" name="auth[driver]" value="<?php echo $this->driver; ?>"><select name="auth[server]"><?php echo optionlist($this->servers, SERVER); ?></select>
42
-<tr><th><?php echo lang('Username'); ?><td><input id="username" name="auth[username]" value="<?php echo h($_GET['username']);  ?>">
42
+<tr><th><?php echo lang('Username'); ?><td><input id="username" name="auth[username]" value="<?php echo h($_GET['username']); ?>">
43 43
 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
44 44
 </table>
45 45
 <p><input type="submit" value="<?php echo lang('Login'); ?>">
Please login to merge, or discard this patch.
include/plugins/file-upload.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 	var $uploadPath, $displayPath, $extensions;
13 13
 
14 14
 	/**
15
-	* @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields)
16
-	* @param string prefix for displaying data, null stands for $uploadPath
17
-	* @param string regular expression with allowed file extensions
18
-	*/
15
+	 * @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields)
16
+	 * @param string prefix for displaying data, null stands for $uploadPath
17
+	 * @param string regular expression with allowed file extensions
18
+	 */
19 19
 	function __construct($uploadPath = '../static/data/', $displayPath = null, $extensions = '[a-zA-Z0-9]+') {
20 20
 		$this->uploadPath = $uploadPath;
21 21
 		$this->displayPath = ($displayPath !== null ? $displayPath : $uploadPath);
Please login to merge, or discard this patch.
include/bigdump.php 3 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 $ajax               = true;   // AJAX mode: import will be done without refreshing the website
56 56
 $linespersession    = 3000;   // Lines to be executed per one import session
57 57
 $delaypersession    = 0;      // You can specify a sleep time in milliseconds after each session
58
-                              // Works only if JavaScript is activated. Use to reduce server overrun
58
+							  // Works only if JavaScript is activated. Use to reduce server overrun
59 59
 
60 60
 // CSV related settings (only if you use a CSV dump)
61 61
 
@@ -353,25 +353,25 @@  discard block
 block discarded – undo
353 353
 if (!$error && isset($_REQUEST["uploadbutton"]))
354 354
 { if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
355 355
   { 
356
-    $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
357
-    $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
358
-    $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
356
+	$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
357
+	$uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
358
+	$uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
359 359
 
360
-    do_action('file_uploaded');
360
+	do_action('file_uploaded');
361 361
 
362
-    if (file_exists($uploaded_filename))
363
-    { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
364
-    }
365
-    else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
366
-    { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
367
-    }
368
-    else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
369
-    { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
370
-      echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
371
-    }
372
-    else
373
-    { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
374
-    }
362
+	if (file_exists($uploaded_filename))
363
+	{ echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
364
+	}
365
+	else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
366
+	{ echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
367
+	}
368
+	else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
369
+	{ echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
370
+	  echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
371
+	}
372
+	else
373
+	{ echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
374
+	}
375 375
   }
376 376
   else
377 377
   { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 
384 384
 if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
385 385
 { if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"])) 
386
-    echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
386
+	echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
387 387
   else
388
-    echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
388
+	echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
389 389
 }
390 390
 
391 391
 // Connect to the database, set charset and execute pre-queries
@@ -395,23 +395,23 @@  discard block
 block discarded – undo
395 395
   
396 396
   if (mysqli_connect_error()) 
397 397
   { echo ("<p class=\"error\">Database connection failed due to ".mysqli_connect_error()."</p>\n");
398
-    echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
399
-    $error=true;
398
+	echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
399
+	$error=true;
400 400
   }
401 401
   if (!$error && $db_connection_charset!=='')
402
-    $mysqli->query("SET NAMES $db_connection_charset");
402
+	$mysqli->query("SET NAMES $db_connection_charset");
403 403
 
404 404
   if (!$error && isset ($pre_query) && sizeof ($pre_query)>0)
405 405
   { reset($pre_query);
406
-    foreach ($pre_query as $pre_query_value)
407
-    {	if (!$mysqli->query($pre_query_value))
408
-    	{ echo ("<p class=\"error\">Error with pre-query.</p>\n");
409
-      	echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n");
410
-      	echo ("<p>MySQL: ".$mysqli->error."</p>\n");
411
-      	$error=true;
412
-      	break;
413
-     }
414
-    }
406
+	foreach ($pre_query as $pre_query_value)
407
+	{	if (!$mysqli->query($pre_query_value))
408
+		{ echo ("<p class=\"error\">Error with pre-query.</p>\n");
409
+	  	echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n");
410
+	  	echo ("<p>MySQL: ".$mysqli->error."</p>\n");
411
+	  	$error=true;
412
+	  	break;
413
+	 }
414
+	}
415 415
   }
416 416
 }
417 417
 else
@@ -428,50 +428,50 @@  discard block
 block discarded – undo
428 428
 if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
429 429
 { if ($dirhandle = opendir($upload_dir)) 
430 430
   { 
431
-    $files=array();
432
-    while (false !== ($files[] = readdir($dirhandle)));
433
-    closedir($dirhandle);
434
-    $dirhead=false;
435
-
436
-    if (sizeof($files)>0)
437
-    { 
438
-      sort($files);
439
-      foreach ($files as $dirfile)
440
-      { 
441
-        if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile))
442
-        { if (!$dirhead)
443
-          { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
444
-            echo ("<tr><th>Filename</th><th>Size</th><th>Date&amp;Time</th><th>Type</th><th>&nbsp;</th><th>&nbsp;</th>\n");
445
-            $dirhead=true;
446
-          }
447
-          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>");
448
-
449
-          if (preg_match("/\.sql$/i",$dirfile))
450
-            echo ("<td>SQL</td>");
451
-          elseif (preg_match("/\.gz$/i",$dirfile))
452
-            echo ("<td>GZip</td>");
453
-          elseif (preg_match("/\.csv$/i",$dirfile))
454
-            echo ("<td>CSV</td>");
455
-          else
456
-            echo ("<td>Misc</td>");
457
-
458
-          if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile))
459
-            echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;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");
431
+	$files=array();
432
+	while (false !== ($files[] = readdir($dirhandle)));
433
+	closedir($dirhandle);
434
+	$dirhead=false;
435
+
436
+	if (sizeof($files)>0)
437
+	{ 
438
+	  sort($files);
439
+	  foreach ($files as $dirfile)
440
+	  { 
441
+		if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile))
442
+		{ if (!$dirhead)
443
+		  { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
444
+			echo ("<tr><th>Filename</th><th>Size</th><th>Date&amp;Time</th><th>Type</th><th>&nbsp;</th><th>&nbsp;</th>\n");
445
+			$dirhead=true;
446
+		  }
447
+		  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>");
448
+
449
+		  if (preg_match("/\.sql$/i",$dirfile))
450
+			echo ("<td>SQL</td>");
451
+		  elseif (preg_match("/\.gz$/i",$dirfile))
452
+			echo ("<td>GZip</td>");
453
+		  elseif (preg_match("/\.csv$/i",$dirfile))
454
+			echo ("<td>CSV</td>");
455
+		  else
456
+			echo ("<td>Misc</td>");
457
+
458
+		  if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile))
459
+			echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;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");
460 460
 // TODO: echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;delimiter=".urlencode($delimiter)."\">Start Import</a></td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
461
-          else
462
-            echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
463
-        }
464
-      }
465
-    }
461
+		  else
462
+			echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
463
+		}
464
+	  }
465
+	}
466 466
 
467
-    if ($dirhead) 
468
-      echo ("</table>\n");
469
-    else 
470
-      echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
467
+	if ($dirhead) 
468
+	  echo ("</table>\n");
469
+	else 
470
+	  echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
471 471
   }
472 472
   else
473 473
   { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
474
-    $error=true;
474
+	$error=true;
475 475
   }
476 476
 }
477 477
 
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
   do { $tempfilename=$upload_dir.'/'.time().".tmp"; } while (file_exists($tempfilename)); 
494 494
   if (!($tempfile=@fopen($tempfilename,"w")))
495 495
   { 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 ");
496
-    echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
496
+	echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
497 497
   }
498 498
   else
499 499
   { fclose($tempfile);
500
-    unlink ($tempfilename);
500
+	unlink ($tempfilename);
501 501
  
502
-    echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes)  ");
503
-    echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
502
+	echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes)  ");
503
+	echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
504 504
 ?>
505 505
 <form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
506 506
 <input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize">
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
   $result = $mysqli->query("SHOW VARIABLES LIKE 'character_set_connection';");
519 519
   if ($result) 
520 520
   { $row = $result->fetch_assoc();
521
-    if ($row) 
522
-    { $charset = $row['Value'];
523
-      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");
524
-    }
525
-    $result->free();
521
+	if ($row) 
522
+	{ $charset = $row['Value'];
523
+	  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");
524
+	}
525
+	$result->free();
526 526
   }
527 527
 }
528 528
 
@@ -534,43 +534,43 @@  discard block
 block discarded – undo
534 534
 // Set current filename ($filename overrides $_REQUEST["fn"] if set)
535 535
 
536 536
   if ($filename!="")
537
-    $curfilename=$filename;
537
+	$curfilename=$filename;
538 538
   else if (isset($_REQUEST["fn"]))
539
-    $curfilename=urldecode($_REQUEST["fn"]);
539
+	$curfilename=urldecode($_REQUEST["fn"]);
540 540
   else
541
-    $curfilename="";
541
+	$curfilename="";
542 542
 
543 543
 // Recognize GZip filename
544 544
 
545 545
   if (preg_match("/\.gz$/i",$curfilename)) 
546
-    $gzipmode=true;
546
+	$gzipmode=true;
547 547
   else
548
-    $gzipmode=false;
548
+	$gzipmode=false;
549 549
 
550 550
   if ((!$gzipmode && !$file=@fopen($upload_dir.'/'.$curfilename,"r")) || ($gzipmode && !$file=@gzopen($upload_dir.'/'.$curfilename,"r")))
551 551
   { echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n");
552
-    echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.".
553
-           "<br>Or, specify \$filename in bigdump.php with the full filename. ".
554
-           "<br>Or, you have to upload the $curfilename to the server first.</p>\n");
555
-    $error=true;
552
+	echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.".
553
+		   "<br>Or, specify \$filename in bigdump.php with the full filename. ".
554
+		   "<br>Or, you have to upload the $curfilename to the server first.</p>\n");
555
+	$error=true;
556 556
   }
557 557
 
558 558
 // Get the file size (can't do it fast on gzipped files, no idea how)
559 559
 
560 560
   else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0))
561 561
   { if (!$gzipmode) $filesize = ftell($file);
562
-    else $filesize = gztell($file);                   // Always zero, ignore
562
+	else $filesize = gztell($file);                   // Always zero, ignore
563 563
   }
564 564
   else
565 565
   { echo ("<p class=\"error\">I can't seek into $curfilename</p>\n");
566
-    $error=true;
566
+	$error=true;
567 567
   }
568 568
 
569 569
 // Stop if csv file is used, but $csv_insert_table is not set
570 570
 
571 571
   if (!$error && ($csv_insert_table == "") && (preg_match("/(\.csv)$/i",$curfilename)))
572 572
   { echo ("<p class=\"error\">You have to specify \$csv_insert_table when using a CSV file. </p>\n");
573
-    $error=true;
573
+	$error=true;
574 574
   }
575 575
 }
576 576
 
@@ -588,171 +588,171 @@  discard block
 block discarded – undo
588 588
 
589 589
   if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
590 590
   { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
591
-    $error=true;
591
+	$error=true;
592 592
   }
593 593
   else
594 594
   {	$_REQUEST["start"]   = floor($_REQUEST["start"]);
595
-    $_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
595
+	$_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
596 596
   }
597 597
 
598 598
 // Set the current delimiter if defined
599 599
 
600 600
   if (isset($_REQUEST["delimiter"]))
601
-    $delimiter = $_REQUEST["delimiter"];
601
+	$delimiter = $_REQUEST["delimiter"];
602 602
 
603 603
 // Empty CSV table if requested
604 604
 
605 605
   if (!$error && $_REQUEST["start"]==1 && $csv_insert_table != "" && $csv_preempty_table)
606 606
   { 
607
-    $query = "DELETE FROM `$csv_insert_table`";
608
-    if (!TESTMODE && !$mysqli->query(trim($query)))
609
-    { echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n");
610
-      echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
611
-      echo ("<p>MySQL: ".$mysqli->error."</p>\n");
612
-      $error=true;
613
-    }
607
+	$query = "DELETE FROM `$csv_insert_table`";
608
+	if (!TESTMODE && !$mysqli->query(trim($query)))
609
+	{ echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n");
610
+	  echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
611
+	  echo ("<p>MySQL: ".$mysqli->error."</p>\n");
612
+	  $error=true;
613
+	}
614 614
   }
615 615
   
616 616
 // Print start message
617 617
 
618 618
   if (!$error)
619 619
   { skin_open();
620
-    if (TESTMODE) 
621
-      echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
622
-    echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
623
-    echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");	
624
-    skin_close();
620
+	if (TESTMODE) 
621
+	  echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
622
+	echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
623
+	echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");	
624
+	skin_close();
625 625
   }
626 626
 
627 627
 // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files)
628 628
 
629 629
   if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize)
630 630
   { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n");
631
-    $error=true;
631
+	$error=true;
632 632
   }
633 633
 
634 634
 // Set file pointer to $_REQUEST["foffset"]
635 635
 
636 636
   if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0)))
637 637
   { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n");
638
-    $error=true;
638
+	$error=true;
639 639
   }
640 640
 
641 641
 // Start processing queries from $file
642 642
 
643 643
   if (!$error)
644 644
   { $query="";
645
-    $queries=0;
646
-    $totalqueries=$_REQUEST["totalqueries"];
647
-    $linenumber=$_REQUEST["start"];
648
-    $querylines=0;
649
-    $inparents=false;
645
+	$queries=0;
646
+	$totalqueries=$_REQUEST["totalqueries"];
647
+	$linenumber=$_REQUEST["start"];
648
+	$querylines=0;
649
+	$inparents=false;
650 650
 
651 651
 // Stay processing as long as the $linespersession is not reached or the query is still incomplete
652 652
 
653
-    while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
654
-    {
653
+	while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
654
+	{
655 655
 
656 656
 // Read the whole next line
657 657
 
658
-      $dumpline = "";
659
-      while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r")
660
-      { if (!$gzipmode)
661
-          $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
662
-        else
663
-          $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
664
-      }
665
-      if ($dumpline==="") break;
658
+	  $dumpline = "";
659
+	  while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r")
660
+	  { if (!$gzipmode)
661
+		  $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
662
+		else
663
+		  $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
664
+	  }
665
+	  if ($dumpline==="") break;
666 666
 
667 667
 // Remove UTF8 Byte Order Mark at the file beginning if any
668 668
 
669
-      if ($_REQUEST["foffset"]==0)
670
-        $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
669
+	  if ($_REQUEST["foffset"]==0)
670
+		$dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
671 671
 
672 672
 // Create an SQL query from CSV line
673 673
 
674
-      if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename)))
675
-      {
676
-        if ($csv_add_slashes)
677
-          $dumpline = addslashes($dumpline);
678
-        $dumpline = explode($csv_delimiter,$dumpline);
679
-        if ($csv_add_quotes)
680
-          $dumpline = "'".implode("','",$dumpline)."'";
681
-        else
682
-          $dumpline = implode(",",$dumpline);
683
-        $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
684
-      }
674
+	  if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename)))
675
+	  {
676
+		if ($csv_add_slashes)
677
+		  $dumpline = addslashes($dumpline);
678
+		$dumpline = explode($csv_delimiter,$dumpline);
679
+		if ($csv_add_quotes)
680
+		  $dumpline = "'".implode("','",$dumpline)."'";
681
+		else
682
+		  $dumpline = implode(",",$dumpline);
683
+		$dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
684
+	  }
685 685
 
686 686
 // Handle DOS and Mac encoded linebreaks (I don't know if it really works on Win32 or Mac Servers)
687 687
 
688
-      $dumpline=str_replace("\r\n", "\n", $dumpline);
689
-      $dumpline=str_replace("\r", "\n", $dumpline);
688
+	  $dumpline=str_replace("\r\n", "\n", $dumpline);
689
+	  $dumpline=str_replace("\r", "\n", $dumpline);
690 690
             
691 691
 // DIAGNOSTIC
692 692
 // echo ("<p>Line $linenumber: $dumpline</p>\n");
693 693
 
694 694
 // Recognize delimiter statement
695 695
 
696
-      if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0)
697
-        $delimiter = str_replace ("DELIMITER ","",trim($dumpline));
696
+	  if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0)
697
+		$delimiter = str_replace ("DELIMITER ","",trim($dumpline));
698 698
 
699 699
 // Skip comments and blank lines only if NOT in parents
700 700
 
701
-      if (!$inparents)
702
-      { $skipline=false;
703
-        reset($comment);
704
-        foreach ($comment as $comment_value)
705
-        { 
701
+	  if (!$inparents)
702
+	  { $skipline=false;
703
+		reset($comment);
704
+		foreach ($comment as $comment_value)
705
+		{ 
706 706
 
707 707
 // DIAGNOSTIC
708 708
 //          echo ($comment_value);
709
-          if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0)
710
-          { $skipline=true;
711
-            break;
712
-          }
713
-        }
714
-        if ($skipline)
715
-        { $linenumber++;
709
+		  if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0)
710
+		  { $skipline=true;
711
+			break;
712
+		  }
713
+		}
714
+		if ($skipline)
715
+		{ $linenumber++;
716 716
 
717 717
 // DIAGNOSTIC
718 718
 // echo ("<p>Comment line skipped</p>\n");
719 719
 
720
-          continue;
721
-        }
722
-      }
720
+		  continue;
721
+		}
722
+	  }
723 723
 
724 724
 // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
725 725
       
726
-      $dumpline_deslashed = str_replace ("\\\\","",$dumpline);
726
+	  $dumpline_deslashed = str_replace ("\\\\","",$dumpline);
727 727
 
728 728
 // Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter
729 729
 
730
-      $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes");
731
-      if ($parents % 2 != 0)
732
-        $inparents=!$inparents;
730
+	  $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes");
731
+	  if ($parents % 2 != 0)
732
+		$inparents=!$inparents;
733 733
 
734 734
 // Add the line to query
735 735
 
736
-      $query .= $dumpline;
736
+	  $query .= $dumpline;
737 737
 
738 738
 // Don't count the line if in parents (text fields may include unlimited linebreaks)
739 739
       
740
-      if (!$inparents)
741
-        $querylines++;
740
+	  if (!$inparents)
741
+		$querylines++;
742 742
       
743 743
 // Stop if query contains more lines as defined by $max_query_lines
744 744
 
745
-      if ($querylines>$max_query_lines)
746
-      {
747
-        echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
748
-        echo ("<p>At this place the current query includes more than ".$max_query_lines." dump lines. That can happen if your dump file was ");
749
-        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 ");
750
-        echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> ");
751
-        echo ("for more infos. Ask for our support services ");
752
-        echo ("in order to handle dump files containing extended inserts.</p>\n");
753
-        $error=true;
754
-        break;
755
-      }
745
+	  if ($querylines>$max_query_lines)
746
+	  {
747
+		echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
748
+		echo ("<p>At this place the current query includes more than ".$max_query_lines." dump lines. That can happen if your dump file was ");
749
+		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 ");
750
+		echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> ");
751
+		echo ("for more infos. Ask for our support services ");
752
+		echo ("in order to handle dump files containing extended inserts.</p>\n");
753
+		$error=true;
754
+		break;
755
+	  }
756 756
 
757 757
 // Execute query if end of query detected ($delimiter as last character) AND NOT in parents
758 758
 
@@ -761,43 +761,43 @@  discard block
 block discarded – undo
761 761
 // echo ("<p>In Parents: ".($inparents?"true":"false")."</p>\n");
762 762
 // echo ("<p>Line: $dumpline</p>\n");
763 763
 
764
-      if ((preg_match('/'.preg_quote($delimiter,'/').'$/',trim($dumpline)) || $delimiter=='') && !$inparents)
765
-      { 
764
+	  if ((preg_match('/'.preg_quote($delimiter,'/').'$/',trim($dumpline)) || $delimiter=='') && !$inparents)
765
+	  { 
766 766
 
767 767
 // Cut off delimiter of the end of the query
768 768
 
769
-        $query = substr(trim($query),0,-1*strlen($delimiter));
769
+		$query = substr(trim($query),0,-1*strlen($delimiter));
770 770
 
771 771
 // DIAGNOSTIC
772 772
 // echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
773 773
 
774
-        if (!TESTMODE && !$mysqli->query($query))
775
-        { echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
776
-          echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
777
-          echo ("<p>MySQL: ".$mysqli->error."</p>\n");
778
-          $error=true;
779
-          break;
780
-        }
781
-        $totalqueries++;
782
-        $queries++;
783
-        $query="";
784
-        $querylines=0;
785
-      }
786
-      $linenumber++;
787
-    }
774
+		if (!TESTMODE && !$mysqli->query($query))
775
+		{ echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
776
+		  echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
777
+		  echo ("<p>MySQL: ".$mysqli->error."</p>\n");
778
+		  $error=true;
779
+		  break;
780
+		}
781
+		$totalqueries++;
782
+		$queries++;
783
+		$query="";
784
+		$querylines=0;
785
+	  }
786
+	  $linenumber++;
787
+	}
788 788
   }
789 789
 
790 790
 // Get the current file position
791 791
 
792 792
   if (!$error)
793 793
   { if (!$gzipmode) 
794
-      $foffset = ftell($file);
795
-    else
796
-      $foffset = gztell($file);
797
-    if (!$foffset)
798
-    { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
799
-      $error=true;
800
-    }
794
+	  $foffset = ftell($file);
795
+	else
796
+	  $foffset = gztell($file);
797
+	if (!$foffset)
798
+	{ echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
799
+	  $error=true;
800
+	}
801 801
   }
802 802
 
803 803
 // Print statistics
@@ -808,63 +808,63 @@  discard block
 block discarded – undo
808 808
 
809 809
   if (!$error)
810 810
   { 
811
-    $lines_this   = $linenumber-$_REQUEST["start"];
812
-    $lines_done   = $linenumber-1;
813
-    $lines_togo   = ' ? ';
814
-    $lines_tota   = ' ? ';
811
+	$lines_this   = $linenumber-$_REQUEST["start"];
812
+	$lines_done   = $linenumber-1;
813
+	$lines_togo   = ' ? ';
814
+	$lines_tota   = ' ? ';
815 815
     
816
-    $queries_this = $queries;
817
-    $queries_done = $totalqueries;
818
-    $queries_togo = ' ? ';
819
-    $queries_tota = ' ? ';
820
-
821
-    $bytes_this   = $foffset-$_REQUEST["foffset"];
822
-    $bytes_done   = $foffset;
823
-    $kbytes_this  = round($bytes_this/1024,2);
824
-    $kbytes_done  = round($bytes_done/1024,2);
825
-    $mbytes_this  = round($kbytes_this/1024,2);
826
-    $mbytes_done  = round($kbytes_done/1024,2);
816
+	$queries_this = $queries;
817
+	$queries_done = $totalqueries;
818
+	$queries_togo = ' ? ';
819
+	$queries_tota = ' ? ';
820
+
821
+	$bytes_this   = $foffset-$_REQUEST["foffset"];
822
+	$bytes_done   = $foffset;
823
+	$kbytes_this  = round($bytes_this/1024,2);
824
+	$kbytes_done  = round($bytes_done/1024,2);
825
+	$mbytes_this  = round($kbytes_this/1024,2);
826
+	$mbytes_done  = round($kbytes_done/1024,2);
827 827
    
828
-    if (!$gzipmode)
829
-    {
830
-      $bytes_togo  = $filesize-$foffset;
831
-      $bytes_tota  = $filesize;
832
-      $kbytes_togo = round($bytes_togo/1024,2);
833
-      $kbytes_tota = round($bytes_tota/1024,2);
834
-      $mbytes_togo = round($kbytes_togo/1024,2);
835
-      $mbytes_tota = round($kbytes_tota/1024,2);
828
+	if (!$gzipmode)
829
+	{
830
+	  $bytes_togo  = $filesize-$foffset;
831
+	  $bytes_tota  = $filesize;
832
+	  $kbytes_togo = round($bytes_togo/1024,2);
833
+	  $kbytes_tota = round($bytes_tota/1024,2);
834
+	  $mbytes_togo = round($kbytes_togo/1024,2);
835
+	  $mbytes_tota = round($kbytes_tota/1024,2);
836 836
       
837
-      $pct_this   = ceil($bytes_this/$filesize*100);
838
-      $pct_done   = ceil($foffset/$filesize*100);
839
-      $pct_togo   = 100 - $pct_done;
840
-      $pct_tota   = 100;
841
-
842
-      if ($bytes_togo==0) 
843
-      { $lines_togo   = '0'; 
844
-        $lines_tota   = $linenumber-1; 
845
-        $queries_togo = '0'; 
846
-        $queries_tota = $totalqueries; 
847
-      }
848
-
849
-      $pct_bar    = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
850
-    }
851
-    else
852
-    {
853
-      $bytes_togo  = ' ? ';
854
-      $bytes_tota  = ' ? ';
855
-      $kbytes_togo = ' ? ';
856
-      $kbytes_tota = ' ? ';
857
-      $mbytes_togo = ' ? ';
858
-      $mbytes_tota = ' ? ';
837
+	  $pct_this   = ceil($bytes_this/$filesize*100);
838
+	  $pct_done   = ceil($foffset/$filesize*100);
839
+	  $pct_togo   = 100 - $pct_done;
840
+	  $pct_tota   = 100;
841
+
842
+	  if ($bytes_togo==0) 
843
+	  { $lines_togo   = '0'; 
844
+		$lines_tota   = $linenumber-1; 
845
+		$queries_togo = '0'; 
846
+		$queries_tota = $totalqueries; 
847
+	  }
848
+
849
+	  $pct_bar    = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
850
+	}
851
+	else
852
+	{
853
+	  $bytes_togo  = ' ? ';
854
+	  $bytes_tota  = ' ? ';
855
+	  $kbytes_togo = ' ? ';
856
+	  $kbytes_tota = ' ? ';
857
+	  $mbytes_togo = ' ? ';
858
+	  $mbytes_tota = ' ? ';
859 859
       
860
-      $pct_this    = ' ? ';
861
-      $pct_done    = ' ? ';
862
-      $pct_togo    = ' ? ';
863
-      $pct_tota    = 100;
864
-      $pct_bar     = str_replace(' ','&nbsp;','<tt>[         Not available for gzipped files          ]</tt>');
865
-    }
860
+	  $pct_this    = ' ? ';
861
+	  $pct_done    = ' ? ';
862
+	  $pct_togo    = ' ? ';
863
+	  $pct_tota    = 100;
864
+	  $pct_bar     = str_replace(' ','&nbsp;','<tt>[         Not available for gzipped files          ]</tt>');
865
+	}
866 866
     
867
-    echo ("
867
+	echo ("
868 868
     <center>
869 869
     <table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
870 870
     <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>
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 
882 882
 // Finish message and restart the script
883 883
 
884
-    if ($linenumber<$_REQUEST["start"]+$linespersession)
885
-    { echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
886
-      echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n");
887
-      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");
888
-      echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation via PayPal. Thank you!</p>\n");
884
+	if ($linenumber<$_REQUEST["start"]+$linespersession)
885
+	{ echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
886
+	  echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n");
887
+	  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");
888
+	  echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation via PayPal. Thank you!</p>\n");
889 889
 ?>
890 890
 
891 891
 <!-- Start Paypal donation code -->
@@ -904,24 +904,24 @@  discard block
 block discarded – undo
904 904
 <!-- End Paypal donation code -->
905 905
 
906 906
 <?php      
907
-      do_action('script_finished');
908
-      $error=true; // This is a semi-error telling the script is finished
909
-    }
910
-    else
911
-    { if ($delaypersession!=0)
912
-        echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
913
-      if (!$ajax) 
914
-        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");
915
-
916
-      echo ("<noscript>\n");
917
-      echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&amp;fn=".urlencode($curfilename)."&amp;foffset=$foffset&amp;totalqueries=$totalqueries&amp;delimiter=".urlencode($delimiter)."\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
918
-      echo ("</noscript>\n");
907
+	  do_action('script_finished');
908
+	  $error=true; // This is a semi-error telling the script is finished
909
+	}
910
+	else
911
+	{ if ($delaypersession!=0)
912
+		echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
913
+	  if (!$ajax) 
914
+		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");
915
+
916
+	  echo ("<noscript>\n");
917
+	  echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&amp;fn=".urlencode($curfilename)."&amp;foffset=$foffset&amp;totalqueries=$totalqueries&amp;delimiter=".urlencode($delimiter)."\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
918
+	  echo ("</noscript>\n");
919 919
    
920
-      echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
921
-    }
920
+	  echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
921
+	}
922 922
   }
923 923
   else 
924
-    echo ("<p class=\"error\">Stopped on error</p>\n");
924
+	echo ("<p class=\"error\">Stopped on error</p>\n");
925 925
 
926 926
 skin_close();
927 927
 
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 	  die;
968 968
   } 
969 969
   else 
970
-    create_ajax_script();	  
970
+	create_ajax_script();	  
971 971
 }
972 972
 
973 973
 // Anyway put out the output from above
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
   
986 986
   if (isset($plugin_actions[$tag]))
987 987
   { reset ($plugin_actions[$tag]);
988
-    foreach ($plugin_actions[$tag] as $action)
989
-      call_user_func_array($action, array());
988
+	foreach ($plugin_actions[$tag] as $action)
989
+	  call_user_func_array($action, array());
990 990
   }
991 991
 }
992 992
 
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -51,28 +51,28 @@  discard block
 block discarded – undo
51 51
 
52 52
 // OPTIONAL SETTINGS 
53 53
 
54
-$filename           = '';     // Specify the dump filename to suppress the file selection dialog
55
-$ajax               = true;   // AJAX mode: import will be done without refreshing the website
56
-$linespersession    = 3000;   // Lines to be executed per one import session
57
-$delaypersession    = 0;      // You can specify a sleep time in milliseconds after each session
54
+$filename           = ''; // Specify the dump filename to suppress the file selection dialog
55
+$ajax               = true; // AJAX mode: import will be done without refreshing the website
56
+$linespersession    = 3000; // Lines to be executed per one import session
57
+$delaypersession    = 0; // You can specify a sleep time in milliseconds after each session
58 58
                               // Works only if JavaScript is activated. Use to reduce server overrun
59 59
 
60 60
 // CSV related settings (only if you use a CSV dump)
61 61
 
62
-$csv_insert_table   = '';     // Destination table for CSV files
63
-$csv_preempty_table = false;  // true: delete all entries from table specified in $csv_insert_table before processing
64
-$csv_delimiter      = ',';    // Field delimiter in CSV file
65
-$csv_add_quotes     = true;   // If your CSV data already have quotes around each field set it to false
66
-$csv_add_slashes    = true;   // If your CSV data already have slashes in front of ' and " set it to false
62
+$csv_insert_table   = ''; // Destination table for CSV files
63
+$csv_preempty_table = false; // true: delete all entries from table specified in $csv_insert_table before processing
64
+$csv_delimiter      = ','; // Field delimiter in CSV file
65
+$csv_add_quotes     = true; // If your CSV data already have quotes around each field set it to false
66
+$csv_add_slashes    = true; // If your CSV data already have slashes in front of ' and " set it to false
67 67
 
68 68
 // Allowed comment markers: lines starting with these strings will be ignored by BigDump
69 69
 
70
-$comment[]='#';                       // Standard comment lines are dropped by default
71
-$comment[]='-- ';
72
-$comment[]='DELIMITER';               // Ignore DELIMITER switch as it's not a valid SQL statement
70
+$comment[] = '#'; // Standard comment lines are dropped by default
71
+$comment[] = '-- ';
72
+$comment[] = 'DELIMITER'; // Ignore DELIMITER switch as it's not a valid SQL statement
73 73
 // $comment[]='---';                  // Uncomment this line if using proprietary dump created by outdated mysqldump
74 74
 // $comment[]='CREATE DATABASE';      // Uncomment this line if your dump contains create database queries in order to ignore them
75
-$comment[]='/*!';                     // Or add your own string to leave out other proprietary things
75
+$comment[] = '/*!'; // Or add your own string to leave out other proprietary things
76 76
 
77 77
 // Pre-queries: SQL queries to be executed at the beginning of each import session
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 // String quotes character
88 88
 
89
-$string_quotes = '\'';                  // Change to '"' if your dump file uses double qoutes for strings
89
+$string_quotes = '\''; // Change to '"' if your dump file uses double qoutes for strings
90 90
 
91 91
 // How many lines may be considered to be one query (except text lines)
92 92
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 if ($ajax)
104 104
   ob_start();
105 105
 
106
-define ('VERSION','0.36b');
107
-define ('DATA_CHUNK_LENGTH',16384);  // How many chars are read per time
108
-define ('TESTMODE',false);           // Set to true to process the file without actually accessing the database
109
-define ('BIGDUMP_DIR',dirname(__FILE__));
110
-define ('PLUGIN_DIR',BIGDUMP_DIR.'/plugins/');
106
+define('VERSION', '0.36b');
107
+define('DATA_CHUNK_LENGTH', 16384); // How many chars are read per time
108
+define('TESTMODE', false); // Set to true to process the file without actually accessing the database
109
+define('BIGDUMP_DIR', dirname(__FILE__));
110
+define('PLUGIN_DIR', BIGDUMP_DIR . '/plugins/');
111 111
 
112 112
 header("Expires: Mon, 1 Dec 2003 01:00:00 GMT");
113 113
 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 foreach ($_REQUEST as $key => $val) 
127 127
 {
128
-  $val = preg_replace("/[^_A-Za-z0-9-\.&= ;\$]/i",'', $val);
128
+  $val = preg_replace("/[^_A-Za-z0-9-\.&= ;\$]/i", '', $val);
129 129
   $_REQUEST[$key] = $val;
130 130
 }
131 131
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 }
302 302
 
303 303
 skin_open();
304
-echo ('<h1>BigDump: Staggered MySQL Dump Importer v'.VERSION.'</h1>');
304
+echo ('<h1>BigDump: Staggered MySQL Dump Importer v' . VERSION . '</h1>');
305 305
 skin_close();
306 306
 
307 307
 do_action('after_headline');
@@ -312,24 +312,24 @@  discard block
 block discarded – undo
312 312
 // Check PHP version
313 313
 
314 314
 if (!$error && !function_exists('version_compare'))
315
-{ echo ("<p class=\"error\">PHP version 4.1.0 is required for BigDump to proceed. You have PHP ".phpversion()." installed. Sorry!</p>\n");
316
-  $error=true;
315
+{ echo ("<p class=\"error\">PHP version 4.1.0 is required for BigDump to proceed. You have PHP " . phpversion() . " installed. Sorry!</p>\n");
316
+  $error = true;
317 317
 }
318 318
 
319 319
 // Check if mysql extension is available
320 320
 
321 321
 if (!$error && !function_exists('mysqli_connect'))
322 322
 { echo ("<p class=\"error\">There is no mySQLi extension found in your PHP installation. You can use an older Bigdump version if your PHP supports mySQL extension.</p>\n");
323
-  $error=true;
323
+  $error = true;
324 324
 }
325 325
 
326 326
 // Calculate PHP max upload size (handle settings like 10M or 100K)
327 327
 
328 328
 if (!$error)
329
-{ $upload_max_filesize=ini_get("upload_max_filesize");
330
-  if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
331
-  if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
332
-  if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024;
329
+{ $upload_max_filesize = ini_get("upload_max_filesize");
330
+  if (preg_match("/([0-9]+)K/i", $upload_max_filesize, $tempregs)) $upload_max_filesize = $tempregs[1] * 1024;
331
+  if (preg_match("/([0-9]+)M/i", $upload_max_filesize, $tempregs)) $upload_max_filesize = $tempregs[1] * 1024 * 1024;
332
+  if (preg_match("/([0-9]+)G/i", $upload_max_filesize, $tempregs)) $upload_max_filesize = $tempregs[1] * 1024 * 1024 * 1024;
333 333
 }
334 334
 
335 335
 // Get the current directory
@@ -346,27 +346,27 @@  discard block
 block discarded – undo
346 346
   $upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
347 347
 */
348 348
   
349
-do_action ('script_runs');
349
+do_action('script_runs');
350 350
 
351 351
 // Handle file upload
352 352
 
353 353
 if (!$error && isset($_REQUEST["uploadbutton"]))
354
-{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
354
+{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"]) == 0)
355 355
   { 
356
-    $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
357
-    $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
358
-    $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
356
+    $uploaded_filename = str_replace(" ", "_", $_FILES["dumpfile"]["name"]);
357
+    $uploaded_filename = preg_replace("/[^_A-Za-z0-9-\.]/i", '', $uploaded_filename);
358
+    $uploaded_filepath = str_replace("\\", "/", $upload_dir . "/" . $uploaded_filename);
359 359
 
360 360
     do_action('file_uploaded');
361 361
 
362 362
     if (file_exists($uploaded_filename))
363 363
     { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
364 364
     }
365
-    else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
365
+    else if (!preg_match("/(\.(sql|gz|csv))$/i", $uploaded_filename))
366 366
     { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
367 367
     }
368
-    else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
369
-    { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
368
+    else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"], $uploaded_filepath))
369
+    { echo ("<p class=\"error\">Error moving uploaded file " . $_FILES["dumpfile"]["tmp_name"] . " to the $uploaded_filepath</p>\n");
370 370
       echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
371 371
     }
372 372
     else
@@ -374,18 +374,18 @@  discard block
 block discarded – undo
374 374
     }
375 375
   }
376 376
   else
377
-  { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
377
+  { echo ("<p class=\"error\">Error uploading file " . $_FILES["dumpfile"]["name"] . "</p>\n");
378 378
   }
379 379
 }
380 380
 
381 381
 
382 382
 // Handle file deletion (delete only in the current directory for security reasons)
383 383
 
384
-if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
385
-{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"])) 
386
-    echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
384
+if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"] != basename($_SERVER["SCRIPT_FILENAME"]))
385
+{ if (preg_match("/(\.(sql|gz|csv))$/i", $_REQUEST["delete"]) && @unlink($upload_dir . '/' . $_REQUEST["delete"])) 
386
+    echo ("<p class=\"success\">" . $_REQUEST["delete"] . " was removed successfully</p>\n");
387 387
   else
388
-    echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
388
+    echo ("<p class=\"error\">Can't remove " . $_REQUEST["delete"] . "</p>\n");
389 389
 }
390 390
 
391 391
 // Connect to the database, set charset and execute pre-queries
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 { $mysqli = new mysqli($db_server, $db_username, $db_password, $db_name);
395 395
   
396 396
   if (mysqli_connect_error()) 
397
-  { echo ("<p class=\"error\">Database connection failed due to ".mysqli_connect_error()."</p>\n");
397
+  { echo ("<p class=\"error\">Database connection failed due to " . mysqli_connect_error() . "</p>\n");
398 398
     echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
399
-    $error=true;
399
+    $error = true;
400 400
   }
401
-  if (!$error && $db_connection_charset!=='')
401
+  if (!$error && $db_connection_charset !== '')
402 402
     $mysqli->query("SET NAMES $db_connection_charset");
403 403
 
404
-  if (!$error && isset ($pre_query) && sizeof ($pre_query)>0)
404
+  if (!$error && isset ($pre_query) && sizeof($pre_query) > 0)
405 405
   { reset($pre_query);
406 406
     foreach ($pre_query as $pre_query_value)
407 407
     {	if (!$mysqli->query($pre_query_value))
408 408
     	{ echo ("<p class=\"error\">Error with pre-query.</p>\n");
409
-      	echo ("<p>Query: ".trim(nl2br(htmlentities($pre_query_value)))."</p>\n");
410
-      	echo ("<p>MySQL: ".$mysqli->error."</p>\n");
411
-      	$error=true;
409
+      	echo ("<p>Query: " . trim(nl2br(htmlentities($pre_query_value))) . "</p>\n");
410
+      	echo ("<p>MySQL: " . $mysqli->error . "</p>\n");
411
+      	$error = true;
412 412
       	break;
413 413
      }
414 414
     }
@@ -425,38 +425,38 @@  discard block
 block discarded – undo
425 425
 
426 426
 // List uploaded files in multifile mode
427 427
 
428
-if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
428
+if (!$error && !isset($_REQUEST["fn"]) && $filename == "")
429 429
 { if ($dirhandle = opendir($upload_dir)) 
430 430
   { 
431
-    $files=array();
431
+    $files = array();
432 432
     while (false !== ($files[] = readdir($dirhandle)));
433 433
     closedir($dirhandle);
434
-    $dirhead=false;
434
+    $dirhead = false;
435 435
 
436
-    if (sizeof($files)>0)
436
+    if (sizeof($files) > 0)
437 437
     { 
438 438
       sort($files);
439 439
       foreach ($files as $dirfile)
440 440
       { 
441
-        if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i",$dirfile))
441
+        if ($dirfile != "." && $dirfile != ".." && $dirfile != basename($_SERVER["SCRIPT_FILENAME"]) && preg_match("/\.(sql|gz|csv)$/i", $dirfile))
442 442
         { if (!$dirhead)
443 443
           { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
444 444
             echo ("<tr><th>Filename</th><th>Size</th><th>Date&amp;Time</th><th>Type</th><th>&nbsp;</th><th>&nbsp;</th>\n");
445
-            $dirhead=true;
445
+            $dirhead = true;
446 446
           }
447
-          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>");
447
+          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>");
448 448
 
449
-          if (preg_match("/\.sql$/i",$dirfile))
449
+          if (preg_match("/\.sql$/i", $dirfile))
450 450
             echo ("<td>SQL</td>");
451
-          elseif (preg_match("/\.gz$/i",$dirfile))
451
+          elseif (preg_match("/\.gz$/i", $dirfile))
452 452
             echo ("<td>GZip</td>");
453
-          elseif (preg_match("/\.csv$/i",$dirfile))
453
+          elseif (preg_match("/\.csv$/i", $dirfile))
454 454
             echo ("<td>CSV</td>");
455 455
           else
456 456
             echo ("<td>Misc</td>");
457 457
 
458
-          if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile))
459
-            echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;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");
458
+          if ((preg_match("/\.gz$/i", $dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i", $dirfile) || preg_match("/\.csv$/i", $dirfile))
459
+            echo ("<td><a href=\"" . $_SERVER["PHP_SELF"] . "?start=1&amp;fn=" . urlencode($dirfile) . "&amp;foffset=0&amp;totalqueries=0&amp;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");
460 460
 // TODO: echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;delimiter=".urlencode($delimiter)."\">Start Import</a></td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
461 461
           else
462 462
             echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
@@ -471,35 +471,35 @@  discard block
 block discarded – undo
471 471
   }
472 472
   else
473 473
   { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
474
-    $error=true;
474
+    $error = true;
475 475
   }
476 476
 }
477 477
 
478 478
 
479 479
 // Single file mode
480 480
 
481
-if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
482
-{ echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($filename)."&amp;foffset=0&amp;totalqueries=0\">Start Import</a> from $filename into $db_name at $db_server</p>\n");
481
+if (!$error && !isset ($_REQUEST["fn"]) && $filename != "")
482
+{ echo ("<p><a href=\"" . $_SERVER["PHP_SELF"] . "?start=1&amp;fn=" . urlencode($filename) . "&amp;foffset=0&amp;totalqueries=0\">Start Import</a> from $filename into $db_name at $db_server</p>\n");
483 483
 }
484 484
 
485 485
 
486 486
 // File Upload Form
487 487
 
488
-if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
488
+if (!$error && !isset($_REQUEST["fn"]) && $filename == "")
489 489
 { 
490 490
 
491 491
 // Test permissions on working directory
492 492
 
493
-  do { $tempfilename=$upload_dir.'/'.time().".tmp"; } while (file_exists($tempfilename)); 
494
-  if (!($tempfile=@fopen($tempfilename,"w")))
493
+  do { $tempfilename = $upload_dir . '/' . time() . ".tmp"; } while (file_exists($tempfilename)); 
494
+  if (!($tempfile = @fopen($tempfilename, "w")))
495 495
   { 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 ");
496 496
     echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
497 497
   }
498 498
   else
499 499
   { fclose($tempfile);
500
-    unlink ($tempfilename);
500
+    unlink($tempfilename);
501 501
  
502
-    echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes)  ");
502
+    echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (" . round($upload_max_filesize / 1024 / 1024) . " Mbytes)  ");
503 503
     echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
504 504
 ?>
505 505
 <form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
@@ -533,44 +533,44 @@  discard block
 block discarded – undo
533 533
 
534 534
 // Set current filename ($filename overrides $_REQUEST["fn"] if set)
535 535
 
536
-  if ($filename!="")
537
-    $curfilename=$filename;
536
+  if ($filename != "")
537
+    $curfilename = $filename;
538 538
   else if (isset($_REQUEST["fn"]))
539
-    $curfilename=urldecode($_REQUEST["fn"]);
539
+    $curfilename = urldecode($_REQUEST["fn"]);
540 540
   else
541
-    $curfilename="";
541
+    $curfilename = "";
542 542
 
543 543
 // Recognize GZip filename
544 544
 
545
-  if (preg_match("/\.gz$/i",$curfilename)) 
546
-    $gzipmode=true;
545
+  if (preg_match("/\.gz$/i", $curfilename)) 
546
+    $gzipmode = true;
547 547
   else
548
-    $gzipmode=false;
548
+    $gzipmode = false;
549 549
 
550
-  if ((!$gzipmode && !$file=@fopen($upload_dir.'/'.$curfilename,"r")) || ($gzipmode && !$file=@gzopen($upload_dir.'/'.$curfilename,"r")))
551
-  { echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n");
552
-    echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename.".
553
-           "<br>Or, specify \$filename in bigdump.php with the full filename. ".
550
+  if ((!$gzipmode && !$file = @fopen($upload_dir . '/' . $curfilename, "r")) || ($gzipmode && !$file = @gzopen($upload_dir . '/' . $curfilename, "r")))
551
+  { echo ("<p class=\"error\">Can't open " . $curfilename . " for import</p>\n");
552
+    echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: $curfilename." .
553
+           "<br>Or, specify \$filename in bigdump.php with the full filename. " .
554 554
            "<br>Or, you have to upload the $curfilename to the server first.</p>\n");
555
-    $error=true;
555
+    $error = true;
556 556
   }
557 557
 
558 558
 // Get the file size (can't do it fast on gzipped files, no idea how)
559 559
 
560
-  else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0))
560
+  else if ((!$gzipmode && @fseek($file, 0, SEEK_END) == 0) || ($gzipmode && @gzseek($file, 0) == 0))
561 561
   { if (!$gzipmode) $filesize = ftell($file);
562
-    else $filesize = gztell($file);                   // Always zero, ignore
562
+    else $filesize = gztell($file); // Always zero, ignore
563 563
   }
564 564
   else
565 565
   { echo ("<p class=\"error\">I can't seek into $curfilename</p>\n");
566
-    $error=true;
566
+    $error = true;
567 567
   }
568 568
 
569 569
 // Stop if csv file is used, but $csv_insert_table is not set
570 570
 
571
-  if (!$error && ($csv_insert_table == "") && (preg_match("/(\.csv)$/i",$curfilename)))
571
+  if (!$error && ($csv_insert_table == "") && (preg_match("/(\.csv)$/i", $curfilename)))
572 572
   { echo ("<p class=\"error\">You have to specify \$csv_insert_table when using a CSV file. </p>\n");
573
-    $error=true;
573
+    $error = true;
574 574
   }
575 575
 }
576 576
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 // START IMPORT SESSION HERE
580 580
 // *******************************************************************************************
581 581
 
582
-if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_match("/(\.(sql|gz|csv))$/i",$curfilename))
582
+if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && preg_match("/(\.(sql|gz|csv))$/i", $curfilename))
583 583
 {
584 584
 
585 585
   do_action('session_start');
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
   if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
590 590
   { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
591
-    $error=true;
591
+    $error = true;
592 592
   }
593 593
   else
594 594
   {	$_REQUEST["start"]   = floor($_REQUEST["start"]);
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
 
603 603
 // Empty CSV table if requested
604 604
 
605
-  if (!$error && $_REQUEST["start"]==1 && $csv_insert_table != "" && $csv_preempty_table)
605
+  if (!$error && $_REQUEST["start"] == 1 && $csv_insert_table != "" && $csv_preempty_table)
606 606
   { 
607 607
     $query = "DELETE FROM `$csv_insert_table`";
608 608
     if (!TESTMODE && !$mysqli->query(trim($query)))
609 609
     { echo ("<p class=\"error\">Error when deleting entries from $csv_insert_table.</p>\n");
610
-      echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
611
-      echo ("<p>MySQL: ".$mysqli->error."</p>\n");
612
-      $error=true;
610
+      echo ("<p>Query: " . trim(nl2br(htmlentities($query))) . "</p>\n");
611
+      echo ("<p>MySQL: " . $mysqli->error . "</p>\n");
612
+      $error = true;
613 613
     }
614 614
   }
615 615
   
@@ -619,95 +619,95 @@  discard block
 block discarded – undo
619 619
   { skin_open();
620 620
     if (TESTMODE) 
621 621
       echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
622
-    echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
623
-    echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");	
622
+    echo ("<p class=\"centr\">Processing file: <b>" . $curfilename . "</b></p>\n");
623
+    echo ("<p class=\"smlcentr\">Starting from line: " . $_REQUEST["start"] . "</p>\n");	
624 624
     skin_close();
625 625
   }
626 626
 
627 627
 // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files)
628 628
 
629
-  if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize)
629
+  if (!$error && !$gzipmode && $_REQUEST["foffset"] > $filesize)
630 630
   { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n");
631
-    $error=true;
631
+    $error = true;
632 632
   }
633 633
 
634 634
 // Set file pointer to $_REQUEST["foffset"]
635 635
 
636
-  if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0)))
637
-  { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n");
638
-    $error=true;
636
+  if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"]) != 0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"]) != 0)))
637
+  { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: " . $_REQUEST["foffset"] . "</p>\n");
638
+    $error = true;
639 639
   }
640 640
 
641 641
 // Start processing queries from $file
642 642
 
643 643
   if (!$error)
644
-  { $query="";
645
-    $queries=0;
646
-    $totalqueries=$_REQUEST["totalqueries"];
647
-    $linenumber=$_REQUEST["start"];
648
-    $querylines=0;
649
-    $inparents=false;
644
+  { $query = "";
645
+    $queries = 0;
646
+    $totalqueries = $_REQUEST["totalqueries"];
647
+    $linenumber = $_REQUEST["start"];
648
+    $querylines = 0;
649
+    $inparents = false;
650 650
 
651 651
 // Stay processing as long as the $linespersession is not reached or the query is still incomplete
652 652
 
653
-    while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
653
+    while ($linenumber < $_REQUEST["start"] + $linespersession || $query != "")
654 654
     {
655 655
 
656 656
 // Read the whole next line
657 657
 
658 658
       $dumpline = "";
659
-      while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r")
659
+      while (!feof($file) && substr($dumpline, -1) != "\n" && substr($dumpline, -1) != "\r")
660 660
       { if (!$gzipmode)
661 661
           $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
662 662
         else
663 663
           $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
664 664
       }
665
-      if ($dumpline==="") break;
665
+      if ($dumpline === "") break;
666 666
 
667 667
 // Remove UTF8 Byte Order Mark at the file beginning if any
668 668
 
669
-      if ($_REQUEST["foffset"]==0)
670
-        $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
669
+      if ($_REQUEST["foffset"] == 0)
670
+        $dumpline = preg_replace('|^\xEF\xBB\xBF|', '', $dumpline);
671 671
 
672 672
 // Create an SQL query from CSV line
673 673
 
674
-      if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename)))
674
+      if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i", $curfilename)))
675 675
       {
676 676
         if ($csv_add_slashes)
677 677
           $dumpline = addslashes($dumpline);
678
-        $dumpline = explode($csv_delimiter,$dumpline);
678
+        $dumpline = explode($csv_delimiter, $dumpline);
679 679
         if ($csv_add_quotes)
680
-          $dumpline = "'".implode("','",$dumpline)."'";
680
+          $dumpline = "'" . implode("','", $dumpline) . "'";
681 681
         else
682
-          $dumpline = implode(",",$dumpline);
683
-        $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
682
+          $dumpline = implode(",", $dumpline);
683
+        $dumpline = 'INSERT INTO ' . $csv_insert_table . ' VALUES (' . $dumpline . ');';
684 684
       }
685 685
 
686 686
 // Handle DOS and Mac encoded linebreaks (I don't know if it really works on Win32 or Mac Servers)
687 687
 
688
-      $dumpline=str_replace("\r\n", "\n", $dumpline);
689
-      $dumpline=str_replace("\r", "\n", $dumpline);
688
+      $dumpline = str_replace("\r\n", "\n", $dumpline);
689
+      $dumpline = str_replace("\r", "\n", $dumpline);
690 690
             
691 691
 // DIAGNOSTIC
692 692
 // echo ("<p>Line $linenumber: $dumpline</p>\n");
693 693
 
694 694
 // Recognize delimiter statement
695 695
 
696
-      if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0)
697
-        $delimiter = str_replace ("DELIMITER ","",trim($dumpline));
696
+      if (!$inparents && strpos($dumpline, "DELIMITER ") === 0)
697
+        $delimiter = str_replace("DELIMITER ", "", trim($dumpline));
698 698
 
699 699
 // Skip comments and blank lines only if NOT in parents
700 700
 
701 701
       if (!$inparents)
702
-      { $skipline=false;
702
+      { $skipline = false;
703 703
         reset($comment);
704 704
         foreach ($comment as $comment_value)
705 705
         { 
706 706
 
707 707
 // DIAGNOSTIC
708 708
 //          echo ($comment_value);
709
-          if (trim($dumpline)=="" || strpos (trim($dumpline), $comment_value) === 0)
710
-          { $skipline=true;
709
+          if (trim($dumpline) == "" || strpos(trim($dumpline), $comment_value) === 0)
710
+          { $skipline = true;
711 711
             break;
712 712
           }
713 713
         }
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 
724 724
 // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
725 725
       
726
-      $dumpline_deslashed = str_replace ("\\\\","",$dumpline);
726
+      $dumpline_deslashed = str_replace("\\\\", "", $dumpline);
727 727
 
728 728
 // Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter
729 729
 
730
-      $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes");
730
+      $parents = substr_count($dumpline_deslashed, $string_quotes) - substr_count($dumpline_deslashed, "\\$string_quotes");
731 731
       if ($parents % 2 != 0)
732
-        $inparents=!$inparents;
732
+        $inparents = !$inparents;
733 733
 
734 734
 // Add the line to query
735 735
 
@@ -742,15 +742,15 @@  discard block
 block discarded – undo
742 742
       
743 743
 // Stop if query contains more lines as defined by $max_query_lines
744 744
 
745
-      if ($querylines>$max_query_lines)
745
+      if ($querylines > $max_query_lines)
746 746
       {
747 747
         echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
748
-        echo ("<p>At this place the current query includes more than ".$max_query_lines." dump lines. That can happen if your dump file was ");
748
+        echo ("<p>At this place the current query includes more than " . $max_query_lines . " dump lines. That can happen if your dump file was ");
749 749
         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 ");
750 750
         echo ("extended inserts or very long procedure definitions. Please read the <a href=\"http://www.ozerov.de/bigdump/usage/\">BigDump usage notes</a> ");
751 751
         echo ("for more infos. Ask for our support services ");
752 752
         echo ("in order to handle dump files containing extended inserts.</p>\n");
753
-        $error=true;
753
+        $error = true;
754 754
         break;
755 755
       }
756 756
 
@@ -761,27 +761,27 @@  discard block
 block discarded – undo
761 761
 // echo ("<p>In Parents: ".($inparents?"true":"false")."</p>\n");
762 762
 // echo ("<p>Line: $dumpline</p>\n");
763 763
 
764
-      if ((preg_match('/'.preg_quote($delimiter,'/').'$/',trim($dumpline)) || $delimiter=='') && !$inparents)
764
+      if ((preg_match('/' . preg_quote($delimiter, '/') . '$/', trim($dumpline)) || $delimiter == '') && !$inparents)
765 765
       { 
766 766
 
767 767
 // Cut off delimiter of the end of the query
768 768
 
769
-        $query = substr(trim($query),0,-1*strlen($delimiter));
769
+        $query = substr(trim($query), 0, -1 * strlen($delimiter));
770 770
 
771 771
 // DIAGNOSTIC
772 772
 // echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
773 773
 
774 774
         if (!TESTMODE && !$mysqli->query($query))
775
-        { echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
776
-          echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
777
-          echo ("<p>MySQL: ".$mysqli->error."</p>\n");
778
-          $error=true;
775
+        { echo ("<p class=\"error\">Error at the line $linenumber: " . trim($dumpline) . "</p>\n");
776
+          echo ("<p>Query: " . trim(nl2br(htmlentities($query))) . "</p>\n");
777
+          echo ("<p>MySQL: " . $mysqli->error . "</p>\n");
778
+          $error = true;
779 779
           break;
780 780
         }
781 781
         $totalqueries++;
782 782
         $queries++;
783
-        $query="";
784
-        $querylines=0;
783
+        $query = "";
784
+        $querylines = 0;
785 785
       }
786 786
       $linenumber++;
787 787
     }
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
       $foffset = gztell($file);
797 797
     if (!$foffset)
798 798
     { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
799
-      $error=true;
799
+      $error = true;
800 800
     }
801 801
   }
802 802
 
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 
809 809
   if (!$error)
810 810
   { 
811
-    $lines_this   = $linenumber-$_REQUEST["start"];
812
-    $lines_done   = $linenumber-1;
811
+    $lines_this   = $linenumber - $_REQUEST["start"];
812
+    $lines_done   = $linenumber - 1;
813 813
     $lines_togo   = ' ? ';
814 814
     $lines_tota   = ' ? ';
815 815
     
@@ -818,35 +818,35 @@  discard block
 block discarded – undo
818 818
     $queries_togo = ' ? ';
819 819
     $queries_tota = ' ? ';
820 820
 
821
-    $bytes_this   = $foffset-$_REQUEST["foffset"];
821
+    $bytes_this   = $foffset - $_REQUEST["foffset"];
822 822
     $bytes_done   = $foffset;
823
-    $kbytes_this  = round($bytes_this/1024,2);
824
-    $kbytes_done  = round($bytes_done/1024,2);
825
-    $mbytes_this  = round($kbytes_this/1024,2);
826
-    $mbytes_done  = round($kbytes_done/1024,2);
823
+    $kbytes_this  = round($bytes_this / 1024, 2);
824
+    $kbytes_done  = round($bytes_done / 1024, 2);
825
+    $mbytes_this  = round($kbytes_this / 1024, 2);
826
+    $mbytes_done  = round($kbytes_done / 1024, 2);
827 827
    
828 828
     if (!$gzipmode)
829 829
     {
830
-      $bytes_togo  = $filesize-$foffset;
830
+      $bytes_togo  = $filesize - $foffset;
831 831
       $bytes_tota  = $filesize;
832
-      $kbytes_togo = round($bytes_togo/1024,2);
833
-      $kbytes_tota = round($bytes_tota/1024,2);
834
-      $mbytes_togo = round($kbytes_togo/1024,2);
835
-      $mbytes_tota = round($kbytes_tota/1024,2);
832
+      $kbytes_togo = round($bytes_togo / 1024, 2);
833
+      $kbytes_tota = round($bytes_tota / 1024, 2);
834
+      $mbytes_togo = round($kbytes_togo / 1024, 2);
835
+      $mbytes_tota = round($kbytes_tota / 1024, 2);
836 836
       
837
-      $pct_this   = ceil($bytes_this/$filesize*100);
838
-      $pct_done   = ceil($foffset/$filesize*100);
837
+      $pct_this   = ceil($bytes_this / $filesize * 100);
838
+      $pct_done   = ceil($foffset / $filesize * 100);
839 839
       $pct_togo   = 100 - $pct_done;
840 840
       $pct_tota   = 100;
841 841
 
842
-      if ($bytes_togo==0) 
842
+      if ($bytes_togo == 0) 
843 843
       { $lines_togo   = '0'; 
844
-        $lines_tota   = $linenumber-1; 
844
+        $lines_tota   = $linenumber - 1; 
845 845
         $queries_togo = '0'; 
846 846
         $queries_tota = $totalqueries; 
847 847
       }
848 848
 
849
-      $pct_bar    = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
849
+      $pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
850 850
     }
851 851
     else
852 852
     {
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
       $pct_done    = ' ? ';
862 862
       $pct_togo    = ' ? ';
863 863
       $pct_tota    = 100;
864
-      $pct_bar     = str_replace(' ','&nbsp;','<tt>[         Not available for gzipped files          ]</tt>');
864
+      $pct_bar     = str_replace(' ', '&nbsp;', '<tt>[         Not available for gzipped files          ]</tt>');
865 865
     }
866 866
     
867 867
     echo ("
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 
882 882
 // Finish message and restart the script
883 883
 
884
-    if ($linenumber<$_REQUEST["start"]+$linespersession)
884
+    if ($linenumber < $_REQUEST["start"] + $linespersession)
885 885
     { echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
886 886
       echo ("<p class=\"successcentr\">IMPORTANT: REMOVE YOUR DUMP FILE and BIGDUMP SCRIPT FROM SERVER NOW!</p>\n");
887 887
       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");
@@ -905,19 +905,19 @@  discard block
 block discarded – undo
905 905
 
906 906
 <?php      
907 907
       do_action('script_finished');
908
-      $error=true; // This is a semi-error telling the script is finished
908
+      $error = true; // This is a semi-error telling the script is finished
909 909
     }
910 910
     else
911
-    { if ($delaypersession!=0)
911
+    { if ($delaypersession != 0)
912 912
         echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
913 913
       if (!$ajax) 
914
-        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");
914
+        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");
915 915
 
916 916
       echo ("<noscript>\n");
917
-      echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&amp;fn=".urlencode($curfilename)."&amp;foffset=$foffset&amp;totalqueries=$totalqueries&amp;delimiter=".urlencode($delimiter)."\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
917
+      echo ("<p class=\"centr\"><a href=\"" . $_SERVER["PHP_SELF"] . "?start=$linenumber&amp;fn=" . urlencode($curfilename) . "&amp;foffset=$foffset&amp;totalqueries=$totalqueries&amp;delimiter=" . urlencode($delimiter) . "\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
918 918
       echo ("</noscript>\n");
919 919
    
920
-      echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
920
+      echo ("<p class=\"centr\">Press <b><a href=\"" . $_SERVER["PHP_SELF"] . "\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
921 921
     }
922 922
   }
923 923
   else 
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 }
929 929
 
930 930
 if ($error)
931
-  echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
931
+  echo ("<p class=\"centr\"><a href=\"" . $_SERVER["PHP_SELF"] . "\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
932 932
 
933 933
 if ($mysqli) $mysqli->close();
934 934
 if ($file && !$gzipmode) fclose($file);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 { global $plugin_actions;
985 985
   
986 986
   if (isset($plugin_actions[$tag]))
987
-  { reset ($plugin_actions[$tag]);
987
+  { reset($plugin_actions[$tag]);
988 988
     foreach ($plugin_actions[$tag] as $action)
989 989
       call_user_func_array($action, array());
990 990
   }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 				 $bytes_this, $bytes_done, $bytes_togo, $bytes_tota,
1009 1009
 				 $kbytes_this, $kbytes_done, $kbytes_togo, $kbytes_tota,
1010 1010
 				 $mbytes_this, $mbytes_done, $mbytes_togo, $mbytes_tota,
1011
-				 $pct_this, $pct_done, $pct_togo, $pct_tota,$pct_bar;
1011
+				 $pct_this, $pct_done, $pct_togo, $pct_tota, $pct_bar;
1012 1012
 
1013 1013
 	header('Content-Type: application/xml');
1014 1014
 	header('Cache-Control: no-cache');
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	echo "<elem22>$pct_done</elem22>";
1056 1056
 	echo "<elem23>$pct_togo</elem23>";
1057 1057
 	echo "<elem24>$pct_tota</elem24>";
1058
-	echo "<elem_bar>".htmlentities($pct_bar)."</elem_bar>";
1058
+	echo "<elem_bar>" . htmlentities($pct_bar) . "</elem_bar>";
1059 1059
 				
1060 1060
 	echo "</root>";		
1061 1061
 }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 	// First Ajax request from initial page
1159 1159
 
1160 1160
 	var http_request = false;
1161
-	var url_request =  get_url(<?php echo ($linenumber.',"'.urlencode($curfilename).'",'.$foffset.','.$totalqueries.',"'.urlencode($delimiter).'"') ;?>);
1161
+	var url_request =  get_url(<?php echo ($linenumber . ',"' . urlencode($curfilename) . '",' . $foffset . ',' . $totalqueries . ',"' . urlencode($delimiter) . '"'); ?>);
1162 1162
 	window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
1163 1163
 	</script>
1164 1164
 
Please login to merge, or discard this patch.
Braces   +142 added lines, -112 removed lines patch added patch discarded remove patch
@@ -100,8 +100,9 @@  discard block
 block discarded – undo
100 100
 // If not familiar with PHP please don't change anything below this line
101 101
 // *******************************************************************************************
102 102
 
103
-if ($ajax)
104
-  ob_start();
103
+if ($ajax) {
104
+  ob_start();
105
+}
105 106
 
106 107
 define ('VERSION','0.36b');
107 108
 define ('DATA_CHUNK_LENGTH',16384);  // How many chars are read per time
@@ -118,8 +119,9 @@  discard block
 block discarded – undo
118 119
 @ini_set('auto_detect_line_endings', true);
119 120
 @set_time_limit(0);
120 121
 
121
-if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get"))
122
-  @date_default_timezone_set(@date_default_timezone_get());
122
+if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
123
+  @date_default_timezone_set(@date_default_timezone_get());
124
+}
123 125
 
124 126
 // Clean and strip anything we don't want from user's input [0.27b]
125 127
 
@@ -327,10 +329,16 @@  discard block
 block discarded – undo
327 329
 
328 330
 if (!$error)
329 331
 { $upload_max_filesize=ini_get("upload_max_filesize");
330
-  if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
331
-  if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
332
-  if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024;
333
-}
332
+  if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) {
333
+  	$upload_max_filesize=$tempregs[1]*1024;
334
+  }
335
+  if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) {
336
+  	$upload_max_filesize=$tempregs[1]*1024*1024;
337
+  }
338
+  if (preg_match("/([0-9]+)G/i",$upload_max_filesize,$tempregs)) {
339
+  	$upload_max_filesize=$tempregs[1]*1024*1024*1024;
340
+  }
341
+  }
334 342
 
335 343
 // Get the current directory
336 344
 /*
@@ -361,19 +369,15 @@  discard block
 block discarded – undo
361 369
 
362 370
     if (file_exists($uploaded_filename))
363 371
     { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
364
-    }
365
-    else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
372
+    } else if (!preg_match("/(\.(sql|gz|csv))$/i",$uploaded_filename))
366 373
     { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
367
-    }
368
-    else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
374
+    } else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
369 375
     { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
370 376
       echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
371
-    }
372
-    else
377
+    } else
373 378
     { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
374 379
     }
375
-  }
376
-  else
380
+  } else
377 381
   { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
378 382
   }
379 383
 }
@@ -382,11 +386,12 @@  discard block
 block discarded – undo
382 386
 // Handle file deletion (delete only in the current directory for security reasons)
383 387
 
384 388
 if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
385
-{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"])) 
386
-    echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
387
-  else
388
-    echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
389
-}
389
+{ if (preg_match("/(\.(sql|gz|csv))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.'/'.$_REQUEST["delete"])) {
390
+    echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
391
+} else {
392
+      echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
393
+  }
394
+  }
390 395
 
391 396
 // Connect to the database, set charset and execute pre-queries
392 397
 
@@ -398,8 +403,9 @@  discard block
 block discarded – undo
398 403
     echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
399 404
     $error=true;
400 405
   }
401
-  if (!$error && $db_connection_charset!=='')
402
-    $mysqli->query("SET NAMES $db_connection_charset");
406
+  if (!$error && $db_connection_charset!=='') {
407
+      $mysqli->query("SET NAMES $db_connection_charset");
408
+  }
403 409
 
404 410
   if (!$error && isset ($pre_query) && sizeof ($pre_query)>0)
405 411
   { reset($pre_query);
@@ -413,8 +419,7 @@  discard block
 block discarded – undo
413 419
      }
414 420
     }
415 421
   }
416
-}
417
-else
422
+} else
418 423
 { $dbconnection = false;
419 424
 }
420 425
 
@@ -446,30 +451,33 @@  discard block
 block discarded – undo
446 451
           }
447 452
           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>");
448 453
 
449
-          if (preg_match("/\.sql$/i",$dirfile))
450
-            echo ("<td>SQL</td>");
451
-          elseif (preg_match("/\.gz$/i",$dirfile))
452
-            echo ("<td>GZip</td>");
453
-          elseif (preg_match("/\.csv$/i",$dirfile))
454
-            echo ("<td>CSV</td>");
455
-          else
456
-            echo ("<td>Misc</td>");
457
-
458
-          if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile))
459
-            echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;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");
460
-// TODO: echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;delimiter=".urlencode($delimiter)."\">Start Import</a></td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
461
-          else
462
-            echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
454
+          if (preg_match("/\.sql$/i",$dirfile)) {
455
+                      echo ("<td>SQL</td>");
456
+          } elseif (preg_match("/\.gz$/i",$dirfile)) {
457
+                      echo ("<td>GZip</td>");
458
+          } elseif (preg_match("/\.csv$/i",$dirfile)) {
459
+                      echo ("<td>CSV</td>");
460
+          } else {
461
+                      echo ("<td>Misc</td>");
462
+          }
463
+
464
+          if ((preg_match("/\.gz$/i",$dirfile) && function_exists("gzopen")) || preg_match("/\.sql$/i",$dirfile) || preg_match("/\.csv$/i",$dirfile)) {
465
+                      echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;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");
466
+          }
467
+          // TODO: echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=".urlencode($dirfile)."&amp;foffset=0&amp;totalqueries=0&amp;delimiter=".urlencode($delimiter)."\">Start Import</a></td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=".urlencode($dirfile)."\">Delete file</a></td></tr>\n");
468
+          else {
469
+                      echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
470
+          }
463 471
         }
464 472
       }
465 473
     }
466 474
 
467
-    if ($dirhead) 
468
-      echo ("</table>\n");
469
-    else 
470
-      echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
471
-  }
472
-  else
475
+    if ($dirhead) {
476
+          echo ("</table>\n");
477
+    } else {
478
+          echo ("<p>No uploaded SQL, GZ or CSV files found in the working directory</p>\n");
479
+    }
480
+  } else
473 481
   { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
474 482
     $error=true;
475 483
   }
@@ -494,8 +502,7 @@  discard block
 block discarded – undo
494 502
   if (!($tempfile=@fopen($tempfilename,"w")))
495 503
   { 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 ");
496 504
     echo ("to upload files here. Alternatively you can upload your dump files via FTP.</p>\n");
497
-  }
498
-  else
505
+  } else
499 506
   { fclose($tempfile);
500 507
     unlink ($tempfilename);
501 508
  
@@ -533,19 +540,21 @@  discard block
 block discarded – undo
533 540
 
534 541
 // Set current filename ($filename overrides $_REQUEST["fn"] if set)
535 542
 
536
-  if ($filename!="")
537
-    $curfilename=$filename;
538
-  else if (isset($_REQUEST["fn"]))
539
-    $curfilename=urldecode($_REQUEST["fn"]);
540
-  else
541
-    $curfilename="";
543
+  if ($filename!="") {
544
+      $curfilename=$filename;
545
+  } else if (isset($_REQUEST["fn"])) {
546
+      $curfilename=urldecode($_REQUEST["fn"]);
547
+  } else {
548
+      $curfilename="";
549
+  }
542 550
 
543 551
 // Recognize GZip filename
544 552
 
545
-  if (preg_match("/\.gz$/i",$curfilename)) 
546
-    $gzipmode=true;
547
-  else
548
-    $gzipmode=false;
553
+  if (preg_match("/\.gz$/i",$curfilename)) {
554
+      $gzipmode=true;
555
+  } else {
556
+      $gzipmode=false;
557
+  }
549 558
 
550 559
   if ((!$gzipmode && !$file=@fopen($upload_dir.'/'.$curfilename,"r")) || ($gzipmode && !$file=@gzopen($upload_dir.'/'.$curfilename,"r")))
551 560
   { echo ("<p class=\"error\">Can't open ".$curfilename." for import</p>\n");
@@ -558,10 +567,13 @@  discard block
 block discarded – undo
558 567
 // Get the file size (can't do it fast on gzipped files, no idea how)
559 568
 
560 569
   else if ((!$gzipmode && @fseek($file, 0, SEEK_END)==0) || ($gzipmode && @gzseek($file, 0)==0))
561
-  { if (!$gzipmode) $filesize = ftell($file);
562
-    else $filesize = gztell($file);                   // Always zero, ignore
563
-  }
564
-  else
570
+  { if (!$gzipmode) {
571
+  	$filesize = ftell($file);
572
+  } else {
573
+    	$filesize = gztell($file);
574
+    }
575
+    // Always zero, ignore
576
+  } else
565 577
   { echo ("<p class=\"error\">I can't seek into $curfilename</p>\n");
566 578
     $error=true;
567 579
   }
@@ -589,16 +601,16 @@  discard block
 block discarded – undo
589 601
   if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
590 602
   { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
591 603
     $error=true;
592
-  }
593
-  else
604
+  } else
594 605
   {	$_REQUEST["start"]   = floor($_REQUEST["start"]);
595 606
     $_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
596 607
   }
597 608
 
598 609
 // Set the current delimiter if defined
599 610
 
600
-  if (isset($_REQUEST["delimiter"]))
601
-    $delimiter = $_REQUEST["delimiter"];
611
+  if (isset($_REQUEST["delimiter"])) {
612
+      $delimiter = $_REQUEST["delimiter"];
613
+  }
602 614
 
603 615
 // Empty CSV table if requested
604 616
 
@@ -617,8 +629,9 @@  discard block
 block discarded – undo
617 629
 
618 630
   if (!$error)
619 631
   { skin_open();
620
-    if (TESTMODE) 
621
-      echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
632
+    if (TESTMODE) {
633
+          echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
634
+    }
622 635
     echo ("<p class=\"centr\">Processing file: <b>".$curfilename."</b></p>\n");
623 636
     echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");	
624 637
     skin_close();
@@ -657,29 +670,35 @@  discard block
 block discarded – undo
657 670
 
658 671
       $dumpline = "";
659 672
       while (!feof($file) && substr ($dumpline, -1) != "\n" && substr ($dumpline, -1) != "\r")
660
-      { if (!$gzipmode)
661
-          $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
662
-        else
663
-          $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
673
+      { if (!$gzipmode) {
674
+                $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
675
+      } else {
676
+                  $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
677
+        }
664 678
       }
665
-      if ($dumpline==="") break;
679
+      if ($dumpline==="") {
680
+      	break;
681
+      }
666 682
 
667 683
 // Remove UTF8 Byte Order Mark at the file beginning if any
668 684
 
669
-      if ($_REQUEST["foffset"]==0)
670
-        $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
685
+      if ($_REQUEST["foffset"]==0) {
686
+              $dumpline=preg_replace('|^\xEF\xBB\xBF|','',$dumpline);
687
+      }
671 688
 
672 689
 // Create an SQL query from CSV line
673 690
 
674 691
       if (($csv_insert_table != "") && (preg_match("/(\.csv)$/i",$curfilename)))
675 692
       {
676
-        if ($csv_add_slashes)
677
-          $dumpline = addslashes($dumpline);
693
+        if ($csv_add_slashes) {
694
+                  $dumpline = addslashes($dumpline);
695
+        }
678 696
         $dumpline = explode($csv_delimiter,$dumpline);
679
-        if ($csv_add_quotes)
680
-          $dumpline = "'".implode("','",$dumpline)."'";
681
-        else
682
-          $dumpline = implode(",",$dumpline);
697
+        if ($csv_add_quotes) {
698
+                  $dumpline = "'".implode("','",$dumpline)."'";
699
+        } else {
700
+                  $dumpline = implode(",",$dumpline);
701
+        }
683 702
         $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
684 703
       }
685 704
 
@@ -693,8 +712,9 @@  discard block
 block discarded – undo
693 712
 
694 713
 // Recognize delimiter statement
695 714
 
696
-      if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0)
697
-        $delimiter = str_replace ("DELIMITER ","",trim($dumpline));
715
+      if (!$inparents && strpos ($dumpline, "DELIMITER ") === 0) {
716
+              $delimiter = str_replace ("DELIMITER ","",trim($dumpline));
717
+      }
698 718
 
699 719
 // Skip comments and blank lines only if NOT in parents
700 720
 
@@ -728,8 +748,9 @@  discard block
 block discarded – undo
728 748
 // Count ' and \' (or " and \") in the dumpline to avoid query break within a text field ending by $delimiter
729 749
 
730 750
       $parents=substr_count ($dumpline_deslashed, $string_quotes)-substr_count ($dumpline_deslashed, "\\$string_quotes");
731
-      if ($parents % 2 != 0)
732
-        $inparents=!$inparents;
751
+      if ($parents % 2 != 0) {
752
+              $inparents=!$inparents;
753
+      }
733 754
 
734 755
 // Add the line to query
735 756
 
@@ -737,8 +758,9 @@  discard block
 block discarded – undo
737 758
 
738 759
 // Don't count the line if in parents (text fields may include unlimited linebreaks)
739 760
       
740
-      if (!$inparents)
741
-        $querylines++;
761
+      if (!$inparents) {
762
+              $querylines++;
763
+      }
742 764
       
743 765
 // Stop if query contains more lines as defined by $max_query_lines
744 766
 
@@ -790,10 +812,11 @@  discard block
 block discarded – undo
790 812
 // Get the current file position
791 813
 
792 814
   if (!$error)
793
-  { if (!$gzipmode) 
794
-      $foffset = ftell($file);
795
-    else
796
-      $foffset = gztell($file);
815
+  { if (!$gzipmode) {
816
+        $foffset = ftell($file);
817
+  } else {
818
+          $foffset = gztell($file);
819
+    }
797 820
     if (!$foffset)
798 821
     { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
799 822
       $error=true;
@@ -847,8 +870,7 @@  discard block
 block discarded – undo
847 870
       }
848 871
 
849 872
       $pct_bar    = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
850
-    }
851
-    else
873
+    } else
852 874
     {
853 875
       $bytes_togo  = ' ? ';
854 876
       $bytes_tota  = ' ? ';
@@ -906,12 +928,13 @@  discard block
 block discarded – undo
906 928
 <?php      
907 929
       do_action('script_finished');
908 930
       $error=true; // This is a semi-error telling the script is finished
909
-    }
910
-    else
911
-    { if ($delaypersession!=0)
912
-        echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
913
-      if (!$ajax) 
914
-        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");
931
+    } else
932
+    { if ($delaypersession!=0) {
933
+            echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
934
+    }
935
+      if (!$ajax) {
936
+              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");
937
+      }
915 938
 
916 939
       echo ("<noscript>\n");
917 940
       echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&amp;fn=".urlencode($curfilename)."&amp;foffset=$foffset&amp;totalqueries=$totalqueries&amp;delimiter=".urlencode($delimiter)."\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
@@ -919,20 +942,26 @@  discard block
 block discarded – undo
919 942
    
920 943
       echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
921 944
     }
922
-  }
923
-  else 
924
-    echo ("<p class=\"error\">Stopped on error</p>\n");
945
+  } else {
946
+      echo ("<p class=\"error\">Stopped on error</p>\n");
947
+  }
925 948
 
926 949
 skin_close();
927 950
 
928 951
 }
929 952
 
930
-if ($error)
931
-  echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
953
+if ($error) {
954
+  echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
955
+}
932 956
 
933
-if ($mysqli) $mysqli->close();
934
-if ($file && !$gzipmode) fclose($file);
935
-else if ($file && $gzipmode) gzclose($file);
957
+if ($mysqli) {
958
+	$mysqli->close();
959
+}
960
+if ($file && !$gzipmode) {
961
+	fclose($file);
962
+} else if ($file && $gzipmode) {
963
+	gzclose($file);
964
+}
936 965
 
937 966
 ?>
938 967
 
@@ -965,10 +994,10 @@  discard block
 block discarded – undo
965 994
   {	ob_end_clean();
966 995
 	  create_xml_response();
967 996
 	  die;
968
-  } 
969
-  else 
970
-    create_ajax_script();	  
971
-}
997
+  } else {
998
+      create_ajax_script();
999
+  }
1000
+  }
972 1001
 
973 1002
 // Anyway put out the output from above
974 1003
 
@@ -985,8 +1014,9 @@  discard block
 block discarded – undo
985 1014
   
986 1015
   if (isset($plugin_actions[$tag]))
987 1016
   { reset ($plugin_actions[$tag]);
988
-    foreach ($plugin_actions[$tag] as $action)
989
-      call_user_func_array($action, array());
1017
+    foreach ($plugin_actions[$tag] as $action) {
1018
+          call_user_func_array($action, array());
1019
+    }
990 1020
   }
991 1021
 }
992 1022
 
Please login to merge, or discard this patch.