@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | ini_set('display_errors', 1); |
50 | 50 | |
51 | 51 | // Load our autoloader |
52 | -require __DIR__ .'/../vendor/autoload.php'; |
|
52 | +require __DIR__.'/../vendor/autoload.php'; |
|
53 | 53 | |
54 | 54 | // Load configuration |
55 | 55 | require 'build_config.php'; |
56 | 56 | |
57 | 57 | // Folder definitions |
58 | -define('BUILDBASE', __DIR__ .'/'); |
|
58 | +define('BUILDBASE', __DIR__.'/'); |
|
59 | 59 | |
60 | 60 | // Don't stop script exectuion on 404... |
61 | 61 | function show_404($page = '', $log_error = TRUE) {} |
62 | 62 | |
63 | 63 | // Make sure we have access to CI() object. |
64 | 64 | ob_start(); |
65 | - require( BUILDBASE .'../index.php' ); |
|
65 | + require(BUILDBASE.'../index.php'); |
|
66 | 66 | ob_end_clean(); |
67 | 67 | |
68 | 68 | //-------------------------------------------------------------------- |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | |
74 | 74 | if (empty($release)) |
75 | 75 | { |
76 | - $release = CLI::prompt("Which script", array_keys($config['builds']) ); |
|
76 | + $release = CLI::prompt("Which script", array_keys($config['builds'])); |
|
77 | 77 | } |
78 | 78 | |
79 | -if (! array_key_exists($release, $config['builds'])) |
|
79 | +if ( ! array_key_exists($release, $config['builds'])) |
|
80 | 80 | { |
81 | - CLI::error('Invalid build specified: '. $release); |
|
81 | + CLI::error('Invalid build specified: '.$release); |
|
82 | 82 | exit(1); |
83 | 83 | } |
84 | 84 | |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | $class_name = $config['builds'][$release]; |
90 | 90 | |
91 | 91 | |
92 | -if (! file_exists(BUILDBASE ."scripts/{$class_name}.php")) |
|
92 | +if ( ! file_exists(BUILDBASE."scripts/{$class_name}.php")) |
|
93 | 93 | { |
94 | - CLI::error('Unable to find build script: '. $class_name .'.php'); |
|
94 | + CLI::error('Unable to find build script: '.$class_name.'.php'); |
|
95 | 95 | exit(1); |
96 | 96 | } |
97 | 97 | |
98 | -require BUILDBASE ."lib/BaseBuilder.php"; |
|
99 | -require BUILDBASE ."scripts/{$class_name}.php"; |
|
98 | +require BUILDBASE."lib/BaseBuilder.php"; |
|
99 | +require BUILDBASE."scripts/{$class_name}.php"; |
|
100 | 100 | |
101 | -$builder = new $class_name( $config['destinations'][$release], get_instance() ); |
|
101 | +$builder = new $class_name($config['destinations'][$release], get_instance()); |
|
102 | 102 | |
103 | -if (! is_object($builder)) |
|
103 | +if ( ! is_object($builder)) |
|
104 | 104 | { |
105 | - CLI::error('Unable to make new class: '. $class_name); |
|
105 | + CLI::error('Unable to make new class: '.$class_name); |
|
106 | 106 | exit(1); |
107 | 107 | } |
108 | 108 | |
@@ -118,4 +118,4 @@ discard block |
||
118 | 118 | $end_time = microtime(true); |
119 | 119 | $elapsed_time = number_format($end_time - $start_time, 4); |
120 | 120 | |
121 | -CLI::write('Done in '. $elapsed_time .' seconds', 'green'); |
|
122 | 121 | \ No newline at end of file |
122 | +CLI::write('Done in '.$elapsed_time.' seconds', 'green'); |
|
123 | 123 | \ No newline at end of file |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | //-------------------------------------------------------------------- |
12 | 12 | |
13 | - public function __construct($ci=null) |
|
13 | + public function __construct($ci = null) |
|
14 | 14 | { |
15 | - $this->ci =& $ci; |
|
15 | + $this->ci = & $ci; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | //-------------------------------------------------------------------- |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | |
31 | 31 | @$this->ensureFolder($destination); |
32 | 32 | |
33 | - while (false !== ( $file = readdir($dir)) ) |
|
33 | + while (false !== ($file = readdir($dir))) |
|
34 | 34 | { |
35 | - if ( ! in_array($file, $this->ignore_files) ) |
|
35 | + if ( ! in_array($file, $this->ignore_files)) |
|
36 | 36 | { |
37 | - if ( is_dir($source .'/'. $file) ) |
|
37 | + if (is_dir($source.'/'.$file)) |
|
38 | 38 | { |
39 | - $this->copyFolder($source .'/'. $file, $destination .'/'. $file); |
|
39 | + $this->copyFolder($source.'/'.$file, $destination.'/'.$file); |
|
40 | 40 | } |
41 | 41 | else { |
42 | - copy($source .'/'. $file, $destination .'/'. $file); |
|
42 | + copy($source.'/'.$file, $destination.'/'.$file); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param $path |
75 | 75 | * @param array $leave_files |
76 | 76 | */ |
77 | - public function cleanFolder($path, $leave_files=[]) |
|
77 | + public function cleanFolder($path, $leave_files = []) |
|
78 | 78 | { |
79 | 79 | foreach (glob("{$path}/*") as $file) |
80 | 80 | { |
@@ -97,25 +97,25 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | - public function compressFolder($source, $destination, $include_dir=false) |
|
100 | + public function compressFolder($source, $destination, $include_dir = false) |
|
101 | 101 | { |
102 | - if (! extension_loaded('zip') ) { |
|
102 | + if ( ! extension_loaded('zip')) { |
|
103 | 103 | CLI::error('ZipArchive extension is required.'); |
104 | 104 | exit(1); |
105 | 105 | } |
106 | 106 | |
107 | - if (! file_exists($source)) { |
|
107 | + if ( ! file_exists($source)) { |
|
108 | 108 | CLI::error('Source folder not found for zipping.'); |
109 | 109 | exit(1); |
110 | 110 | } |
111 | 111 | |
112 | 112 | if (file_exists($destination)) |
113 | 113 | { |
114 | - unlink ($destination); |
|
114 | + unlink($destination); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $zip = new ZipArchive(); |
118 | - if (! $zip->open($destination, ZIPARCHIVE::CREATE)) |
|
118 | + if ( ! $zip->open($destination, ZIPARCHIVE::CREATE)) |
|
119 | 119 | { |
120 | 120 | CLI::error('Unknown error opening zip file.'); |
121 | 121 | exit(1); |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | |
130 | 130 | if ($include_dir) { |
131 | 131 | |
132 | - $arr = explode("/",$source); |
|
133 | - $maindir = $arr[count($arr)- 1]; |
|
132 | + $arr = explode("/", $source); |
|
133 | + $maindir = $arr[count($arr) - 1]; |
|
134 | 134 | |
135 | 135 | $source = ""; |
136 | - for ($i=0; $i < count($arr) - 1; $i++) { |
|
137 | - $source .= '/' . $arr[$i]; |
|
136 | + for ($i = 0; $i < count($arr) - 1; $i++) { |
|
137 | + $source .= '/'.$arr[$i]; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $source = substr($source, 1); |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | $file = str_replace('\\', '/', $file); |
148 | 148 | |
149 | 149 | // Ignore "." and ".." folders |
150 | - if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..', '.DS_Store')) ) |
|
150 | + if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..', '.DS_Store'))) |
|
151 | 151 | continue; |
152 | 152 | |
153 | 153 | $file = realpath($file); |
154 | 154 | |
155 | 155 | if (is_dir($file) === true) |
156 | 156 | { |
157 | - $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); |
|
157 | + $zip->addEmptyDir(str_replace($source.'/', '', $file.'/')); |
|
158 | 158 | } |
159 | 159 | else if (is_file($file) === true) |
160 | 160 | { |
161 | - $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); |
|
161 | + $zip->addFromString(str_replace($source.'/', '', $file), file_get_contents($file)); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | |
17 | 17 | protected $ignore_files = ['.', '..', '.git', 'vendor', '.idea', '.travis.yml', 'build']; |
18 | 18 | |
19 | - public function __construct($destination, $ci=null) |
|
19 | + public function __construct($destination, $ci = null) |
|
20 | 20 | { |
21 | 21 | parent::__construct($ci); |
22 | 22 | |
23 | - $this->source_path = realpath(BUILDBASE .'../'); |
|
23 | + $this->source_path = realpath(BUILDBASE.'../'); |
|
24 | 24 | |
25 | 25 | if (empty($this->source_path)) |
26 | 26 | { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->cleanTestsFolder(); |
47 | 47 | |
48 | 48 | CLI::write("\tRemoving application modules..."); |
49 | - $this->cleanFolder($this->dest_path .'/application/modules', ['index.html', '.htaccess']); |
|
49 | + $this->cleanFolder($this->dest_path.'/application/modules', ['index.html', '.htaccess']); |
|
50 | 50 | |
51 | 51 | CLI::write("\tGenerating default encryption key for config file..."); |
52 | 52 | $this->generateEncryptionKey(); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | private function cleanTempFiles() |
62 | 62 | { |
63 | 63 | // Remove Log Files |
64 | - $this->cleanFolder($this->dest_path .'/application/logs', ['index.html', '.htaccess']); |
|
64 | + $this->cleanFolder($this->dest_path.'/application/logs', ['index.html', '.htaccess']); |
|
65 | 65 | |
66 | 66 | // Cache Files |
67 | - $this->cleanFolder($this->dest_path .'/application/cache', ['index.html', '.htaccess']); |
|
67 | + $this->cleanFolder($this->dest_path.'/application/cache', ['index.html', '.htaccess']); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | //-------------------------------------------------------------------- |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public function cleanTestsFolder() |
73 | 73 | { |
74 | 74 | // Remove coverage Files |
75 | - $this->cleanFolder($this->dest_path .'/tests/_output', ['.gitignore']); |
|
75 | + $this->cleanFolder($this->dest_path.'/tests/_output', ['.gitignore']); |
|
76 | 76 | |
77 | 77 | // Remove our Acceptance tests |
78 | - $this->cleanFolder($this->dest_path .'/tests/acceptance/myth'); |
|
79 | - rmdir($this->dest_path .'/tests/acceptance/myth'); |
|
78 | + $this->cleanFolder($this->dest_path.'/tests/acceptance/myth'); |
|
79 | + rmdir($this->dest_path.'/tests/acceptance/myth'); |
|
80 | 80 | |
81 | 81 | // Remove our Unit tests |
82 | - $this->cleanFolder($this->dest_path .'/tests/unit/myth'); |
|
83 | - rmdir($this->dest_path .'/tests/unit/myth'); |
|
82 | + $this->cleanFolder($this->dest_path.'/tests/unit/myth'); |
|
83 | + rmdir($this->dest_path.'/tests/unit/myth'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | //-------------------------------------------------------------------- |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | $length = 16; |
95 | 95 | |
96 | 96 | $this->ci->load->library('Encryption'); |
97 | - $key = bin2hex( $this->ci->encryption->create_key( $length ) ); |
|
97 | + $key = bin2hex($this->ci->encryption->create_key($length)); |
|
98 | 98 | |
99 | 99 | $replace = "hex2bin( '$key' )"; |
100 | 100 | |
101 | 101 | $kit = new FileKit(); |
102 | 102 | |
103 | - $kit->replaceIn(BUILDBASE .'../application/config/config.php', "'PLEASE_CHANGE_ME!'", $replace); |
|
103 | + $kit->replaceIn(BUILDBASE.'../application/config/config.php', "'PLEASE_CHANGE_ME!'", $replace); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | //-------------------------------------------------------------------- |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct($destination) |
19 | 19 | { |
20 | - $this->source_path = realpath(BUILDBASE .'../'); |
|
20 | + $this->source_path = realpath(BUILDBASE.'../'); |
|
21 | 21 | |
22 | 22 | if (empty($this->source_path)) |
23 | 23 | { |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | exit(1); |
26 | 26 | } |
27 | 27 | |
28 | - $this->dest_path = BUILDBASE . $destination; |
|
29 | - $this->dest_path = rtrim($this->dest_path, '/ ') .'/'. date('Y-m-d'); |
|
28 | + $this->dest_path = BUILDBASE.$destination; |
|
29 | + $this->dest_path = rtrim($this->dest_path, '/ ').'/'.date('Y-m-d'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | //-------------------------------------------------------------------- |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $this->cleanTestsFolder(); |
52 | 52 | |
53 | 53 | CLI::write("\tRemoving application modules..."); |
54 | - $this->cleanFolder($this->dest_path .'/application/modules', ['index.html', '.htaccess']); |
|
54 | + $this->cleanFolder($this->dest_path.'/application/modules', ['index.html', '.htaccess']); |
|
55 | 55 | |
56 | 56 | CLI::write("\tCompressing files..."); |
57 | - $this->compressFolder($this->dest_path, $this->dest_path .'/Sprint_'. date('Y-m-d') .'.zip'); |
|
57 | + $this->compressFolder($this->dest_path, $this->dest_path.'/Sprint_'.date('Y-m-d').'.zip'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | //-------------------------------------------------------------------- |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | private function cleanTempFiles() |
67 | 67 | { |
68 | 68 | // Remove Log Files |
69 | - $this->cleanFolder($this->dest_path .'/application/logs', ['index.html', '.htaccess']); |
|
69 | + $this->cleanFolder($this->dest_path.'/application/logs', ['index.html', '.htaccess']); |
|
70 | 70 | |
71 | 71 | // Cache Files |
72 | - $this->cleanFolder($this->dest_path .'/application/cache', ['index.html', '.htaccess']); |
|
72 | + $this->cleanFolder($this->dest_path.'/application/cache', ['index.html', '.htaccess']); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | //-------------------------------------------------------------------- |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | public function cleanTestsFolder() |
78 | 78 | { |
79 | 79 | // Remove coverage Files |
80 | - $this->cleanFolder($this->dest_path .'/tests/_output', ['.gitignore']); |
|
80 | + $this->cleanFolder($this->dest_path.'/tests/_output', ['.gitignore']); |
|
81 | 81 | |
82 | 82 | // Remove our Acceptance tests |
83 | - $this->cleanFolder($this->dest_path .'/tests/acceptance/myth'); |
|
84 | - rmdir($this->dest_path .'/tests/acceptance/myth'); |
|
83 | + $this->cleanFolder($this->dest_path.'/tests/acceptance/myth'); |
|
84 | + rmdir($this->dest_path.'/tests/acceptance/myth'); |
|
85 | 85 | |
86 | 86 | // Remove our Unit tests |
87 | - $this->cleanFolder($this->dest_path .'/tests/unit/myth'); |
|
88 | - rmdir($this->dest_path .'/tests/unit/myth'); |
|
87 | + $this->cleanFolder($this->dest_path.'/tests/unit/myth'); |
|
88 | + rmdir($this->dest_path.'/tests/unit/myth'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | //-------------------------------------------------------------------- |
@@ -268,7 +268,7 @@ |
||
268 | 268 | define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/')); |
269 | 269 | |
270 | 270 | // Path to the myth folder |
271 | - define('MYTHPATH', rtrim( str_replace('\\', '/', $myth_folder), '/ ') .'/' ); |
|
271 | + define('MYTHPATH', rtrim(str_replace('\\', '/', $myth_folder), '/ ').'/'); |
|
272 | 272 | |
273 | 273 | // The path to the "application" folder |
274 | 274 | if (is_dir($application_folder)) |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | //-------------------------------------------------------------------- |
43 | 43 | |
44 | - public function __construct($ci=null) |
|
44 | + public function __construct($ci = null) |
|
45 | 45 | { |
46 | 46 | parent::__construct($ci); |
47 | 47 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | // so request authorization by the client. |
108 | 108 | if (empty($username) || empty($password)) |
109 | 109 | { |
110 | - $this->ci->output->set_header('WWW-Authenticate: Basic realm="'. config_item('api.realm') .'"'); |
|
110 | + $this->ci->output->set_header('WWW-Authenticate: Basic realm="'.config_item('api.realm').'"'); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | // No digest string? Then you're done. Go home. |
158 | 158 | if (empty($digest_string)) |
159 | 159 | { |
160 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
160 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); |
168 | 168 | $digest = (empty($matches[1]) || empty($matches[2])) ? array() : array_combine($matches[1], $matches[2]); |
169 | 169 | |
170 | - if (! array_key_exists('username', $digest)) |
|
170 | + if ( ! array_key_exists('username', $digest)) |
|
171 | 171 | { |
172 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
172 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Grab the user that corresponds to that "username" |
177 | 177 | // exact field determined in the api config file - api.auth_field setting. |
178 | - $user = $this->user_model->as_array()->find_by( config_item('api.auth_field'), $digest['username'] ); |
|
179 | - if (! $user) |
|
178 | + $user = $this->user_model->as_array()->find_by(config_item('api.auth_field'), $digest['username']); |
|
179 | + if ( ! $user) |
|
180 | 180 | { |
181 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
181 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | |
188 | 188 | if ($digest['qop'] == 'auth') |
189 | 189 | { |
190 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] ); |
|
190 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri']); |
|
191 | 191 | } else { |
192 | 192 | $body = file_get_contents('php://input'); |
193 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] .':'. md5($body) ); |
|
193 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri'].':'.md5($body)); |
|
194 | 194 | } |
195 | - $valid_response = md5($A1 .':'. $digest['nonce'].':'. $digest['nc'] .':'. $digest['cnonce'] .':'. $digest['qop'] .':'. $A2); |
|
195 | + $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); |
|
196 | 196 | |
197 | 197 | if ($digest['response'] != $valid_response) |
198 | 198 | { |
199 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
199 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | break; |
234 | 234 | } |
235 | 235 | |
236 | - if (! $user) |
|
236 | + if ( ! $user) |
|
237 | 237 | { |
238 | 238 | $this->user = null; |
239 | 239 | return $user; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | // If throttling time is above zero, we can't allow |
248 | 248 | // logins now. |
249 | - if ($time = (int)$this->isThrottled($user['email']) > 0) |
|
249 | + if ($time = (int) $this->isThrottled($user['email']) > 0) |
|
250 | 250 | { |
251 | 251 | $this->error = sprintf(lang('api.throttled'), $time); |
252 | 252 | return false; |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | { |
275 | 275 | $blacklist = explode(',', config_item('api.ip_blacklist')); |
276 | 276 | |
277 | - array_walk($blacklist, function (&$item, $key) { |
|
277 | + array_walk($blacklist, function(&$item, $key) { |
|
278 | 278 | $item = trim($item); |
279 | 279 | }); |
280 | 280 | |
281 | 281 | if (in_array($this->ci->input->ip_address(), $blacklist)) |
282 | 282 | { |
283 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
283 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return true; |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | |
300 | 300 | array_push($whitelist, '127.0.0.1', '0.0.0.0'); |
301 | 301 | |
302 | - array_walk($whitelist, function (&$item, $key) { |
|
302 | + array_walk($whitelist, function(&$item, $key) { |
|
303 | 303 | $item = trim($item); |
304 | 304 | }); |
305 | 305 | |
306 | - if (! in_array($this->ci->input->ip_address(), $whitelist)) |
|
306 | + if ( ! in_array($this->ci->input->ip_address(), $whitelist)) |
|
307 | 307 | { |
308 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
308 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | return true; |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @return bool|mixed|void |
364 | 364 | */ |
365 | - public function login($credentials, $remember=false) |
|
365 | + public function login($credentials, $remember = false) |
|
366 | 366 | { |
367 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
367 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | //-------------------------------------------------------------------- |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function logout() |
381 | 381 | { |
382 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
382 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | //-------------------------------------------------------------------- |
@@ -55,11 +55,11 @@ |
||
55 | 55 | $time = date('Y-m-d H:00:00'); |
56 | 56 | |
57 | 57 | $query = $this->db->select('id') |
58 | - ->where('user_id', (int)$user_id) |
|
58 | + ->where('user_id', (int) $user_id) |
|
59 | 59 | ->where('created_on >=', $time) |
60 | 60 | ->get($this->table_name); |
61 | 61 | |
62 | - return (int)$query->num_rows(); |
|
62 | + return (int) $query->num_rows(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //-------------------------------------------------------------------- |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return bool |
58 | 58 | */ |
59 | - public function restrict($uri=null, $return_only=false) |
|
59 | + public function restrict($uri = null, $return_only = false) |
|
60 | 60 | { |
61 | 61 | $this->setupAuthClasses(); |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | if (method_exists($this, 'setMessage')) |
69 | 69 | { |
70 | - $this->setMessage( lang('auth.not_logged_in') ); |
|
70 | + $this->setMessage(lang('auth.not_logged_in')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | if ($return_only) |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | if (empty($uri)) |
79 | 79 | { |
80 | - redirect( \Myth\Route::named('login') ); |
|
80 | + redirect(\Myth\Route::named('login')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | redirect($uri); |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function restrictToGroups($groups, $uri='') |
|
109 | + public function restrictToGroups($groups, $uri = '') |
|
110 | 110 | { |
111 | 111 | $this->setupAuthClasses(); |
112 | 112 | |
113 | 113 | if ($this->authenticate->isLoggedIn()) |
114 | 114 | { |
115 | - if ($this->authorize->inGroup($groups, $this->authenticate->id() ) ) |
|
115 | + if ($this->authorize->inGroup($groups, $this->authenticate->id())) |
|
116 | 116 | { |
117 | 117 | return true; |
118 | 118 | } |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | |
121 | 121 | if (method_exists($this, 'setMessage')) |
122 | 122 | { |
123 | - $this->setMessage( lang('auth.not_enough_privilege') ); |
|
123 | + $this->setMessage(lang('auth.not_enough_privilege')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | if (empty($uri)) |
127 | 127 | { |
128 | - redirect( \Myth\Route::named('login') .'?request_uri='. current_url() ); |
|
128 | + redirect(\Myth\Route::named('login').'?request_uri='.current_url()); |
|
129 | 129 | } |
130 | 130 | |
131 | - redirect($uri .'?request_uri='. current_url()); |
|
131 | + redirect($uri.'?request_uri='.current_url()); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | //-------------------------------------------------------------------- |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return bool |
149 | 149 | */ |
150 | - public function restrictWithPermissions($permissions, $uri='') |
|
150 | + public function restrictWithPermissions($permissions, $uri = '') |
|
151 | 151 | { |
152 | 152 | $this->setupAuthClasses(); |
153 | 153 | |
154 | 154 | if ($this->authenticate->isLoggedIn()) |
155 | 155 | { |
156 | - if ($this->authorize->hasPermission($permissions, $this->authenticate->id() ) ) |
|
156 | + if ($this->authorize->hasPermission($permissions, $this->authenticate->id())) |
|
157 | 157 | { |
158 | 158 | return true; |
159 | 159 | } |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | |
162 | 162 | if (method_exists($this, 'setMessage')) |
163 | 163 | { |
164 | - $this->setMessage( lang('auth.not_enough_privilege') ); |
|
164 | + $this->setMessage(lang('auth.not_enough_privilege')); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if (empty($uri)) |
168 | 168 | { |
169 | - redirect( \Myth\Route::named('login') .'?request_uri='. current_url() ); |
|
169 | + redirect(\Myth\Route::named('login').'?request_uri='.current_url()); |
|
170 | 170 | } |
171 | 171 | |
172 | - redirect($uri .'?request_uri='. current_url()); |
|
172 | + redirect($uri.'?request_uri='.current_url()); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | //-------------------------------------------------------------------- |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | $auth = config_item('auth.authenticate_lib'); |
199 | 199 | |
200 | 200 | if (empty($auth)) { |
201 | - throw new \RuntimeException( lang('auth.no_authenticate') ); |
|
201 | + throw new \RuntimeException(lang('auth.no_authenticate')); |
|
202 | 202 | } |
203 | 203 | |
204 | - $this->authenticate = new $auth( get_instance() ); |
|
204 | + $this->authenticate = new $auth(get_instance()); |
|
205 | 205 | |
206 | 206 | get_instance()->load->model('auth/user_model', 'user_model', true); |
207 | - $this->authenticate->useModel( get_instance()->user_model ); |
|
207 | + $this->authenticate->useModel(get_instance()->user_model); |
|
208 | 208 | |
209 | 209 | // Try to log us in automatically. |
210 | - if (! $this->authenticate->isLoggedIn()) |
|
210 | + if ( ! $this->authenticate->isLoggedIn()) |
|
211 | 211 | { |
212 | 212 | $this->authenticate->viaRemember(); |
213 | 213 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $auth = config_item('auth.authorize_lib'); |
219 | 219 | |
220 | 220 | if (empty($auth)) { |
221 | - throw new \RuntimeException( lang('auth.no_authenticate') ); |
|
221 | + throw new \RuntimeException(lang('auth.no_authenticate')); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $this->authorize = new $auth(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param $credentials |
52 | 52 | * @param bool $remember |
53 | 53 | */ |
54 | - public function login($credentials, $remember=false); |
|
54 | + public function login($credentials, $remember = false); |
|
55 | 55 | |
56 | 56 | //-------------------------------------------------------------------- |
57 | 57 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param bool $return_user |
66 | 66 | * @return mixed |
67 | 67 | */ |
68 | - public function validate($credentials, $return_user=false); |
|
68 | + public function validate($credentials, $return_user = false); |
|
69 | 69 | |
70 | 70 | //-------------------------------------------------------------------- |
71 | 71 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param null $message |
189 | 189 | * @return mixed |
190 | 190 | */ |
191 | - public function changeStatus($newStatus, $message=null); |
|
191 | + public function changeStatus($newStatus, $message = null); |
|
192 | 192 | |
193 | 193 | //-------------------------------------------------------------------- |
194 | 194 |