-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchangeAns.php
More file actions
60 lines (60 loc) · 1.57 KB
/
changeAns.php
File metadata and controls
60 lines (60 loc) · 1.57 KB
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
<?php
function setSalt($password)
{
$ret = array(
"password" => "",
"salt" => ""
);
$ret['salt'] = md5(uniqid(rand(), true));
$ret['password'] = hash("sha256", $ret['salt'].$password);
return $ret;
}
if(!isset($_SESSION))
session_start();
if ((!isset($_SESSION['type']))||$_SESSION['type']!="mod") {
$_SESSION = array();
?>
<style type="text/css">
form input
{
border: 1px solid black;
border-radius: 3px;
outline: none;
}
</style>
<div style="position: absolute;display: block; left: 50%; transform: translateX(-50%);">
<form action="<?php echo $GLOBALS['host'] ; ?>backend.php?file=/Mod/Login" method="post" style="position: relative;">
<input type="text" name="user" value="Email"><br>
<input type="password" name="pass" ><br>
<input type="submit" name="submit">
</form>
</div>
<?php } else { ?>
<?php
if(!isset($_POST['qno']))
{
?>
<form method="post" action="/changePass.php">
<input type="text" name="qno" placeholder="Q No"/>
<input type="text" name="Ans" placeholder="Answer"/>
<input type="submit" name="submit" />
</form>
<?php
}
else
{
include_once "qn_config/conf.php";
include_once 'qn_lib/mod_manage.php';
if(!isset($_POST['qno'])||!isset($_POST['Ans']))
exit("error in submission");
$conne = qnDB_M::start();
$resultFn = setSalt($_POST['Ans']);
$sql = 'UPDATE qn_ques SET Answer="'.$resultFn['password'].'", qn_salter="'.$resultFn['salt'].'" WHERE q_id='.$_POST['qno'] . ';';
echo $sql;
$query = mysqli_query($conne, $sql);
qnDB_M::stop();
if(!$query)
exit("Query failed" . mysqli_error($conne));
else
exit("Query passed");
} } ?>