This commit is contained in:
Shish 2020-10-29 08:08:42 +00:00
parent 8a58ede5b3
commit 6789bd5fdd
2 changed files with 30 additions and 30 deletions

View file

@ -12,7 +12,7 @@ class ForumTheme extends Themelet
$page->set_title(html_escape("Forum")); $page->set_title(html_escape("Forum"));
$page->set_heading(html_escape("Forum")); $page->set_heading(html_escape("Forum"));
$page->add_block(new Block("Forum", $html, "main", 10)); $page->add_block(new Block("Forum", $html, "main", 10));
$this->display_paginator($page, "forum/index", null, $pageNumber, $totalPages); $this->display_paginator($page, "forum/index", null, $pageNumber, $totalPages);
} }
@ -24,7 +24,7 @@ class ForumTheme extends Themelet
$max_characters = $config->get_int('forumMaxCharsPerPost'); $max_characters = $config->get_int('forumMaxCharsPerPost');
$html = make_form(make_link("forum/create")); $html = make_form(make_link("forum/create"));
if (!is_null($threadTitle)) { if (!is_null($threadTitle)) {
$threadTitle = html_escape($threadTitle); $threadTitle = html_escape($threadTitle);
} }
@ -32,7 +32,7 @@ class ForumTheme extends Themelet
if (!is_null($threadText)) { if (!is_null($threadText)) {
$threadText = html_escape($threadText); $threadText = html_escape($threadText);
} }
$html .= " $html .= "
<table style='width: 500px;'> <table style='width: 500px;'>
<tr><td>Title:</td><td><input type='text' name='title' value='$threadTitle'></td></tr> <tr><td>Title:</td><td><input type='text' name='title' value='$threadTitle'></td></tr>
@ -51,25 +51,25 @@ class ForumTheme extends Themelet
$page->set_heading(html_escape($blockTitle)); $page->set_heading(html_escape($blockTitle));
$page->add_block(new Block($blockTitle, $html, "main", 120)); $page->add_block(new Block($blockTitle, $html, "main", 120));
} }
public function display_new_post_composer(Page $page, $threadID) public function display_new_post_composer(Page $page, $threadID)
{ {
global $config; global $config;
$max_characters = $config->get_int('forumMaxCharsPerPost'); $max_characters = $config->get_int('forumMaxCharsPerPost');
$html = make_form(make_link("forum/answer")); $html = make_form(make_link("forum/answer"));
$html .= '<input type="hidden" name="threadID" value="'.$threadID.'" />'; $html .= '<input type="hidden" name="threadID" value="'.$threadID.'" />';
$html .= " $html .= "
<table style='width: 500px;'> <table style='width: 500px;'>
<tr><td>Message:</td><td><textarea id='message' name='message' ></textarea> <tr><td>Message:</td><td><textarea id='message' name='message' ></textarea>
<tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr> <tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr>
</td></tr>"; </td></tr>";
$html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr> $html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
</table> </table>
</form> </form>
@ -84,9 +84,9 @@ class ForumTheme extends Themelet
public function display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber, $totalPages) public function display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber, $totalPages)
{ {
global $config, $page/*, $user*/; global $config, $page/*, $user*/;
$posts_per_page = $config->get_int('forumPostsPerPage'); $posts_per_page = $config->get_int('forumPostsPerPage');
$current_post = 0; $current_post = 0;
$html = $html =
@ -96,7 +96,7 @@ class ForumTheme extends Themelet
"<th id=threadHeadUser>User</th>". "<th id=threadHeadUser>User</th>".
"<th>Message</th>". "<th>Message</th>".
"</tr></thead>"; "</tr></thead>";
foreach ($posts as $post) { foreach ($posts as $post) {
$current_post++; $current_post++;
$message = $post["message"]; $message = $post["message"];
@ -104,29 +104,29 @@ class ForumTheme extends Themelet
$tfe = new TextFormattingEvent($message); $tfe = new TextFormattingEvent($message);
send_event($tfe); send_event($tfe);
$message = $tfe->formatted; $message = $tfe->formatted;
$message = str_replace('\n\r', '<br>', $message); $message = str_replace('\n\r', '<br>', $message);
$message = str_replace('\r\n', '<br>', $message); $message = str_replace('\r\n', '<br>', $message);
$message = str_replace('\n', '<br>', $message); $message = str_replace('\n', '<br>', $message);
$message = str_replace('\r', '<br>', $message); $message = str_replace('\r', '<br>', $message);
$message = stripslashes($message); $message = stripslashes($message);
$userLink = "<a href='".make_link("user/".$post["user_name"]."")."'>".$post["user_name"]."</a>"; $userLink = "<a href='".make_link("user/".$post["user_name"]."")."'>".$post["user_name"]."</a>";
$poster = User::by_name($post["user_name"]); $poster = User::by_name($post["user_name"]);
$gravatar = $poster->get_avatar_html(); $gravatar = $poster->get_avatar_html();
$rank = "<sup class='user_rank'>{$post["user_class"]}</sup>"; $rank = "<sup class='user_rank'>{$post["user_class"]}</sup>";
$postID = $post['id']; $postID = $post['id'];
//if($user->can(Permissions::FORUM_ADMIN)){ //if($user->can(Permissions::FORUM_ADMIN)){
//$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>"; //$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
//} else { //} else {
//$delete_link = ""; //$delete_link = "";
//} //}
if ($showAdminOptions) { if ($showAdminOptions) {
$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>"; $delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
} else { } else {
@ -152,17 +152,17 @@ class ForumTheme extends Themelet
<td class='forumSubmessage'></td> <td class='forumSubmessage'></td>
</tr>"; </tr>";
} }
$html .= "</tbody></table>"; $html .= "</tbody></table>";
$this->display_paginator($page, "forum/view/".$threadID, null, $pageNumber, $totalPages); $this->display_paginator($page, "forum/view/".$threadID, null, $pageNumber, $totalPages);
$page->set_title(html_escape($threadTitle)); $page->set_title(html_escape($threadTitle));
$page->set_heading(html_escape($threadTitle)); $page->set_heading(html_escape($threadTitle));
$page->add_block(new Block($threadTitle, $html, "main", 20)); $page->add_block(new Block($threadTitle, $html, "main", 20));
} }
public function add_actions_block(Page $page, $threadID) public function add_actions_block(Page $page, $threadID)
{ {
@ -192,29 +192,29 @@ class ForumTheme extends Themelet
$current_post = 0; $current_post = 0;
foreach ($threads as $thread) { foreach ($threads as $thread) {
$oe = ($current_post++ % 2 == 0) ? "even" : "odd"; $oe = ($current_post++ % 2 == 0) ? "even" : "odd";
global $config; global $config;
$titleSubString = $config->get_int('forumTitleSubString'); $titleSubString = $config->get_int('forumTitleSubString');
if ($titleSubString < strlen($thread["title"])) { if ($titleSubString < strlen($thread["title"])) {
$title = substr($thread["title"], 0, $titleSubString); $title = substr($thread["title"], 0, $titleSubString);
$title = $title."..."; $title = $title."...";
} else { } else {
$title = $thread["title"]; $title = $thread["title"];
} }
if ($thread["sticky"] == "Y") { if (bool_escape($thread["sticky"])) {
$sticky = "Sticky: "; $sticky = "Sticky: ";
} else { } else {
$sticky = ""; $sticky = "";
} }
$html .= "<tr class='$oe'>". $html .= "<tr class='$oe'>".
'<td class="left">'.$sticky.'<a href="'.make_link("forum/view/".$thread["id"]).'">'.$title."</a></td>". '<td class="left">'.$sticky.'<a href="'.make_link("forum/view/".$thread["id"]).'">'.$title."</a></td>".
'<td><a href="'.make_link("user/".$thread["user_name"]).'">'.$thread["user_name"]."</a></td>". '<td><a href="'.make_link("user/".$thread["user_name"]).'">'.$thread["user_name"]."</a></td>".
"<td>".autodate($thread["uptodate"])."</td>". "<td>".autodate($thread["uptodate"])."</td>".
"<td>".$thread["response_count"]."</td>"; "<td>".$thread["response_count"]."</td>";
if ($showAdminOptions) { if ($showAdminOptions) {
$html .= '<td><a href="'.make_link("forum/nuke/".$thread["id"]).'" title="Delete '.$title.'">Delete</a></td>'; $html .= '<td><a href="'.make_link("forum/nuke/".$thread["id"]).'" title="Delete '.$title.'">Delete</a></td>';
} }

View file

@ -70,7 +70,7 @@ class TipsTheme extends Themelet
$html .= "</tr></thead>"; $html .= "</tr></thead>";
foreach ($tips as $tip) { foreach ($tips as $tip) {
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No"; $tip_enable = bool_escape($tip['enable']) ? "Yes" : "No";
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>"; $set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";
$html .= "<tr>". $html .= "<tr>".