-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotesave.php
52 lines (39 loc) · 1.19 KB
/
notesave.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
<?php
$page="notesave";
$reqauth=true;
include ("inc/config.php");
include ("inc/form.php");
include ("inc/crypt.php");
check_csrf();
sql_conn();
$userid = $_SESSION['id'];
$key = $_SESSION['key'];
$authed_login = $_SESSION['login'];
$now = time();
$itemid = get_post('itemid');
$notedata = get_post('notes');
$catid = get_post('catid');
$noteid = get_post('noteid');
$site = get_post('site');
if ($itemid==0) $noteid=0;
$newnoteid = $noteid;
if (!empty($notedata)){
if ($noteid==0){
$query="insert into notes values(NULL, '$notedata')";
} else {
$query="update notes set note='$notedata' where id=$noteid";
}
if (!$result=sql_query($db, $query)){
set_error("Error: ($page) saving password notes for '$site': ". sql_error($db));
} else {
if ($noteid==0) $newnoteid=sql_insert_id($db);
}
if ($noteid != $newnoteid){
$query="update logins set noteid='$newnoteid' where id='$itemid'";
if (!$result=sql_query($db, $query)){
set_error("Error: ($page) updating logins noteid: ". sql_error($db));
}
set_status("Notes updated for \"$site\"");
}
}
header("Location: catview.php?catid=$catid");