This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
manage.php
171 lines (153 loc) · 6.04 KB
/
manage.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
// ****************************************************************************
//
// ZZJ Audit Tool v1.5
// Copyright (C) 2010 ZigZagJoe ([email protected]) and
// Copyright (C) 2012 Equto ([email protected])
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License,or
// (at your option) any later version.
//
// 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, write to the Free Software
// Foundation, Inc.,59 Temple Place,Suite 330,Boston,MA 02111-1307 USA
//
// ****************************************************************************
// acount management
define("MANAGE_PHP", true);
if( isset( $_SERVER['HTTPS'] ) ) {
define("URL_SCHEME", "https" );
}
else {
define("URL_SCHEME", "http" );
}
define("SELF_URL", URL_SCHEME."://" . $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?");
require_once("eve.php");
require_once("audit.funcs.php");
require_once("audit.views.php");
require_once("login.php");
require_once("manage.func.php");
if(!loggedIn()){
echo "<span class=\"infobar\">< ".get_loginbar()."></span><br>";
echo get_form_divs();
echo "You are not logged in";
insert_header("Jackknife - Manage Account");
}else
#save a key
if(isset($_GET['saveKey'])){
if(isset($_POST['save'])){
$id=add_api_key($Db,$_SESSION['uid'],$_POST['apik'],$_POST['vcode'],$_POST['keyName'],$_POST['notes']);
echo $id['id'];
echo"<br><a href='index.php'> Auditor</a> <a href='manage.php'> Manage Account </a>";
insert_header("Jackknife - Save Key");
}else{
echo "<span class=\"infobar\">< ".get_loginbar(true)."></span><br>";
echo get_form_divs();
echo save_api_view();
insert_header("Jackknife - Save Key");
}
}else
#remove a key
if(isset($_GET['removeKey'])){
insert_header("Jackknife - Remove Key");
if(isset($_GET['id'])){
$id=remove_api_key($Db,$_GET['id']);
echo $id['id'];
}else{
echo "Key to remove not supplied";
}
echo"<br><a href='index.php'> Auditor</a> <a href='manage.php'> Manage Account </a>";
}else {
# editing a key name
if (isset($_GET['editName'])) {
if (isset($_POST['name'])) {
$id = edit_api_key($Db, $_POST['id'], $_POST['name']);
redirect("/manage.php");
} else {
$result = $Db->selectWhere("keyInformation",['id'=>$_GET['id'],'userID'=>$_SESSION['uid']],['keyName']);
if ($result != false) {
if ($result->rows > 0) {
$row = $result->results[0];
echo <<<EOD
<form id='name' action="manage.php?editName" method="POST">
<input type="hidden" name="id" value="{$_GET['id']}">
<input type='text' name='name' style=\"display:none;\"id='name' value='{$row['keyName']}'/>
<input type="submit" value="Edit name">
</form>
EOD;
} else {
echo "This key does not exist, please try again";
}
}
}
echo "<br><a href='index.php'> Auditor</a> <a href='manage.php'> Manage Account </a>";
insert_header("Jackknife - Edit Notes");
} else
#Editing notes of a key
if (isset($_GET['editNotes'])) {
# if notes have been changed
if (isset($_POST['Notes'])) {
$id = edit_api_key($Db, $_POST['id'], $name = "", $_POST['Notes']);
redirect("/manage.php");
} else {
# first page
$result = $Db->selectWhere("keyInformation",['id'=>$_GET['id'],'userID'=>$_SESSION['uid']],['notes']);
if ($result != false) {
if ($result->rows > 0) {
$row = $result->results[0];
echo <<<EOD
<form id='notes' action="manage.php?editNotes" method="POST">
<input type="hidden" name="id" value="{$_GET['id']}">
<textarea name="Notes" Cols="50" Rows="15" id="noteText" style="resize:none;background-color:#222222; color:#EEEEEE;" onKeyDown="limitText(this,3000)">{$row['notes']}</textarea><br>
<input type="submit" value="Save Notes">
</form>
EOD;
} else {
echo "This key does not exist, please try again";
}
}
}
echo "<br><a href='index.php'> Auditor</a> <a href='manage.php'> Manage Account </a>";
insert_header("Jackknife - Edit Notes");
} else
# Editing password and emails
if (isset($_GET['editAccount'])) {
if (isset($_POST['oldPass'])) {
if (isset($_POST['email']) && ($_POST['email'] != $_SESSION['email']))
$email = (($user->changeEmail($_POST['email'], $_POST['oldPass']) > 0) ? "Email changed" : "");
if (isset($_POST['Password1']) && isset($_POST['Password2']) && ($_POST['Password2'] == $_POST['Password1']) && !empty($_POST['Password1']))
$pass = (($user->changePassword($_POST['Password1'], $_POST['oldPass']) > 0) ? "Password changed" : "");
if ($email && $pass)
$pass .= " and ";
if ($pass || $email)
mail($_SESSION['email'], $pass . $email, wordwrap("Your " . $pass . $email . " has been changed for Eve Jackknife", 70));
redirect("/manage.php");
} else {
# account page
$result = $Db->selectWhere("accounts",['id'=>$_GET['id']]);
if ($result != false) {
if ($result->rows > 0) {
$row = $result->results[0];
}
}
}
echo "<br><a href='index.php'> Auditor</a> <a href='manage.php'> Manage Account </a>";
insert_header("Jackknife - Edit Notes");
} #standard account page
else {
echo "<span class=\"infobar\">< " . get_loginbar() . "<a onclick=\"if(!show_div('account')) return false;\" href='manage.php?editAccount=1'> Account Settings</a> ></span><br>";
echo get_form_divs();
echo makeDiv("account", get_account_change($_SESSION['email']));
echo management_view($Db);
insert_header("Jackknife - Manage Account");
$_SESSION['redirect'] = "manage.php";
}
}
?>