-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetdocsandcomments.php
More file actions
129 lines (103 loc) · 3.52 KB
/
getdocsandcomments.php
File metadata and controls
129 lines (103 loc) · 3.52 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
//returns docs and comments connected to a course
session_start();
if ($db_conn=OCILogon("ora_p1t7", "a36959104", "ug")) {
$email = $_SESSION['email'];
$course = $_SESSION[('courseselect' . (string)$_POST['courseSelect'])];
//insert any comments
if (!empty($_POST['comment'])) {
$comment = $_POST['comment'];
$commentId = 1;
$email = $_SESSION['email'];
//find largest comment id
$cmdstr = "select max(comment_id) from ns_comment";
$parsed = OCIParse($db_conn, $cmdstr); // parse the statement
if (!$parsed){
$e = OCIError($db_conn);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
$r=OCIExecute($parsed, OCI_DEFAULT);
if (!$r){
$e = oci_error($parsed);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
$row = OCI_Fetch_Array($parsed, OCI_NUM);
if (empty($row)) {
$_SESSION['gd_error'] = "Internal server error";
OCILogoff($db_conn);
header('Location:noteshare.php');
}
else {
$commentId += $row[0];
}
$cmdstr = "insert into ns_comment values(default, '$comment', $commentId, '$email', '$course[0]', '$course[2]', '$course[3]', '$course[4]', $course[5])";
$parsed = OCIParse($db_conn, $cmdstr); // parse the statement
if (!$parsed){
$e = OCIError($db_conn);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
$r=OCIExecute($parsed, OCI_DEFAULT);
if (!$r){
$e = oci_error($parsed);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
OCICommit($db_conn);
}
$cmdstr = "select document_id, document_name, document_time, email from document where institution = '$course[3]' and dept = '$course[2]' and course_num = $course[0] and tyear = $course[5]";
$parsed = OCIParse($db_conn, $cmdstr); // parse the statement
if (!$parsed){
$e = OCIError($db_conn);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
$r=OCIExecute($parsed, OCI_DEFAULT);
if (!$r){
$e = oci_error($parsed);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
OCICommit($db_conn);
echo("select worked");
$i = 0;
while ($row = OCI_Fetch_Array($parsed, OCI_NUM)) {
$_SESSION['document_res' . (string)$i] = $row;
$i++;
}
$cmdstr = "select comment_id, text, comment_time, email from ns_comment where institution = '$course[3]' and dept = '$course[2]' and course_num = $course[0] and tyear = $course[5]";
$parsed = OCIParse($db_conn, $cmdstr); // parse the statement
if (!$parsed){
$e = OCIError($db_conn);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
$r=OCIExecute($parsed, OCI_DEFAULT);
if (!$r){
$e = oci_error($parsed);
$_SESSION['gd_error'] = htmlentities($e['message']);
header('Location:noteshare.php');
exit;
}
OCICommit($db_conn);
echo("select worked");
$i = 0;
while ($row = OCI_Fetch_Array($parsed, OCI_NUM)) {
$_SESSION['comment_res' . (string)$i] = $row;
$i++;
}
header('Location:noteshare.php');
}else {
$e = OCIError();
echo htmlentities($e['message']);
}
?>