psql db schema test
[mirrors/Kyberia-bloodline.git] / trash / login2.inc
CommitLineData
51ff3226 1<?php
2function login2() {
3
4 global $db,$error,$node_id;
5 $login=addslashes($_POST['login']);
6 $password=$_POST['password'];
7 $hash=md5($password);
8 $login_type=$_POST['login_type'];
9
10 if (!session_id()) {
11 $error='asi nemas zapnute cookies alebo co';
12 return false;
13 }
14
15 switch ($login_type) {
16 case "name":
17 $q="select * from users where login='$login'";
18 $set=$db->query($q);
19 $set->next();
e909f81b 20 require(INCLUDE_DIR.'ldap.inc');
51ff3226 21 $user_id=$set->getString('user_id');
22 $user_name=$login;
23 break;
24 case "id":
25 $q="select * from users where user_id='$login'";
26 $set=$db->query($q);
27 $set->next();
e909f81b 28 require(INCLUDE_DIR.'ldap.inc');
51ff3226 29 $user_id=$login;
30 $user_name=$set->getString('user_name');
31 break;
32 }
33
34 $ldap_response=LDAPuser::auth($user_id,$password);
35 if ($set->getString('password')!=$hash and !$ldap_response) {
36 $error="Zadal si nespravne uzivatelske meno alebo heslo. Rob so sebou nieco";
e23557a6 37 $log->log('login',$node_id,'failed',$_SERVER['REMOTE_ADDR'],$login);
51ff3226 38 return false;
39 }
40
41 elseif ($set->getString('user_status')=='waiting') {
42 $error='Tvoja registracia este nebola schvalena.';
43 return false;
44 }
45
46 else {
47 $user_id=$set->getString('user_id');
48 $cube_vector=$set->getString('cube_vector');
49
50 // saves friends list as an array into user session
51 $q="select distinct node_parent,node_name from nodes where node_creator='$user_id' and external_link='session://friend' order by node_parent";
52 $friendset=$db->query($q);
53
54 while ($friendset->next()){
55 $_SESSION['friends'][$friendset->getString('node_parent')]=true;
56 }
57
58 $q="select nodes.node_name,nodes.node_id from node_access left join nodes on node_access.node_id=nodes.node_id where node_access.user_id='$user_id' and node_bookmark='yes' order by node_name";
59 $bookmarkset=$db->query($q);
60
61 while ($bookmarkset->next()){
62 $_SESSION['bookmarks'][$bookmarkset->getString('node_id')]=$bookmarkset->getString('node_name');
63 }
64
65 //saves ignored users as an array into user session
66 $q="select node_parent,node_name from nodes where node_creator='$user_id' and external_link='session://ignore'";
67 $ignoreset=$db->query($q);
68
69 while ($ignoreset->next()){
70 $_SESSION['ignore'][$ignoreset->getString('node_parent')]=true;
71 }
72
73 LDAPuser::replicate($user_name,$user_id,$password);
74
75 $_SESSION['user_id']=$user_id;
76
77 $_SESSION['user_name']=$user_name;
78 if (!empty($cube_vector)) $_SESSION['cube_vector']=$cube_vector;
79 if (empty($_SESSION['template_set'])) $_SESSION['template_set']=$set->getString('template_set');
80 if (is_numeric($_POST['screen_width'])) $_SESSION['browser']['screen_width']=$_POST['screen_width'];
81 if (is_numeric($_POST['screen_height'])) $_SESSION['browser']['screen_height']=$_POST['screen_height'];
82 $_SESSION['listing_amount']=$set->getString('listing_amount');
83
84 $_SESSION['listing_order']=$set->getString('listing_order');
85 $_SESSION['header_id']=$set->getString('header_id');
e23557a6 86 $log->log('login',$node_id,'ok',$user_name);
51ff3226 87 }
88 return true;
89}
e909f81b 90?>
This page took 0.376287 seconds and 4 git commands to generate.