-
Notifications
You must be signed in to change notification settings - Fork 0
/
identities_setup.php
109 lines (94 loc) · 3.05 KB
/
identities_setup.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
<?php include('MyFunctions.inc.php');
if (isset($_POST["step"])) $step = $_POST["step"]; else $step = "";
$name = "";
if($step != '1')
{
if (isset($_GET["id"])) $id = $_GET["id"]; else $id = "";
if (!empty($id))
{
// We modify an existing reminder
$result = mysql_query( "SELECT * FROM `identities` where `id`='$id'" )
or die (mysql_error()."<br>Couldn't execute query: $query");
$row = mysql_fetch_array( $result );
$name = $row["name"];
$identity_file = $row["identity_file"];
echo ("$name\n");
}
?>
<html>
<HEAD>
<TITLE>Add Modify Identities</TITLE>
<LINK REL=STYLESHEET HREF="skm.css" TYPE="text/css">
</HEAD>
<BODY>
<?php start_main_frame("<a href=\"show_all_hosts.php\"> SKM </a> > Add/Modify Identities"); ?>
<?php start_left_pane(); ?>
<?php display_menu(); ?>
<?php end_left_pane(); ?>
<?php start_right_pane(); ?>
<center>
<form name="identities_setup" action="identities_setup.php" enctype="multipart/form-data" method="post">
<fieldset><legend>Add / Modify an identity account</legend>
<table border='0' align='center' class="modif_contact">
<tr>
<td class="Type">Identity Name : </td>
<td class="Content" width="80%">
<input name="name" size="50" type="text" maxlength="255" value="<?php echo("$name"); ?>">
</td>
</tr>
<tr>
<td class="Type">Private key file : </td>
<td class="Content" width="80%">
<input type="file" name="ufile">
</td>
</tr>
</table>
</fieldset>
<center>
<input name="step" type="hidden" value="1">
<input name="id" type="hidden" value="<?php echo("$id");?>">
<input name="submit" type="submit" value="submit">
</center>
</form>
</center>
<? end_right_pane(); ?>
<? end_main_frame(); ?>
</body>
</html>
<?php
}
else
{
$id = $_POST['id'];
$name = $_POST['name'];
$fileName = $_FILES['ufile']['name'];
$tmpName = $_FILES['ufile']['tmp_name'];
$fileSize = $_FILES['ufile']['size'];
$fileType = $_FILES['ufile']['type'];
// Slurp the content of the file into a variable
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
/*
echo("<html><head></head><body>");
echo("$id $name $fileName $tmpName $fileSize $fileType $content ");
echo("</body></html>");
*/
if(empty($id)){
// this is a new account
mysql_query( "INSERT INTO `identities` (`name`,`identity_file`,`file_size` ) VALUES('$name','$content','$fileSize')" ) or die(mysql_error()."<br>Couldn't execute query: $query");
header("Location:identities.php");
echo ("Account Added, redirecting...");
exit ();
} elseif ($id > 1) {
mysql_query( "UPDATE `identities` SET `name` = '$name', `identity_file`='$content', `file_size`='$fileSize' WHERE `id` = '$id' " );
// Let's go to the Reminder List page
header("Location:identities.php");
echo ("Account Modified, redirecting...");
exit ();
} else {
die('You are really not allowed to edit the root user');
}
}
?>