@@ -19,11 +19,17 @@ public function __construct()
1919 */
2020 public function format_bytes ($ bytes = 0 )
2121 {
22- if ($ bytes < 1024 ) return $ bytes .' B ' ;
23- elseif ($ bytes < 1048576 ) return round ($ bytes / 1024 , 2 ).' KiB ' ;
24- elseif ($ bytes < 1073741824 ) return round ($ bytes / 1048576 , 2 ).' MiB ' ;
25- elseif ($ bytes < 1099511627776 ) return round ($ bytes / 1073741824 , 2 ).' GiB ' ;
26- else return round ($ bytes / 1099511627776 , 2 ).' TiB ' ;
22+ if ($ bytes < 1024 ) {
23+ return $ bytes .' B ' ;
24+ } elseif ($ bytes < 1048576 ) {
25+ return round ($ bytes / 1024 , 2 ).' KiB ' ;
26+ } elseif ($ bytes < 1073741824 ) {
27+ return round ($ bytes / 1048576 , 2 ).' MiB ' ;
28+ } elseif ($ bytes < 1099511627776 ) {
29+ return round ($ bytes / 1073741824 , 2 ).' GiB ' ;
30+ } else {
31+ return round ($ bytes / 1099511627776 , 2 ).' TiB ' ;
32+ }
2733 }
2834
2935 /**
@@ -35,13 +41,20 @@ public function short_number($n = 0)
3541 $ n = (0 +str_replace (", " , "" , $ n ));
3642
3743 // is this a number?
38- if (!is_numeric ($ n )) return false ;
44+ if (!is_numeric ($ n )) {
45+ return false ;
46+ }
3947
4048 // now filter it;
41- if ($ n > 1000000000000 ) return round (($ n /1000000000000 ), 2 ).'t ' ;
42- elseif ($ n > 1000000000 ) return round (($ n /1000000000 ), 2 ).'b ' ;
43- elseif ($ n > 1000000 ) return round (($ n /1000000 ), 2 ).'m ' ;
44- elseif ($ n > 1000 ) return round (($ n /1000 ), 2 ).'k ' ;
49+ if ($ n > 1000000000000 ) {
50+ return round (($ n /1000000000000 ), 2 ).'t ' ;
51+ } elseif ($ n > 1000000000 ) {
52+ return round (($ n /1000000000 ), 2 ).'b ' ;
53+ } elseif ($ n > 1000000 ) {
54+ return round (($ n /1000000 ), 2 ).'m ' ;
55+ } elseif ($ n > 1000 ) {
56+ return round (($ n /1000 ), 2 ).'k ' ;
57+ }
4558
4659 return number_format ($ n );
4760 }
@@ -124,7 +137,7 @@ public function slugify($text)
124137 $ text = strtolower ($ text );
125138 // remove unwanted characters
126139 $ text = preg_replace ('~[^-\w]+~ ' , '' , $ text );
127- if (empty ($ text )){
140+ if (empty ($ text )) {
128141 return 'n-a ' ;
129142 }
130143 return $ text ;
@@ -262,7 +275,7 @@ public function http_response_code_text($domain)
262275 //set status color to warning if not 200
263276 if ($ status == 200 ) {
264277 $ labelColor = 'success ' ;
265- } elseif ($ status == 404 ) {
278+ } elseif ($ status == 404 ) {
266279 $ labelColor = 'warning ' ;
267280 } else {
268281 $ labelColor = 'danger ' ;
@@ -277,7 +290,8 @@ public function http_response_code_text($domain)
277290 /**
278291 *
279292 */
280- public function response_code_text ($ code ) {
293+ public function response_code_text ($ code )
294+ {
281295 switch ($ code ) {
282296 case 100 : $ text = 'Continue ' ; break ;
283297 case 101 : $ text = 'Switching Protocols ' ; break ;
@@ -406,7 +420,7 @@ public function get_ip_info($ip = null)
406420 // if we dont have a status query the API
407421 if (empty ($ ipinfo ['status ' ])) {
408422 $ ch = curl_init ();
409- curl_setopt ($ ch , CURLOPT_URL ,'http://ip-api.com/json/ ' .$ ip );
423+ curl_setopt ($ ch , CURLOPT_URL , 'http://ip-api.com/json/ ' .$ ip );
410424 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
411425 $ data = curl_exec ($ ch );
412426
@@ -447,8 +461,8 @@ public function get_ip_info($ip = null)
447461 * $ids = $this->app->helper->hashid()->decode($ids);
448462 */
449463 public function hashid (
450- $ salt = 'SHA256ed.f0r.4a5h.sa1tlng ' ,
451- $ length = 6 ,
464+ $ salt = 'SHA256ed.f0r.4a5h.sa1tlng ' ,
465+ $ length = 6 ,
452466 $ alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 '
453467 ) {
454468 return new \Hashids \Hashids (
@@ -466,15 +480,15 @@ public function hashid(
466480 * @param int $last_page
467481 * @return string
468482 */
469- function pagination ($ totalposts , $ p , $ last_page , $ link_class = 'ajax-link ' , $ adjacents = 3 , $ key = 'pg ' )
483+ public function pagination ($ totalposts , $ p , $ last_page , $ link_class = 'ajax-link ' , $ adjacents = 3 , $ key = 'pg ' )
470484 {
471485 $ ret = null ;
472486 $ prev = ($ p -1 );
473487 $ next = ($ p +1 );
474488 $ last_page = ($ totalposts -1 );
475489
476490 // sorting
477- $ sorting =
491+ $ sorting =
478492 (!empty ($ _GET ['c ' ]) ? '&c= ' .$ _GET ['c ' ] : '' ).
479493 (!empty ($ _GET ['o ' ]) ? '&o= ' .($ _GET ['o ' ] == 'asc ' ? 'asc ' : 'desc ' ) : '' );
480494
@@ -488,8 +502,8 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
488502 $ ret .= '<li class="disabled"><a href="javascript:void(0)">« Previous</a></li> ' ;
489503 }
490504
491- if ($ totalposts < 7 + ($ adjacents * 2 )){
492- for ($ counter = 1 ; $ counter <= $ totalposts ; $ counter ++){
505+ if ($ totalposts < 7 + ($ adjacents * 2 )) {
506+ for ($ counter = 1 ; $ counter <= $ totalposts ; $ counter ++) {
493507 if ($ counter == $ p ) {
494508 $ ret .= '<li class="active"><a href="javascript:void(0)"> ' .$ counter .'</a></li> ' ;
495509 } else {
@@ -498,7 +512,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
498512 }
499513 } elseif ($ totalposts > 5 + ($ adjacents * 2 )) {
500514 if ($ p < 1 + ($ adjacents * 2 )) {
501- for ($ counter = 1 ; $ counter < 4 + ($ adjacents * 2 ); $ counter ++){
515+ for ($ counter = 1 ; $ counter < 4 + ($ adjacents * 2 ); $ counter ++) {
502516 if ($ counter == $ p ) {
503517 $ ret .= '<li class="active"><a href="javascript:void(0)"> ' .$ counter .'</a></li> ' ;
504518 } else {
@@ -510,11 +524,11 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
510524 $ ret .= ' <li><a href="? ' .$ key .'= ' .$ totalposts .'' .$ sorting .'" class=" ' .$ link_class .'" data-keep-state="true"> ' .$ totalposts .'</a></li> ' ;
511525 }
512526 //in middle; hide some front and some back
513- elseif ($ totalposts - ($ adjacents * 2 ) > $ p && $ p > ($ adjacents * 2 )){
527+ elseif ($ totalposts - ($ adjacents * 2 ) > $ p && $ p > ($ adjacents * 2 )) {
514528 $ ret .= ' <li><a href="? ' .$ key .'=1 ' .$ sorting .'" class=" ' .$ link_class .'" data-keep-state="true">1</a></li> ' ;
515529 $ ret .= ' <li><a href="? ' .$ key .'=2 ' .$ sorting .'" class=" ' .$ link_class .'" data-keep-state="true">2</a></li> ' ;
516530 $ ret .= ' <li class="disabled"><a href="javascript:void(0)">...</a></li> ' ;
517- for ($ counter = $ p - $ adjacents ; $ counter <= $ p + $ adjacents ; $ counter ++){
531+ for ($ counter = $ p - $ adjacents ; $ counter <= $ p + $ adjacents ; $ counter ++) {
518532 if ($ counter == $ p ) {
519533 $ ret .= ' <li class="active"><a href="javascript:void(0)"> ' .$ counter .'</a></li> ' ;
520534 } else {
@@ -528,7 +542,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
528542 $ ret .= ' <li><a href="? ' .$ key .'=1 ' .$ sorting .'" class=" ' .$ link_class .'" data-keep-state="true">1</a></li> ' ;
529543 $ ret .= ' <li><a href="? ' .$ key .'=2 ' .$ sorting .'" class=" ' .$ link_class .'" data-keep-state="true">2</a></li> ' ;
530544 $ ret .= ' <li class="active"><a href="javascript:void(0)">...</a></li> ' ;
531- for ($ counter = $ totalposts - (2 + ($ adjacents * 2 )); $ counter <= $ totalposts ; $ counter ++){
545+ for ($ counter = $ totalposts - (2 + ($ adjacents * 2 )); $ counter <= $ totalposts ; $ counter ++) {
532546 if ($ counter == $ p ) {
533547 $ ret .= ' <li class="active"><a href="javascript:void(0)"> ' .$ counter .'</a></li> ' ;
534548 } else {
@@ -605,7 +619,6 @@ public function vincentyGreatCircleDistance($latitudeFrom, $longitudeFrom, $lati
605619 $ angle = atan2 (sqrt ($ a ), $ b );
606620 return $ angle * $ earthRadius ;
607621 }
608-
609622 }
610623
611- }
624+ }
0 commit comments