This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathheader.php
241 lines (231 loc) · 8.01 KB
/
header.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
<?php
function checkPass($user, $password) {
global $db_prefix_forum;
global $con;
$password = sha1($password);
$result = mysql_query("SELECT * FROM ".$db_prefix_forum."users WHERE name='$user' AND password='$password'",$con);
return mysql_fetch_array($result);
}
function navbox() {
global $loggedIn;
global $user;
global $userID;
?><div class="box_right">
<h2>Navigation</h2>
<ul class="nav2">
<li class="nav2">
<a href=".">Home</a>
</li>
<li class="nav2">
<a href="forum.php">Forum</a>
</li>
<?php if ($loggedIn) { ?>
<li class="nav2">
<?php echo "<a href=\"forum.php?type=user&userid=$userID\">$user</a>"; ?>
</li>
<li class="nav2">
<a href="forum.php?type=post&mode=logout">Logout</a>
</li>
<?php } else { ?>
<li class="nav2">
<a href="forum.php?type=login">Log In</a>
</li>
<?php } ?>
</ul>
</div>
<?php }
function showOther($type) {
global $con;
global $db_prefix;
if ($result = mysql_query("SELECT text FROM `".$db_prefix."other` WHERE type='$type'",$con)); else die(mysql_error());
$row = mysql_fetch_array($result);
return $row['text'];
}
function upOther($type, $value) {
global $con;
global $db_prefix;
mysql_query("DELETE FROM `".$db_prefix."other` WHERE type='$type'", $con) or die(mysql_error());
mysql_query("INSERT INTO `".$db_prefix."other` (type,text) VALUES ('$type','$value')", $con) or die(mysql_error());
}
function formatNews($row) {
$i = $row['id'];
echo "<b>".$row['title']."</b><br/>";
echo "".nl2br($row['text'])."<br/>";
echo " <button type=\"button\" onClick=\"editNews($i)\">Edit</button>";
echo "<button type=\"button\" onClick=\"delNews($i)\">Delete</button>";
}
function formatProject($row) {
$i = $row['id'];
echo "<b>".$row['title']."</b><br/>";
echo "".nl2br($row['text'])."<br/>";
echo " <button type=\"button\" onClick=\"editProj($i)\">Edit</button>";
echo "<button type=\"button\" onClick=\"delProj($i)\">Delete</button>";
}
function formatMember($row) {
$i = $row['id'];
echo $row['firstName']." ".$row['lastName'];
if ($row['position'])
echo "<span class=\"job\"> - ".$row['position']."</span>";
echo " <button type=\"button\" onClick=\"editMem($i)\">Edit</button>";
echo "<button type=\"button\" onClick=\"delMem($i)\">Delete</button>";
}
function formatOther($row) {
$i = $row['id'];
echo "<a href=\"".$row['link']."\">".$row['text']."</a>";
echo " <button type=\"button\" onClick=\"editOth($i)\">Edit</button>";
echo "<button type=\"button\" onClick=\"delOth($i)\">Delete</button>";
}
function sqlcon() {
global $con;
global $db_prefix;
include '../config.php';
$con = mysql_connect($db_host,$db_name,$db_pass);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
if (mysql_select_db($db_db, $con)); else die(mysql_error());
}
function adminAbout() {
global $con;
global $db_prefix;
sqlcon(); ?>
<h2>About</h2>
<form name="form1">
<textarea cols="100" rows="20" id="about"><?php
$result = mysql_query("SELECT text FROM ".$db_prefix."other WHERE type='about'",$con);
$row = mysql_fetch_row($result);
echo $row[0];
?></textarea>
<div id="aboutResult"></div>
<button type="button" onClick="postAbout()">Submit</button>
</form>
<?php }
function adminNews() {
global $con;
global $db_prefix;
sqlcon(); ?>
<h2>News</h2>
<ul id="newslist"><?php
$result = mysql_query("SELECT * FROM ".$db_prefix."news",$con);
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
echo "<li id=\"news".$row['id']."\">";
formatNews($row);
echo "</li>\n";
}
?></ul>
<div id="newsadd"><button type="button" onClick="editNews('add')">Add New Story</button></div>
<?php }
function adminProjects() {
global $con;
global $db_prefix;
sqlcon(); ?>
<h2>Projects</h2>
<ul id="projlist"><?php
$result = mysql_query("SELECT * FROM ".$db_prefix."projects",$con);
while ($row = mysql_fetch_array($result)) {
echo "<li id=\"proj".$row['id']."\">";
formatProject($row);
echo "</li>\n";
}
?></ul>
<div id="projadd"><button type="button" onClick="editProj('add')">Add New Project</button></div>
<?php }
function memList() {
global $con;
global $db_prefix;
sqlcon();
$result = mysql_query("SELECT * FROM ".$db_prefix."members WHERE position!='' ORDER BY id",$con);
$prevID = '';
$rowArray;
$i = 0;
while ($row = mysql_fetch_array($result)) {
$rowArray[$i] = $row;
$i++;
}
for ($j=0; $j<$i; $j++) {
$ID = $rowArray[$j]['id'];
$nextID = $rowArray[$j+1]['id'];
echo "<li id=\"mem$ID\">";
if ($prevID)
echo "<a href=\"javascript:void()\" onClick=\"ajax('type=memmove&id1=$prevID&id2=$ID', 'memlist', false)\" style=\"text-decoration: none;\">↑</a>";
else echo "↑";
if ($nextID)
echo "<a href=\"javascript:void()\" onClick=\"ajax('type=memmove&id1=$ID&id2=$nextID', 'memlist', false)\" style=\"text-decoration: none;\">↓</a>";
else echo "↓";
echo " ";
formatMember($rowArray[$j]);
echo "</li>\n";
$prevID = $ID;
}
$result = mysql_query("SELECT * FROM ".$db_prefix."members WHERE position='' ORDER BY lastName",$con);
while ($row = mysql_fetch_array($result)) {
echo "<li id=\"mem".$row['id']."\">";
formatMember($row);
echo "</li>\n";
}
}
function adminMembers() { /* ?>
<h2>Members</h2>
<ul id="memlist">
<?php memList(); ?>
</ul>
<div id="memadd"><button type="button" onClick="editMem('add')">Add New Member</button></div>
<?php */
echo "<br />Members are now automatically listed from all those people with satuses other than non-member in the forums.";
}
function adminComments() { /*
global $con;
global $db_prefix;
sqlcon();?>
<h2>Delete Comments</h2>
<?php
$result = mysql_query("SELECT * FROM ".$db_prefix."comments",$con);
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
echo "<div id=\"com".$i."\">";
echo "<b>" . $row['name'] . "</b><br />";
echo nl2br($row['comment']) . "<br />";
echo "<form><button type=\"button\" onClick=\"delCom($i)\">Delete</button></form></div>\n";
} */
echo "<br />User the forum instead of comments.";
}
function adminOther() {
global $con;
global $db_prefix;
sqlcon(); ?>
<h2>Links</h2>
<?php
$types = Array('links');
for ($j=0; $j<count($types); $j++) {
$type = $types[$j];
echo "<ul id=\"oth$type"."list\">";
$result = mysql_query("SELECT * FROM ".$db_prefix."other WHERE type='$type'",$con);
while ($row = mysql_fetch_array($result)) {
echo "<li id=\"oth".$row['id']."\">";
formatOther($row);
echo "</li>\n";
}
echo "</ul>";
echo "<div id=\"oth$type\"><button type=\"button\" onClick=\"editOth('$type')\">Add New Item</button></div>";
echo "<br/>";
}
}
function dirList ($directory) {
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..')
$results[] = $file;
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
?>