1 | <?php
|
---|
2 |
|
---|
3 | function ErrorHandler()
|
---|
4 | {
|
---|
5 | }
|
---|
6 |
|
---|
7 | class 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();
|
---|
50 | $Database->Connect($this->Config['Mangos']['DatabaseHost'], $this->Config['Mangos']['DatabaseUser'], $this->Config['Mangos']['DatabasePassword'], $this->Config['Mangos']['DatabaseRealmd']);
|
---|
51 | if(mysqli_connect_error())
|
---|
52 | {
|
---|
53 | die('Přihlášení k databázi selhalo: '.mysqli_connect_error());
|
---|
54 | }
|
---|
55 | $Database->charset($this->Config['Database']['Charset']);
|
---|
56 | return($Database);
|
---|
57 | }
|
---|
58 |
|
---|
59 | function OpenWebDatabase()
|
---|
60 | {
|
---|
61 | $Database = new Database();
|
---|
62 | $Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']);
|
---|
63 | if(mysqli_connect_error())
|
---|
64 | {
|
---|
65 | die('Přihlášení k databázi selhalo: '.mysqli_connect_error());
|
---|
66 | }
|
---|
67 | $Database->charset($this->Config['Database']['Charset']);
|
---|
68 | return($Database);
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | ?>
|
---|