diff --git a/bin/prepare.php b/bin/prepare.php index b5c9f429c..ae86c81c5 100644 --- a/bin/prepare.php +++ b/bin/prepare.php @@ -22,7 +22,7 @@ echo sprintf("Connecting to database %s@%s/%s", $user, $host, $dbname) . PHP_EOL $iter = 30; $connected = false; -while ($connected == false && $iter > 0) { +while (!$connected && $iter > 0) { try { $dbh = new PDO($type . ':host=' . $host, $user, $password, array( diff --git a/src/bb-library/Api/Handler.php b/src/bb-library/Api/Handler.php index b7d7fe764..3215d9018 100644 --- a/src/bb-library/Api/Handler.php +++ b/src/bb-library/Api/Handler.php @@ -79,7 +79,9 @@ final class Api_Handler implements InjectionAwareInterface if($this->_acl_exception) { throw new \Box_Exception('You do not have access to :mod module', array(':mod'=>$mod), 725); } else { - if(BB_DEBUG) error_log('You do not have access to '.$mod. ' module'); + if(BB_DEBUG) { + error_log('You do not have access to '.$mod. ' module'); + } return null; } } @@ -110,7 +112,9 @@ final class Api_Handler implements InjectionAwareInterface } } $res = $api->{$method_name}($arguments); - if($this->_enable_cache) $this->_cache[$cache_key] = $res; + if($this->_enable_cache){ + $this->_cache[$cache_key] = $res; + } return $res; } } \ No newline at end of file diff --git a/src/bb-library/Box/AppClient.php b/src/bb-library/Box/AppClient.php index 44b3e9eb7..8a66c64a9 100644 --- a/src/bb-library/Box/AppClient.php +++ b/src/bb-library/Box/AppClient.php @@ -55,7 +55,9 @@ class Box_AppClient extends Box_App try { return $this->render($tpl, array('post'=>$_POST), $ext); } catch(Exception $e) { - if(BB_DEBUG) error_log($e); + if(BB_DEBUG){ + error_log($e); + } } // throw new \Box_Exception('Page :url not found', array(':url'=>$page), 404); $e = new \Box_Exception('Page :url not found', array(':url'=>$this->url), 404); diff --git a/src/bb-library/Box/Curl.php b/src/bb-library/Box/Curl.php index b202c0323..68f0ec6d9 100644 --- a/src/bb-library/Box/Curl.php +++ b/src/bb-library/Box/Curl.php @@ -74,8 +74,9 @@ class Box_Curl { public function useAuth($use) { $this->authentication = 0; - if ($use == true) + if ($use){ $this->authentication = 1; + } } public function setName($name) { diff --git a/src/bb-library/Box/Database.php b/src/bb-library/Box/Database.php index 4a48403b9..cbe93a5ff 100644 --- a/src/bb-library/Box/Database.php +++ b/src/bb-library/Box/Database.php @@ -38,7 +38,9 @@ class Box_Database implements InjectionAwareInterface { $type = $this->_getTypeFromModelName($modelName); $bean = $this->orm->dispense($type); - if($type == $modelName) return $bean; + if($type == $modelName){ + return $bean; + } return $bean->box(); } @@ -76,7 +78,9 @@ class Box_Database implements InjectionAwareInterface { $type = $this->_getTypeFromModelName($modelName); $bean = $this->orm->findOne($type, $sql, $values); - if($type == $modelName) return $bean; + if($type == $modelName) { + return $bean; + } if($bean && $bean->id) { return $bean->box(); } @@ -87,7 +91,9 @@ class Box_Database implements InjectionAwareInterface { $type = $this->_getTypeFromModelName($modelName); $beans = $this->orm->find($type, $sql, $values); - if($type == $modelName) return $beans; + if($type == $modelName){ + return $beans; + } foreach ($beans as &$bean) { $bean = $bean->box(); } @@ -110,7 +116,9 @@ class Box_Database implements InjectionAwareInterface $type = $this->_getTypeFromModelName($modelName); $bean = $this->orm->load($type, $id); - if ($type == $modelName) return $bean; + if ($type == $modelName){ + return $bean; + } if ($bean && $bean->id) { return $bean->box(); } diff --git a/src/bb-library/Box/Ftp.php b/src/bb-library/Box/Ftp.php index e5a2b0df0..7200abb6b 100644 --- a/src/bb-library/Box/Ftp.php +++ b/src/bb-library/Box/Ftp.php @@ -35,41 +35,48 @@ class Box_Ftp } // Set defaults: - if ( empty($opt['port']) ) + if ( empty($opt['port']) ) { $this->options['port'] = 21; - else + } else { $this->options['port'] = $opt['port']; + } - if ( empty($opt['hostname']) ) + if ( empty($opt['hostname']) ) { throw new \Box_Exception('FTP hostname is required'); - else + } else { $this->options['hostname'] = $opt['hostname']; + } - if ( isset($opt['root']) && ! empty($opt['root']) ) + if ( isset($opt['root']) && ! empty($opt['root']) ) { $this->bb_root = $opt['root']; + } // Check if the options provided are OK. - if ( empty($opt['username']) ) + if ( empty($opt['username']) ) { throw new \Box_Exception('FTP username is required'); - else + } else { $this->options['username'] = $opt['username']; + } - if ( empty($opt['password']) ) + if ( empty($opt['password']) ) { throw new \Box_Exception('FTP password is required'); - else + } else { $this->options['password'] = $opt['password']; + } $this->options['ssl'] = false; - if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) + if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) { $this->options['ssl'] = true; + } } public function connect() { - if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) + if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->timeout); - else + } else { $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->timeout); + } if ( ! $this->link ) { throw new \Box_Exception('Failed to connect to FTP Server :host : :port',array(':host'=>$this->options['hostname'], ':port'=>$this->options['port'])); @@ -97,21 +104,25 @@ class Box_Ftp public function get_contents($file, $type = '', $resumepos = 0 ) { - if( empty($type) ) + if( empty($type) ) { $type = FTP_BINARY; + } $temp = tmpfile(); - if ( ! $temp ) + if ( ! $temp ) { return false; + } - if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) ) + if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) ) { return false; + } fseek($temp, 0); //Skip back to the start of the file being written to $contents = ''; - while ( ! feof($temp) ) + while ( ! feof($temp) ) { $contents .= fread($temp, 8192); + } fclose($temp); return $contents; @@ -127,12 +138,14 @@ class Box_Ftp */ public function put_contents($file, $contents, $type = '' ) { - if( empty($type) ) + if( empty($type) ) { $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; + } $temp = tmpfile(); - if ( ! $temp ) + if ( ! $temp ) { return false; + } fwrite($temp, $contents); fseek($temp, 0); //Skip back to the start of the file being written to @@ -198,15 +211,19 @@ class Box_Ftp public function chmod($file, $mode = false, $recursive = false) { - if( ! $mode ) + if( ! $mode ) { $mode = $this->permission; - if( ! $mode ) return false; - if ( ! $this->exists($file) && ! $this->is_dir($file) ) + } + + if ( ! $this->exists($file) && ! $this->is_dir($file) ) { return false; + } + if ( ! $recursive || ! $this->is_dir($file) ) { - if ( ! function_exists('ftp_chmod') ) + if ( ! function_exists('ftp_chmod') ) { return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + } return @ftp_chmod($this->link, $mode, $file); } //Is a directory, and we want recursive @@ -254,8 +271,9 @@ class Box_Ftp */ public function copyDir($source, $destination, $overwrite = false ) { - if( ! $overwrite && !$this->is_dir($destination) ) + if( ! $overwrite && !$this->is_dir($destination) ) { return false; + } if( $overwrite && !$this->is_dir($destination) ) { if(!$this->mkdir($destination)) { @@ -270,7 +288,9 @@ class Box_Ftp $res = false; $this->chdir($source); $dir_contents = $this->dirlist($source, false, true); - if (empty($dir_contents)) { return true; } + if (empty($dir_contents)) { + return true; + } foreach($dir_contents as $name=>$params) { if ($params['isdir']) { @@ -289,11 +309,13 @@ class Box_Ftp */ public function copy($source, $destination, $overwrite = false ) { - if( ! $overwrite && $this->exists($destination) ) + if( ! $overwrite && $this->exists($destination) ) { return false; + } $content = $this->get_contents($source); - if( false === $content) + if( false === $content) { return false; + } return $this->put_contents($destination, $content); } @@ -304,17 +326,22 @@ class Box_Ftp public function delete($file, $recursive = false ) { - if ( empty($file) ) + if ( empty($file) ) { return false; - if ( $this->is_file($file) ) + } + if ( $this->is_file($file) ) { return @ftp_delete($this->link, $file); - if ( !$recursive ) + } + if ( !$recursive ) { return @ftp_rmdir($this->link, $file); + } $filelist = $this->dirlist( $this->trailingslashit($file) ); - if ( !empty($filelist) ) - foreach ( $filelist as $delete_file ) + if ( !empty($filelist) ) { + foreach ( $filelist as $delete_file ) { $this->delete( $this->trailingslashit($file) . $delete_file['name'], $recursive); + } + } return @ftp_rmdir($this->link, $file); } @@ -376,14 +403,18 @@ class Box_Ftp */ public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { - if( !ftp_mkdir($this->link, $path) ) + if( !ftp_mkdir($this->link, $path) ) { return false; - if( $chmod ) + } + if( $chmod ) { $this->chmod($path, $chmod); - if( $chown ) + } + if( $chown ) { $this->chown($path, $chown); - if( $chgrp ) + } + if( $chgrp ) { $this->chgrp($path, $chgrp); + } return true; } @@ -397,8 +428,9 @@ class Box_Ftp static $is_windows; $b = array(); - if ( is_null($is_windows) ) + if ( is_null($is_windows) ) { $is_windows = strpos( strtolower(ftp_systype($this->link)), 'win') !== false; + } if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|