Passed
Push — master ( f37c96...1d5800 )
by Peter
05:42
created
bin/cron/logwatch.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 use const rosasurfer\WINDOWS;
22 22
 
23 23
 require(dirname(realpath(__FILE__)).'/../../app/init.php');
24
-!CLI && exit(1|stderr('error: This script must be executed in CLI mode.'));
24
+!CLI && exit(1 | stderr('error: This script must be executed in CLI mode.'));
25 25
 
26 26
 
27 27
 // --- Configuration --------------------------------------------------------------------------------------------------------
28 28
 
29 29
 
30
-set_time_limit(0);                                          // no time limit for CLI
31
-$quiet = false;                                             // whether or not "quiet" mode is enabled (e.g. for CRON)
30
+set_time_limit(0); // no time limit for CLI
31
+$quiet = false; // whether or not "quiet" mode is enabled (e.g. for CRON)
32 32
 
33 33
 
34 34
 // --- Parse and validate command line arguments ----------------------------------------------------------------------------
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 $args = array_slice($_SERVER['argv'], 1);
38 38
 
39 39
 foreach ($args as $i => $arg) {
40
-    if ($arg == '-h') { help(); exit(0);                           }    // help
40
+    if ($arg == '-h') { help(); exit(0); }    // help
41 41
     if ($arg == '-q') { $quiet = true; unset($args[$i]); continue; }    // quiet mode
42 42
 
43 43
     stderr('invalid argument: '.$arg);
@@ -51,22 +51,22 @@  discard block
 block discarded – undo
51 51
 
52 52
 // (1) define the location of the error log
53 53
 $errorLog = ini_get('error_log');
54
-if (empty($errorLog) || $errorLog=='syslog') {              // errors are logged elsewhere
55
-    if (empty($errorLog)) $quiet || echoPre('errors are logged elsewhere ('.(CLI     ?    'stderr':'sapi'  ).')');
56
-    else                  $quiet || echoPre('errors are logged elsewhere ('.(WINDOWS ? 'event log':'syslog').')');
54
+if (empty($errorLog) || $errorLog == 'syslog') {              // errors are logged elsewhere
55
+    if (empty($errorLog)) $quiet || echoPre('errors are logged elsewhere ('.(CLI ? 'stderr' : 'sapi').')');
56
+    else                  $quiet || echoPre('errors are logged elsewhere ('.(WINDOWS ? 'event log' : 'syslog').')');
57 57
     exit(0);
58 58
 }
59 59
 
60 60
 
61 61
 // (2) check log file for existence and process it
62
-if (!is_file    ($errorLog)) { $quiet || echoPre('error log empty: '       .$errorLog); exit(0); }
62
+if (!is_file($errorLog)) { $quiet || echoPre('error log empty: '.$errorLog); exit(0); }
63 63
 if (!is_writable($errorLog)) {            stderr('cannot access log file: '.$errorLog); exit(1); }
64 64
 $errorLog = realpath($errorLog);
65 65
 
66 66
 // rename the file; we don't want to lock it as doing so could block the main app
67 67
 $tempName = tempnam(dirname($errorLog), basename($errorLog).'.');
68 68
 if (!rename($errorLog, $tempName)) {
69
-    stderr('cannot rename log file: '  .$errorLog);
69
+    stderr('cannot rename log file: '.$errorLog);
70 70
     exit(1);
71 71
 }
72 72
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 $hFile = fopen($tempName, 'rb');
76 76
 $line  = $entry = '';
77 77
 $i = 0;
78
-while (($line=fgets($hFile)) !== false) {
78
+while (($line = fgets($hFile)) !== false) {
79 79
     $i++;
80
-    $line = trim($line, "\r\n");                // PHP doesn't correctly handle EOL_NETSCAPE which is error_log() standard on Windows
80
+    $line = trim($line, "\r\n"); // PHP doesn't correctly handle EOL_NETSCAPE which is error_log() standard on Windows
81 81
     if (strStartsWith($line, '[')) {            // lines starting with a bracket "[" are considered the start of an entry
82 82
         processEntry($entry);
83 83
         $entry = '';
84 84
     }
85 85
     $entry .= $line.NL;
86 86
 }
87
-processEntry($entry);                           // process the last entry (if any)
87
+processEntry($entry); // process the last entry (if any)
88 88
 
89 89
 // delete the processed file
90 90
 fclose($hFile);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     }                                                               // without receivers mail is sent to the system user
122 122
     !$receivers && $receivers[] = strtolower(get_current_user().'@localhost');
123 123
 
124
-    $subject = strtok($entry, "\r\n");                              // that's CR or LF, not CRLF
124
+    $subject = strtok($entry, "\r\n"); // that's CR or LF, not CRLF
125 125
     $message = $entry;
126 126
     $sender  = null;
127 127
     $headers = [];
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,8 +52,11 @@  discard block
 block discarded – undo
52 52
 // (1) define the location of the error log
53 53
 $errorLog = ini_get('error_log');
54 54
 if (empty($errorLog) || $errorLog=='syslog') {              // errors are logged elsewhere
55
-    if (empty($errorLog)) $quiet || echoPre('errors are logged elsewhere ('.(CLI     ?    'stderr':'sapi'  ).')');
56
-    else                  $quiet || echoPre('errors are logged elsewhere ('.(WINDOWS ? 'event log':'syslog').')');
55
+    if (empty($errorLog)) {
56
+        $quiet || echoPre('errors are logged elsewhere ('.(CLI     ?    'stderr':'sapi'  ).')');
57
+    } else {
58
+        $quiet || echoPre('errors are logged elsewhere ('.(WINDOWS ? 'event log':'syslog').')');
59
+    }
57 60
     exit(0);
58 61
 }
59 62
 
@@ -105,9 +108,13 @@  discard block
 block discarded – undo
105 108
  * @param  string $entry - a single log entry
106 109
  */
107 110
 function processEntry($entry) {
108
-    if (!is_string($entry)) throw new IllegalTypeException('Illegal type of parameter $entry: '.gettype($entry));
111
+    if (!is_string($entry)) {
112
+        throw new IllegalTypeException('Illegal type of parameter $entry: '.gettype($entry));
113
+    }
109 114
     $entry = trim($entry);
110
-    if (!strlen($entry)) return;
115
+    if (!strlen($entry)) {
116
+        return;
117
+    }
111 118
 
112 119
     $config = Application::getConfig();
113 120
 
@@ -151,8 +158,9 @@  discard block
 block discarded – undo
151 158
  * @param  string $message [optional] - additional message to display (default: none)
152 159
  */
153 160
 function help($message = null) {
154
-    if (isset($message))
155
-        echo $message.NL;
161
+    if (isset($message)) {
162
+            echo $message.NL;
163
+    }
156 164
 
157 165
     $self = basename($_SERVER['PHP_SELF']);
158 166
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,5 +164,5 @@
 block discarded – undo
164 164
            -h   This help screen.
165 165
 
166 166
 
167
-HELP;
167
+help;
168 168
 }
Please login to merge, or discard this patch.
app/init.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 use rosasurfer\util\PHP;
4 4
 
5 5
 // class loader
6
-require(($appRoot=dirname(__DIR__)).'/vendor/autoload.php');
6
+require(($appRoot = dirname(__DIR__)).'/vendor/autoload.php');
7 7
 
8 8
 
9 9
 // php.ini settings
10 10
 error_reporting(E_ALL & ~E_DEPRECATED);
11
-PHP::ini_set('log_errors',        1                                );
12
-PHP::ini_set('error_log',         $appRoot.'/etc/log/php-error.log');
13
-PHP::ini_set('session.save_path', $appRoot.'/etc/tmp'              );
14
-PHP::ini_set('default_charset',  'UTF-8'                           );
15
-PHP::ini_set('memory_limit',     '128M'                            );
11
+PHP::ini_set('log_errors', 1);
12
+PHP::ini_set('error_log', $appRoot.'/etc/log/php-error.log');
13
+PHP::ini_set('session.save_path', $appRoot.'/etc/tmp');
14
+PHP::ini_set('default_charset', 'UTF-8');
15
+PHP::ini_set('memory_limit', '128M');
16 16
 
17 17
 
18 18
 // create a new application
Please login to merge, or discard this patch.
app/controller/actions/DownloadAction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
         $files = [
25 25
             0 => ['BankersFX Core Volume.ex4', $config['app.dir.root'].'/etc/mql/indicators/BankersFX CVI v1.20.0.ex4'],
26
-            1 => ['BankersFX Lib.ex4',         $config['app.dir.root'].'/etc/mql/libraries/BankersFX Lib.ex4'         ],
26
+            1 => ['BankersFX Lib.ex4', $config['app.dir.root'].'/etc/mql/libraries/BankersFX Lib.ex4'],
27 27
         ];
28 28
         if (!isset($files[$file])) {
29 29
             $request->setActionError('file', 'error: Unknown file identifier');
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
             // make the download non-cacheable
41 41
             header('Pragma: private');
42 42
             header('Cache-control: private');
43
-            header('Expires: '.gmdate(DATE_RFC2822, time() - 1*YEAR));
43
+            header('Expires: '.gmdate(DATE_RFC2822, time() - 1 * YEAR));
44 44
 
45 45
             // erase an existing output buffer and work around an IE bug (Content-Disposition is ignored)
46 46
             ob_get_level() && ob_end_clean();
47 47
             ini_get_bool('zlib.output_compression') && PHP::ini_set('zlib.output_compression', false);
48 48
 
49 49
             // close the session to not block following requests
50
-            (session_status()==PHP_SESSION_ACTIVE) && session_write_close();
50
+            (session_status() == PHP_SESSION_ACTIVE) && session_write_close();
51 51
 
52 52
             // serve the file
53 53
             $hFile = fopen($fullFilename, 'rb');
Please login to merge, or discard this patch.
app/controller/actions/CheckLicenseAction.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         if (false && !$request->isSecure()) {
23 23
             $url = $request->getUrl();
24 24
             $url = 'https'.strRight($url, -4);
25
-            return new ActionForward('generic', $url, $redirect=true);
25
+            return new ActionForward('generic', $url, $redirect = true);
26 26
         }
27 27
         $config = $this->di()['config'];
28 28
 
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
             $knownAccount = (bool) ($license = $config->get('bfx.accounts.'.$account, null));
38 38
             !$license && $license = $config->get('bfx.accounts.default');
39 39
 
40
-            $expires = date('Ymd', time() + 1*MONTH);                       // extend license for 30 days
40
+            $expires = date('Ymd', time() + 1 * MONTH); // extend license for 30 days
41 41
             $reply = $account.'|'.$license.'|A|'.$expires.'|mt4tfv|ok';
42 42
         }
43 43
         else {
44 44
             $reply = 'ERROR: Unknown or missing account number.|no';
45 45
         }
46
-        $knownAccount || Logger::log('reply: '.$reply, L_INFO);             // log requests for unknown accounts
46
+        $knownAccount || Logger::log('reply: '.$reply, L_INFO); // log requests for unknown accounts
47 47
 
48 48
         echo $reply;
49 49
         return null;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@
 block discarded – undo
39 39
 
40 40
             $expires = date('Ymd', time() + 1*MONTH);                       // extend license for 30 days
41 41
             $reply = $account.'|'.$license.'|A|'.$expires.'|mt4tfv|ok';
42
-        }
43
-        else {
42
+        } else {
44 43
             $reply = 'ERROR: Unknown or missing account number.|no';
45 44
         }
46 45
         $knownAccount || Logger::log('reply: '.$reply, L_INFO);             // log requests for unknown accounts
Please login to merge, or discard this patch.