source: branches/posledni/inc/system.php

Last change on this file was 695, checked in by george, 15 years ago
  • Upraveno: Použití názvů světů v URL namísto RealmIndex.
  • Přidáno: Stránka zobrazující informace o jednotlivých světech.
  • Odebráno: Nezobrazovat kategorie aktualit. Stačí jen jedna.
  • Přidáno: Funkce pro generování XML seznamu hráčů ve stylu WoWEmu pro wowstatus.
File size: 2.2 KB
Line 
1<?php
2
3function ErrorHandler()
4{
5}
6
7class System
8{
9 var $Config;
10 var $Database;
11
12 function __construct($Config)
13 {
14 $this->Config = $Config;
15 $this->Database = $this->OpenWebDatabase();
16 }
17
18 function NetworkPortState($Address, $Port, $Timeout = 1)
19 {
20 set_error_handler('ErrorHandler');
21 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))
22 {
23 fclose($Socket);
24 $Result = true;
25 } else $Result = false;
26 restore_error_handler();
27 return($Result);
28 }
29
30 function SQLURLName($Name)
31 {
32 return('LOWER(REPLACE('.$Name.', " ", "-"))');
33 }
34
35 function SeoUrl($Address)
36 {
37 $Diakritika = array("á","ä","č","ď","é","ě","ë","í","ň","ó","ö","ř","š","ť","ú","ů","ü","ý","ž","Á","Ä","Č","Ď","É","Ě","Ë","Í","Ň","Ó","Ö","Ř","Š","Ť","Ú","Ů","Ü","Ý","Ž");
38 $Nediakritika = array("a","a","c","d","e","e","e","i","n","o","o","r","s","t","u","u","u","y","z","A","A","C","D","E","E","E","I","N","O","O","R","S","T","U","U","U","Y","Z");
39 $Address = str_replace($Diakritika, $Nediakritika, $Address);
40 $Address = strtolower($Address);
41 $Address = preg_replace("/[^[:alpha:][:digit:]]/", "-", $Address);
42 $Address = trim($Address, "-");
43 $Address = preg_replace("/[-]+/", "-", $Address);
44 return($Address);
45 }
46
47 function OpenLogonServerDatabase()
48 {
49 $Database = new Database($this->Config['Mangos']['DatabaseHost'], $this->Config['Mangos']['DatabaseUser'], $this->Config['Mangos']['DatabasePassword'], $this->Config['Mangos']['DatabaseRealmd']);
50 if(mysqli_connect_error())
51 {
52 die('Přihlášení k databázi selhalo: '.mysqli_connect_error());
53 }
54 $Database->charset($this->Config['Database']['Charset']);
55 return($Database);
56 }
57
58 function OpenWebDatabase()
59 {
60 $Database = new Database($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']);
61 if(mysqli_connect_error())
62 {
63 die('Přihlášení k databázi selhalo: '.mysqli_connect_error());
64 }
65 $Database->charset($this->Config['Database']['Charset']);
66 return($Database);
67 }
68}
69
70?>
Note: See TracBrowser for help on using the repository browser.