Changeset 55 for trunk/Global.php
- Timestamp:
- Apr 7, 2020, 12:55:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Global.php
r54 r55 3 3 function HumanDate($Time) 4 4 { 5 return (date('j.n.Y', $Time));5 return date('j.n.Y', $Time); 6 6 } 7 7 8 8 function HumanTime($Time) 9 9 { 10 return (date('H:i:s', $Time));10 return date('H:i:s', $Time); 11 11 } 12 12 … … 16 16 $Time = HumanTime($Time); 17 17 if ($Time != '00:00:00') $Output .= ' '.$Time; 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 28 28 function ProcessURL() 29 29 { 30 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))30 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 31 31 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 32 32 else $PathString = ''; 33 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);33 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 34 34 $PathItems = explode('/', $PathString); 35 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))35 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false)) 36 36 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 37 37 else $_SERVER['QUERY_STRING'] = ''; 38 38 parse_str($_SERVER['QUERY_STRING'], $_GET); 39 return ($PathItems);39 return $PathItems; 40 40 } 41 41 … … 44 44 $Result = array(); 45 45 $Parts = explode('&', $QueryString); 46 foreach ($Parts as $Part)47 { 48 if ($Part != '')49 { 50 if (!strpos($Part, '=')) $Part .= '=';46 foreach ($Parts as $Part) 47 { 48 if ($Part != '') 49 { 50 if (!strpos($Part, '=')) $Part .= '='; 51 51 $Item = explode('=', $Part); 52 52 $Result[$Item[0]] = $Item[1]; 53 53 } 54 54 } 55 return ($Result);55 return $Result; 56 56 } 57 57 … … 59 59 { 60 60 $Parts = array(); 61 foreach ($QueryStringArray as $Index => $Item)61 foreach ($QueryStringArray as $Index => $Item) 62 62 { 63 63 if ($Index != 'lvm') $Parts[] = $Index.'='.$Item; 64 64 } 65 return (implode('&', $Parts));65 return implode('&', $Parts); 66 66 } 67 67 … … 77 77 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 78 78 79 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;80 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;81 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;82 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;79 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 80 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 81 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 82 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 83 83 $CurrentPage = $_SESSION['Page']; 84 84 … … 87 87 88 88 $Result = ''; 89 if ($PageCount > 1)90 { 91 if ($CurrentPage > 0)89 if ($PageCount > 1) 90 { 91 if ($CurrentPage > 0) 92 92 { 93 93 $QueryItems['page'] = 0; … … 98 98 $PagesMax = $PageCount - 1; 99 99 $PagesMin = 0; 100 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;101 if ($PagesMin < ($CurrentPage - $Around))100 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 101 if ($PagesMin < ($CurrentPage - $Around)) 102 102 { 103 103 $Result.= ' ... '; 104 104 $PagesMin = $CurrentPage - $Around; 105 105 } 106 for ($i = $PagesMin; $i <= $PagesMax; $i++)107 { 108 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';106 for ($i = $PagesMin; $i <= $PagesMax; $i++) 107 { 108 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 109 109 else { 110 110 $QueryItems['page'] = $i; … … 112 112 } 113 113 } 114 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';115 if ($CurrentPage < ($PageCount - 1))114 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 115 if ($CurrentPage < ($PageCount - 1)) 116 116 { 117 117 $QueryItems['page'] = ($CurrentPage + 1); … … 122 122 } 123 123 $Result = '<div style="text-align: center">'.$Result.'</div>'; 124 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,124 return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 125 125 'Page' => $CurrentPage, 126 126 'Output' => $Result, 127 ) );127 ); 128 128 } 129 129 … … 135 135 global $OrderDirSQL, $OrderArrowImage, $Config; 136 136 137 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];138 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))137 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 138 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 139 139 $_SESSION['OrderDir'] = $_GET['OrderDir']; 140 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;141 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;140 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 141 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 142 142 143 143 // Check OrderCol 144 144 $Found = false; 145 foreach ($Columns as $Column)146 { 147 if ($Column['Name'] == $_SESSION['OrderCol'])145 foreach ($Columns as $Column) 146 { 147 if ($Column['Name'] == $_SESSION['OrderCol']) 148 148 { 149 149 $Found = true; … … 151 151 } 152 152 } 153 if ($Found == false)153 if ($Found == false) 154 154 { 155 155 $_SESSION['OrderCol'] = $DefaultColumn; … … 157 157 } 158 158 // Check OrderDir 159 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;159 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 160 160 161 161 $Result = ''; 162 162 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 163 foreach ($Columns as $Index => $Column)163 foreach ($Columns as $Index => $Column) 164 164 { 165 165 $QueryItems['OrderCol'] = $Column['Name']; 166 166 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 167 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.167 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 168 168 Link2('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>'; 169 169 else $ArrowImage = ''; 170 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';170 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 171 171 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 172 172 } 173 return (array(173 return array( 174 174 'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']], 175 175 'Output' => '<tr>'.$Result.'</tr>', 176 176 'Column' => $_SESSION['OrderCol'], 177 177 'Direction' => $_SESSION['OrderDir'], 178 ) );178 ); 179 179 } 180 180 … … 182 182 { 183 183 list($Usec, $Sec) = explode(' ', microtime()); 184 return ( (float)$Usec + (float)$Sec);184 return (float)$Usec + (float)$Sec; 185 185 } 186 186 … … 322 322 $Output .= '<div class="filter-num-box">'. 323 323 '<div class="label-box">'.$Item['Title'].'</div>'. 324 '<input value="'.$_SESSION[$Item['Name']].'" onkeyup="if (event.keyCode!=9) upf(\''.$Item['Name'].'\',$(this).val(),(event.keyCode==13?0:1)); '.324 '<input value="'.$_SESSION[$Item['Name']].'" onkeyup="if (event.keyCode!=9) upf(\''.$Item['Name'].'\',$(this).val(),(event.keyCode==13?0:1)); '. 325 325 '" id="'.$Item['Name'].'" autocomplete="off" type="text"/>'. 326 326 '</div> '; … … 350 350 $Output .= '<div class="filter-num-box">'. 351 351 '<div class="label-box">'.$Item['Title'].'</div>'. 352 '<input value="'.$_SESSION[$Item['Name'].'od'].'" onkeyup="if (event.keyCode!=9) upf(\''.$Item['Name'].'od\',$(this).val(),(event.keyCode==13?0:1)); '.352 '<input value="'.$_SESSION[$Item['Name'].'od'].'" onkeyup="if (event.keyCode!=9) upf(\''.$Item['Name'].'od\',$(this).val(),(event.keyCode==13?0:1)); '. 353 353 '" id="'.$Item['Name'].'od" autocomplete="off" type="text"/>'. 354 354 '<div class="label-box">-</div>'. 355 355 '<input value="'.$_SESSION[$Item['Name'].'do'].'" onkeyup="'. 356 'if (event.keyCode!=9) upf(\''.$Item['Name'].'do\',$(this).val(),(event.keyCode==13?0:1));" '.356 'if (event.keyCode!=9) upf(\''.$Item['Name'].'do\',$(this).val(),(event.keyCode==13?0:1));" '. 357 357 'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>'. 358 358 '<div class="label-box">'.$Item['Units'].'</div>'. … … 368 368 { 369 369 $Where = ''; 370 foreach ($this->Items as $Item)370 foreach ($this->Items as $Item) 371 371 { 372 372 if ($Item['DbName'] != '')
Note:
See TracChangeset
for help on using the changeset viewer.