51ff3226 |
1 | <?php |
2 | function login_test() { |
3 | // lockout capatibility |
4 | // with freezy's mod's |
5 | // with honeypot. check this:: http://kyberia.sk/id/2192591 |
6 | |
7 | global $db,$error,$node_id; |
8 | $login=addslashes($_POST['login']); |
9 | $password=$_POST['password']; |
10 | // $hash=md5($password); |
11 | $login_type=$_POST['login_type']; |
12 | $lo=$login.'[Locked_OUT]'; |
13 | if (!session_id()) { |
14 | $error='asi nemas zapnute cookies alebo co'; |
15 | return false; |
16 | } |
17 | |
18 | switch ($login_type) { |
19 | case "name": |
20 | $q="select * from users where login='$login' || '$lo'"; |
21 | echo $q; |
22 | $set=$db->query($q); |
23 | $set->next(); |
e909f81b |
24 | require(INCLUDE_DIR.'ldap.inc'); |
51ff3226 |
25 | $user_id=$set->getString('user_id'); |
26 | $user_name=$set->getString('login'); |
27 | break; |
28 | case "id": |
29 | $q="select * from users where user_id='$login'"; |
30 | $set=$db->query($q); |
31 | $set->next(); |
e909f81b |
32 | require(INCLUDE_DIR.'ldap.inc'); |
51ff3226 |
33 | $user_id=$set->getString('user_id'); |
34 | $user_name=$set->getString('login'); |
35 | break; |
36 | } |
37 | |
38 | $ldap_response=LDAPuser::auth($user_id,$password); |
39 | // if (($set->getString('password')!=$hash) && !$ldap_response) { |
40 | if (!$ldap_response) { |
41 | $error="Zadal si nespravne uzivatelske meno [alebo id] alebo heslo. Rob so sebou nieco"; |
e23557a6 |
42 | // $log->log('login',$node_id,'failed',$_SERVER['REMOTE_ADDR'],$login); |
51ff3226 |
43 | return false; |
44 | } |
45 | |
46 | elseif ($set->getString('header_id')==2091520) { |
47 | $error='Tvoja registracia este nebola schvalena.'; |
48 | return false; |
49 | } |
50 | |
51 | |
52 | |
53 | else { |
54 | $now=date("Y-m-d H:i:s"); |
55 | $lockout=$set->getString('acc_lockout'); |
56 | if ($lockout >= $now ){ |
57 | global $error; |
58 | $error="Account lockout mas aktivny. Sorry ale neprihlasis sa minimalne do $lockout. Prajem |
59 | prijemnu odvykacku:-)"; |
60 | return false;} |
61 | |
62 | |
63 | |
64 | $cube_vector=$set->getString('cube_vector'); |
65 | |
66 | // saves friends list as an array into user session |
67 | $q="select distinct node_parent,node_name from nodes where node_creator='$user_id' and |
68 | external_link='session://friend' order by node_parent"; |
69 | $friendset=$db->query($q); |
70 | |
71 | while ($friendset->next()){ |
72 | $_SESSION['friends'][$friendset->getString('node_parent')]=true; |
73 | } |
74 | |
75 | $q="select nodes.node_name,nodes.node_id from node_access left join nodes on node_access.node_id=nodes.node_id |
76 | where node_access.user_id='$user_id' and node_bookmark='yes' order by node_name"; |
77 | $bookmarkset=$db->query($q); |
78 | |
79 | while ($bookmarkset->next()){ |
80 | |
81 | $_SESSION['bookmarks'][$bookmarkset->getString('node_id')]=$bookmarkset->getString('node_name'); |
82 | } |
83 | |
84 | //saves ignored users as an array into user session |
85 | $q="select node_parent,node_name from nodes where node_creator='$user_id' and |
86 | external_link='session://ignore'"; |
87 | $ignoreset=$db->query($q); |
88 | |
89 | while ($ignoreset->next()){ |
90 | $_SESSION['ignore'][$ignoreset->getString('node_parent')]=true; |
91 | } |
92 | |
93 | LDAPuser::replicate($user_name,$user_id,$password); |
94 | |
95 | $_SESSION['user_id']=$user_id; |
96 | $_SESSION['user_name']=addslashes($user_name); |
97 | if (!empty($cube_vector)) $_SESSION['cube_vector']=$cube_vector; |
98 | if (empty($_SESSION['template_set'])) |
99 | $_SESSION['template_set']=$set->getString('template_set'); |
100 | if (is_numeric($_POST['screen_width'])) |
101 | $_SESSION['browser']['screen_width']=$_POST['screen_width']; |
102 | if (is_numeric($_POST['screen_height'])) |
103 | $_SESSION['browser']['screen_height']=$_POST['screen_height']; |
104 | $_SESSION['listing_amount']=$set->getString('listing_amount'); |
105 | |
106 | $_SESSION['listing_order']=$set->getString('listing_order'); |
107 | $_SESSION['header_id']=$set->getString('header_id'); |
e23557a6 |
108 | $log->log('login',$node_id,'ok',$user_name); |
51ff3226 |
109 | if ($user_id==1583521){ |
110 | $ip=$_SERVER['REMOTE_ADDR']; |
111 | $forwarded=$_SERVER['HTTP_X_FORWARDED_FOR']; |
112 | $ubik['mail_to']="789"; |
113 | $ubik['mail_text']="kostra logged from ip: $ip HTTP_X_FORWARDED_FOR is: |
114 | $forwarded"; |
115 | ubik::ubikMail($ubik); |
116 | } |
117 | |
118 | } |
119 | return true; |
120 | } |
e909f81b |
121 | ?> |