source: includes/classes.php

Last change on this file was 7, checked in by george, 16 years ago

Opraveno: Nemožnost editace serveru s názvem obsaženým v jiném názvu.

File size: 4.0 KB
Line 
1<?
2function ulink($uri, $thing)
3 {
4 global $config;
5 return '<a href="'.$config['base_url'].$uri.'">'.$thing.'</a>';
6 }
7function menuitem($uri, $thing)
8 {
9 global $config;
10 return '<a class="menuitem" href="'.$config['base_url'].$uri.'">'.$thing.'</a>';
11 }
12
13function window_open($uri, $thing, $width, $height, $left, $top)
14 {
15 global $config;
16 return "<a href=\"#\" onclick=\" window.open('$uri', 'win', 'width=$width,height=$height,menubar=yes,resizable=yes,left=$left,top=$top'); return false;\">$thing</a>";
17 }
18
19function is_email($a)
20 {
21 return ereg("^.+@.+\..+$",$a);
22 }
23
24function check_registr()
25 {
26 global $posted, $db;
27 $return['error'] =false;
28 if ($posted['pass1']!=$posted['pass2'])
29 {
30 $return['error'] =true;
31 $return['error_key'] = 'pass_error';
32
33 }
34 if (empty($posted['pass1']))
35 {
36 $return['error'] =true;
37 $return['error_key'] = 'no_pass';
38
39 }
40
41 $pocet = $db->query_result('SELECT COUNT(*) as pocet FROM `users` WHERE name="'.$posted['name'].'"');
42 if ($pocet==1)
43 {
44 $return['error'] =true;
45 $return['error_key'] = 'login_error';
46
47 }
48 if (empty($posted['name']))
49 {
50 $return['error'] =true;
51 $return['error_key'] = 'no_login';
52
53 }
54 if (!is_email($posted['email']))
55 {
56 $return['error'] =true;
57 $return['error_key'] = 'email_wrong';
58
59 }
60 $poce = $db->query_result('SELECT COUNT(*) as pocet FROM `users` WHERE email="'.$posted['email'].'"');
61 if ($poce==1)
62 {
63 $return['error'] =true;
64 $return['error_key'] = 'email_used';
65
66 }
67
68 return $return;
69 }
70
71function check_add_server()
72 {
73 global $_POST, $posted, $db;
74 $return['error'] = false;
75 if (empty($_POST['accept']))
76 {
77 $return['error'] = true;
78 $return['error_msg'] = 'not_accept';
79 }
80 if (($_POST['web']=='http://') || ($_POST['web_reg']=='http://'))
81 {
82 $return['error'] = true;
83 $return['error_msg'] = 'not_web';
84 }
85 if (empty($_POST['name']))
86 {
87 $return['error'] = true;
88 $return['error_msg'] = 'not_name';
89 }
90 else {
91 $exist = $db->query_result("SELECT count(*) as pocet FROM `servers` where `name` like '%".$posted['name']."%'");
92 if ($exist==1)
93 {
94 $return['error'] = true;
95 $return['error_msg'] = 'name_used';
96 }}
97 return $return;
98 }
99
100function print_nick($a)
101 {
102 global $db, $user;
103 $b = $db->strip($db->query_fetch_assoc('SELECT `name`, `admin`, `ban` FROM `users` WHERE `id`='.(int)$a));
104 if ($b['admin']==1)
105 {
106 $return = ulink('user/'.$a, $b['name'].'(Admin)');
107 }
108 elseif (($b['ban']==1) && ($user['admin']==1))
109 {
110 $return = ulink('user/'.$a, $b['name'].'(Banned)');
111 }
112 else
113 {
114 $return = ulink('user/'.$a, $b['name']);
115 }
116 return $return;
117 }
118
119function datum($cas)
120 {
121 global $dny, $mesice;
122$vcera=strtotime("-1 day");
123if (date("zY")==date("zY", $cas))
124 {
125 $dnes="Dnes ".Date("H:i:s", $cas);
126 }
127elseif (date("zY", $vcera)==date("zY", $cas))
128 {
129 $dnes="Včera ".date("H:i:s", $cas);
130 }
131else
132 {
133$dnes = $dny[Date("D", $cas)] . Date(" d. ", $cas) .
134$mesice[(int)Date("m", $cas)] . Date(" Y - H:i:s", $cas);
135}
136return($dnes);
137 }
138
139function check_edit_server($server_id)
140 {
141 global $_POST, $posted, $db;
142 $return['error'] = false;
143 if (empty($_POST['name']))
144 {
145 $return['error'] = true;
146 $return['error_msg'] = 'not_name';
147 }
148 else {
149 $exist = $db->query_result("SELECT count(*) as pocet FROM `servers` where (`name` like TRIM('".$posted['name']."') AND NOT `id`=$server_id)");
150 if ($exist==1)
151 {
152 $return['error'] = true;
153 $return['error_msg'] = 'name_used';
154 }}
155 return $return;
156 }
157
158function delserver($server)
159 {
160 global $db;
161 $db->query(0, 'DELETE FROM `servers` WHERE `id`='.$server.' LIMIT 1');
162 $db->query(0, 'delete from `comments` where `server`='.$server);
163 $db->query(0, 'delete from `ratings` where `server_id`='.$server);
164 }
165?>
Note: See TracBrowser for help on using the repository browser.