本文整理汇总了PHP中forum::check_block方法的典型用法代码示例。如果您正苦于以下问题:PHP forum::check_block方法的具体用法?PHP forum::check_block怎么用?PHP forum::check_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum
的用法示例。
在下文中一共展示了forum::check_block方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Skjema for å opprette ny tråd
*/
protected function show()
{
// kontroller rankkravet
if (!$this->forum->check_rank()) {
// sett opp ranknavnet
$rank_info = game::$ranks['items_number'][\Kofradia\Forum\Category::TOPIC_MIN_RANK];
echo '
<div class="bg1_c xsmall">
<h1 class="bg1">Ny forumtråd i ' . htmlspecialchars($this->forum->get_name()) . '<span class="left"></span><span class="right"></span></h1>
<p class="h_left"><a href="forum?id=' . $this->forum->id . '">« Tilbake</a></p>
<div class="bg1">
<div class="error_box" style="padding: 10px 0">
<p>Du har for lav rank for å kunne opprette forumtråder i forumet.</p>
<p>For å kunne opprette en ny forumtråd må du ha nådd ranken <b>' . htmlspecialchars($rank_info['name']) . '</b>.</p>
<p>Se også <a href="' . ess::$s['relative_path'] . '/node/5">hjelp</a>.</p>
<p><a href="forum?id=' . $this->forum->id . '">Tilbake</a></p>
</div>
</div>
</div>';
return;
}
// kontroller blokkeringer
$block = $this->forum->check_block();
// opprette forumtråden?
if (!$block && isset($_POST['opprett'])) {
$title = postval("title");
$text = postval("text");
// type forumtråd og låst/ulåst
$type = NULL;
$locked = NULL;
if ($this->forum->fmod) {
$type = postval("type");
$locked = isset($_POST['locked']);
}
// forsøk å opprett forumtråden
$this->forum->add_topic($title, $text, $type, $locked);
}
echo '
<div class="bg1_c forumw forumnewtopic">
<h1 class="bg1">Ny forumtråd i ' . htmlspecialchars($this->forum->get_name()) . '<span class="left"></span><span class="right"></span></h1>
<p class="h_left"><a href="forum?id=' . $this->forum->id . '">« Tilbake</a></p>
<div class="bg1">
<boxes />
<div id="topic_info_add"></div>
<div class="forum_reply_edit_c">
<form action="" method="post">
<dl class="dl_2x">
<dt>Tittel</dt>
<dd>
<input type="text" name="title" id="topic_title" class="styled w300" value="' . htmlspecialchars(postval("title")) . '" maxlength="40" />';
if ($this->forum->fmod) {
$type = intval(postval("type"));
echo '
<select name="type" id="topic_type">
<option value="1"' . ($type == 1 ? ' selected="selected"' : '') . '>Normal forumtråd</option>
<option value="2"' . ($type == 2 ? ' selected="selected"' : '') . '>Sticky forumtråd</option>
<option value="3"' . ($type == 3 ? ' selected="selected"' : '') . '>Viktig forumtråd</option>
</select>
</dd>
<dt>Låst</dt>
<dd><input type="checkbox" name="locked" id="topic_locked"' . (isset($_POST['locked']) ? ' checked="checked"' : '') . ' /><label for="topic_locked"> Lås forumtråden for endringer</label>';
}
echo '</dd>
<dt>Innhold</dt>
<dd><textarea name="text" rows="20" cols="75" id="topic_text">' . htmlspecialchars(postval("text")) . '</textarea></dd>
</dl>
<p class="c">Husk at <a href="' . ess::$s['relative_path'] . '/node/6" target="_blank">forumreglene</a> til enhver tid skal følges.</p>
<p class="c">
' . show_sbutton("Opprett", 'name="opprett" accesskey="s" id="topic_add"') . '
' . show_sbutton("Forhåndsvis", 'name="preview" accesskey="p" id="topic_preview"') . '
</p>
</form>
</div>
<div id="topic_info">';
// forhåndsvisning
if (isset($_POST['preview'])) {
$data = array("ft_text" => postval("text"));
echo '
<div class="forum">' . \Kofradia\Forum\Category::template_topic_preview($data) . '
</div>';
}
echo '
</div>
</div>
</div>';
// div javascript
ess::$b->page->add_js_file(ess::$s['relative_path'] . "/js/forum.js");
ess::$b->page->add_js_domready('
new NewForumTopic(' . $this->forum->id . ');');
}
示例2: add_reply
/**
* Legg til nytt forumsvar
* @param string $text
* @param boolean $no_concatenate ikke sammenslå med evt. forrige forumsvar
* @param boolean $announce annonser på IRC/spilleloggen
*/
public function add_reply($text, $no_concatenate, $announce)
{
if (!\login::$logged_in) {
throw new HSNotLoggedIn();
}
// er forumtråden låst?
if ($this->info['ft_locked'] != 0 && !$this->forum->fmod) {
$this->add_reply_error_locked();
return;
}
// er forumtråden slettet?
if ($this->info['ft_deleted'] != 0) {
$this->add_reply_error_deleted();
return;
}
// kontroller blokkering
if ($this->forum->check_block()) {
return;
}
// kontroller ventetid før nytt forumsvar kan legges til
$this->forum->check_timers();
if ($this->forum->wait_reply > 0) {
$this->add_reply_error_wait($this->forum->wait_reply);
return;
}
// kontroller tekstlengde
$text = trim($text);
if (\Kofradia\Forum\Category::check_length($text) < \Kofradia\Forum\Category::REPLY_MIN_LENGTH) {
$this->add_reply_error_length();
return;
}
// sjekk om vi skal sammenslå dette med det siste forumsvaret
if (!$no_concatenate) {
// hent siste forumsvaret
$result = \Kofradia\DB::get()->query("SELECT fr_id, fr_up_id, fr_time FROM forum_replies WHERE fr_ft_id = {$this->id} AND fr_deleted = 0 ORDER BY fr_time DESC LIMIT 1");
$row = $result->fetch();
// fant forumsvar, og tilhører brukeren
// forumsvaret er nyere enn 6 timer
if ($row && $row['fr_up_id'] == \login::$user->player->id && time() - $row['fr_time'] < 21600) {
// slå sammen med dette forumsvaret
$text = "\n\n[hr]\n\n{$text}";
\Kofradia\DB::get()->exec("UPDATE forum_replies SET fr_text = CONCAT(fr_text, " . \Kofradia\DB::quote($text) . "), fr_last_edit = " . time() . ", fr_last_edit_up_id = " . \login::$user->player->id . " WHERE fr_id = {$row['fr_id']}");
// annonsere forumsvaret?
if ($announce && ($reply = $this->get_reply($row['fr_id']))) {
$reply->announce();
}
// logg
\Kofradia\Forum\Log::add_reply_concatenated($this, $row['fr_id']);
$this->add_reply_merged($row['fr_id']);
return;
}
}
// legg til som nytt forumsvar
\Kofradia\DB::get()->exec("INSERT INTO forum_replies SET fr_time = " . time() . ", fr_up_id = " . \login::$user->player->id . ", fr_text = " . \Kofradia\DB::quote($text) . ", fr_ft_id = {$this->id}");
$reply_id = \Kofradia\DB::get()->lastInsertId();
// oppdater forumtråden med antall forumsvar og siste forumsvar
\Kofradia\DB::get()->exec("UPDATE forum_topics SET ft_replies = ft_replies + 1, ft_last_reply = {$reply_id} WHERE ft_id = {$this->id}");
// oppdater spilleren
if ($this->forum->ff) {
\Kofradia\DB::get()->exec("UPDATE ff_members SET ffm_forum_replies = ffm_forum_replies + 1 WHERE ffm_up_id = " . \login::$user->player->id . " AND ffm_ff_id = {$this->forum->ff->id}");
\Kofradia\DB::get()->exec("UPDATE users_players SET up_forum_ff_num_replies = up_forum_ff_num_replies + 1 WHERE up_id = " . \login::$user->player->id);
} else {
\Kofradia\DB::get()->exec("UPDATE users, users_players SET up_forum_num_replies = up_forum_num_replies + 1, u_forum_reply_time = " . time() . " WHERE up_id = " . \login::$user->player->id . " AND up_u_id = u_id");
}
// annonsere forumsvaret?
if ($announce && ($reply = $this->get_reply($reply_id))) {
$reply->announce();
}
// oppdater tid om nødvendig
$this->forum->update_change_time();
// logg
\Kofradia\Forum\Log::add_reply_added($this, $reply_id);
// fullført
$this->add_reply_complete($reply_id);
}