Kyberia v1.0
[mirrors/Kyberia-bloodline.git] / inc / friends_eventz.inc
1 <?php
2 switch ($_POST['event']) {
3 case 'pridaj priatela':
4 $status=eventz::addfriend();
5 if ($status) {
6 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
7 }
8 else echo $error;
9 break;
10
11 case 'zmaz priatela':
12 $status=eventz::deletefriend();
13 if ($status) {
14 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
15 }
16 else echo $error;
17 break;
18
19 case 'zmen nastavenie':
20 $status=eventz::changeseting();
21 if ($status) {
22 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
23 }
24 else echo $error;
25 break;
26
27 case 'denniky':
28 $status=eventz::alljournaux();
29 if ($status) {
30 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
31 }
32 else echo $error;
33 break;
34
35 case 'kluby':
36 $status=eventz::allforum();
37 if ($status) {
38 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
39 }
40 else echo $error;
41 break;
42 }
43
44 class eventz {
45
46 function addfriend() {
47 global $kyberia;
48 global $user_id;
49 global $user_name;
50 $friend_text=$_POST['friend_text'];
51 $friend_name=$_POST['friend_name'];
52
53 if (empty($friend_name)) {
54 global $error;
55 $error="Nezadal si meno priatela.";
56 return false;
57 }
58
59
60 $q="select id from user where login='$friend_name'";
61 $result=$kyberia->query($q);
62 $result->next();
63 $friend=$result->getRecord();
64 $friend_id=$friend['id'];
65
66 if (empty($friend_text)) {
67 global $error;
68 $error="Nezadal si text k priatelovi.";
69 return false;
70 }
71
72 elseif ($friend_id==$user_id) {
73 global $error;
74 $error="egotrip?";
75 return false;
76 }
77
78 elseif(empty($friend_id)) {
79 global $error;
80 $error="Uzivatel neexistuje!";
81 return false;
82 }
83
84 $friend_text=strip_tags($friend_text,'<a><b><i><u><img><br><p><font>');
85 $friend_text=str_replace("\n","<br>",$friend_text);
86 $friend_text = EregI_Replace("((( )|(\n)|(^))+)(http://|ftp://|https://)([[:alnum:]][^,[:space:]]*)","\\2<a href=\"\\6\\7\">\\6\\7</a>",$friend_text);
87 $friend_text=addslashes($friend_text);
88 $q="select * from friends where user_id='$user_id' and friend_id='$friend_id'";
89 $result=$kyberia->query($q);
90
91 if (($result->getNumRows())>0) {
92 $q="update friends set friend_text='$friend_text' where user_id='$user_id' and friend_id='$friend_id'";
93 $kyberia->query($q);
94 $kyberia->ubikMail($friend_id,"Uzivatel $user_name zmenil tvoj friend komentar na text: $friend_text");
95 }
96
97 else {
98 $q="insert into friends set user_id='$user_id',friend_text='$friend_text',friend_id='$friend_id'";
99 $result=mysql_query($q);
100 $kyberia->ubikMail($friend_id,"Uzivatel $user_name si ta pridal medzi priatelov s textom: $friend_text");
101 $q="update user set charisma=charisma+1 where id='$friend_id'";
102 $kyberia->query($q);
103
104 $q2="select friend_id from friends where user_id='$user_id'";
105 $set2=$kyberia->query($q2);
106 $friends_serial="";
107 while ($set2->next()){
108 $friends_serial.=($set2->getString('friend_id')).";";
109 }
110 $kyberia->query("update user set friends_serial='$friends_serial' where id='$user_id'");
111
112
113 return true;
114 }
115
116
117 }
118
119 function deletefriend() {
120 global $kyberia;
121 global $user_id;
122 global $user_name;
123 $friend_text=$_POST['friend_text'];
124 $friend_name=$_POST['friend_name'];
125
126 $q="select id from user where login='$friend_name'";
127 $result=$kyberia->query($q);
128 $result->next();
129 $friend=$result->getRecord();
130 $friend_id=$friend['id'];
131
132 if(empty($friend_id)) {
133 global $error;
134 $error="Uzivatel neexistuje!";
135 return false;
136 }
137
138 $kyberia->query("delete from friends where friend_id='$friend_id' and user_id='$user_id'");
139 $kyberia->query("update user set charisma=charisma-1 where id='$friend_id'");
140
141 $q2="select friend_id from friends where user_id='$user_id'";
142 $set2=$kyberia->query($q2);
143 $friends_serial="";
144 while ($set2->next()){
145 $friends_serial.=($set2->getString('friend_id')).";";
146 }
147 $kyberia->query("update user set friends_serial='$friends_serial' where id='$user_id'");
148
149 }
150
151
152 function changeseting() {
153 global $kyberia;
154 global $user_id;
155 global $user_name;
156 global $jornaux;
157 global $forum;
158
159 if($jornaux){
160 foreach($jornaux as $indx => $valu){
161 $valu2=explode("_",$valu);
162 $val=$valu2['1'];
163 if (!($send[$val])){
164 $send[$val]=0;
165 $s_j[$val]='1';
166 $send[$val]+=$s_j[$val];
167 }
168 }
169 }
170
171 if($forum){
172 foreach($forum as $indx => $valu){
173 $valu2=explode("_",$valu);
174 $val=$valu2['1'];
175 if (!($check[$val])){
176 if(!$send[$val]){$send[$val]=0;}
177 $check[$val]=1;
178 $s_f[$val]='1';
179 $send[$val]+=($s_f[$val])*2;
180 }
181 }
182 }
183
184 $q="select * from friends where user_id='$user_id'";
185 $set=$kyberia->query($q);
186
187 while ($set->next()){
188 $f_id=$set->getString('friend_id');
189 $s_mail=$set->getString('send_mail');
190 $db_send[$f_id]=$s_mail;
191 if(!$send[$f_id]){$send[$f_id]=0;}
192 if (($db_send[$f_id])!=($send[$f_id])){
193 $modify[$f_id]=$send[$f_id];
194
195 }
196 }
197 if($modify){
198 foreach($modify as $f_id => $s_m){
199 $q="update friends set send_mail='$s_m' where user_id='$user_id' and friend_id='$f_id'";
200 $kyberia->query($q);
201 }
202 }
203
204 }
205
206
207 function alljournaux() {
208 global $kyberia;
209 global $user_id;
210 global $user_name;
211 global $jornaux;
212 global $forum;
213 $journauxall=$_POST['journauxall'];
214
215 if(!$journauxall){
216 $journauxall=0;
217 }else{$journauxall=1;}
218
219 if($forum){
220 foreach($forum as $indx => $valu){
221 $valu2=explode("_",$valu);
222 $val=$valu2['1'];
223 if (!($check[$val])){
224 $send[$val]=0;
225 $check[$val]=1;
226 $s_f[$val]='1';
227 $send[$val]+=($s_f[$val])*2;
228 $send[$val]+=$journauxall;
229 }
230 }
231 }
232
233 $q="select * from friends where user_id='$user_id'";
234 $set=$kyberia->query($q);
235
236 while ($set->next()){
237 $f_id=$set->getString('friend_id');
238 $s_mail=$set->getString('send_mail');
239 $db_send[$f_id]=$s_mail;
240 if(!$send[$f_id]){$send[$f_id]=$journauxall;}
241 if (($db_send[$f_id])!=($send[$f_id])){
242 $modify[$f_id]=$send[$f_id];
243
244 }
245 }
246 if($modify){
247 foreach($modify as $f_id => $s_m){
248 $q="update friends set send_mail='$s_m' where user_id='$user_id' and friend_id='$f_id'";
249 $kyberia->query($q);
250 }
251 }
252
253 }
254
255 function allforum() {
256 global $kyberia;
257 global $user_id;
258 global $user_name;
259 global $jornaux;
260 global $forum;
261 $forumall=$_POST['forumall'];
262
263 if(!$forumall){
264 $forumall=0;
265 }else{$forumall=1;}
266
267 if($jornaux){
268 foreach($jornaux as $indx => $valu){
269 $valu2=explode("_",$valu);
270 $val=$valu2['1'];
271 if (!($check[$val])){
272 $check[$val]=1;
273 $send[$val]=0;
274 $s_j[$val]='1';
275 $send[$val]+=$s_j[$val];
276 $send[$val]+=$forumall*2;
277 }
278 }
279 }
280
281
282 $q="select * from friends where user_id='$user_id'";
283 $set=$kyberia->query($q);
284
285 while ($set->next()){
286 $f_id=$set->getString('friend_id');
287 $s_mail=$set->getString('send_mail');
288 $db_send[$f_id]=$s_mail;
289 if(!$send[$f_id]){$send[$f_id]=$forumall*2;}
290 if (($db_send[$f_id])!=($send[$f_id])){
291 $modify[$f_id]=$send[$f_id];
292
293 }
294 }
295 if($modify){
296 foreach($modify as $f_id => $s_m){
297 $q="update friends set send_mail='$s_m' where user_id='$user_id' and friend_id='$f_id'";
298 $kyberia->query($q);
299 }
300 }
301
302 }
303
304
305
306
307
308
309 }
This page took 0.371565 seconds and 5 git commands to generate.