-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSubmissionsPage.php
49 lines (48 loc) · 1.38 KB
/
SubmissionsPage.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
<?php
namespace MyForum;
/**
* Page that lists all contributions.
*/
final class SubmissionsPage extends lib\HomePage {
use lib\DataBase;
/*
* Evaluate when reloading
*/
protected function init(){
session_start();
$pre = self::prefix();
$thrd = $_GET['thread'];
if (isset($_POST["new"])){//New Entry
$val=trim(htmlspecialchars($_POST["new"])) ;
if ($val != ""){
self::insert(into: 'posts', values: array($thrd, $val));
if (!isset($_SESSION['posted'.$thrd])){
$_SESSION['posted'.$thrd]=true;
}
}
}
if (!isset($_SESSION['posted'.$thrd])){
return $this->render('submissions.php', 'sub_first');
}
}
/*
* Output
*/
protected function body(){
$pre = self::prefix();
$thrd = $_GET['thread'];
$thr = self::select(from: 'threads', what: 'name', where: 'id', value: $thrd);
$ret="";
$ret .= $this->render('submissions.php', 'sub_subnav', array('name' => $thr[0]['name']));
$thrd = $_GET['thread'];
$rows = self::select(from: 'posts', where: 'thread_ID', value: $thrd);
$ret .= $this->render('submissions.php', 'sub_table_head');
foreach ($rows as $row) {
$ret .= $this->render('submissions.php', 'sub_table_row', array('row' => $row));
}
$uri = "../submissons/$_GET[thread].html";
$ret .= $this->render('submissions.php', 'sub_table_end', array('uri' => $uri));
return $ret;
}
}
?>