Changeset 655 for trunk/Common/Global.php
- Timestamp:
- May 11, 2014, 4:28:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r636 r655 5 5 /* @var $Database Database */ 6 6 $Database = NULL; 7 7 8 8 include_once(dirname(__FILE__).'/VarDumper.php'); 9 9 include_once(dirname(__FILE__).'/Base.php'); … … 17 17 include_once(dirname(__FILE__).'/Config.php'); 18 18 include_once(dirname(__FILE__).'/Setup/Setup.php'); 19 include_once(dirname(__FILE__).'/PrefixMultiplier.php'); 19 20 20 21 //define('NEW_PERMISSION', '1'); 21 22 22 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 23 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 23 24 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'); 24 25 25 26 $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 26 27 $YesNo = array(false => 'Ne', true => 'Ano'); 27 28 28 29 function HumanSize($Value) 29 30 { … … 54 55 function HumanDate($Time) 55 56 { 56 if($Time != '') { 57 if($Time != '') { 57 58 $Date = explode(' ', $Time); 58 59 $Parts = explode('-', $Date[0]); 59 60 if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]); 60 61 else return(' '); 61 } else return(' '); 62 } else return(' '); 62 63 } 63 64 … … 70 71 if($Count>1) 71 72 { 72 if($Page>0) 73 if($Page>0) 73 74 { 74 75 $Result.= '<a href="'.$URL.'0"><<</a> '; … … 88 89 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> '; 89 90 if($i==$Page) $Result.= '</strong>'; 90 } 91 } 91 92 if($PagesMax<($Count-1)) $Result .= ' .. '; 92 if($Page<($Count-1)) 93 if($Page<($Count-1)) 93 94 { 94 95 $Result.= '<a href="'.$URL.($Page+1).'">></a> '; … … 97 98 } 98 99 return($Result); 99 } 100 } 100 101 101 102 function ExtractTime($Time) 102 { 103 { 103 104 return(array( 104 'Year' => date('Y', $Time), 105 'Month' => date('n', $Time), 105 'Year' => date('Y', $Time), 106 'Month' => date('n', $Time), 106 107 'Day' => date('j', $Time), 107 108 'Hour' => date('h', $Time), … … 137 138 } 138 139 139 class Paging 140 class Paging 140 141 { 141 142 var $TotalCount; … … 144 145 var $SQLLimit; 145 146 var $Page; 146 147 147 148 function __construct() 148 149 { 149 150 global $System; 150 151 151 152 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 152 153 $this->Around = $System->Config['Web']['VisiblePagingItems']; 153 154 } 154 155 155 156 function Show() 156 157 { 157 158 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 158 159 159 160 $Result = ''; 160 if(array_key_exists('all', $QueryItems)) 161 if(array_key_exists('all', $QueryItems)) 161 162 { 162 163 $PageCount = 1; 163 $ItemPerPage = $this->TotalCount; 164 } else 164 $ItemPerPage = $this->TotalCount; 165 } else 165 166 { 166 167 $ItemPerPage = $this->ItemPerPage; … … 168 169 $PageCount = floor($this->TotalCount / $ItemPerPage) + 1; 169 170 } 170 171 171 172 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 172 173 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 173 174 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 174 175 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 175 $CurrentPage = $_SESSION['Page']; 176 176 $CurrentPage = $_SESSION['Page']; 177 177 178 $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: '; 178 179 179 180 $Result = ''; 180 181 if($PageCount > 1) 181 182 { 182 if($CurrentPage > 0) 183 if($CurrentPage > 0) 183 184 { 184 $QueryItems['page'] = 0; 185 $QueryItems['page'] = 0; 185 186 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 186 187 $QueryItems['page'] = ($CurrentPage - 1); … … 202 203 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 203 204 } 204 } 205 } 205 206 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 206 if($CurrentPage < ($PageCount - 1)) 207 if($CurrentPage < ($PageCount - 1)) 207 208 { 208 209 $QueryItems['page'] = ($CurrentPage + 1); … … 214 215 $QueryItems['all'] = '1'; 215 216 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 216 217 217 218 $Result = '<div style="text-align: center">'.$Result.'</div>'; 218 219 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; … … 225 226 { 226 227 global $System; 227 228 228 229 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 229 230 230 231 $Result = ''; 231 if(array_key_exists('all', $QueryItems)) 232 if(array_key_exists('all', $QueryItems)) 232 233 { 233 234 $PageCount = 1; 234 $ItemPerPage = $TotalCount; 235 } else 235 $ItemPerPage = $TotalCount; 236 } else 236 237 { 237 238 $ItemPerPage = $System->Config['Web']['ItemsPerPage']; … … 239 240 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 240 241 } 241 242 242 243 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 243 244 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; … … 245 246 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 246 247 $CurrentPage = $_SESSION['Page']; 247 248 248 249 249 250 $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: '; 250 251 … … 252 253 if($PageCount > 1) 253 254 { 254 if($CurrentPage > 0) 255 { 256 $QueryItems['page'] = 0; 255 if($CurrentPage > 0) 256 { 257 $QueryItems['page'] = 0; 257 258 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 258 259 $QueryItems['page'] = ($CurrentPage - 1); … … 274 275 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 275 276 } 276 } 277 } 277 278 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 278 if($CurrentPage < ($PageCount - 1)) 279 if($CurrentPage < ($PageCount - 1)) 279 280 { 280 281 $QueryItems['page'] = ($CurrentPage + 1); … … 286 287 $QueryItems['all'] = '1'; 287 288 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 288 289 289 290 $Result = '<div style="text-align: center">'.$Result.'</div>'; 290 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 291 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 291 292 'Page' => $CurrentPage, 292 293 'Output' => $Result, … … 300 301 { 301 302 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 302 303 303 304 if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 304 305 if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 305 306 if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 306 307 if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 307 308 308 309 // Check OrderCol 309 310 $Found = false; … … 312 313 if($Column['Name'] == $_SESSION['OrderCol']) 313 314 { 314 $Found = true; 315 $Found = true; 315 316 break; 316 317 } … … 323 324 // Check OrderDir 324 325 if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 325 326 326 327 $Result = ''; 327 328 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 362 363 { 363 364 global $Database; 364 365 365 366 $DbResult = $Database->query('SELECT Id FROM Member WHERE (SELECT Member FROM NetworkDevice WHERE (SELECT Device FROM NetworkInterface WHERE LocalIP = "'.$IP.'") = NetworkDevice.Id) = Member.Id'); 366 367 if($DbResult->num_rows > 0) 367 368 { 368 $DbRow = $DbResult->fetch_assoc(); 369 $DbRow = $DbResult->fetch_assoc(); 369 370 return($DbRow['Id']); 370 371 } else return(''); … … 374 375 { 375 376 return(str_replace( 376 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 377 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 377 378 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), 378 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 379 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 379 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 380 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 380 381 $Text)); 381 382 } … … 384 385 { 385 386 return(strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', 386 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 387 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 387 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 388 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 388 389 'ť' => 't', 'ň' => 'n', 'ó' => 'o', 389 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 390 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 390 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 391 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 391 392 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', 392 393 ))); … … 395 396 function NotBlank($Text) 396 397 { 397 if($Text == '') return(' '); 398 if($Text == '') return(' '); 398 399 else return($Text); 399 400 } … … 403 404 preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); 404 405 return str_replace($matches[0], $matches[1], $string); 405 } 406 } 406 407 407 408 function html2txt($document) … … 414 415 $text = preg_replace($search, '', $document); 415 416 return $text; 416 } 417 } 417 418 418 419 function ProcessURL() … … 425 426 if(strpos($_SERVER['REQUEST_URI'], '?') !== false) 426 427 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 427 else $_SERVER['QUERY_STRING'] = ''; 428 else $_SERVER['QUERY_STRING'] = ''; 428 429 parse_str($_SERVER['QUERY_STRING'], $_GET); 429 430 return($PathItems);
Note:
See TracChangeset
for help on using the changeset viewer.