-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewnote.php
More file actions
executable file
·111 lines (92 loc) · 3.41 KB
/
newnote.php
File metadata and controls
executable file
·111 lines (92 loc) · 3.41 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
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
<?php $sqlpath = $_SERVER['DOCUMENT_ROOT'];
$sqlpath .= "/sql-connect.php";
include_once($sqlpath);
$title = 'Untitled';
$body = '';
$edited = date('ymdHi');
$dailyStatus = $_GET['dailyStatus'];
$currentDate = date("Ymd");
$noteExists = false;
$existID = '';
$currentYear = date("Y");
$currentMonth = date('m - F Y');
$sql = "SELECT title,id FROM notes WHERE lineage LIKE '259-%' && title LIKE '$currentDate%' ORDER BY title ASC";
$sqldata = mysqli_query($dbcon, $sql) or die('error getting data');
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
$noteExists = true;
$existID = $row['id'];
}
$sql = "SELECT title,id FROM notes WHERE lineage LIKE '259-%' && title LIKE '$currentYear'";
$sqldata = mysqli_query($dbcon, $sql) or die('error getting data');
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
$yearExists = true;
$yearID = $row['id'];
}
$sql = "SELECT title,id FROM notes WHERE lineage LIKE '259-%' && title LIKE '$currentMonth%' ORDER BY title ASC";
$sqldata = mysqli_query($dbcon, $sql) or die('error getting data');
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
$monthExists = true;
$monthID = $row['id'];
}
if ($dailyStatus == 'daily'){
if( $noteExists !== true){
if ($yearExists !== true){
$sql = "INSERT INTO notes (title,type,body,lineage,edited,viewed) VALUES ('$currentYear','','<h1>$currentYear</h1>','','$edited','$edited')";
if ($dbcon->query($sql) === TRUE) {
$yearID = $dbcon->insert_id;
$newlineage = '259-'.$yearID;
$sql1 = "UPDATE notes SET lineage= '$newlineage' WHERE id LIKE '$yearID'";
if ($dbcon->query($sql1) === TRUE) {
//echo $last_id;
}
}
}
else {
$newlineage = '259-'.$yearID;
}
if ($monthExists !== true){
$sql = "INSERT INTO notes (title,type,body,lineage,edited,viewed) VALUES ('$currentMonth','','<h1>$currentMonth</h1>','','$edited','$edited')";
if ($dbcon->query($sql) === TRUE) {
$monthID = $dbcon->insert_id;
$newlineage = '259-'.$yearID.'-'.$monthID;
$sql1 = "UPDATE notes SET lineage= '$newlineage' WHERE id LIKE '$monthID'";
if ($dbcon->query($sql1) === TRUE) {
//echo $last_id;
}
}
}
else {
$newlineage = '259-'.$yearID.'-'.$monthID;
}
$currentDate .= ' - '.date("d F, Y");
$body = $currentDate;
$sql = "INSERT INTO notes (title,type,body,lineage,edited,viewed) VALUES ('$currentDate','','<h1>$body</h1>','','$edited','$edited')";
if ($dbcon->query($sql) === TRUE) {
$last_id = $dbcon->insert_id;
$newlineage .= '-'.$last_id;
$sql1 = "UPDATE notes SET lineage= '$newlineage' WHERE id LIKE '$last_id'";
if ($dbcon->query($sql1) === TRUE) {
echo $last_id;
}
}
else {
echo "Error: " . $sql . "<br>" . $dbcon->error;
}
}
else {
echo $existID;
}
}
else {
$sql = "INSERT INTO notes (title,type,body,lineage,edited,viewed) VALUES ('$title','','$body','','$edited','$edited')";
if ($dbcon->query($sql) === TRUE) {
$last_id = $dbcon->insert_id;
$sql1 = "UPDATE notes SET lineage= '$last_id' WHERE id LIKE '$last_id'";
if ($dbcon->query($sql1) === TRUE) {
echo $last_id;
}
}
else {
echo "Error: " . $sql . "<br>" . $dbcon->error;
}
}