@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // check full path of image uploaded |
| 83 | 83 | |
| 84 | - public function testFullpath(){ |
|
| 84 | + public function testFullpath(){ |
|
| 85 | 85 | $this->bulletproof->setLocation('uploads'); |
| 86 | 86 | $this->bulletproof->setName('2012'); |
| 87 | 87 | $this->bulletproof->setMime(['jpeg']); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | // check json return value of image |
| 95 | - public function testJsonOutput(){ |
|
| 95 | + public function testJsonOutput(){ |
|
| 96 | 96 | $upload = $this->bulletproof->setName('we_belive_in_json')->upload(); |
| 97 | 97 | $this->assertSame($upload->getJson(), |
| 98 | 98 | '{"name":"we_belive_in_json","mime":"jpeg","height":345,"width":384,"size":17438,"storage":"uploads","path":"uploads\/we_belive_in_json.jpeg"}'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function testImageSizeFailWithMsg () { |
| 120 | 120 | $this->bulletproof->setSize(888, 9999); |
| 121 | 121 | $upload = $this->bulletproof->upload(); |
| 122 | - $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
|
| 122 | + $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // check invalid dimension fails with msg |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // check if the name provide in the html input is read by bulletproof |
| 31 | - public function testImageNameIsSame () { |
|
| 31 | + public function testImageNameIsSame() { |
|
| 32 | 32 | $this->bulletproof->setName('samayo'); |
| 33 | 33 | $this->assertEquals($this->bulletproof->getName(), 'samayo'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | // test image accepts certain mime types |
| 38 | - public function testMimeTypes () { |
|
| 38 | + public function testMimeTypes() { |
|
| 39 | 39 | $this->bulletproof->setMime(['jpeg']); |
| 40 | 40 | $upload = $this->bulletproof->upload(); |
| 41 | 41 | $this->assertEquals($upload->getMime(), 'jpeg'); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // check dimensions params |
| 45 | - public function testDimensions () { |
|
| 45 | + public function testDimensions() { |
|
| 46 | 46 | // give it out of range (minimum dimentions than the class requires) |
| 47 | 47 | $this->bulletproof->setDimension(1, 'b'); |
| 48 | 48 | $upload = $this->bulletproof->upload(); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // check size of the image is correct |
| 54 | - public function testSize () { |
|
| 54 | + public function testSize() { |
|
| 55 | 55 | $this->bulletproof->upload(); |
| 56 | 56 | $this->assertEquals($this->bulletproof->getSize(), 17438); // 17438 is size of the monkey.jpg |
| 57 | 57 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // check if setting image storage is correct |
| 76 | - public function testLocation () { |
|
| 76 | + public function testLocation() { |
|
| 77 | 77 | $this->bulletproof->setLocation('uploads'); |
| 78 | 78 | $this->assertEquals($this->bulletproof->getStorage(), 'uploads'); |
| 79 | 79 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // check full path of image uploaded |
| 83 | 83 | |
| 84 | - public function testFullpath(){ |
|
| 84 | + public function testFullpath() { |
|
| 85 | 85 | $this->bulletproof->setLocation('uploads'); |
| 86 | 86 | $this->bulletproof->setName('2012'); |
| 87 | 87 | $this->bulletproof->setMime(['jpeg']); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | // check json return value of image |
| 95 | - public function testJsonOutput(){ |
|
| 95 | + public function testJsonOutput() { |
|
| 96 | 96 | $upload = $this->bulletproof->setName('we_belive_in_json')->upload(); |
| 97 | 97 | $this->assertSame($upload->getJson(), |
| 98 | 98 | '{"name":"we_belive_in_json","mime":"jpeg","height":345,"width":384,"size":17438,"storage":"uploads","path":"uploads\/we_belive_in_json.jpeg"}'); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // check invalid mimetype fails |
| 103 | 103 | |
| 104 | - public function testMimeTypeFail () { |
|
| 104 | + public function testMimeTypeFail() { |
|
| 105 | 105 | $this->bulletproof->setMime(['gif']); |
| 106 | 106 | $upload = $this->bulletproof->upload(); |
| 107 | 107 | $this->assertFalse($upload); |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | // check invalid mimetype fails with msg |
| 111 | 111 | |
| 112 | - public function testMimeTypeFailWithMsg () { |
|
| 112 | + public function testMimeTypeFailWithMsg() { |
|
| 113 | 113 | $this->bulletproof->setMime(['gif']); |
| 114 | 114 | $upload = $this->bulletproof->upload(); |
| 115 | 115 | $this->assertEquals($this->bulletproof->getError(), 'Invalid File! Only (gif) image types are allowed'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // check invalid size with msg |
| 119 | - public function testImageSizeFailWithMsg () { |
|
| 119 | + public function testImageSizeFailWithMsg() { |
|
| 120 | 120 | $this->bulletproof->setSize(888, 9999); |
| 121 | 121 | $upload = $this->bulletproof->upload(); |
| 122 | 122 | $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // check invalid dimension fails with msg |
| 126 | -public function testImageDimensionFailWithMsg () { |
|
| 126 | +public function testImageDimensionFailWithMsg() { |
|
| 127 | 127 | $this->bulletproof->setDimension(42, 43); |
| 128 | 128 | $this->bulletproof->upload(); |
| 129 | 129 | $this->assertEquals($this->bulletproof->getError(), 'Image height/width should be less than 43/42 pixels'); |
@@ -4,10 +4,10 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class BulletproofTest extends \Bulletproof\Image { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * Return true at this point since we can't upload files |
|
| 9 | - * during test (or can we? I don't know!) |
|
| 10 | - */ |
|
| 7 | + /** |
|
| 8 | + * Return true at this point since we can't upload files |
|
| 9 | + * during test (or can we? I don't know!) |
|
| 10 | + */ |
|
| 11 | 11 | public function isSaved($tmp, $desination) |
| 12 | 12 | { |
| 13 | 13 | return true; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * Prevent class from making new folder |
| 18 | 18 | */ |
| 19 | 19 | public function setLocation($dir = "bulletproof", $optionalPermision = 0666){ |
| 20 | - $this->location = $dir; |
|
| 21 | - return $this; |
|
| 20 | + $this->location = $dir; |
|
| 21 | + return $this; |
|
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | /** |
| 17 | 17 | * Prevent class from making new folder |
| 18 | 18 | */ |
| 19 | - public function setLocation($dir = "bulletproof", $optionalPermision = 0666){ |
|
| 19 | + public function setLocation($dir = "bulletproof", $optionalPermision = 0666) { |
|
| 20 | 20 | $this->location = $dir; |
| 21 | 21 | return $this; |
| 22 | 22 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | // you want to allow, and if so: |
| 24 | 24 | header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); |
| 25 | 25 | header('Access-Control-Allow-Credentials: true'); |
| 26 | - header('Access-Control-Max-Age: 86400'); // cache for 1 day |
|
| 26 | + header('Access-Control-Max-Age: 86400'); // cache for 1 day |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Access-Control headers are received during OPTIONS requests |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | if (is_numeric($val)) { |
| 92 | - $int = (int)$val; |
|
| 93 | - $float = (float)$val; |
|
| 92 | + $int = (int) $val; |
|
| 93 | + $float = (float) $val; |
|
| 94 | 94 | |
| 95 | 95 | $val = ($int == $float) ? $int : $float; |
| 96 | 96 | return $val; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | function get_includes() |
| 179 | 179 | { |
| 180 | - $included = array_values(array_filter(array_map(function ($arr) { |
|
| 180 | + $included = array_values(array_filter(array_map(function($arr) { |
|
| 181 | 181 | if (is_string($arr)) { |
| 182 | 182 | if (strpos($arr, 'vendor')) { |
| 183 | 183 | return ''; |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function cors() |
| 17 | 17 | { |
| 18 | - if (!headers_sent()) return; |
|
| 18 | + if (!headers_sent()) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 19 | 21 | |
| 20 | 22 | // Allow from any origin |
| 21 | 23 | if (isset($_SERVER['HTTP_ORIGIN'])) { |
@@ -151,7 +153,9 @@ discard block |
||
| 151 | 153 | if (!file_exists(dirname($file))) { |
| 152 | 154 | mkdir(dirname($file)); |
| 153 | 155 | } |
| 154 | - if (file_exists($file)) delete($file); |
|
| 156 | + if (file_exists($file)) { |
|
| 157 | + delete($file); |
|
| 158 | + } |
|
| 155 | 159 | file_put_contents($file, $content, ($append ? FILE_APPEND : 0)); |
| 156 | 160 | } |
| 157 | 161 | |
@@ -19,9 +19,13 @@ |
||
| 19 | 19 | $thePost = $_POST[$name]; |
| 20 | 20 | if ($flag != POST_DEFAULT_FLAG) { |
| 21 | 21 | if ($flag == POST_NOT_NULL) { |
| 22 | - if ($thePost != null) return $thePost; |
|
| 22 | + if ($thePost != null) { |
|
| 23 | + return $thePost; |
|
| 24 | + } |
|
| 23 | 25 | } else if ($flag == POST_NOT_EMPTY) { |
| 24 | - if (!empty($thePost)) return $thePost; |
|
| 26 | + if (!empty($thePost)) { |
|
| 27 | + return $thePost; |
|
| 28 | + } |
|
| 25 | 29 | } |
| 26 | 30 | } else { |
| 27 | 31 | return $thePost; |
@@ -9,7 +9,11 @@ |
||
| 9 | 9 | function current_timestamp($date = null) |
| 10 | 10 | { |
| 11 | 11 | $timestamp = $date; |
| 12 | - if (is_string($date)) $timestamp = strtotime($date); |
|
| 13 | - if (is_null($date)) $timestamp = time(); |
|
| 12 | + if (is_string($date)) { |
|
| 13 | + $timestamp = strtotime($date); |
|
| 14 | + } |
|
| 15 | + if (is_null($date)) { |
|
| 16 | + $timestamp = time(); |
|
| 17 | + } |
|
| 14 | 18 | return date("Y-m-d H:i:s", $timestamp); |
| 15 | 19 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | $username = $_REQUEST['user']; |
| 5 | 5 | $password = $_REQUEST['pass']; |
| 6 | 6 | if (isset($_REQUEST['g-recaptcha-response'])) { |
| 7 | - GoogleExt\recaptcha::verifyCaptcha(function () use ($username, $password) { |
|
| 7 | + GoogleExt\recaptcha::verifyCaptcha(function() use ($username, $password) { |
|
| 8 | 8 | dologin($username, $password); |
| 9 | 9 | }); |
| 10 | 10 | } else { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | if (isset($_REQUEST['check'])) { |
| 16 | - user()->check_login(function ($session) { |
|
| 16 | + user()->check_login(function($session) { |
|
| 17 | 17 | e($session); |
| 18 | 18 | }); |
| 19 | 19 | } |
@@ -49,7 +49,9 @@ discard block |
||
| 49 | 49 | public static function get_profile_picture() |
| 50 | 50 | { |
| 51 | 51 | if (!empty(self::get_profile())) { |
| 52 | - if (isset(self::get_profile()['picture'])) return self::get_profile()['picture']; |
|
| 52 | + if (isset(self::get_profile()['picture'])) { |
|
| 53 | + return self::get_profile()['picture']; |
|
| 54 | + } |
|
| 53 | 55 | } |
| 54 | 56 | return 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No_image_available.svg/480px-No_image_available.svg.png'; |
| 55 | 57 | } |
@@ -57,7 +59,9 @@ discard block |
||
| 57 | 59 | public static function get_profile_name() |
| 58 | 60 | { |
| 59 | 61 | if (!empty(self::get_profile())) { |
| 60 | - if (isset(self::get_profile()['name'])) return self::get_profile()['name']; |
|
| 62 | + if (isset(self::get_profile()['name'])) { |
|
| 63 | + return self::get_profile()['name']; |
|
| 64 | + } |
|
| 61 | 65 | } |
| 62 | 66 | return 'Login Required'; |
| 63 | 67 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | function get_blog_byurl(string $url) |
| 25 | 25 | { |
| 26 | - $blog = $this->service->blogs->getByUrl($url); |
|
| 26 | + $blog = $this->service->blogs->getByUrl($url); |
|
| 27 | 27 | $this->blogid = $blog->getId(); |
| 28 | 28 | return $blog; |
| 29 | 29 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | <div class="container"> |
| 27 | 27 | <form action="" method="post"> |
| 28 | - <div class="form-group"><textarea oninput='this.style.height = "";this.style.height = this.scrollHeight + "px"' id="body" name="desc" class="form-control"><?php echo isset($singlepost->content) ? $singlepost->content : ''; ?></textarea></div> |
|
| 28 | + <div class="form-group"><textarea oninput='this.style.height = "";this.style.height = this.scrollHeight + "px"' id="body" name="desc" class="form-control"><?php echo isset($singlepost->content) ? $singlepost->content : ''; ?></textarea></div> |
|
| 29 | 29 | </form> |
| 30 | 30 | </div> |
| 31 | 31 | \ No newline at end of file |