-
Notifications
You must be signed in to change notification settings - Fork 1
/
LinkCategory.php
executable file
·152 lines (137 loc) · 4.33 KB
/
LinkCategory.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
<?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>
Page to create and maintain link categories used in Link Admin
*/
require("header.php");
if($strReferer != $strPageURL and $PostVarCount > 0)
{
printPg("Invalid operation, Bad Reference!!!","error");
exit;
}
if(isset($_POST["btnSubmit"]))
{
$btnSubmit = $_POST["btnSubmit"];
}
else
{
$btnSubmit = "";
}
printPg("Link Categories","h1");
if(($PostVarCount == 1) and ($btnSubmit == "Go Back"))
{
header("Location: $strPageURL");
}
if($btnSubmit == "Save")
{
$iSortNum = CleanSQLInput(substr(trim($_POST["iSortNum"]),0,49));
$strLinkCat = CleanSQLInput(substr(trim($_POST["txtLinkCat"]),0,49));
$iLinkCatID = CleanSQLInput(substr(trim($_POST["iLinkCatID"]),0,49));
if($iSortNum == "")
{
$iSortNum = 0;
}
$strQuery = "update tbllinkcategory set vcCategory = '$strLinkCat', iSortNum = $iSortNum where iCatID = $iLinkCatID;";
UpdateSQL($strQuery,"update");
}
if($btnSubmit == "Delete")
{
$iLinkCatID = intval(substr(trim($_POST["iLinkCatID"]),0,49));
$strQuery = "delete from tbllinkcategory where iCatID = $iLinkCatID;";
UpdateSQL($strQuery,"delete");
}
if($btnSubmit == "Insert")
{
$iSortNum = CleanSQLInput(substr(trim($_POST["iSortNum"]),0,49));
$strLinkCat = CleanSQLInput(substr(trim($_POST["txtLinkCat"]),0,49));
if($iSortNum == "")
{
$iSortNum = 0;
}
if($strLinkCat == "")
{
printPg("Please provide a document catergory name to insert","note");
}
else
{
$strQuery = "insert tbllinkcategory (vcCategory, iSortNum) values ('$strLinkCat',$iSortNum);";
UpdateSQL($strQuery,"insert");
}
}
//Print the normal form after update is complete.
$strQuery = "SELECT vcCategory, iSortNum, iCatID FROM tbllinkcategory order by iSortNum;";
$QueryData = QuerySQL($strQuery);
if($QueryData[0] > 0)
{
print "<table class=center>\n";
print "<tr>\n";
print "<th class=lbl>Update existing Category</th>\n";
print "<th width = 100></th>\n";
print "<th class=lbl>Or Insert New one</th>\n";
print "</tr>\n";
print "<tr>\n";
print "<td>\n";
print "<table border = 0>\n";
print "<tr><th></th><th class=lbl>Category Name</th><th class=lbl>Sort order</th></tr>\n";
foreach($QueryData[1] as $Row)
{
$vcLinkCat = $Row["vcCategory"];
$iSortNum = $Row["iSortNum"];
$iLinkCatID = $Row["iCatID"];
if($WritePriv <= $Priv)
{
print "<form method=\"POST\">\n";
print "<tr valign=\"top\">\n";
print "<td class=\"lbl\"><input type=\"hidden\" value=\"$iLinkCatID\" name=\"iLinkCatID\"> </td>\n";
print "<td><input type=\"text\" value=\"$vcLinkCat\" name=\"txtLinkCat\" size=\"30\" ></td>\n";
print "<td><input type=\"text\" value=\"$iSortNum\" name=\"iSortNum\" size=\"13\" ></td>\n";
print "<td><input type=\"Submit\" value=\"Save\" name=\"btnSubmit\"></td>";
print "<td><input type=\"Submit\" value=\"Delete\" name=\"btnSubmit\"></td>";
print "</tr>\n";
print "</form>\n";
}
else
{
print "$vcLinkCat : $iSortNum<br>\n";
}
}
print "</table>\n";
print "</td>\n<td>\n</td>\n<td>\n";
}
else
{
if($QueryData[0] == 0)
{
print "<table class=center>\n";
print "<tr>\n";
print "<th class=lbl>Insert New Category</th>\n";
print "</tr>\n";
print "<tr>\n";
print "<td>\n";
}
if($QueryData[0] < 0)
{
$strMsg = Array2String($QueryData[1]);
error_log("Query of $strQuery did not return data. Rowcount: $QueryData[0] Msg:$strMsg");
printPg($ErrMsg,"error");
}
}
print "<form method=\"POST\">\n";
print "<table>\n";
print "<tr>\n";
print "<td align = right class = lbl>Category: </td>\n";
print "<td><input type=\"text\" name=\"txtLinkCat\" size=\"30\" ></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td align = right class = lbl>Sort Order: </td>\n";
print "<td><input type=\"text\" name=\"iSortNum\" size=\"13\" ></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td colspan=2 align=center><input type=\"Submit\" value=\"Insert\" name=\"btnSubmit\"></td>\n";
print "</tr>\n";
print "</table>\n";
print "</form>\n</td>\n</tr>\n</table>\n";
require("footer.php");
?>