-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkuser.php
151 lines (119 loc) · 3.91 KB
/
mkuser.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
151
<?php
include_once 'phppagestart.php';
echo '<!DOCTYPE html>';
// error_reporting( -1 );
// ini_set( 'display_errors', 1 );
include_once('lang.php');
$newuser=$_POST['newuser'];
$newpass=$_POST['newpass'];
$now=time();
if ((isset($_SESSION['username'])) && ($_SESSION['loggedin']=='yes') && (isset($_SESSION['password'])) && (isset($_SESSION['expire'])) && ($_SESSION['expire'] >= $now))
{
if (($_SESSION['expire'] - $now) <= $addtime)
{
$_SESSION['expire']=($_SESSION['expire'] + $buytime);
}
else
{
echo '';
}
}
else
{
echo '';
}
?>
<html><head>
<?php
// one page method below
if (($_POST['newuser'] !='null' ) && ($_POST['newuser'] !='' ) && ($_POST['newuser'] !='/' ) && ($_POST['newuser'] !='admin' ) && ($_POST['newuser'] !='Admin' ))
{
// echo '<meta charset="UTF-8">';
echo "<meta HTTP-EQUIV='REFRESH' content='1; url=usermanager.php?rand=$rand&user=$newuser'>";
}
else
{
echo '';
}
?>
<meta charset="UTF-8">
<meta name="author" content="root">
<meta name="robots" content="noindex">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title><?php echo $title; ?></title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head><body>
<table id='page_header'><tr><td>
<a href='airscan.php'>
<img id='logo' src='images/AirScan.png' alt='AirScan'>
</a></td>
</tr>
<tr><td><hr></td></tr>
</table>
<?php
if (($_SESSION['username'] == 'admin') && ($_SESSION['loggedin'] == 'yes') && ($pass=$_SESSION['password']))
{
if ((($_POST['newuser'] != '' ) && ($_POST['newuser'] != '' ) && ($_POST['newuser'] != '/' ) && ($_POST['newuser'] != 'admin' ) && ($_POST['newuser'] != 'Admin' )) && (($_POST['newpass'] !='null' ) && ($_POST['newpass'] != '' ) && ($_POST['newpass'] != '/' )))
{
$mkuser1 = 'mkdir '.$filepath.$newuser;
$mkdir1 = shell_exec($mkuser1);
//echo "<pre>$mkdir1</pre><br/><br/>";
$copytemplate1='cp usertemplate/index.php '.$filepath.$newuser;
$copyindex1 = shell_exec($copytemplate1);
//echo '<pre>'.$copytemplate.'</pre><br/><br/>';
$mkuser2 = 'mkdir '.$usersfilespath.$newuser;
$mkdir2 = shell_exec($mkuser);
//echo "<pre>$mkdir2</pre><br/><br/>";
// fopen("users/$newuser.php", "w")
$newuserfile = fopen($usersfilespath.$_POST['newuser'].'.php', 'w') or die("Unable to open file!");
$opentxt = "<?php\n";
fwrite($newuserfile, $opentxt);
$eol="\n";
// $newpassword = '$pass = '.$_POST['newpass'].';';
// fwrite($newuserfile, $newpassword);
// fwrite($newuserfile, $eol);
// $newpath = '$userpath = scans/'.$_POST['newuser'].';';
$newpassword = '$pass = \''.$_POST['newpass'].'\';';
fwrite($newuserfile, $newpassword);
fwrite($newuserfile, $eol);
//$newpath = '$userpath = $filepath.$_POST['newuser'].'/\';';
// $newpath = '$userpath = \'scans/'.$_POST['newuser'].'/\';'
//$newpath = '$userpath = $filepath.$_POST['newuser'].'/\';';
$newpath = '$userpath = \''.$filepath.$_POST['newuser'].'/\';';
fwrite($newuserfile, $newpath);
fwrite($newuserfile, $eol);
$closetxt = "?>\n";
fwrite($newuserfile, $closetxt);
fclose($newuserfile);
echo '<br/><center><span style="color:#666; font-weight:bold">'.$newuser.' '.$createdsuccessfully.'</span><br/></center>';
// echo "<br/><a href='usermanager.php?user=$newuser>Go back</a><br/>";
}
else
{
echo '<br/><center>'.$sorryerror.'
<br/><br/>
<button onclick="goBack()">'.$goback.'</button>
<script>
function goBack() {
window.history.back();
}
</script></center>';
}
}
else
{
echo '<br/><center>'.$sorrymustlogin.'
<br/><br/>
<button onclick="goBack()">'.$goback.'</button>
<script>
function goBack() {
window.history.back();
}
</script></center>';
}
echo $usersfilepath;
?>
</body></html>`