Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
halojoy committed Feb 11, 2018
1 parent b53de24 commit 882e795
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
3 changes: 3 additions & 0 deletions core/classAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public function validAdmin()
case 'topiclock':
$this->adm->topiclock();
break;
case 'setperpage':
$this->adm->setperpage();
break;
default:
$this->adm->adminhome();
break;
Expand Down
30 changes: 30 additions & 0 deletions core/classAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Admin
public $googlemail;
public $googlepass;
public $datetime;
public $perpage;

public function __construct($pdo, $settings)
{
Expand All @@ -21,6 +22,7 @@ public function __construct($pdo, $settings)
$this->googlemail = $settings->googlemail;
$this->googlepass = $settings->googlepass;
$this->datetime = $settings->datetime;
$this->perpage = $settings->perpage;
}

public function adminhome()
Expand Down Expand Up @@ -49,6 +51,10 @@ public function adminhome()
<form class="link" method="post">
<input class="link" type="submit" value="Lock Topics">
<input type="hidden" name="act" value="topiclock">
</form><br>
<form class="link" method="post">
<input class="link" type="submit" value="Posts Per Page">
<input type="hidden" name="act" value="setperpage">
</form><br><br>
<form class="link" method="post">
<input class="link" type="submit" value="Delete Post">
Expand Down Expand Up @@ -481,6 +487,30 @@ public function topiclock()
<?php
}

public function setperpage()
{
if (isset($_POST['perpage'])) {
$perpage = $_POST['perpage'];
if (is_numeric($perpage)) {
$sql = "UPDATE settings SET setvalue='$perpage' WHERE setkey='perpage'";
$this->pdo->exec($sql);
}
header('location:./admin.php');
exit();
}
?>
<form method="post">
<b>Posts Per Page</b><br><br>
Number of posts per each page:
<input type="text" name="perpage" size="6"
value="<?php echo $this->perpage ?>"><br><br>
<input type="submit" value="SUBMIT">
<input type="hidden" name="act" value="setperpage">
<br><br>
</form>
<?php
}

public function forumdelete()
{
if (isset($_POST['delfid'])) {
Expand Down
2 changes: 1 addition & 1 deletion core/classCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function generateCode()
*/
public function generateImage($string)
{
$font = 'data/mriam.ttf';
$font = __DIR__.'/../data/mriam.ttf';
$captcha = $this->prepareString($string, $font);

$image = imagecreatetruecolor($this->width, $this->height);
Expand Down
2 changes: 1 addition & 1 deletion core/classDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function getSticky($forumid)
public function notSticky($forumid)
{
$sql = "SELECT * FROM topics WHERE t_fid=$forumid AND t_sticky='0'
ORDER BY t_lastptime DESC LIMIT 20";
ORDER BY t_lastptime DESC LIMIT 30";
$ret = $this->querySQL($sql);

return $ret->fetchAll();
Expand Down
46 changes: 44 additions & 2 deletions core/classForum.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ class Forum
public $sess;
public $dateform;
public $datetime;
public $perpage;

public function __construct($pdo, $sess, $settings)
{
$this->pdo = $pdo;
$this->sess = $sess;
$this->dateform = $settings->dateform;
$this->datetime = $settings->datetime;
$this->perpage = $settings->perpage;
}

public function forums()
Expand Down Expand Up @@ -156,13 +158,53 @@ public function posts($tid, $tsubj)
}}
?>
<span class="leftspace">&nbsp;</span>
<span class="boldy"><?php echo $tsubj ?></span>
<span style="float:left" class="boldy"><?php echo $tsubj ?></span>
<?php
$posts = $this->pdo->getPosts($tid);
// Pagination
$totposts = $this->pdo->rowCount;
$pp = $this->perpage;
if ($totposts > $pp) {
$totpages = ceil($totposts/$pp);
$pno = isset($_POST['pno']) ? $_POST['pno'] : 1;
if ($pno > $totpages || $pno < 2)
$pno = 1;
echo '<span style="float:left">&nbsp;&nbsp;(..</span>';
for($i=1;$i<=$totpages;$i++) {
if ($i == $pno) {
echo '<span style="float:left">&nbsp;&nbsp;</span>
<span style="float:left;border:1px solid">'.$i.'</span>';
} else {
?>
<span style="float:left">&nbsp;&nbsp;</span>
<form class="link" method="post">
<input class="link" type="submit" value="<?php echo $i ?>">
<input type="hidden" name="act" value="posts">
<input type="hidden" name="tid" value="<?php echo $tid ?>">
<input type="hidden" name="pno" value="<?php echo $i ?>">
</form>
<?php
}
}
?>
<span style="float:left">&nbsp;&nbsp;</span>
<form class="link" method="post">
<input class="link" type="submit" value="Last">
<input type="hidden" name="act" value="posts">
<input type="hidden" name="tid" value="<?php echo $tid ?>">
<input type="hidden" name="pno" value="<?php echo $totpages ?>">
</form>
<?php
echo '&nbsp;)';
$posts = array_slice($posts, --$pno * $pp, $pp);
}
?>
<div class="postupright"><a href="?act=posts&tid=<?php echo $tid ?>"><?php echo TOPICLINK ?></a>&nbsp;</div>

<table id="posts">
<?php

$posts = $this->pdo->getPosts($tid);


foreach($posts as $row) {
?>
Expand Down
1 change: 1 addition & 0 deletions setup/setup3.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
$pdo->exec("INSERT INTO settings (setkey, setvalue) VALUES ('googlepass', '$googlepass')");
$pdo->exec("INSERT INTO settings (setkey, setvalue) VALUES ('cryptokey', '$cryptokey')");
$pdo->exec("INSERT INTO settings (setkey, setvalue) VALUES ('cryptoiv', '$cryptoiv')");
$pdo->exec("INSERT INTO settings (setkey, setvalue) VALUES ('perpage', '10')");

$pdo->exec("INSERT INTO forums (f_name, f_desc, f_order)
VALUES ('$forumname', '$forumdesc', 1)");
Expand Down

0 comments on commit 882e795

Please sign in to comment.