Rev 465 | Rev 472 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 297 | freddie | 1 | <?php |
| 2 | |||
| 3 | require '_config.php'; |
||
| 4 | |||
| 5 | class Taios_Page |
||
| 6 | { |
||
| 7 | function __construct($title, $url = "") |
||
| 8 | { |
||
| 9 | $this->title = $title; |
||
| 10 | $this->url = $url; |
||
| 11 | |||
| 12 | $this->drawnHeader = false; |
||
| 13 | $this->drawnMiddle = false; |
||
| 14 | $this->drawnFooter = false; |
||
| 15 | |||
| 16 | $this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD); |
||
| 17 | if (!$this->db) |
||
| 18 | { |
||
| 19 | $this->drawError('Failed to connect to database: ' . mysql_error()); |
||
| 20 | } |
||
| 21 | |||
| 22 | if (!mysql_select_db('Tim32')) |
||
| 23 | { |
||
| 24 | $this->drawError('Failed to select database: ' . mysql_error()); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | function drawHeader() |
||
| 29 | { |
||
| 30 | if (!$this->drawnHeader) |
||
| 31 | { |
||
| 32 | write('<!DOCTYPE html>'); |
||
| 33 | write('<html>'); |
||
| 34 | write('<head>'); |
||
| 35 | write('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">'); |
||
| 36 | write('<title>Tim32 · ' . $this->title . '</title>'); |
||
| 462 | tom | 37 | write('<link href="' . $this->url . 'styles.css" rel="stylesheet" type="text/css" media="screen" />'); |
| 463 | tom | 38 | write('<link rel="shortcut icon" href="' . $this->url . 'data/favicon.png" />'); |
| 297 | freddie | 39 | write('</head>'); |
| 40 | write('<body>'); |
||
| 41 | write('<div class="sidebar">'); |
||
| 42 | write('<div class="sidebar-header">'); |
||
| 43 | write('<h1>Tim32</h1>'); |
||
| 44 | write('</div>'); |
||
| 45 | write('<div class="sidebar-menu">'); |
||
| 46 | $this->drawMenuItem('Home', 'index.php'); |
||
| 47 | $this->drawMenuItem('Blog', 'blog/'); |
||
| 48 | $this->drawMenuItem('Projects', 'projects/'); |
||
| 49 | $this->drawMenuItem('Forums', 'forums/'); |
||
| 50 | $this->drawMenuItem('Wiki', 'wiki/'); |
||
| 51 | $this->drawMenuItem('Photos', 'photos/'); |
||
| 52 | write('<br />'); |
||
| 471 | muzer | 53 | if ($this->isLoggedIn() && $this->isUserNormal($this->getLoggedInUser())) |
| 297 | freddie | 54 | { |
| 55 | $this->drawMenuItem('Administration', 'admin/'); |
||
| 56 | $this->drawMenuItem('Logout', 'logout-do.php'); |
||
| 57 | } |
||
| 471 | muzer | 58 | else if ($this->isLoggedIn()) |
| 59 | { |
||
| 60 | $this->drawMenuItem('Logout', 'logout-do.php'); |
||
| 61 | if ($this->getLoggedInUser()->username != "cake") |
||
| 62 | $this->drawMenuItem('You are banned', NULL); |
||
| 63 | } |
||
| 297 | freddie | 64 | else |
| 65 | { |
||
| 66 | $this->drawMenuItem('Login', 'login.php'); |
||
| 67 | $this->drawMenuItem('Register', 'register.php'); |
||
| 68 | } |
||
| 69 | write('<br />'); |
||
| 70 | $this->drawnHeader = true; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | function drawMenuItem($t, $u) |
||
| 75 | { |
||
| 471 | muzer | 76 | if($u == NULL) |
| 77 | { |
||
| 78 | write('<p style="color:red">' . $t . '</p>'); |
||
| 79 | } |
||
| 80 | else |
||
| 81 | { |
||
| 82 | write('<p><a href="' . $this->url . $u . '">' . $t . '</a></p>'); |
||
| 83 | } |
||
| 297 | freddie | 84 | } |
| 85 | |||
| 86 | function drawMiddle() |
||
| 87 | { |
||
| 88 | if (!$this->drawnMiddle) |
||
| 89 | { |
||
| 90 | write('<br />'); |
||
| 91 | write('</div>'); |
||
| 92 | write('</div>'); |
||
| 93 | write('<div class="content">'); |
||
| 94 | write('<h2>' . $this->title . '</h2>'); |
||
| 95 | |||
| 96 | $this->drawnMiddle = true; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | function drawFooter() |
||
| 101 | { |
||
| 102 | if (!$this->drawnFooter) |
||
| 103 | { |
||
| 465 | tom | 104 | write('<br /><p class="copyright">Tim32</p>'); |
| 297 | freddie | 105 | write('</div>'); |
| 106 | write('</body>'); |
||
| 107 | write('</html>'); |
||
| 108 | |||
| 109 | $this->drawnFooter = true; |
||
| 110 | } |
||
| 111 | |||
| 112 | die(); |
||
| 113 | } |
||
| 114 | |||
| 115 | function drawError($text, $die = true) |
||
| 116 | { |
||
| 117 | $this->drawHeader(); |
||
| 118 | $this->drawMiddle(); |
||
| 119 | |||
| 120 | write('<h4 style="color: red;">Error: ' . $text . '</h4>'); |
||
| 121 | |||
| 122 | if ($die) |
||
| 123 | { |
||
| 124 | $this->drawFooter(); |
||
| 125 | die(); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 | function drawBlogPostTree($id, $first = false) |
||
| 130 | { |
||
| 131 | $post = $this->getBlogPost($id); |
||
| 132 | if ($first) |
||
| 133 | { |
||
| 134 | write('<h3><a href="post.php?id=' . $id . '">' . $post->title. '</a> <a href="post.php?id=' . $post->parent->ID . '">^</a></h3>'); |
||
| 135 | } |
||
| 136 | else |
||
| 137 | { |
||
| 138 | write('<a href="post.php?id=' . $id . '"><h3>' . $post->title. '</h3></a>'); |
||
| 139 | } |
||
| 140 | write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
||
| 141 | write('<p>' . $this->replaceBBCode($post->content) . '</p>'); |
||
| 142 | |||
| 143 | if ($this->isUserNormal($this->getLoggedInUser())) |
||
| 144 | { |
||
| 145 | echo '<p class="bold"><a href="add-post.php?id=' . $id . '">Add Comment</a>'; |
||
| 146 | if ($this->isUserAdmin($this->getLoggedInUser()) || $this->getLoggedInUser()->ID == $post->author->ID) |
||
| 147 | { |
||
| 148 | echo ' · <a href="edit-post.php?id=' . $id . '">Edit Post</a>'; |
||
| 149 | echo ' · <a href="del-post.php?id=' . $id . '">Delete Post</a>'; |
||
| 150 | } |
||
| 151 | write('</p><br />'); |
||
| 152 | } |
||
| 153 | |||
| 154 | $ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
||
| 155 | for ($i = 0; $i < count($ids); $i++) |
||
| 156 | { |
||
| 157 | write('<div class="indent">'); |
||
| 158 | $this->drawBlogPostTree($ids[$i]); |
||
| 159 | write('</div>'); |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | function drawBlogCategoriesMenu() |
||
| 164 | { |
||
| 165 | $cats = array(); |
||
| 166 | |||
| 167 | $ids = $this->findIDs('BlogPosts', 'WHERE ParentID = -1'); |
||
| 168 | for ($i = 0; $i < count($ids); $i++) |
||
| 169 | { |
||
| 170 | $cat = $this->getBlogPost($ids[$i])->category; |
||
| 171 | if (!in_array($cat, $cats)) |
||
| 172 | { |
||
| 173 | array_push($cats, $cat); |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 177 | write('<h3>Categories</h3>'); |
||
| 178 | for ($i = 0; $i < count($cats); $i++) |
||
| 179 | { |
||
| 180 | $this->drawMenuItem($cats[$i], 'blog/index.php?cat=' . $cats[$i]); |
||
| 181 | } |
||
| 182 | } |
||
| 183 | |||
| 184 | function replaceBBCode($str) |
||
| 185 | { |
||
| 437 | tom | 186 | /*$newstrarray = explode("\n", $str); |
| 434 | tom | 187 | $newstr = ""; |
| 188 | foreach ($newstrarray as $line) |
||
| 189 | { |
||
| 436 | tom | 190 | if ($line == "\n" || $line == " \n" || $line == "\n " || $line == "\n\r") |
| 434 | tom | 191 | { |
| 192 | $line = "</p><p>"; |
||
| 193 | } |
||
| 194 | |||
| 195 | $newstr .= ($line . "\n"); |
||
| 437 | tom | 196 | }*/ |
| 197 | |||
| 198 | $newstr = $str; |
||
| 434 | tom | 199 | $newstr = str_replace("<", "[", $newstr); |
| 308 | tom | 200 | $newstr = str_replace(">", "]", $newstr); |
| 437 | tom | 201 | $newstr = str_replace("\n", "</p><p>", $newstr); |
| 362 | tom | 202 | $newstr = str_replace("\\'", "'", $newstr); |
| 203 | $newstr = str_replace("\\\"",'"', $newstr); |
||
| 297 | freddie | 204 | $newstr = str_replace(' ', ' ', $newstr); |
| 205 | $newstr = str_replace(' :)', ' <img src="' . $this->url . 'data/smilies/face-smile.png" class="smiley" />', $newstr); |
||
| 206 | $newstr = str_replace(' :p', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />', $newstr); |
||
| 207 | $newstr = str_replace(' :P', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />',$newstr); |
||
| 208 | $newstr = str_replace(' :|', ' <img src="' . $this->url . 'data/smilies/face-plain.png" class="smiley" />',$newstr); |
||
| 209 | $newstr = str_replace(' :D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
||
| 210 | $newstr = str_replace(' =D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
||
| 211 | $newstr = str_replace(' :(', ' <img src="' . $this->url . 'data/smilies/face-sad.png" class="smiley" />',$newstr); |
||
| 212 | $newstr = str_replace(' :0', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
||
| 213 | $newstr = str_replace(' :o', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
||
| 214 | $newstr = str_replace(' :O', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
||
| 215 | $newstr = str_replace(' :/', ' <img src="' . $this->url . 'data/smilies/face-uncertain.png" class="smiley" />',$newstr); |
||
| 216 | $newstr = str_replace(' ;)', ' <img src="' . $this->url . 'data/smilies/face-wink.png" class="smiley" />',$newstr); |
||
| 217 | |||
| 218 | $bbcode = array( |
||
| 219 | '/\[b\](.+?)\[\/b\]/is', |
||
| 220 | '/\[i\](.+?)\[\/i\]/is', |
||
| 221 | '/\[u\](.+?)\[\/u\]/is', |
||
| 222 | '/\[url\](.+?)\[\/url\]/is', |
||
| 360 | tom | 223 | '/\[url=(.+?)\](.+?)\[\/url\]/is', |
| 297 | freddie | 224 | '/\[code\](.+?)\[\/code\]/is', |
| 401 | tom | 225 | '/\[img\](.+?)\[\/img\]/is', |
| 226 | '/\[ul\](.+?)\[\/ul\]/is', |
||
| 227 | '/\[ol\](.+?)\[\/ol\]/is', |
||
| 450 | tom | 228 | '/\[li\](.+?)\[\/li\]/is', |
| 452 | tom | 229 | '/\[mono\](.+?)\[\/mono\]/is' |
| 297 | freddie | 230 | ); |
| 231 | |||
| 232 | $html = array( |
||
| 233 | '<b>$1</b>', |
||
| 234 | '<i>$1</i>', |
||
| 235 | '<u>$1</u>', |
||
| 429 | tom | 236 | '<a href="$1">$1</a>', |
| 237 | '<a href="$1">$2</a>', |
||
| 408 | tom | 238 | '<div class="code">$1</div>', |
| 401 | tom | 239 | '<img src="$1" />', |
| 240 | '<ul>$1</ul>', |
||
| 241 | '<ol>$1</ol>', |
||
| 450 | tom | 242 | '<li>$1</li>', |
| 455 | tom | 243 | '<span style="font-family: Droid Sans Mono, monospace, fixed; margin-left: 1em; margin-right: 1em;">$1</span>', |
| 297 | freddie | 244 | ); |
| 245 | |||
| 246 | $newstr = preg_replace($bbcode, $html, $newstr); |
||
| 247 | |||
| 248 | return $newstr; |
||
| 249 | } |
||
| 250 | |||
| 251 | function redirect($u) |
||
| 252 | { |
||
| 253 | header('Location: ' . $u); |
||
| 254 | die(); |
||
| 255 | } |
||
| 256 | |||
| 257 | function isLoggedIn() |
||
| 258 | { |
||
| 259 | $cookie = $_COOKIE['Tim32_Login']; |
||
| 260 | if (!empty($cookie)) |
||
| 261 | { |
||
| 262 | $clist = explode('|~|', $cookie); |
||
| 263 | $user = $this->getUserByUsername($clist[0]); |
||
| 264 | if ($user) |
||
| 265 | { |
||
| 266 | if ($user->password == $clist[1]) |
||
| 267 | { |
||
| 268 | return true; |
||
| 269 | } |
||
| 270 | } |
||
| 271 | } |
||
| 272 | |||
| 273 | return false; |
||
| 274 | } |
||
| 275 | |||
| 276 | function isUserAdmin() |
||
| 277 | { |
||
| 278 | if ($this->isLoggedIn()) |
||
| 279 | { |
||
| 280 | if ($this->getLoggedInUser()->accessID <= 0) |
||
| 281 | { |
||
| 282 | return true; |
||
| 283 | } |
||
| 284 | } |
||
| 285 | |||
| 286 | return false; |
||
| 287 | } |
||
| 288 | |||
| 289 | function isUserGM() |
||
| 290 | { |
||
| 291 | if ($this->isLoggedIn()) |
||
| 292 | { |
||
| 293 | if ($this->getLoggedInUser()->accessID <= 1) |
||
| 294 | { |
||
| 295 | return true; |
||
| 296 | } |
||
| 297 | } |
||
| 298 | |||
| 299 | return false; |
||
| 300 | } |
||
| 301 | |||
| 302 | function isUserNormal() |
||
| 303 | { |
||
| 304 | if ($this->isLoggedIn()) |
||
| 305 | { |
||
| 306 | if ($this->getLoggedInUser()->accessID <= 2) |
||
| 307 | { |
||
| 308 | return true; |
||
| 309 | } |
||
| 310 | } |
||
| 311 | |||
| 312 | return false; |
||
| 313 | } |
||
| 314 | |||
| 471 | muzer | 315 | function isUserBanned() |
| 316 | { |
||
| 317 | if ($this->isLoggedIn()) |
||
| 318 | { |
||
| 319 | if ($this->getLoggedInUser()->accessID >= 3) |
||
| 320 | { |
||
| 321 | return true; |
||
| 322 | } |
||
| 323 | } |
||
| 324 | |||
| 325 | return false; |
||
| 326 | } |
||
| 327 | |||
| 384 | tom | 328 | function checkChallengeStatus($challengeID, $previous, $next) |
| 329 | { |
||
| 330 | $currentChallengeID = $this->getLoggedInUser()->challengeID; |
||
| 331 | |||
| 332 | if (!$this->isLoggedIn()) |
||
| 333 | { |
||
| 334 | $this->redirect('index.php'); |
||
| 335 | } |
||
| 336 | else if ($currentChallengeID > $challengeID) |
||
| 337 | { |
||
| 338 | $this->redirect($next . '.php'); |
||
| 339 | } |
||
| 340 | else if ($currentChallengeID < $challengeID) |
||
| 341 | { |
||
| 342 | $this->redirect($previous . '.php'); |
||
| 343 | } |
||
| 344 | } |
||
| 345 | |||
| 297 | freddie | 346 | function checkLoggedIn() |
| 347 | { |
||
| 348 | if (!$this->isLoggedIn()) |
||
| 349 | { |
||
| 350 | $this->drawError('You need to be logged in.'); |
||
| 351 | } |
||
| 352 | } |
||
| 353 | |||
| 354 | function query($query) |
||
| 355 | { |
||
| 356 | $result = mysql_query($query); |
||
| 357 | if (!$result) |
||
| 358 | { |
||
| 359 | $this->drawError('Query Failed: ' . $query . "\n" . 'MySQL Error: ' . mysql_error()); |
||
| 360 | } |
||
| 361 | |||
| 362 | return $result; |
||
| 363 | } |
||
| 364 | |||
| 365 | function findIDs($table, $query = '') |
||
| 366 | { |
||
| 367 | $array = array(); |
||
| 368 | |||
| 369 | $result = $this->query('SELECT ID FROM ' . $table . ' ' . $query); |
||
| 370 | while ($row = mysql_fetch_array($result)) |
||
| 371 | { |
||
| 372 | array_push($array, $row['ID']); |
||
| 373 | } |
||
| 374 | |||
| 375 | return $array; |
||
| 376 | } |
||
| 377 | |||
| 378 | function getUserByID($id) |
||
| 379 | { |
||
| 380 | $result = $this->query('SELECT * FROM Users WHERE ID = ' . $id); |
||
| 381 | while ($row = mysql_fetch_array($result)) |
||
| 382 | { |
||
| 383 | $user = new User; |
||
| 384 | $user->ID = $row['ID']; |
||
| 385 | $user->accessID = $row['AccessID']; |
||
| 386 | $user->username = $row['Username']; |
||
| 387 | $user->password = $row['Password']; |
||
| 388 | $user->emailAddress = $row['EmailAddress']; |
||
| 389 | $user->name = $row['Name']; |
||
| 390 | $user->challengeID = $row['ChallengeID']; |
||
| 391 | |||
| 392 | return $user; |
||
| 393 | } |
||
| 394 | |||
| 395 | return false; |
||
| 396 | } |
||
| 397 | |||
| 398 | function getUserByUsername($username) |
||
| 399 | { |
||
| 400 | $result = $this->query('SELECT * FROM Users WHERE Username = "' . $username . '"'); |
||
| 401 | while ($row = mysql_fetch_array($result)) |
||
| 402 | { |
||
| 403 | return $this->getUserByID($row['ID']); |
||
| 404 | } |
||
| 405 | |||
| 406 | return false; |
||
| 407 | } |
||
| 408 | |||
| 409 | function getLoggedInUser() |
||
| 410 | { |
||
| 411 | if ($this->isLoggedIn()) |
||
| 412 | { |
||
| 413 | $clist = explode('|~|', $_COOKIE['Tim32_Login']); |
||
| 414 | return $this->getUserByUsername($clist[0]); |
||
| 415 | } |
||
| 416 | |||
| 417 | return false; |
||
| 418 | } |
||
| 419 | |||
| 420 | function getBlogPost($id) |
||
| 421 | { |
||
| 422 | $result = $this->query('SELECT * FROM BlogPosts WHERE ID = ' . $id); |
||
| 423 | while ($row = mysql_fetch_array($result)) |
||
| 424 | { |
||
| 425 | $post = new BlogPost; |
||
| 426 | $post->ID = $row['ID']; |
||
| 427 | if ($row['ParentID'] == -1) |
||
| 428 | { |
||
| 429 | $post->parent = -1; |
||
| 430 | } |
||
| 431 | else |
||
| 432 | { |
||
| 433 | $post->parent = $this->getBlogPost($row['ParentID']); |
||
| 434 | } |
||
| 435 | $post->author = $this->getUserByID($row['AuthorID']); |
||
| 436 | $post->user = $this->getUserByID($row['AuthorID']); // For some older pages |
||
| 437 | $post->title = $row['Title']; |
||
| 438 | $post->content = $row['Content']; |
||
| 439 | $post->datePosted = strtotime($row['DatePosted']); |
||
| 440 | $post->category = $row['Category']; |
||
| 441 | $post->spam = $row['Spam']; |
||
| 442 | |||
| 443 | return $post; |
||
| 444 | } |
||
| 445 | |||
| 446 | $this->drawError('Cannot find blog post, #' . $id); |
||
| 447 | } |
||
| 448 | |||
| 449 | function getProject($id) |
||
| 450 | { |
||
| 451 | $result = $this->query('SELECT * FROM Projects WHERE ID = ' . $id); |
||
| 452 | while ($row = mysql_fetch_array($result)) |
||
| 453 | { |
||
| 454 | $project = new Project; |
||
| 455 | |||
| 456 | $project->ID = $row['ID']; |
||
| 457 | $project->author = $this->getUserByID($row['AuthorID']); |
||
| 458 | $project->title = $row['Title']; |
||
| 459 | $project->description = $row['Description']; |
||
| 460 | $project->logoURL = $row['LogoURL']; |
||
| 461 | $project->downloadURL = $row['DownloadURL']; |
||
| 462 | $project->websiteURL = $row['WebsiteURL']; |
||
| 463 | $project->latestVersion = $row['LatestVersion']; |
||
| 464 | $project->lastUpdate = strtotime($row['LastUpdate']); |
||
| 465 | |||
| 466 | return $project; |
||
| 467 | } |
||
| 468 | |||
| 469 | return false; |
||
| 470 | } |
||
| 471 | |||
| 472 | function getForumCategory($id) |
||
| 473 | { |
||
| 474 | $result = $this->query('SELECT * FROM ForumCategories WHERE ID = ' . $id); |
||
| 475 | while ($row = mysql_fetch_array($result)) |
||
| 476 | { |
||
| 477 | $f = new ForumCategory; |
||
| 478 | |||
| 479 | $f->ID = $row['ID']; |
||
| 480 | $f->parent = $this->getForumCategory($row['ParentID']); |
||
| 481 | $f->title = $row['Title']; |
||
| 482 | $f->description = $row['Description']; |
||
| 483 | |||
| 484 | return $f; |
||
| 485 | } |
||
| 486 | |||
| 487 | return false; |
||
| 488 | } |
||
| 489 | |||
| 490 | function getForumPost($id) |
||
| 491 | { |
||
| 492 | $result = $this->query('SELECT * FROM ForumPosts WHERE ID = ' . $id); |
||
| 493 | while ($row = mysql_fetch_array($result)) |
||
| 494 | { |
||
| 495 | $f = new ForumPost; |
||
| 496 | |||
| 497 | $f->ID = $row['ID']; |
||
| 498 | $f->author = $this->getUserByID($row['AuthorID']); |
||
| 499 | $f->category = $this->getForumCategory($row['CategoryID']); |
||
| 500 | $f->parent = $this->getForumPost($row['ParentID']); |
||
| 501 | $f->title = $row['Title']; |
||
| 502 | $f->content = $row['Content']; |
||
| 503 | $f->datePosted = strtotime($row['DatePosted']); |
||
| 504 | $f->spam = $row['Spam']; |
||
| 505 | |||
| 506 | return $f; |
||
| 507 | } |
||
| 508 | |||
| 509 | return false; |
||
| 510 | } |
||
| 511 | |||
| 512 | function delBlogPost($id) |
||
| 513 | { |
||
| 514 | $ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
||
| 515 | for ($i = 0; $i < count($ids); $i++) |
||
| 516 | { |
||
| 517 | $this->delBlogPost($ids[$i]); |
||
| 518 | } |
||
| 519 | |||
| 520 | $this->query('DELETE FROM BlogPosts WHERE ID=' . $id); |
||
| 521 | } |
||
| 522 | |||
| 523 | function getGetID() |
||
| 524 | { |
||
| 525 | $id = $_GET['id']; |
||
| 526 | if (empty($id)) |
||
| 527 | { |
||
| 528 | $id = 1; |
||
| 529 | } |
||
| 530 | |||
| 531 | return $id; |
||
| 532 | } |
||
| 533 | |||
| 534 | function getPostID() |
||
| 535 | { |
||
| 536 | $id = $_POST['id']; |
||
| 537 | if (empty($id)) |
||
| 538 | { |
||
| 539 | $id = 1; |
||
| 540 | } |
||
| 541 | |||
| 542 | return $id; |
||
| 543 | } |
||
| 544 | |||
| 545 | } |
||
| 546 | |||
| 547 | class User |
||
| 548 | { |
||
| 549 | public $ID; |
||
| 550 | public $accessID; |
||
| 551 | public $username; |
||
| 552 | public $password; |
||
| 553 | public $emailAddress; |
||
| 554 | public $name; |
||
| 443 | tom | 555 | |
| 297 | freddie | 556 | public $challengeID; |
| 557 | } |
||
| 558 | |||
| 559 | class BlogPost |
||
| 560 | { |
||
| 561 | public $ID; |
||
| 562 | public $parent; |
||
| 563 | public $author; |
||
| 564 | public $title; |
||
| 565 | public $content; |
||
| 566 | public $datePosted; |
||
| 567 | public $category; |
||
| 568 | public $spam; |
||
| 569 | } |
||
| 570 | |||
| 571 | class Project |
||
| 572 | { |
||
| 573 | public $ID; |
||
| 574 | public $author; |
||
| 575 | public $title; |
||
| 576 | public $description; |
||
| 426 | tom | 577 | |
| 434 | tom | 578 | |
| 297 | freddie | 579 | public $logoURL; |
| 580 | public $downloadURL; |
||
| 581 | public $websiteURL; |
||
| 582 | public $latestVersion; |
||
| 583 | public $lastUpdate; |
||
| 584 | } |
||
| 585 | |||
| 586 | class ForumCategory |
||
| 587 | { |
||
| 588 | public $ID; |
||
| 589 | public $parent; |
||
| 590 | public $title; |
||
| 591 | public $description; |
||
| 401 | tom | 592 | |
| 297 | freddie | 593 | } |
| 594 | |||
| 595 | class ForumPost |
||
| 596 | { |
||
| 597 | public $id; |
||
| 598 | public $author; |
||
| 599 | public $category; |
||
| 600 | public $parent; |
||
| 601 | public $title; |
||
| 602 | public $content; |
||
| 603 | public $datePosted; |
||
| 604 | public $spam; |
||
| 605 | } |
||
| 606 | |||
| 607 | function write($str) |
||
| 608 | { |
||
| 609 | echo $str; |
||
| 610 | echo "\n"; |
||
| 611 | } |
||
| 612 | |||
| 613 | ?> |