-
Notifications
You must be signed in to change notification settings - Fork 1
/
names_list.php
executable file
·150 lines (129 loc) · 6.81 KB
/
names_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
include("data.php");
$keyword = $_REQUEST['str'];
$con=mysql_connect($DatabaseServer,$DatabaseUsername,$DatabasePassword);
$s=mysql_select_db($DatabaseName,$con);
if($keyword=="")
echo "";
else
{
// $sql_staff="SELECT * FROM staff WHERE first_name LIKE '$keyword%' and username IS NOT NULL ORDER BY last_name";
$sql_staff="SELECT * FROM login_authentication,staff WHERE login_authentication.user_id=staff.staff_id and first_name LIKE '$keyword%' and username IS NOT NULL and login_authentication.profile_id NOT IN(3,4) ORDER BY last_name";
// $sql_student="SELECT * FROM students WHERE first_name LIKE '$keyword%' and username IS NOT NULL ORDER BY last_name";
$sql_student="SELECT * FROM login_authentication,students WHERE login_authentication.user_id=students.student_id and first_name LIKE '$keyword%' and username IS NOT NULL and login_authentication.profile_id=3 ORDER BY last_name";
$sql_people="SELECT * FROM login_authentication,people WHERE login_authentication.user_id=people.staff_id and first_name LIKE '$keyword%' and username IS NOT NULL and login_authentication.profile_id=4 ORDER BY last_name";
$result_staff = mysql_query($sql_staff) or die(mysql_error());
$result_student = mysql_query($sql_student) or die(mysql_error());
$result_people = mysql_query($sql_people) or die(mysql_error());
// print_r($result_staff);
if(mysql_num_rows($result_staff))
{
while($row = mysql_fetch_array($result_staff))
{
$str = strtolower($row['last_name'].' '.$row['first_name'].','.$row['username']);
if(trim($row['username']!=""))
echo '<a id="search'.$row['staff_id'].'" onclick="a(\''.$row['username'].'\')">'.$str.'</a><br>';
}
}
else
echo "";
if(mysql_num_rows($result_student))
{
while($row_student = mysql_fetch_array($result_student))
{
$str = strtolower($row_student['last_name'].' '.$row_student['first_name'].','.$row_student['username']);
if(trim($row_student['username']!=""))
echo '<a id="search'.$row_student['student_id'].'" onclick="a(\''.$row_student['username'].'\')">'.$str.'</a><br>';
}
}
else
echo "";
if(mysql_num_rows($result_people))
{
while($row_people = mysql_fetch_array($result_people))
{
$str = strtolower($row_people['last_name'].' '.$row_people['first_name'].','.$row_people['username']);
if(trim($row_people['username']!=""))
echo '<a id="search'.$row_people['staff_id'].'" onclick="a(\''.$row_people['username'].'\')">'.$str.'</a><br>';
}
}
else
echo "";
}
$pos=strpos($keyword,',');
$lastpos=strrpos($keyword,',');
$str1=substr($keyword,$pos+1,strlen($keyword));
$str2=substr($keyword,$lastpos+1,strlen($keyword));
if($str2!="")
{
if($pos!=0 || $lastpos!=0)
{
// $sql_staff="SELECT * FROM staff WHERE (first_name LIKE '$str1%' or first_name LIKE '$str2%') and username IS NOT NULL ORDER BY last_name";
$sql_staff="SELECT * FROM login_authentication,staff WHERE login_authentication.user_id=staff.staff_id and (first_name LIKE '$str1%' or first_name LIKE '$str2%') and username IS NOT NULL and login_authentication.profile_id NOT IN(3,4) ORDER BY last_name";
// $sql_student="SELECT * FROM students WHERE (first_name LIKE '$str1%' or first_name LIKE '$str2%') and username IS NOT NULL ORDER BY last_name";
$sql_student="SELECT * FROM login_authentication,students WHERE login_authentication.user_id=students.student_id and (first_name LIKE '$str1%' or first_name LIKE '$str2%') and username IS NOT NULL and login_authentication.profile_id=3 ORDER BY last_name";
$sql_people="SELECT * FROM login_authentication,people WHERE login_authentication.user_id=people.staff_id and (first_name LIKE '$str1%' or first_name LIKE '$str2%') and username IS NOT NULL and login_authentication.profile_id=4 ORDER BY last_name";
$result_staff = mysql_query($sql_staff) or die(mysql_error());
$result_student = mysql_query($sql_student) or die(mysql_error());
$result_people = mysql_query($sql_people) or die(mysql_error());
if(mysql_num_rows($result_staff))
{
while($row = mysql_fetch_array($result_staff))
{
$str = strtolower($row['last_name'].' '.$row['first_name'].','.$row['username']);
$newpos=$lastpos+1;
if(trim($row['username']!=""))
echo '<a id="search'.$row['staff_id'].'" onclick="b(\''.$newpos.'\',\''.$row['username'].'\');">'.$str.'</a><br>';
}
}
else
echo "";
if(mysql_num_rows($result_student))
{
while($row_student = mysql_fetch_array($result_student))
{
$str = strtolower($row_student['last_name'].' '.$row_student['first_name'].','.$row_student['username']);
$newpos=$lastpos+1;
if(trim($row_student['username']!=""))
echo '<a id="search'.$row_student['student_id'].'" onclick="b(\''.$newpos.'\',\''.$row_student['username'].'\')">'.$str.'</a><br>';
}
}
else
echo "";
if(mysql_num_rows($result_people))
{
while($row_student = mysql_fetch_array($result_people))
{
$str = strtolower($row_people['last_name'].' '.$row_people['first_name'].','.$row_people['username']);
$newpos=$lastpos+1;
if(trim($row_people['username']!=""))
echo '<a id="search'.$row_people['student_id'].'" onclick="b(\''.$newpos.'\',\''.$row_people['username'].'\')">'.$str.'</a><br>';
}
}
else
echo "";
}
}
else
echo "";
$group_id=mysql_query("select distinct group_id,group_name from mail_group where group_name LIKE '$keyword%'");
if(mysql_num_rows($group_id))
{
while($row=mysql_fetch_array($group_id))
{
$str=strtolower($row['group_name']);
$id=$row['group_id'];
$group=mysql_query("select * from mail_groupmembers where group_id=$id");
while($r=mysql_fetch_array($group))
{
$name[]=$r['user_name'];
}
if(!empty($name) && count($name)>0)
$username=implode(',',$name);
echo '<a id="search'.$row['group_id'].'" onclick="a(\''.$str.'\')">'.$str.'</a><br>';
}
}
else {
echo "";
}
?>