-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser1.php
More file actions
65 lines (48 loc) · 1.28 KB
/
user1.php
File metadata and controls
65 lines (48 loc) · 1.28 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
61
62
63
64
65
<?php
include("header.php");
if($_SESSION['flag']=="allowed")
{
$sub = $_POST['sub'];
$name = $_POST['name'];
$pass = $_POST['password'];
$check_user = `cat /etc/passwd | grep $name`;
if($sub=="sub1")
{
if($check_user)
{
echo '<label class="alert alert-danger"> User <b>'.$name.'</b> already exists!!</label>';
}
else
{
echo '<ol class="breadcrumb col-xs-offset-1">
<li><a href="index.php">Home</a></li>
<li><a href="system.php">Systems</a></li>
<li class="active">AddUser</li>
</ol> <br>';
$cmd = `sudo useradd $name`;
$cmd1 = `echo $pass | sudo passwd --stdin $name`;
echo '<label class="alert alert-success"> User <b>'.$name.'</b> succesfully Added!!</label>';
}
}
if($sub=="sub2")
{
if($check_user)
{
echo '<ol class="breadcrumb col-xs-offset-1">
<li><a href="index.php">Home</a></li>
<li><a href="system.php">Systems</a></li>
<li class="active">DeleteUser</li>
</ol> <br>';
$x = `sudo userdel -r $name`;
echo $x;
echo '<label class="alert alert-success"> User <b>'.$name.'</b> succesfully Deleted</label>';
}
else
{
echo '<label class="alert alert-danger"> User <b>'.$name.'</b> does not exist!!</label>';
}
}
}
else
header("location:index.php");
?>