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