-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReviewCommentAdmin.php
executable file
·267 lines (248 loc) · 7.57 KB
/
ReviewCommentAdmin.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
/*
Copyright © 2009,2015,2022 Siggi Bjarnason.
Licensed under GNU GPL v3 and later. Check out LICENSE.TXT for details
or see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>
Manages the Review Comments
*/
require("header.php");
$DocRoot = "ReviewMedia/";
if($strReferer != $strPageURL and $PostVarCount > 0)
{
printPg("Invalid operation, Bad Reference!!!","error");
exit;
}
if(isset($_POST["btnSubmit"]))
{
$btnSubmit = $_POST["btnSubmit"];
}
else
{
$btnSubmit = "";
}
printPg("Feedback Administration","h1");
if($btnSubmit == "Save")
{
$iFeedbackID = CleanSQLInput(substr(trim($_POST["iFeedbackID"]),0,9));
$strFeedbackName = CleanSQLInput(substr(trim($_POST["txtFeedbackName"]),0,99));
$strDescr = CleanSQLInput($_POST["txtDescr"]);
$strMMURL= CleanSQLInput(substr(trim($_POST["txtMMURL"]),0,99));
$strImgPath="";
if(isset($_FILES["fPict"]))
{
if($_FILES["fPict"]["name"]!="")
{
$tmpFile = $_FILES["fPict"]["tmp_name"];
$Error = $_FILES["fPict"]["error"];
$DocFileName = $_FILES["fPict"]["name"];
$DocBaseName = str_replace(" ","_",basename($DocFileName));
$newPath = $DocRoot . $DocBaseName;
if($Error == UPLOAD_ERR_OK)
{
if(move_uploaded_file($tmpFile, $newPath))
{
$strImgPath = $newPath;
printPg("File $DocBaseName uploaded successfully","normal");
}
else
{
printPg("Couldn't move file to $newPath","error");
}
}
else
{
$ErrMsg = codeToMessage($Error);
printPg("Error \"$ErrMsg\" while uploading $DocFileName","error");
}
}
}
if($strImgPath == "")
{
$strImgPath = $strMMURL;
}
$strQuery = "update tblFeedback set vcFeedbackName = '$strFeedbackName', "
. "tFeedbackDescr = '$strDescr', vcImgPath = '$strImgPath' where iFeedbackID = $iFeedbackID;";
UpdateSQL($strQuery,"update");
}
if($btnSubmit == "Delete")
{
$iFeedbackID = CleanSQLInput(substr(trim($_POST["iFeedbackID"]),0,9));
$strQuery = "delete from tblFeedback where iFeedbackID = $iFeedbackID;";
UpdateSQL($strQuery,"delete");
}
if($btnSubmit == "Insert")
{
$strFeedbackName = CleanSQLInput(substr(trim($_POST["txtFeedbackName"]),0,99));
$strDescr = CleanSQLInput($_POST["txtDescr"]);
$strMMURL = CleanSQLInput(substr(trim($_POST["txtMMURL"]),0,99));
$strImgPath ="";
if(isset($_FILES["fPict"]))
{
if($_FILES["fPict"]["name"]!="")
{
$tmpFile = $_FILES["fPict"]["tmp_name"];
$Error = $_FILES["fPict"]["error"];
$DocFileName = $_FILES["fPict"]["name"];
$DocBaseName = basename($DocFileName);
$newPath = $DocRoot . $DocBaseName;
if($Error == UPLOAD_ERR_OK)
{
if(move_uploaded_file($tmpFile, $newPath))
{
$strImgPath = $newPath;
printPg("File $DocBaseName uploaded successfully<br>","normal");
}
else
{
printPg("Couldn't save file to $newPath","error");
}
}
else
{
$ErrMsg = codeToMessage($Error);
printPg("Error \"$ErrMsg\" while uploading $DocFileName","error");
}
}
else
{
$strImgPath = $strMMURL;
}
}
else
{
$strImgPath = $strMMURL;
}
if($strFeedbackName == "")
{
printPg("Please provide a name for the feedback to insert","error");
}
else
{
$strQuery = "insert tblFeedback (vcFeedbackName, tFeedbackDescr, vcImgPath) "
. "values ('$strFeedbackName','$strDescr', '$strImgPath');";
UpdateSQL($strQuery,"insert");
}
}
//Print the normal form after update is complete.
print "<table>\n";
print "<tr>\n";
print "<th>Update existing feedback</th>\n";
print "<th width = 100></th>\n";
if($btnSubmit != "Edit")
{
print "<th class=lbl>Or Insert New one</th>";
}
print "</tr>\n";
print "<tr>\n";
print "<td valign=\"top\">\n";
print "<table border = 0>\n";
$strQuery = "select iFeedbackID, vcFeedbackName, tFeedbackDescr from tblFeedback;";
$QueryData = QuerySQL($strQuery);
if($QueryData[0] > 0)
{
foreach($QueryData[1] as $Row)
{
$vcFeedbackName = $Row["vcFeedbackName"];
$iFeedbackID = $Row["iFeedbackID"];
if ($WritePriv <= $Priv)
{
print "<form method=\"POST\">\n";
print "<tr valign=\"top\">\n";
print "<td class=\"lbl\"><input type=\"hidden\" value=\"$iFeedbackID\" name=\"iFeedbackID\"></td>\n";
print "<td>$vcFeedbackName</td>\n";
print "<td><input type=\"Submit\" value=\"Edit\" name=\"btnSubmit\"></td>";
print "<td><input type=\"Submit\" value=\"Delete\" name=\"btnSubmit\"></td>";
print "</tr>\n";
print "</form>\n";
}
else
{
print "<tr><td>$vcFeedbackName</td></tr>\n";
}
}
}
else
{
if($QueryData[0] == 0)
{
printPg("No Records","note");
}
else
{
$strMsg = Array2String($QueryData[1]);
error_log("Query of $strQuery did not return data. Rowcount: $QueryData[0] Msg:$strMsg");
printPg($ErrMsg,"error");
}
}
print "</table>\n";
print "<form method=\"POST\">\n";
print "<input type=\"Submit\" value=\"Go Back\" name=\"btnSubmit\">\n";
print "</form>";
print "</td>\n";
print "<td>\n";
print "</td>\n";
print "<td valign=\"top\">\n";
if(isset($_POST["iFeedbackID"]) and $btnSubmit == "Edit")
{
$iFeedbackID = $_POST["iFeedbackID"];
$strQuery = "select iFeedbackID, vcFeedbackName, tFeedbackDescr, vcImgPath from tblFeedback where iFeedbackID = $iFeedbackID;";
$QueryData = QuerySQL($strQuery);
if($QueryData[0] > 0)
{
foreach($QueryData[1] as $Row)
{
$strFeedbackName = $Row["vcFeedbackName"];
$strClassDescr = $Row["tFeedbackDescr"];
$strMMURL = $Row["vcImgPath"];
$strBtnLabel = "Save";
}
}
else
{
if($QueryData[0] == 0)
{
$strFeedbackName = "";
$strClassDescr = "";
$iFeedbackID = "";
$strMMURL ="";
$strBtnLabel = "Insert";
}
else
{
$strMsg = Array2String($QueryData[1]);
error_log("Query of $strQuery did not return data. Rowcount: $QueryData[0] Msg:$strMsg");
printPg($ErrMsg,"error");
}
}
}
else
{
$strFeedbackName = "";
$strClassDescr = "";
$iFeedbackID = "";
$strMMURL ="";
$strBtnLabel = "Insert";
}
print "<form method=\"POST\" enctype=\"multipart/form-data\">\n";
print "<input type=\"hidden\" value=\"$iFeedbackID\" name=\"iFeedbackID\">";
print "<span class=\"lbl\">Feedback Name:</span>\n";
print "<input type=\"text\" name=\"txtFeedbackName\" size=\"70\" value=\"$strFeedbackName\"><br>\n";
print "<span class=\"lbl\">Attach Picture: </span>\n";
print "<input type=\"File\" name=\"fPict\" size=\"30\" >\n<br>\n";
print "<span class=\"lbl\">Or specify a URL to picture or video:</span>\n";
print "<input type=\"text\" name=\"txtMMURL\" size=\"47\" value=\"$strMMURL\"><br>\n";
print "<div class=\"lbl\">Description:</div>\n";
print "<textarea name=\"txtDescr\" rows=\"10\" cols=\"80\">$strClassDescr</textarea>\n<br>\n";
print "<div align=\"center\"><input type=\"Submit\" value=\"$strBtnLabel\" name=\"btnSubmit\"></div>\n";
print "</form>\n";
if(isset($_POST["iFeedbackID"]))
{
print "<form method=\"POST\">\n";
print "<input type=\"Submit\" value=\"Go Back\" name=\"btnSubmit\">\n";
print "</form>\n";
}
print "</td>\n";
print "</tr>\n";
print "</table>\n";
require("footer.php");
?>