Changeset 284 for trunk/includes/global_function.php
- Timestamp:
- Dec 11, 2009, 11:41:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global_function.php
r255 r284 20 20 function getmonthyears($Days) 21 21 { 22 $month = floor($Days / 30); 23 $year = floor($month / 12); 24 $Days = floor($Days - $month * 30); 25 $month = $month - $year * 12; 26 return($year.'r '.$month.'m '.$Days.'d'); 27 } 28 29 function ListPaging($Address, $Table, $Where, $ItemsPerPage, $CurrentPage) 30 { 31 global $Database; 32 33 echo('<div style="text-align: center">'); 34 $Line = mysql_fetch_row($Database->SQLCommand('SELECT count(*) FROM '.$Table.' '.$Where)); 35 $ItemCount = $Line[0]; 36 $PageCount = floor($ItemCount / $ItemsPerPage) + 1; 22 $month = floor($Days / 30); 23 $year = floor($month / 12); 24 $Days = floor($Days - $month * 30); 25 $month = $month - $year * 12; 26 return($year.'r '.$month.'m '.$Days.'d'); 27 } 28 29 function GetPageList($TotalCount) 30 { 31 global $Database, $Config; 32 33 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 34 35 $ItemPerPage = $Config['Web']['ItemsPerPage']; 36 $Around = round($Config['Web']['VisiblePagingItems'] / 2); 37 $Result = ''; 38 $PageCount = ceil($TotalCount / $ItemPerPage); 39 40 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 41 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 42 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 43 $CurrentPage = $_SESSION['Page']; 37 44 38 echo('Počet položek: <strong>'.$ItemCount.'</strong> Zobrazit stránku: '); 39 40 //if($CurrentPage > $PageCount) $CurrentPage = $PageCount; 41 for($Page = 1; $Page <= $PageCount; $Page++) 42 { 43 if($CurrentPage == $Page) echo('<strong>'.$Page.'</strong> '); 44 else echo('<a href="'.$Address.$Page.'">'.$Page.'</a> '); 45 } 46 echo('</div>'); 45 $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: '; 46 47 $Result = ''; 48 if($PageCount > 1) 49 { 50 if($CurrentPage > 0) 51 { 52 $QueryItems['page'] = 0; 53 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 54 $QueryItems['page'] = ($CurrentPage - 1); 55 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> '; 56 } 57 $PagesMax = $PageCount - 1; 58 $PagesMin = 0; 59 if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 60 if($PagesMin < ($CurrentPage - $Around)) 61 { 62 $Result.= ' .. '; 63 $PagesMin = $CurrentPage - $Around; 64 } 65 for($i = $PagesMin; $i <= $PagesMax; $i++) 66 { 67 if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 68 else { 69 $QueryItems['page'] = $i; 70 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 71 } 72 } 73 if($PagesMax < ($PageCount - 1)) $Result .= ' .. '; 74 if($CurrentPage < ($PageCount - 1)) 75 { 76 $QueryItems['page'] = ($CurrentPage + 1); 77 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> '; 78 $QueryItems['page'] = ($PageCount - 1); 79 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>'; 80 } 81 } 82 $Result = '<div style="text-align: center">'.$Result.'</div>'; 83 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 84 'Page' => $CurrentPage, 85 'Output' => $Result, 86 )); 47 87 } 48 88 … … 55 95 { 56 96 $start = strpos($s,'<'); 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 97 $end = strpos($s,'>'); 98 if($start != 0) 99 { 100 $end = $start-1; 101 $start = 0; 102 } 103 $line = trim(substr($s,$start,$end+1)); 104 if(strlen($line)>0) 105 if($line[0] == '<') 106 { 107 if($s[$start+1] == '/') 108 { 109 $n = $n - 2; 110 $nn = $n; 111 } else 112 { 113 if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1); 114 else $cmd = substr($line,1,strlen($line)-2); 75 115 //echo('['.$cmd.']'); 76 77 78 116 if(strpos($s,'</'.$cmd.'>')) $n = $n + 2; 117 } 118 }// else $line = '['.$line.']'; 79 119 //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n")); 80 81 82 120 if($line != '') $out .= (str_repeat(' ',$nn).$line."\n"); 121 $s = substr($s,$end+1,strlen($s)); 122 $nn = $n; 83 123 } 84 124 return($out); … … 96 136 if($Selected == $Language['Id']) echo(' selected="selected"'); echo('>'.$Language['Name'].'</option>'); 97 137 } 98 echo('</select>'); 138 echo('</select>'); 99 139 } 100 140 … … 125 165 } else 126 166 { 127 if(!isset($_SERVER['REMOTE_ADDR'])) 128 { 129 return(true); 130 } else { 131 return(false); 132 } 167 return(!isset($_SERVER['REMOTE_ADDR'])); 133 168 } 134 169 } … … 150 185 $DbResult = $Database->SQLCommand('SELECT * FROM `language`'); 151 186 while($DbRow = mysql_fetch_assoc($DbResult)) 152 187 $Result[$DbRow['Id']] = $DbRow; 153 188 return($Result); 154 189 } … … 162 197 while($DbRow = mysql_fetch_assoc($DbResult)) 163 198 { 164 165 199 $DbRow['Items'] = array(); 200 $Result[$DbRow['Id']] = $DbRow; 166 201 } 167 202 $DbResult = $Database->SQLCommand('SELECT * FROM `group_item`'); 168 203 while($DbRow = mysql_fetch_assoc($DbResult)) 169 204 { 170 205 $Result[$DbRow['Group']]['Items'][] = $DbRow; 171 206 } 172 207 return($Result); … … 175 210 $LogTypes = array 176 211 ( 177 // index, indexname , barva , popis 178 array('0', '', 'brown', ''), 179 array('1', 'Překlady', 'green', 'Operace s překladdy'), 180 array('2', 'Stažení', 'brown', 'Stáhnutí souboru'), 181 array('3', 'Uživatelé', 'blue', 'Přihlášení uživatelů, nastavení, registrace'), 182 array('4', 'Moderátor', 'orange', 'Operace administrátorů a moderátorů'), 183 array('10', 'Chyby', 'red', 'Zachycené chybové hlášení'), 184 array('11', 'Import', '#A020F0', 'Záznam změn při importu'), 212 0 => array('Name' => '', 'Color' => 'brown', 'Description' => ''), 213 1 => array('Name' => 'Překlady', 'Color' => 'green', 'Description' => 'Operace s překladdy'), 214 2 => array('Name' => 'Stažení', 'Color' => 'brown', 'Description' => 'Stáhnutí souboru'), 215 3 => array('Name' => 'Uživatelé', 'Color' => 'blue', 'Description' => 'Přihlášení uživatelů, nastavení, registrace'), 216 4 => array('Name' => 'Moderátor', 'Color' => 'orange', 'Description' => 'Operace administrátorů a moderátorů'), 217 10 => array('Name' => 'Chyby', 'Color' => 'red', 'Description' => 'Zachycené chybové hlášení'), 218 11 => array('Name' => 'Import', 'Color' => '#A020F0', 'Description' => 'Záznam změn při importu'), 185 219 ); 186 220 … … 189 223 function WriteLog($Text, $Type) 190 224 { 191 global $Database, $Config ,$_SERVER;225 global $Database, $Config; 192 226 193 if(!isset($_SERVER['REMOTE_ADDR'])) 194 { 195 $user = 0; 196 $ip = 'Konzole'; 197 } else { 198 $user = @$_SESSION['UserID']; 199 $ip = addslashes($_SERVER['REMOTE_ADDR']); 200 } 227 if(!isset($_SERVER['REMOTE_ADDR'])) 228 { 229 $user = 0; 230 $ip = 'Konzole'; 231 } else 232 { 233 $user = @$_SESSION['UserID']; 234 $ip = addslashes($_SERVER['REMOTE_ADDR']); 235 } 201 236 202 237 if($user == '') $user = 0; … … 209 244 $client_files = array 210 245 ( 211 '0'=> 'LocalizationStrings',212 '1'=> 'SpellBufDescription_1',213 '2'=> 'SpellDescription_1',214 '3'=> 'SpellDescription_2',215 '4'=> 'SpellDescription_3',216 '5'=> 'SpellDescription_4',217 '6'=> 'tallent',246 0 => 'LocalizationStrings', 247 1 => 'SpellBufDescription_1', 248 2 => 'SpellDescription_1', 249 3 => 'SpellDescription_2', 250 4 => 'SpellDescription_3', 251 5 => 'SpellDescription_4', 252 6 => 'tallent', 218 253 ); 219 254 … … 231 266 if($Prev) 232 267 { 233 268 $sql = 'SELECT ID FROM '.$Table.' as item WHERE Language = 0 AND NOT EXISTS(SELECT entry FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = item.entry) AND ID < '.$TextID.' ORDER BY ID DESC LIMIT 1'; 234 269 } else 235 270 { 236 271 $sql = 'SELECT ID FROM '.$Table.' as item WHERE Language = 0 AND NOT EXISTS(SELECT entry FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = item.entry) AND ID > '.$TextID.' ORDER BY ID LIMIT 1'; 237 272 } 238 273 … … 240 275 if($Next) 241 276 { 242 243 244 277 if($Prev) echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> '); 278 else echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> '); 279 return 'form.php?group='.$GroupId.'&ID='.$Next['ID']; 245 280 } 246 281 } … … 264 299 $old = str_replace("Â", "", $old); 265 300 $old = str_replace("�", "", $old); 266 301 267 302 268 303 if (($GroupItem['MangosColumn'] <> '') and ($Group['MangosDatabase'] == 'mangos')) … … 282 317 $new = str_replace("�", "", $new); 283 318 284 285 286 287 319 if (($old == 'null') or ($old == 'NULL')) $old = ''; 320 if (($new == 'null') or ($new == 'NULL')) $new = ''; 321 322 288 323 if(($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 289 324 { … … 299 334 { 300 335 global $Database,$BuildNumbers; 301 336 302 337 if (isset($BuildNumbers[$Version]) == false) 303 338 {
Note:
See TracChangeset
for help on using the changeset viewer.