From 78cefd0fe70ff8d665f180207a62c9b0b1880f7f Mon Sep 17 00:00:00 2001 From: RN Kushwaha Date: Thu, 4 Jan 2018 23:25:21 +0530 Subject: [PATCH] Added Namespace Added Namespace to files --- src/Core/Cruzer.php | 643 ++++++++++++++++++++++++++++++++++++ src/Core/Functions.php | 729 ----------------------------------------- 2 files changed, 643 insertions(+), 729 deletions(-) create mode 100644 src/Core/Cruzer.php delete mode 100755 src/Core/Functions.php diff --git a/src/Core/Cruzer.php b/src/Core/Cruzer.php new file mode 100644 index 0000000..d9ca46a --- /dev/null +++ b/src/Core/Cruzer.php @@ -0,0 +1,643 @@ + + * @since v 1.0.0 + */ + + public static function humanTiming ($time, $reseverse = false ) { + if( $reseverse === true ){ + $time = strtotime($time) - time(); + } else{ + $time = time() - strtotime($time); + } + + $time = ($time<1)? 1 : $time; + $tokens = array ( + 31536000 => 'year', + 2592000 => 'month', + 604800 => 'week', + 86400 => 'day', + 3600 => 'hour', + 60 => 'minute', + 1 => 'second' + ); + + foreach ($tokens as $unit => $text) { + if ($time < $unit) continue; + $numberOfUnits = floor($time / $unit); + return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':''); + } + } + } + + public static function _status( $status, $formated = true, $statusFor='default' ){ + if( $formated === false && $statusFor == 'default' ){ + switch ($status) { + case '1': $st = 'Active'; break; + case '0': $st = 'Inactive'; break; + case '2': $st = 'Blocked'; break; + default: $st = 'Pending'; break; + } + } elseif( $formated === false && $statusFor == 'shipments' ){ + switch ($status) { + case '1': $st = 'Approved'; break; + case '2': $st = 'Available'; break; + case '3': $st = 'Cancelled'; break; + case '4': $st = 'Customs'; break; + case '5': $st = 'Delivered'; break; + case '6': $st = 'Delivered-Pending Payment'; break; + case '7': $st = 'Dispenser'; break; + case '8': $st = 'Distribution'; break; + case '9': $st = 'Earring Collection'; break; + case '10': $st = 'Effective'; break; + case '11': $st = 'In Transit'; break; + case '12': $st = 'In warehouse'; break; + case '13': $st = 'Invoiced'; break; + case '14': $st = 'On route'; break; + case '15': $st = 'Packaged'; break; + case '16': $st = 'Received Office'; break; + default: $st = 'Pending'; break; + } + } elseif( $formated === true && $statusFor == 'shipments' ){ + switch ($status) { + case '1': $st = 'Approved'; break; + case '2': $st = 'Available'; break; + case '3': $st = 'Cancelled'; break; + case '4': $st = 'Customs'; break; + case '5': $st = 'Delivered'; break; + case '6': $st = 'Delivered-Pending Payment'; break; + case '7': $st = 'Dispenser'; break; + case '8': $st = 'Distribution'; break; + case '9': $st = 'Earring Collection'; break; + case '10': $st = 'Effective'; break; + case '11': $st = 'In Transit'; break; + case '12': $st = 'In warehouse'; break; + case '13': $st = 'Invoiced'; break; + case '14': $st = 'On route'; break; + case '15': $st = 'Packaged'; break; + case '16': $st = 'Received Office'; break; + default: $st = 'Pending'; break; + } + } elseif( $formated === false && $statusFor == 'notifications' ){ + switch ($status) { + case '0': $st = 'Unread'; break; + case '1': $st = 'Viewed'; break; + default: $st = 'Pending'; break; + } + } elseif( $formated === true && $statusFor == 'notifications' ){ + switch ($status) { + case '0': $st = 'Unread'; break; + case '1': $st = 'Viewed'; break; + default: $st = 'Pending'; break; + } + } else{ + switch ($status) { + case '1': $st = 'Active'; break; + case '0': $st = 'Inactive'; break; + case '2': $st = 'Blocked'; break; + default: $st = 'Pending'; break; + } + } + + return $st; + } + + public static function _formatFlightTime( $time, $full=true ){ + $newTime1 = explode('T',$time); + if( isset($newTime1[1]) ){ + $newTime2 = str_replace('+','-', $newTime1[1]); + $newTime = explode('-', $newTime2); + if( is_array($newTime) && count($newTime)){ + if( $full === true ){ + $format['time'] = $newTime[0]; + if(isset($newTime) && count($newTime)>1 ) $format['deduction'] = $newTime[1]; + $format['date'] = $newTime1[0]; + return $format; + } else{ + return $newTime[0]; + } + } + } + } + + public static function __status( $status, $formated = true, $statusFor='default' ){ + echo _status($status, $formated, $statusFor); + } + + + public static function _matchUrl( $urlToMatch='', $requestUrl ){ + if( preg_match('/^'.str_replace('/','\/',$urlToMatch).'/', $requestUrl)){ + return true; + } + + return false; + } + + public static function _pr( $arr=array(), $exit=false){ + echo "
";
+          print_r($arr);
+          echo "
";
+          if($exit){
+              exit();
+          }
+      }
+
+      public static function __br( $repeat = 1 ){
+          if($repeat>0){
+              for ($i=0; $i < $repeat; $i++) {
+                  echo "
"; + } + } + } + + public static function _( $string = null, $print = false ){ + if(func_num_args()==2){ + if( $print ){ + echo htmlspecialchars($string); + } else{ + return htmlspecialchars($string); + } + } else{ + return htmlspecialchars($string); + } + } + + public static function __( $string = null, $escape = true){ + if($escape === true){ + echo htmlspecialchars($string); + } else{ + echo $string; + } + } + + public static function _form( $action='', $options = array(), $csrf = true ){ + $form = '
$value) { + $form.= $key.'="'.$value.'"'; + } + } + $form.= '>'; + + if($csrf === true){ + $form.= _CSRF(true); + } + return $form; + } + + + public static function __form( $action='', $options = array(), $csrf = true ){ + echo _form( $action, $options, $csrf ); + } + + + public static function _CSRF( $full_field = false ){ + $token = session_id(); + $token = sha1($token.SALT); + + if( $full_field === true ){ + return ''; + } + return $token; + } + + public static function _checkCSRF( $csrf='', $terminate = true, $terminate_msg = 'Invalid Token' ){ + if( $csrf == '' ){ + $csrf = isset($_POST['_csrf']) ? $_POST['_csrf'] : (isset($_GET['_csrf']) ? $_GET['_csrf'] : '' ); + } + + if( $csrf !== _CSRF() && $terminate === true ){ + __($terminate_msg);exit; + } + + return $csrf === _CSRF(); + } + + public static function _a( $title, $link, $options = array(), $escape = false ){ + if( $escape === false ){ + $anchor = ' $value) { + $anchor.= $key.'="'.$value.'"'; + } + } + $anchor.= '>'.$title.''; + } else{ + $anchor = ' $value) { + $anchor.= _($key).'="'._($value).'"'; + } + } + $anchor.= '>'._($title).''; + } + + return $anchor; + } + + public static function __a( $title, $link, $options = array(), $escape = false ){ + echo _a($title, $link, $options , $escape ); + } + + public static function _css( $links, $defer = false, $version = false ){ + $css = ''; + if( is_array($links) && count($links) ){ + foreach ($links as $key => $value) { + if($version) $value = $value.'?v='.$version; + $css.= ' $value) { + if($version) $value = $value.'?v='.$version; + $js.= ''."\r\n"; - } - }elseif( $links!=''){ - if($version) $links = $links.'?v='.$version; - $js.= '