Commit | Line | Data |
---|---|---|
bc13d5d6 H |
1 | <?php |
2 | ||
3 | switch ($_POST['event']) { | |
4 | case 'zmen data': | |
5 | $status=personalize_eventz::updateData(); | |
6 | if($status) { | |
7 | Header("Location:".SCRIPT."?action=$action"); | |
8 | } | |
9 | break; | |
10 | ||
11 | case 'zmen ikonu': | |
12 | $status=personalize_eventz::updateIcon(); | |
13 | if($status) { | |
14 | // Header("Location:".SCRIPT."?action=$action&status=$status"); | |
15 | } | |
16 | break; | |
17 | ||
18 | case 'zmen heslo': | |
19 | $status=personalize_eventz::updatePassword(); | |
20 | if($status) { | |
21 | Header("Location:".SCRIPT."?action=$action&status=$status"); | |
22 | } | |
23 | break; | |
24 | ||
25 | case 'zmen nastavenie': | |
26 | $status=personalize_eventz::updateSettings(); | |
27 | if($status) { | |
28 | Header("Location:".SCRIPT."?action=$action&status=$status"); | |
29 | } | |
30 | break; | |
31 | } | |
32 | ||
33 | class personalize_eventz { | |
34 | ||
35 | function updateData() { | |
36 | global $kyberia; | |
37 | global $user_id; | |
38 | $user_info=$_POST['user_info']; | |
39 | $email=$_POST['email']; | |
40 | $user_icq=$_POST['user_icq']; | |
41 | $user_www=$_POST['user_www']; | |
42 | $user_ad=$_POST['user_ad']; | |
43 | $q="UPDATE user set id='$user_id'"; | |
44 | if (!empty($user_info)) { | |
45 | $user_info=str_replace("\n","<br>",$user_info); | |
46 | $q.=", user_info='$user_info'"; | |
47 | } | |
48 | if (!empty($email)) $q.=", email='$email' "; | |
49 | if (!empty($user_icq)) $q.=", user_icq='$user_icq' "; | |
50 | if (!empty($user_www)) $q.=", user_www='$user_www' "; | |
51 | if (!empty($user_ad)) $q.=", user_ad='$user_ad' "; | |
52 | $q.=" where id='$user_id'"; | |
53 | $kyberia->query($q); | |
54 | } | |
55 | ||
56 | ||
57 | function updateSettings() { | |
58 | global $kyberia; | |
59 | global $user_id; | |
60 | global $error; | |
61 | $user_amount=addSlashes($_POST['user_amount']); | |
62 | $user_sad=addSlashes($_POST['user_sad']); | |
63 | $user_happy=addSlashes($_POST['user_happy']); | |
64 | $user_drugged=addSlashes($_POST['user_drugged']); | |
65 | $user_love=addSlashes($_POST['user_love']); | |
66 | $user_agressive=addSlashes($_POST['user_agressive']); | |
67 | $user_active_icons=$_POST['user_active_icons']; | |
68 | $user_icons_in_forum=$_POST['user_icons_in_forum']; | |
69 | ||
70 | if ($user_amount>100) { | |
71 | $error="Pocet zobrazitelnych prispevkov nemoze byt vacsi ako 100."; | |
72 | return false; | |
73 | } | |
74 | ||
75 | $q="UPDATE user set user_amount='$user_amount'"; | |
76 | // if (!empty($user_ad)) $q.=", user_ad='$user_ad' "; | |
77 | $q.=",user_sad='$user_sad'"; | |
78 | $q.=",user_happy='$user_happy'"; | |
79 | $q.=",user_drugged='$user_drugged'"; | |
80 | $q.=",user_agressive='$user_agressive'"; | |
81 | $q.=",user_love='$user_love'"; | |
82 | $q.=",user_active_icons='$user_active_icons'"; | |
83 | $q.=",user_icons_in_forum='$user_icons_in_forum'"; | |
84 | $q.=" where id='$user_id'"; | |
85 | $kyberia->query($q); | |
86 | $q="UPDATE session set user_amount='$user_amount'"; | |
87 | // if (!empty($user_ad)) $q.=", user_ad='$user_ad' "; | |
88 | $q.=" where user_id='$user_id'"; | |
89 | $kyberia->query($q); | |
90 | return true; | |
91 | } | |
92 | ||
93 | ||
94 | function updateIcon() { | |
95 | global $user_name; | |
96 | $icon=$_FILES['icon']; | |
97 | if (empty($icon['tmp_name'])) { | |
98 | global $error; | |
99 | $error='Zle zadany subor'; | |
100 | return false; | |
101 | } | |
102 | ||
103 | else { | |
104 | if (strstr($icon['name'],".gif")) { | |
105 | $cmd=GIFSICLE." --resize 50x_ ".$icon['tmp_name']." > ".ICONDIR.strtolower($user_name).".gif"; | |
106 | } | |
107 | ||
108 | elseif (strstr($icon['name'],".jpg")){ | |
109 | $cmd=NETPBM."/jpegtopnm ".$icon['tmp_name']." | ".NETPBM."/pnmscale -width=50 | ".NETPBM."/ppmquant 256 | ".NETPBM."/ppmtogif > ".ICONDIR.strtolower($user_name).".gif"; | |
110 | } | |
111 | ||
112 | ||
113 | echo $cmd; | |
114 | shell_exec($cmd); | |
115 | return "Pozor pozor! Vymena ikony pravdepodobne prebehla uspesne ale tvoj prehliadac ju ma ulozenu v cache. Klikni preto prosim <a href='http://www.kyberia.sk/images/users/$user_name.gif'>sem</a> a daj refresh. Mala by sa nacitat nova ikona. Ked to neurobis tak nebravcuj."; | |
116 | } | |
117 | } | |
118 | ||
119 | function updatePassword() { | |
120 | global $kyberia; | |
121 | global $user_id; | |
122 | global $user_name; | |
123 | $oldpassword=$_POST['oldpassword']; | |
124 | $password1=$_POST['password1']; | |
125 | $password2=$_POST['password2']; | |
126 | $set=$kyberia->query("select * from user where id='$user_id' and password='".md5($oldpassword)."'"); | |
127 | if($set->getNumRows()==0) { | |
128 | global $error; | |
129 | $error="Zadal si zle stare heslo."; | |
130 | return false; | |
131 | } | |
132 | elseif($password1!=$password2) { | |
133 | global $error; | |
134 | $error="Heslo a overovacie heslo niesu rovnake. Prosim skus znova."; | |
135 | return false; | |
136 | } | |
137 | elseif(strlen($password1)<6) { | |
138 | global $error; | |
139 | $error="Heslo musi mat minimalne 6 znakov. Noze potrap mozocek."; | |
140 | return false; | |
141 | } | |
142 | else { | |
143 | $kyberia->query("update user set password='".md5($password1)."' where id='$user_id'"); | |
144 | return "heslo uspesne zmenene"; | |
145 | } | |
146 | ||
147 | } | |
148 | ||
149 | } |