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($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 | ?>
|
---|