本文整理汇总了PHP中Forum::getForums方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::getForums方法的具体用法?PHP Forum::getForums怎么用?PHP Forum::getForums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forum
的用法示例。
在下文中一共展示了Forum::getForums方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strtotime
$endDate = strtotime(date("Y-m-d", $d) . ' 23:59');
$array[] = $torrents = $torrent->getSweTvGuideTorrents($startDate, $endDate);
}
$memcache && $memcache->set($cacheId, $array, MEMCACHE_COMPRESSED, 60 * 15);
if ($week == 0) {
$user->updateLastTorrentViewAccess('last_tvbrowse');
}
httpResponse($array);
}
break;
/* Forum */
/* Forum */
case validateRoute('GET', 'forums'):
$forum = new Forum($db, $user);
$user->updateLastForumAccess();
httpResponse($forum->getForums());
break;
case validateRoute('GET', 'forums/\\d+'):
$forum = new Forum($db, $user);
$user->updateLastForumAccess();
httpResponse($forum->getForum($params[1]));
break;
case validateRoute('GET', 'forums/\\d+/topics'):
$forum = new Forum($db, $user);
$user->updateLastForumAccess();
list($result, $totalCount) = $forum->getTopics($params[1], (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
httpResponse($result, $totalCount);
break;
case validateRoute('GET', 'forums/\\d+/topics/\\d+'):
$forum = new Forum($db, $user);
$user->updateLastForumAccess();
示例2: Execute
public function Execute(Template $template, Session $session, $request)
{
/* Create the ancestors bar (if we run into any trouble */
$template = CreateAncestors($template, $template['L_POSTREPLY']);
/* Open a connection to the database */
$this->dba = DBA::Open();
/* Set the a variable to this user's permissions and id */
$user_perms = isset($session['user']['perms']) ? $session['user']['perms'] : ALL;
$user_id = $session['user']['id'];
/* Quote all of the REQUEST variables */
foreach ($request as $key => $val) {
$request[$key] = $this->dba->Quote($val);
}
/* Parse the body text to replace bbcodes, emoticons, etc */
$parser = new BBParser(substr($request['message'], 0, $template['postmaxchars']));
//$parser->addOmit('omit', 'omit');
$request['message'] = $parser->Execute();
/* Get forums, etc */
try {
$forum = new Forum();
$stack = $forum->getForums();
} catch (DBA_Exception $e) {
return new TplException($e, $template);
}
/* Get the id of whatever you are replying to */
$parent_id = intval($request['replyto_id']);
try {
/* This gets a result from whatever the parent_id is */
@($parent = $this->dba->GetRow("SELECT * FROM " . POSTS . " WHERE id = {$parent_id}"));
// todo error checking
/* Even though the $parent could be the thread, we still need to get the thread, because we don't want to check if it is or not the thread */
@($thread = $this->dba->GetRow("SELECT * FROM " . POSTS . " WHERE row_left <= " . $parent['row_left'] . " AND row_right >= " . $parent['row_right'] . " AND row_type = 2"));
/* Get the forum from the thread's parent_id */
@($f = $forum->getForum($thread['parent_id']));
} catch (DBA_Exception $e) {
return new TplException($e, $template);
}
/* I came into the weirdest problem.. It seems to be that sqlite_escape_string make that Ø when nothing is passed to it. */
if ($request['title'] == 'Ø' || !$request['title']) {
$title = 'Re: ' . stripslashes($this->dba->Quote($parent['name']));
} else {
$title = stripslashes($request['title']);
}
/* Is this forum password-protected? */
if ($f['private'] == 1 && @$_SESSION['forum_logged'] != $f['id']) {
$template['forum_id'] = $f['id'];
$template->content = array('file' => 'forum_login.html');
} else {
/* Check if the forum is locked or suspended, and if it is one of the above, check if the user is an admin or a moderator */
if (($f['suspend'] == 1 && $session['user']['perms'] & ADMIN || $f['suspend'] != 1) && ($thread['row_locked'] != 1 || $thread['row_locked'] == 1 && $f['is_link'] != 1 && $session['user']['perms'] >= MOD) && ($f['row_lock'] != 1 || $f['row_lock'] == 1 && $session['user']['perms'] >= MOD)) {
/* If the parent_id is invalid */
if ($parent_id != 0 || !$parent_id) {
/* Get the number of replies on the same level as this */
if ($this->getNumOnLevel($parent_id) > 0) {
$left = $parent['row_right'];
} else {
$left = $parent['row_left'] + 1;
}
/* Get the depth and set the right value */
$depth = $parent['row_level'] + 1;
$right = $left + 1;
/* If this user has permission to post */
if ($user_perms >= $f['can_reply']) {
/* Should we ammend to the thread? */
if (($thread['row_right'] - $thread['row_left'] - 1) / 2 == 0 && $thread['poster_id'] == $session['user']['id']) {
try {
/* Create new body text */
$body_text = stripslashes($this->dba->Quote($thread['body_text'])) . "\n<br />\n<br /><!-- OMIT --><strong>" . $title . "</strong>\n<br />" . stripslashes($request['message']) . "<!-- /OMIT -->";
/* Ammend to the thread */
@$this->dba->Query("UPDATE " . POSTS . " SET body_text = '{$body_text}' WHERE id = " . $thread['id']);
} catch (DBA_Exception $e) {
return new TplException($e, $template);
}
} else {
$time = time();
try {
/* Make space in the Forums table for the reply */
@$this->dba->Query("UPDATE " . FORUMS . " SET row_right = row_right+2 WHERE row_left < {$left} AND row_right >= {$left}");
/* Keep making space in the Forums table for the reply */
@$this->dba->Query("UPDATE " . FORUMS . " SET row_left = row_left+2, row_right=row_right+2 WHERE row_left >= {$left}");
/* Make space in the Posts table for the reply */
@$this->dba->Query("UPDATE " . POSTS . " SET row_right = row_right+2 WHERE row_left < {$left} AND row_right >= {$left}");
/* Keep making space in the Posts table for the reply */
@$this->dba->Query("UPDATE " . POSTS . " SET row_left = row_left+2, row_right=row_right+2 WHERE row_left >= {$left}");
/* Finally Insert the reply into the database */
@$this->dba->Query("INSERT INTO " . POSTS . " (row_left, row_right, name, parent_id, row_level, body_text, created, poster_name, poster_id, row_type, forum_id) VALUES ({$left}, {$right}, '{$title}', {$parent_id}, {$depth}, '" . stripslashes($request['message']) . "', " . time() . ", '" . $session['user']['name'] . "', " . $session['user']['id'] . ", 4, " . $f['id'] . ")");
/* Set the last reply info for the thread info */
@$this->dba->Query("UPDATE " . POSTS . " SET last_reply = " . $time . ", reply_uid = " . $session['user']['id'] . ", reply_uname = '" . $session['user']['name'] . "' WHERE id = " . $thread['id']);
/* get the last post by this user */
$last_post_id = @$this->lastPostByUser($session['user']['id']);
/* Update the post count for the forum */
$this->dba->Query("UPDATE " . FORUMS . " SET posts = posts+1, thread_created = {$time}, thread_name = '" . $title . "', thread_id = " . $thread['id'] . ", thread_uname = '" . $session['user']['name'] . "', thread_uid = " . $session['user']['id'] . " WHERE id = " . $f['id']);
/* Update the user count if the user exists :) */
if ($user_id != 0) {
$this->dba->Query("UPDATE " . USERS . " SET posts = posts+1 WHERE id = " . $session['user']['id']);
}
} catch (DBA_Exception $e) {
return new TplException($e, $template);
}
}
//.........这里部分代码省略.........