Changeset 874 for trunk/Common/Global.php
- Timestamp:
- Apr 6, 2020, 11:56:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r873 r874 30 30 $UnitIndex++; 31 31 } 32 return ($Value.' '.$UnitNames[$UnitIndex]);32 return $Value.' '.$UnitNames[$UnitIndex]; 33 33 } 34 34 … … 36 36 { 37 37 list($Usec, $Sec) = explode(' ', microtime()); 38 return ( (float)$Usec + (float)$Sec);38 return (float)$Usec + (float)$Sec; 39 39 } 40 40 … … 48 48 function HumanDate($Time) 49 49 { 50 if ($Time != '') { 50 if ($Time != '') 51 { 51 52 $Date = explode(' ', $Time); 52 53 $Parts = explode('-', $Date[0]); 53 if ($Date != '0000-00-00') return ( ($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);54 else return (' ');55 } else return (' ');54 if ($Date != '0000-00-00') return ($Parts[2] * 1).'.'.($Parts[1] * 1).'.'.$Parts[0]; 55 else return ' '; 56 } else return ' '; 56 57 } 57 58 … … 62 63 $Around = 10; 63 64 $Result = ''; 64 if ($Count >1)65 { 66 if ($Page >0)65 if ($Count > 1) 66 { 67 if ($Page > 0) 67 68 { 68 69 $Result.= '<a href="'.$URL.'0"><<</a> '; 69 $Result.= '<a href="'.$URL.($Page -1).'"><</a> ';70 } 71 $PagesMax = $Count -1;70 $Result.= '<a href="'.$URL.($Page - 1).'"><</a> '; 71 } 72 $PagesMax = $Count - 1; 72 73 $PagesMin = 0; 73 if ($PagesMax >($Page+$Around)) $PagesMax = $Page+$Around;74 if ($PagesMin <($Page-$Around))74 if ($PagesMax > ($Page + $Around)) $PagesMax = $Page + $Around; 75 if ($PagesMin < ($Page - $Around)) 75 76 { 76 77 $Result.= ' .. '; 77 $PagesMin = $Page -$Around;78 } 79 for ($i =$PagesMin;$i<=$PagesMax;$i++)80 { 81 if ($i ==$Page) $Result.= '<strong>';82 $Result .= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';83 if ($i ==$Page) $Result.= '</strong>';84 } 85 if ($PagesMax <($Count-1)) $Result .= ' .. ';86 if ($Page <($Count-1))87 { 88 $Result .= '<a href="'.$URL.($Page+1).'">></a> ';89 $Result .= '<a href="'.$URL.($Count-1).'">>></a>';90 } 91 } 92 return ($Result);78 $PagesMin = $Page - $Around; 79 } 80 for ($i = $PagesMin; $i <= $PagesMax; $i++) 81 { 82 if ($i == $Page) $Result.= '<strong>'; 83 $Result .= '<a href="'.$URL.$i.'">'.($i + 1).'</a> '; 84 if ($i == $Page) $Result.= '</strong>'; 85 } 86 if ($PagesMax < ($Count - 1)) $Result .= ' .. '; 87 if ($Page < ($Count - 1)) 88 { 89 $Result .= '<a href="'.$URL.($Page + 1).'">></a> '; 90 $Result .= '<a href="'.$URL.($Count - 1).'">>></a>'; 91 } 92 } 93 return $Result; 93 94 } 94 95 95 96 function ExtractTime($Time) 96 97 { 97 return (array(98 return array( 98 99 'Year' => date('Y', $Time), 99 100 'Month' => date('n', $Time), … … 102 103 'Minute' => date('i', $Time), 103 104 'Second' => date('s', $Time) 104 ) );105 ); 105 106 } 106 107 … … 118 119 } 119 120 } 120 return ($Result);121 return $Result; 121 122 } 122 123 … … 128 129 $Parts[] = $Index.'='.$Item; 129 130 } 130 return (implode('&', $Parts));131 return implode('&', $Parts); 131 132 } 132 133 … … 199 200 200 201 $Result = '<div style="text-align: center">'.$Result.'</div>'; 201 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,202 return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 202 203 'Page' => $CurrentPage, 203 204 'Output' => $Result, 204 ) );205 ); 205 206 } 206 207 … … 253 254 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 254 255 } 255 return (array(256 return array( 256 257 'SQL' => ' ORDER BY `'.$_SESSION[$ObjectName.'OrderCol'].'` '.$OrderDirSQL[$_SESSION[$ObjectName.'OrderDir']], 257 258 'Output' => '<tr>'.$Result.'</tr>', 258 259 'Column' => $_SESSION[$ObjectName.'OrderCol'], 259 260 'Direction' => $_SESSION[$ObjectName.'OrderDir'], 260 ) );261 ); 261 262 } 262 263 … … 265 266 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 266 267 else $IP = '0.0.0.0'; 267 return ($IP);268 return $IP; 268 269 } 269 270 … … 282 283 } 283 284 } 284 return ($Result);285 return $Result; 285 286 } 286 287 … … 295 296 { 296 297 $DbRow = $DbResult->fetch_assoc(); 297 return ($DbRow['Id']);298 } else return ('');298 return $DbRow['Id']; 299 } else return ''; 299 300 } 300 301 … … 302 303 { 303 304 $Result = shell_exec('which '.$Command); 304 return (!empty($Result));305 return !empty($Result); 305 306 } 306 307 307 308 function RemoveDiacritic($Text) 308 309 { 309 return (str_replace(310 return str_replace( 310 311 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 311 312 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), 312 313 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 313 314 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 314 $Text) );315 $Text); 315 316 } 316 317 317 318 function RouterOSIdent($Name) 318 319 { 319 return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',320 return strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-', 320 321 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 321 322 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', … … 324 325 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 325 326 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', 326 )));327 )); 327 328 } 328 329 329 330 function NotBlank($Text) 330 331 { 331 if ($Text == '') return (' ');332 else return ($Text);332 if ($Text == '') return ' '; 333 else return $Text; 333 334 } 334 335 … … 361 362 else $_SERVER['QUERY_STRING'] = ''; 362 363 parse_str($_SERVER['QUERY_STRING'], $_GET); 363 return ($PathItems);364 return $PathItems; 364 365 } 365 366
Note:
See TracChangeset
for help on using the changeset viewer.