2 switch ($_POST['event']) {
3 case 'pridaj priatela':
4 $status=eventz::addfriend();
6 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
12 $status=eventz::deletefriend();
14 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
19 case 'zmen nastavenie':
20 $status=eventz::changeseting();
22 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
28 $status=eventz::alljournaux();
30 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
36 $status=eventz::allforum();
38 Header("Location:".SCRIPT."?action=ludia&subaction=friends");
46 function addfriend() {
50 $friend_text=$_POST['friend_text'];
51 $friend_name=$_POST['friend_name'];
53 if (empty($friend_name)) {
55 $error="Nezadal si meno priatela.";
60 $q="select id from user where login='$friend_name'";
61 $result=$kyberia->query($q);
63 $friend=$result->getRecord();
64 $friend_id=$friend['id'];
66 if (empty($friend_text)) {
68 $error="Nezadal si text k priatelovi.";
72 elseif ($friend_id==$user_id) {
78 elseif(empty($friend_id)) {
80 $error="Uzivatel neexistuje!";
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);
91 if (($result->getNumRows())>0) {
92 $q="update friends set friend_text='$friend_text' where user_id='$user_id' and friend_id='$friend_id'";
94 $kyberia->ubikMail($friend_id,"Uzivatel $user_name zmenil tvoj friend komentar na text: $friend_text");
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'";
104 $q2="select friend_id from friends where user_id='$user_id'";
105 $set2=$kyberia->query($q2);
107 while ($set2->next()){
108 $friends_serial.=($set2->getString('friend_id')).";";
110 $kyberia->query("update user set friends_serial='$friends_serial' where id='$user_id'");
119 function deletefriend() {
123 $friend_text=$_POST['friend_text'];
124 $friend_name=$_POST['friend_name'];
126 $q="select id from user where login='$friend_name'";
127 $result=$kyberia->query($q);
129 $friend=$result->getRecord();
130 $friend_id=$friend['id'];
132 if(empty($friend_id)) {
134 $error="Uzivatel neexistuje!";
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'");
141 $q2="select friend_id from friends where user_id='$user_id'";
142 $set2=$kyberia->query($q2);
144 while ($set2->next()){
145 $friends_serial.=($set2->getString('friend_id')).";";
147 $kyberia->query("update user set friends_serial='$friends_serial' where id='$user_id'");
152 function changeseting() {
160 foreach($jornaux as $indx => $valu){
161 $valu2=explode("_",$valu);
166 $send[$val]+=$s_j[$val];
172 foreach($forum as $indx => $valu){
173 $valu2=explode("_",$valu);
175 if (!($check[$val])){
176 if(!$send[$val]){$send[$val]=0;}
179 $send[$val]+=($s_f[$val])*2;
184 $q="select * from friends where user_id='$user_id'";
185 $set=$kyberia->query($q);
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];
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'";
207 function alljournaux() {
213 $journauxall=$_POST['journauxall'];
217 }else{$journauxall=1;}
220 foreach($forum as $indx => $valu){
221 $valu2=explode("_",$valu);
223 if (!($check[$val])){
227 $send[$val]+=($s_f[$val])*2;
228 $send[$val]+=$journauxall;
233 $q="select * from friends where user_id='$user_id'";
234 $set=$kyberia->query($q);
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];
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'";
255 function allforum() {
261 $forumall=$_POST['forumall'];
268 foreach($jornaux as $indx => $valu){
269 $valu2=explode("_",$valu);
271 if (!($check[$val])){
275 $send[$val]+=$s_j[$val];
276 $send[$val]+=$forumall*2;
282 $q="select * from friends where user_id='$user_id'";
283 $set=$kyberia->query($q);
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];
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'";