@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path=dirname(__FILE__).'/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | // Global variables |
37 | -$version='1.11'; |
|
38 | -$error=0; |
|
37 | +$version = '1.11'; |
|
38 | +$error = 0; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // -------------------- START OF YOUR CODE HERE -------------------- |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. |
45 | 45 | |
46 | 46 | //$langs->setDefaultLang('en_US'); // To change default language of $langs |
47 | -$langs->load("main"); // To load language file for default language |
|
47 | +$langs->load("main"); // To load language file for default language |
|
48 | 48 | @set_time_limit(0); |
49 | 49 | |
50 | 50 | // Load user and its permissions |
51 | -$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | -if (! $result > 0) { |
|
51 | +$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | +if (!$result > 0) { |
|
53 | 53 | dol_print_error('', $user->error); |
54 | 54 | exit; |
55 | 55 | } |
@@ -68,24 +68,24 @@ discard block |
||
68 | 68 | $com = new Commande($db); |
69 | 69 | |
70 | 70 | $com->ref = 'ABCDE'; |
71 | -$com->socid = 4; // Put id of third party (rowid in llx_societe table) |
|
71 | +$com->socid = 4; // Put id of third party (rowid in llx_societe table) |
|
72 | 72 | $com->date = dol_now(); |
73 | 73 | $com->note_public = 'A public comment'; |
74 | 74 | $com->note_private = 'A private comment'; |
75 | 75 | $com->source = 1; |
76 | 76 | $com->remise_percent = 0; |
77 | 77 | |
78 | -$orderline1=new OrderLine($db); |
|
79 | -$orderline1->tva_tx=10.0; |
|
80 | -$orderline1->remise_percent=0; |
|
81 | -$orderline1->qty=1; |
|
82 | -$com->lines[]=$orderline1; |
|
78 | +$orderline1 = new OrderLine($db); |
|
79 | +$orderline1->tva_tx = 10.0; |
|
80 | +$orderline1->remise_percent = 0; |
|
81 | +$orderline1->qty = 1; |
|
82 | +$com->lines[] = $orderline1; |
|
83 | 83 | |
84 | 84 | // Create order |
85 | -$idobject=$com->create($user); |
|
85 | +$idobject = $com->create($user); |
|
86 | 86 | if ($idobject > 0) { |
87 | 87 | // Change status to validated |
88 | - $result=$com->valid($user); |
|
88 | + $result = $com->valid($user); |
|
89 | 89 | if ($result > 0) { |
90 | 90 | print "OK Object created with id ".$idobject."\n"; |
91 | 91 | } else { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | // -------------------- END OF YOUR CODE -------------------- |
102 | 102 | |
103 | -if (! $error) { |
|
103 | +if (!$error) { |
|
104 | 104 | $db->commit(); |
105 | 105 | print '--- end ok'."\n"; |
106 | 106 | } else { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path=dirname(__FILE__).'/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | // Global variables |
37 | -$version='1.7'; |
|
38 | -$error=0; |
|
37 | +$version = '1.7'; |
|
38 | +$error = 0; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // -------------------- START OF YOUR CODE HERE -------------------- |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. |
45 | 45 | |
46 | 46 | //$langs->setDefaultLang('en_US'); // To change default language of $langs |
47 | -$langs->load("main"); // To load language file for default language |
|
47 | +$langs->load("main"); // To load language file for default language |
|
48 | 48 | @set_time_limit(0); |
49 | 49 | |
50 | 50 | // Load user and its permissions |
51 | -$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | -if (! $result > 0) { |
|
51 | +$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | +if (!$result > 0) { |
|
53 | 53 | dol_print_error('', $user->error); |
54 | 54 | exit; |
55 | 55 | } |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | //$obj->initAsSpecimen(); |
69 | 69 | |
70 | 70 | $obj->ref = 'ABCDE'; |
71 | -$obj->socid = 4; // Put id of third party (rowid in llx_societe table) |
|
71 | +$obj->socid = 4; // Put id of third party (rowid in llx_societe table) |
|
72 | 72 | $obj->date = dol_now(); |
73 | 73 | $obj->note_public = 'A public comment'; |
74 | 74 | $obj->note_private = 'A private comment'; |
75 | 75 | $obj->cond_reglement_id = 1; |
76 | 76 | |
77 | -$line1=new FactureLigne($db); |
|
78 | -$line1->tva_tx=10.0; |
|
79 | -$line1->remise_percent=0; |
|
80 | -$line1->qty=1; |
|
81 | -$line1->total_ht=100; |
|
82 | -$line1->total_tva=10; |
|
83 | -$line1->total_ttc=110; |
|
84 | -$obj->lines[]=$line1; |
|
77 | +$line1 = new FactureLigne($db); |
|
78 | +$line1->tva_tx = 10.0; |
|
79 | +$line1->remise_percent = 0; |
|
80 | +$line1->qty = 1; |
|
81 | +$line1->total_ht = 100; |
|
82 | +$line1->total_tva = 10; |
|
83 | +$line1->total_ttc = 110; |
|
84 | +$obj->lines[] = $line1; |
|
85 | 85 | |
86 | 86 | // Create invoice |
87 | -$idobject=$obj->create($user); |
|
87 | +$idobject = $obj->create($user); |
|
88 | 88 | if ($idobject > 0) { |
89 | 89 | // Change status to validated |
90 | - $result=$obj->validate($user); |
|
90 | + $result = $obj->validate($user); |
|
91 | 91 | if ($result > 0) { |
92 | 92 | print "OK Object created with id ".$idobject."\n"; |
93 | 93 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | // -------------------- END OF YOUR CODE -------------------- |
104 | 104 | |
105 | -if (! $error) { |
|
105 | +if (!$error) { |
|
106 | 106 | $db->commit(); |
107 | 107 | print '--- end ok'."\n"; |
108 | 108 | } else { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path=dirname(__FILE__).'/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | // Global variables |
37 | -$version='1.7'; |
|
38 | -$error=0; |
|
37 | +$version = '1.7'; |
|
38 | +$error = 0; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // -------------------- START OF YOUR CODE HERE -------------------- |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. |
45 | 45 | |
46 | 46 | //$langs->setDefaultLang('en_US'); // To change default language of $langs |
47 | -$langs->load("main"); // To load language file for default language |
|
47 | +$langs->load("main"); // To load language file for default language |
|
48 | 48 | @set_time_limit(0); |
49 | 49 | |
50 | 50 | // Load user and its permissions |
51 | -$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | -if (! $result > 0) { |
|
51 | +$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | +if (!$result > 0) { |
|
53 | 53 | dol_print_error('', $user->error); |
54 | 54 | exit; |
55 | 55 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | print "***** ".$script_file." (".$version.") *****\n"; |
60 | -if (! isset($argv[1])) { // Check parameters |
|
60 | +if (!isset($argv[1])) { // Check parameters |
|
61 | 61 | print "Usage: ".$script_file." id_thirdparty ...\n"; |
62 | 62 | exit; |
63 | 63 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | // Create contract object |
74 | 74 | $obj = new Contrat($db); |
75 | -$obj->socid=$argv[1]; |
|
75 | +$obj->socid = $argv[1]; |
|
76 | 76 | |
77 | -$listofcontractsforcompany=$obj->getListOfContracts('all'); |
|
77 | +$listofcontractsforcompany = $obj->getListOfContracts('all'); |
|
78 | 78 | |
79 | 79 | print $listofcontractsforcompany; |
80 | 80 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path=dirname(__FILE__).'/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | // Global variables |
37 | -$version='1.7'; |
|
38 | -$error=0; |
|
37 | +$version = '1.7'; |
|
38 | +$error = 0; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // -------------------- START OF YOUR CODE HERE -------------------- |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. |
45 | 45 | |
46 | 46 | //$langs->setDefaultLang('en_US'); // To change default language of $langs |
47 | -$langs->load("main"); // To load language file for default language |
|
47 | +$langs->load("main"); // To load language file for default language |
|
48 | 48 | @set_time_limit(0); |
49 | 49 | |
50 | 50 | // Load user and its permissions |
51 | -$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | -if (! $result > 0) { |
|
51 | +$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | +if (!$result > 0) { |
|
53 | 53 | dol_print_error('', $user->error); |
54 | 54 | exit; |
55 | 55 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $obj->nom = 'ABCDEF'; |
72 | 72 | |
73 | 73 | // Create user |
74 | -$idobject=$obj->create($user); |
|
74 | +$idobject = $obj->create($user); |
|
75 | 75 | if ($idobject > 0) { |
76 | 76 | // Change status to validated |
77 | - $result=$obj->setStatut(1); |
|
77 | + $result = $obj->setStatut(1); |
|
78 | 78 | if ($result > 0) { |
79 | 79 | print "OK Object created with id ".$idobject."\n"; |
80 | 80 | } else { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | // -------------------- END OF YOUR CODE -------------------- |
93 | 93 | |
94 | -if (! $error) { |
|
94 | +if (!$error) { |
|
95 | 95 | $db->commit(); |
96 | 96 | print '--- end ok'."\n"; |
97 | 97 | } else { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path=dirname(__FILE__).'/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | // Global variables |
37 | -$version='1.10'; |
|
38 | -$error=0; |
|
37 | +$version = '1.10'; |
|
38 | +$error = 0; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // -------------------- START OF YOUR CODE HERE -------------------- |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. |
45 | 45 | |
46 | 46 | //$langs->setDefaultLang('en_US'); // To change default language of $langs |
47 | -$langs->load("main"); // To load language file for default language |
|
47 | +$langs->load("main"); // To load language file for default language |
|
48 | 48 | @set_time_limit(0); |
49 | 49 | |
50 | 50 | // Load user and its permissions |
51 | -$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | -if (! $result > 0) { |
|
51 | +$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. |
|
52 | +if (!$result > 0) { |
|
53 | 53 | dol_print_error('', $user->error); |
54 | 54 | exit; |
55 | 55 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; |
66 | 66 | |
67 | 67 | // Create instance of object |
68 | -$myproduct=new Product($db); |
|
68 | +$myproduct = new Product($db); |
|
69 | 69 | |
70 | 70 | // Definition of product instance properties |
71 | 71 | $myproduct->ref = '1234'; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | // -------------------- END OF YOUR CODE -------------------- |
93 | 93 | |
94 | -if (! $error) { |
|
94 | +if (!$error) { |
|
95 | 95 | $db->commit(); |
96 | 96 | print '--- end ok'."\n"; |
97 | 97 | } else { |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | |
29 | 29 | $sapi_type = php_sapi_name(); |
30 | 30 | $script_file = basename(__FILE__); |
31 | -$path = dirname(__FILE__) . '/'; |
|
31 | +$path = dirname(__FILE__).'/'; |
|
32 | 32 | |
33 | 33 | // Test si mode batch |
34 | 34 | $sapi_type = php_sapi_name(); |
35 | 35 | if (substr($sapi_type, 0, 3) == 'cgi') { |
36 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
36 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
37 | 37 | exit(); |
38 | 38 | } |
39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // this is the default, it can be overridden here, or specified as the third parameter on the command line |
45 | 45 | $config['engine'] = "InnoDB"; |
46 | 46 | |
47 | -if (! ($argv[1] && $argv[2])) { |
|
47 | +if (!($argv[1] && $argv[2])) { |
|
48 | 48 | echo "Usage: php pg2mysql_cli.php <inputfilename> <outputfilename> [engine]\n"; |
49 | 49 | exit(); |
50 | 50 | } else { |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | if ($s < pow(2, 14)) { |
103 | 103 | return "{$s}B"; |
104 | 104 | } elseif ($s < pow(2, 20)) { |
105 | - return sprintf("%.1f", round($s / 1024, 1)) . "K"; |
|
105 | + return sprintf("%.1f", round($s / 1024, 1))."K"; |
|
106 | 106 | } elseif ($s < pow(2, 30)) { |
107 | - return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M"; |
|
107 | + return sprintf("%.1f", round($s / 1024 / 1024, 1))."M"; |
|
108 | 108 | } else { |
109 | - return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G"; |
|
109 | + return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1))."G"; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | $fs = filesize($infilename); |
141 | - echo "Filesize: " . formatsize($fs) . "\n"; |
|
141 | + echo "Filesize: ".formatsize($fs)."\n"; |
|
142 | 142 | |
143 | 143 | while ($instr = fgets($infp)) { |
144 | - $linenum ++; |
|
144 | + $linenum++; |
|
145 | 145 | $memusage = round(memory_get_usage(true) / 1024 / 1024); |
146 | 146 | $len = strlen($instr); |
147 | 147 | $pgsqlchunk[] = $instr; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | if (strlen($instr) > 3 && ($instr[$len - 3] == ")" && $instr[$len - 2] == ";" && $instr[$len - 1] == "\n") && $inquotes == false) { |
166 | - $chunkcount ++; |
|
166 | + $chunkcount++; |
|
167 | 167 | |
168 | 168 | if ($linenum % 10000 == 0) { |
169 | 169 | $currentpos = ftell($infp); |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | |
216 | 216 | fputs($outfp, "\n"); |
217 | 217 | |
218 | - fputs($outfp, '/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;' . "\n"); |
|
219 | - fputs($outfp, '/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;' . "\n"); |
|
220 | - fputs($outfp, '/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;' . "\n"); |
|
221 | - fputs($outfp, '/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;' . "\n"); |
|
222 | - fputs($outfp, '/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;' . "\n"); |
|
223 | - fputs($outfp, '/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;' . "\n"); |
|
224 | - fputs($outfp, '/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;' . "\n"); |
|
218 | + fputs($outfp, '/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;'."\n"); |
|
219 | + fputs($outfp, '/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;'."\n"); |
|
220 | + fputs($outfp, '/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;'."\n"); |
|
221 | + fputs($outfp, '/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;'."\n"); |
|
222 | + fputs($outfp, '/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;'."\n"); |
|
223 | + fputs($outfp, '/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;'."\n"); |
|
224 | + fputs($outfp, '/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;'."\n"); |
|
225 | 225 | |
226 | 226 | printf("Completed! %9d lines %9d sql chunks\n\n", $linenum, $chunkcount); |
227 | 227 | |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | if ($header) { |
253 | - $output = "-- Converted with " . PRODUCT . "-" . VERSION . "\n"; |
|
254 | - $output .= "-- Converted on " . date("r") . "\n"; |
|
253 | + $output = "-- Converted with ".PRODUCT."-".VERSION."\n"; |
|
254 | + $output .= "-- Converted on ".date("r")."\n"; |
|
255 | 255 | $output .= "\n"; |
256 | 256 | |
257 | 257 | $output .= "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n"; |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | |
283 | 283 | $reg = array(); |
284 | 284 | if (preg_match('/CREATE SEQUENCE (?:public\.)(.*)_(id|rowid|id_comment)_seq/', $line, $reg)) { |
285 | - $outputatend .= '-- Make field ' . $reg[2] . ' auto_increment for table ' . $reg[1] . "\n"; |
|
286 | - $outputatend .= 'ALTER TABLE ' . $reg[1] . ' CHANGE COLUMN ' . $reg[2] . ' ' . $reg[2] . ' INTEGER NOT NULL AUTO_INCREMENT;' . "\n\n"; |
|
285 | + $outputatend .= '-- Make field '.$reg[2].' auto_increment for table '.$reg[1]."\n"; |
|
286 | + $outputatend .= 'ALTER TABLE '.$reg[1].' CHANGE COLUMN '.$reg[2].' '.$reg[2].' INTEGER NOT NULL AUTO_INCREMENT;'."\n\n"; |
|
287 | 287 | // var_dump($outputatend); |
288 | 288 | } |
289 | 289 | |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | |
300 | 300 | $reg2 = array(); |
301 | 301 | if (preg_match('/CREATE TABLE ([^\s]+)/', $line, $reg2)) { |
302 | - $output .= 'DROP TABLE IF EXISTS `' . $reg2[1] . '`;' . "\n"; |
|
302 | + $output .= 'DROP TABLE IF EXISTS `'.$reg2[1].'`;'."\n"; |
|
303 | 303 | } |
304 | 304 | $output .= $line; |
305 | - $linenumber ++; |
|
305 | + $linenumber++; |
|
306 | 306 | continue; |
307 | 307 | } |
308 | 308 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $output .= $tbl_extra; |
314 | 314 | $output .= $line; |
315 | 315 | |
316 | - $linenumber ++; |
|
316 | + $linenumber++; |
|
317 | 317 | $tbl_extra = ""; |
318 | 318 | continue; |
319 | 319 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $arrayofprimaryalreadyintabledef[$in_create_table] = $in_create_table; |
380 | 380 | } |
381 | 381 | |
382 | - $specialfields = array("repeat","status","type","call"); |
|
382 | + $specialfields = array("repeat", "status", "type", "call"); |
|
383 | 383 | |
384 | 384 | $field = getfieldname($line); |
385 | 385 | if (in_array($field, $specialfields)) { |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $lastchr = substr($output, - 2, 1); |
399 | 399 | // echo "lastchr=$lastchr"; |
400 | 400 | if ($lastchr == ",") { |
401 | - $output = substr($output, 0, - 2) . "\n"; |
|
401 | + $output = substr($output, 0, - 2)."\n"; |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | $after = str_replace(" (E'", " ('", $after); |
424 | 424 | $after = str_replace(", E'", ", '", $after); |
425 | 425 | |
426 | - $output .= $before . " VALUES " . $after; |
|
427 | - $linenumber ++; |
|
426 | + $output .= $before." VALUES ".$after; |
|
427 | + $linenumber++; |
|
428 | 428 | continue; |
429 | 429 | } else { |
430 | 430 | // this insert spans multiple lines, so keep dumping the lines until we reach a line |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | $inquotes = false; |
452 | 452 | } |
453 | 453 | |
454 | - $output .= $before . " VALUES " . $after; |
|
454 | + $output .= $before." VALUES ".$after; |
|
455 | 455 | do { |
456 | - $linenumber ++; |
|
456 | + $linenumber++; |
|
457 | 457 | |
458 | 458 | // in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string') |
459 | 459 | // ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $line = str_replace("public.", "", $line); |
487 | 487 | $pkey = $line; |
488 | 488 | |
489 | - $linenumber ++; |
|
489 | + $linenumber++; |
|
490 | 490 | if (!empty($lines[$linenumber])) { |
491 | 491 | $line = $lines[$linenumber]; |
492 | 492 | } else { |
@@ -501,14 +501,14 @@ discard block |
||
501 | 501 | $output .= str_replace("\n", "", $pkey); |
502 | 502 | // the postgres and mysql syntax for this is (at least, in the example im looking at) |
503 | 503 | // identical, so we can just add it as is. |
504 | - $output .= $line . "\n"; |
|
504 | + $output .= $line."\n"; |
|
505 | 505 | } else { |
506 | - $output .= '-- ' . str_replace("\n", "", $pkey); |
|
507 | - $output .= '-- ' . $line . "\n"; |
|
506 | + $output .= '-- '.str_replace("\n", "", $pkey); |
|
507 | + $output .= '-- '.$line."\n"; |
|
508 | 508 | } |
509 | 509 | } else { |
510 | - $output .= '-- ' . str_replace("\n", "", $pkey); |
|
511 | - $output .= '-- ' . $line . "\n"; |
|
510 | + $output .= '-- '.str_replace("\n", "", $pkey); |
|
511 | + $output .= '-- '.$line."\n"; |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $tablename = str_replace('public.', '', $matches[2]); |
523 | 523 | $columns = $matches[3]; |
524 | 524 | if ($tablename && $columns) { |
525 | - $output .= "ALTER TABLE `" . $tablename . "` ADD INDEX " . $indexname . "( {$columns} ) ;\n"; |
|
525 | + $output .= "ALTER TABLE `".$tablename."` ADD INDEX ".$indexname."( {$columns} ) ;\n"; |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $tablename = str_replace('public.', '', $matches[2]); |
535 | 535 | $columns = str_replace('"', '', $matches[3]); |
536 | 536 | if ($tablename && $columns) { |
537 | - $output .= "ALTER TABLE `" . $tablename . "` ADD UNIQUE INDEX " . $indexname . " ( {$columns} ) ;\n"; |
|
537 | + $output .= "ALTER TABLE `".$tablename."` ADD UNIQUE INDEX ".$indexname." ( {$columns} ) ;\n"; |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | } |
@@ -565,23 +565,23 @@ discard block |
||
565 | 565 | if ($line == "\\.\n") { |
566 | 566 | $in_insert = false; |
567 | 567 | if ($values) { |
568 | - $output .= "INSERT INTO $heads VALUES\n" . implode(",\n", $values) . ";\n\n"; |
|
568 | + $output .= "INSERT INTO $heads VALUES\n".implode(",\n", $values).";\n\n"; |
|
569 | 569 | } |
570 | 570 | } else { |
571 | 571 | $vals = explode(' ', $line); |
572 | 572 | foreach ($vals as $i => $val) { |
573 | - $vals[$i] = ($val == '\\N') ? 'NULL' : "'" . str_replace("'", "\\'", trim($val)) . "'"; |
|
573 | + $vals[$i] = ($val == '\\N') ? 'NULL' : "'".str_replace("'", "\\'", trim($val))."'"; |
|
574 | 574 | } |
575 | - $values[] = '(' . implode(',', $vals) . ')'; |
|
575 | + $values[] = '('.implode(',', $vals).')'; |
|
576 | 576 | if (count($values) >= 1000) { |
577 | - $output .= "INSERT INTO $heads VALUES\n" . implode(",\n", $values) . ";\n"; |
|
577 | + $output .= "INSERT INTO $heads VALUES\n".implode(",\n", $values).";\n"; |
|
578 | 578 | $values = array(); |
579 | 579 | } |
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
583 | - $linenumber ++; |
|
583 | + $linenumber++; |
|
584 | 584 | } |
585 | 585 | |
586 | - return array('output' => $output,'outputatend' => $outputatend); |
|
586 | + return array('output' => $output, 'outputatend' => $outputatend); |
|
587 | 587 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | |
26 | 26 | $sapi_type = php_sapi_name(); |
27 | 27 | $script_file = basename(__FILE__); |
28 | -$path = dirname(__FILE__) . '/'; |
|
28 | +$path = dirname(__FILE__).'/'; |
|
29 | 29 | |
30 | 30 | // Test si mode batch |
31 | 31 | $sapi_type = php_sapi_name(); |
32 | 32 | if (substr($sapi_type, 0, 3) == 'cgi') { |
33 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
33 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
34 | 34 | exit(); |
35 | 35 | } |
36 | 36 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $outputdir = dirname($outputpath); |
52 | 52 | $outputfile = basename($outputpath); |
53 | 53 | |
54 | -if (! is_dir($outputdir)) { |
|
54 | +if (!is_dir($outputdir)) { |
|
55 | 55 | print 'Error: dir '.$outputdir.' does not exists or is not writable'."\n"; |
56 | 56 | exit(1); |
57 | 57 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * - Exclude param optioncss, token, sortfield, sortorder |
25 | 25 | */ |
26 | 26 | |
27 | -$crawledLinks=array(); |
|
28 | -const MAX_DEPTH=2; |
|
27 | +$crawledLinks = array(); |
|
28 | +const MAX_DEPTH = 2; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | function followLink($url, $depth = 0) |
37 | 37 | { |
38 | 38 | global $crawledLinks; |
39 | - $crawling=array(); |
|
40 | - if ($depth>MAX_DEPTH) { |
|
39 | + $crawling = array(); |
|
40 | + if ($depth > MAX_DEPTH) { |
|
41 | 41 | echo "<div style='color:red;'>The Crawler is giving up!</div>"; |
42 | 42 | return; |
43 | 43 | } |
44 | - $options=array( |
|
44 | + $options = array( |
|
45 | 45 | 'http'=>array( |
46 | 46 | 'method'=>"GET", |
47 | 47 | 'user-agent'=>"gfgBot/0.1\n" |
48 | 48 | ) |
49 | 49 | ); |
50 | - $context=stream_context_create($options); |
|
51 | - $doc=new DomDocument(); |
|
50 | + $context = stream_context_create($options); |
|
51 | + $doc = new DomDocument(); |
|
52 | 52 | @$doc->loadHTML(file_get_contents($url, false, $context)); |
53 | - $links=$doc->getElementsByTagName('a'); |
|
54 | - $pageTitle=getDocTitle($doc, $url); |
|
55 | - $metaData=getDocMetaData($doc); |
|
53 | + $links = $doc->getElementsByTagName('a'); |
|
54 | + $pageTitle = getDocTitle($doc, $url); |
|
55 | + $metaData = getDocMetaData($doc); |
|
56 | 56 | foreach ($links as $i) { |
57 | - $link=$i->getAttribute('href'); |
|
57 | + $link = $i->getAttribute('href'); |
|
58 | 58 | if (ignoreLink($link)) continue; |
59 | - $link=convertLink($url, $link); |
|
59 | + $link = convertLink($url, $link); |
|
60 | 60 | if (!in_array($link, $crawledLinks)) { |
61 | - $crawledLinks[]=$link; |
|
62 | - $crawling[]=$link; |
|
61 | + $crawledLinks[] = $link; |
|
62 | + $crawling[] = $link; |
|
63 | 63 | insertIntoDatabase($link, $pageTitle, $metaData, $depth); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | foreach ($crawling as $crawlURL) |
67 | - followLink($crawlURL, $depth+1); |
|
67 | + followLink($crawlURL, $depth + 1); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function convertLink($site, $path) |
76 | 76 | { |
77 | - if (substr_compare($path, "//", 0, 2)==0) |
|
77 | + if (substr_compare($path, "//", 0, 2) == 0) |
|
78 | 78 | return parse_url($site)['scheme'].$path; |
79 | - elseif (substr_compare($path, "http://", 0, 7)==0 |
|
80 | - or substr_compare($path, "https://", 0, 8)==0 |
|
81 | - or substr_compare($path, "www.", 0, 4)==0 |
|
79 | + elseif (substr_compare($path, "http://", 0, 7) == 0 |
|
80 | + or substr_compare($path, "https://", 0, 8) == 0 |
|
81 | + or substr_compare($path, "www.", 0, 4) == 0 |
|
82 | 82 | ) |
83 | 83 | return $path; |
84 | 84 | else return $site.'/'.$path; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function ignoreLink($url) |
92 | 92 | { |
93 | - return $url[0]=="#" or substr($url, 0, 11) == "javascript:"; |
|
93 | + return $url[0] == "#" or substr($url, 0, 11) == "javascript:"; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function getDocTitle(&$doc, $url) |
118 | 118 | { |
119 | - $titleNodes=$doc->getElementsByTagName('title'); |
|
120 | - if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue)) |
|
119 | + $titleNodes = $doc->getElementsByTagName('title'); |
|
120 | + if (count($titleNodes) == 0 or !isset($titleNodes[0]->nodeValue)) |
|
121 | 121 | return $url; |
122 | - $title=str_replace('', '\n', $titleNodes[0]->nodeValue); |
|
123 | - return (strlen($title)<1)?$url:$title; |
|
122 | + $title = str_replace('', '\n', $titleNodes[0]->nodeValue); |
|
123 | + return (strlen($title) < 1) ? $url : $title; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function getDocMetaData(&$doc) |
131 | 131 | { |
132 | - $metaData=array(); |
|
133 | - $metaNodes=$doc->getElementsByTagName('meta'); |
|
132 | + $metaData = array(); |
|
133 | + $metaNodes = $doc->getElementsByTagName('meta'); |
|
134 | 134 | foreach ($metaNodes as $node) |
135 | 135 | $metaData[$node->getAttribute("name")] = $node->getAttribute("content"); |
136 | 136 | if (!isset($metaData['description'])) |
137 | - $metaData['description']='No Description Available'; |
|
138 | - if (!isset($metaData['keywords'])) $metaData['keywords']=''; |
|
137 | + $metaData['description'] = 'No Description Available'; |
|
138 | + if (!isset($metaData['keywords'])) $metaData['keywords'] = ''; |
|
139 | 139 | return array( |
140 | 140 | 'keywords'=>str_replace('', '\n', $metaData['keywords']), |
141 | 141 | 'description'=>str_replace('', '\n', $metaData['description']) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Bbb |
20 | 20 | { |
21 | - const BBB='bbb'; |
|
21 | + const BBB = 'bbb'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * do |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | global $globalaaa, $globalbbb; |
31 | 31 | echo 'dobbb'."\n"; |
32 | - $globalaaa.='+bbb'; |
|
33 | - $globalbbb.='+bbb'; |
|
32 | + $globalaaa .= '+bbb'; |
|
33 | + $globalbbb .= '+bbb'; |
|
34 | 34 | } |
35 | 35 | } |