-
Notifications
You must be signed in to change notification settings - Fork 207
/
Validator.php
133 lines (119 loc) · 3.61 KB
/
Validator.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
<?php
#**************************************************************************
# openSIS is a free student information system for public and non-public
# schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
# openSIS is web-based, open source, and comes packed with features that
# include student demographic info, scheduling, grade book, attendance,
# report cards, eligibility, transcripts, parent portal,
# student portal and more.
#
# Visit the openSIS web site at http://www.opensis.com to learn more.
# If you have question regarding this system or the license, please send
# an email to [email protected].
#
# This program is released under the terms of the GNU General Public License as
# published by the Free Software Foundation, version 2 of the License.
# See license.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include 'RedirectRootInc.php';
include 'ConfigInc.php';
include 'Warehouse.php';
$flag = $_GET['u'];
$usr = substr($flag, -4);
$userid = $_GET['userid'];
$profileid = $_GET['profileid'];
// ------------------------ For Unique Checking ---------------------------------- //
$un = substr($flag, 0, -4);
$un = strtoupper($un);
// ------------------------ For Unique Checking ---------------------------------- //
switch ($_GET['validate'])
{
case 'pass':
$res_pass_chk = DBQuery("SELECT * FROM login_authentication WHERE password = '".md5($_GET['password'])."' AND user_id!='".$_GET['stfid']."' AND profile_id=0");
$num_pass = $res_pass_chk->num_rows;
if($num_pass==0)
{
echo 1;
}
break;
case 'pass_o':
$res_pass_chk = DBQuery("SELECT * FROM login_authentication WHERE password = '".md5($_GET['password'])."' AND profile_id=0");
$num_pass = $res_pass_chk->num_rows;
if($num_pass==0)
{
echo '1_'.$_GET['opt'];
}
else
{
echo '0_'.$_GET['opt'];
}
break;
default :
if($usr == 'user')
{
if (trim($userid) != '')
$result = DBGet(DBQuery("SELECT username FROM login_authentication WHERE NOT(user_id = '" . $userid . "' AND profile_id = '".$profileid."')"));
else
$result = DBGet(DBQuery("SELECT username FROM login_authentication"));
$xyz = 0;
foreach ($result as $k => $v)
{
$unames[$xyz] = strtoupper($v['USERNAME']); // For Unique Checking.
$xyz++;
}
if ($un != '')
{
if (in_array ($un, $unames))
{
echo '0';
}
else
{
echo '1';
}
exit;
}
}
else
{
if (trim($userid) != '')
$result = DBGet(DBQuery("SELECT username FROM login_authentication WHERE NOT(user_id = '" . $userid . "' AND profile_id = '".$profileid."')"));
else
$result = DBGet(DBQuery("SELECT username FROM login_authentication"));
$xyz = 0;
foreach ($result as $k => $v)
{
$unames[$xyz] = strtoupper($v['USERNAME']); // For Unique Checking.
$xyz++;
}
if ($un != '')
{
if(is_array($unames))
{
if (in_array ($un, $unames))
{
echo '0';
}
else
{
echo '1';
}
} else {
echo '1';
}
exit;
}
}
break;
}
?>