📄 forums.php
字号:
<?php
//******************************************************//
// ///////// //// /////
// // // // // //
// // ///// ////// //// ////
// // // //// // // // //
// ///////// ///// ////// ///// /////
//******************************************************//
// icebb.net // 1.0
//******************************************************//
// forums admin module
// $Id: forums.php 946 2005-11-18 03:58:13Z mutantmonkey $
//******************************************************//
class forums
{
function run()
{
global $icebb,$config,$db,$std;
$this->lang = $icebb->admin->learn_language('global');
$this->html = $icebb->admin_skin->load_template('forums');
$icebb->admin->page_title = "Forums";
switch($icebb->input['func'])
{
case 'new':
$this->new_forum();
break;
case 'edit':
$this->edit();
break;
case 'children':
$this->show_children();
break;
case 'del':
$this->delete();
break;
case 'mod':
$this->moderator();
break;
case 'duplicate':
$this->duplicate();
break;
case 'announce':
$this->announce();
break;
case 'new_announce':
$this->new_announce();
break;
case 'edit_announce':
$this->edit_announce();
break;
default:
$this->show_forums();
break;
}
$icebb->admin->html = $this->html->display($icebb->admin->html);
$icebb->admin->output();
}
function duplicate()
{
global $icebb,$config,$db,$std;
if(empty($icebb->input['fid']))
{
$icebb->admin->error("No Forum ID choosen.");
}
if(isset($icebb->input['submit']))
{
$fq = $db->query("SELECT * FROM icebb_forums WHERE fid={$icebb->input['fid']} LIMIT 1");
if($db->get_num_rows($fq) <= 0)
{
$icebb->admin->error("No such forum");
}
$f = $db->fetch_row($fq);
$lastfq = $db->query("SELECT * FROM icebb_forums ORDER BY sort ASC LIMIT 1");
$lastforum = $db->fetch_row($lastfq);
$db->insert('icebb_forums',array(
'sort' => $lastforum['sort']+1,
'name' => $icebb->input['name'],
'description' => $icebb->input['description'],
'parent' => $icebb->input['parent'],
'postable' => $f['postable'],
'redirecturl' => $f['redirecturl'],
'perms' => $f['perms'],
'password' => $f['password'],
'moderators' => $f['moderators'],
));
$icebb->admin->redirect("Duplicate created",$icebb->base_url."act=forums");
}
else
{
$fq = $db->query("SELECT * FROM icebb_forums WHERE fid={$icebb->input['fid']} LIMIT 1");
if($db->get_num_rows($fq) <= 0)
{
$icebb->admin->error("No such forum");
}
$f = $db->fetch_row($fq);
$icebb->user['g_permgroup'] = 1;
$forumlist = $std->get_forum_listing();
$forumslist = $this->forum_list_children($forumlist,'0');
$parentlist[] = array('0','Root (Make this forum a category)');
foreach($forumslist as $f2)
{
$parentlist[] = $f2;
}
$icebb->admin->page_title = "Duplicate forum: {$f['name']}";
$icebb->admin_skin->table_titles= array(array('{none}','40%'),array('{none}','60%'));
$icebb->admin->html = $icebb->admin_skin->start_form('admin.php',array('sessid'=>$icebb->adsess['sessid'],'act'=>'forums','func'=>'duplicate','fid'=>$icebb->input['fid']),'post'," name='adminfrm'");
$icebb->admin->html .= $icebb->admin_skin->start_table("Settings");
$icebb->admin->html .= $icebb->admin_skin->table_row(array("<strong>Forum Name</strong>",$icebb->admin_skin->form_input('name',$f['name'])));
$icebb->admin->html .= $icebb->admin_skin->table_row(array("<strong>Forum Description</strong><br />Enter a description for the forum. HTML is allowed, but you do not need to use <br> tags.",$icebb->admin_skin->form_textarea('description',$f['description'])));
$icebb->admin->html .= $icebb->admin_skin->table_row(array("<strong>Parent Forum</strong><br />The \"parent\" of the forum. That is, the category or forum that this forum will appear in.",$icebb->admin_skin->form_dropdown('parent',$parentlist,$f['parent'])));
$icebb->admin->html .= $icebb->admin_skin->end_table();
$icebb->admin->html .= "<div class='buttonrow'><input type='submit' name='submit' value='Create Duplicate' class='button' /></div></form>";
}
}
function show_forums()
{
global $icebb,$config,$db,$std;
if(isset($icebb->input['reorder']))
{
if(is_array($icebb->input['reorder-root-forums']))
{
$icebb->input['forum_sort'] = array(); $c = 0;
foreach($icebb->input['reorder-root-forums'] as $ro => $rf)
{ $c++;
$icebb->input['forum_sort'][$rf]= $c;
}
}
foreach($icebb->input['forum_sort'] as $k => $v)
{
$db->query("UPDATE icebb_forums SET sort='{$v}' WHERE fid='{$k}' LIMIT 1");
}
$this->recache_forums();
$icebb->admin->redirect("Forums reordered","{$icebb->base_url}act=forums");
}
$db->query("SELECT COUNT(*) FROM icebb_forums WHERE parent='0' ORDER BY sort");
$fr = $db->fetch_row();
$frsort = $fr['COUNT(*)'];
for($i=1; $i <= $frsort; $i++)
{
$sortlist[] = array($i,$i);
}
foreach($icebb->cache['forums'] as $fo)
{
$this->subforums[$fo['parent']][]= $fo;
}
if(is_array($icebb->cache['moderators']))
{
foreach($icebb->cache['moderators'] as $mo)
{
$this->moderators[$mo['mforum']][]= $mo;
}
}
$z = 0;
// parent forums
$parentq = $db->query("SELECT * FROM icebb_forums WHERE parent='0' ORDER BY sort");
$total = $db->get_num_rows();
while($c = $db->fetch_row($parentq))
{
$z++;
$c['total'] = $total;
$c['on'] = $z;
$tforum = $db->query("SELECT * FROM icebb_forums WHERE parent='{$c['fid']}' ORDER BY sort");
while($r = $db->fetch_row($tforum))
{
$children2 = array();
$tas = $db->query("SELECT fid,name FROM icebb_forums WHERE parent='{$r['fid']}' ORDER BY sort");
while($t = $db->fetch_row($tas))
{
$children2[]= $t;
}
$children .= $this->html->list_forums_forum_child($r,$children2);
}
//$children = $this->get_childrenof($c['fid']);
$forums .= $this->html->list_forums_forum($c,$children);
$children = '';
}
$icebb->admin->html = $this->html->list_forums($forums);
}
function get_childrenof($fid,$before='')
{
global $icebb,$db,$std;
if(is_array($this->subforums[$fid]))
{
foreach($this->subforums[$fid] as $sf)
{
$data .= $this->html->list_forums_forum_child_child($sf,$before." '-"," style='display:none'");
if(count($this->subforums[$sf['fid']])>=1)
{
$data .= $this->get_childrenof($sf['fid'],$before.' ');
}
}
}
return $data;
}
function show_children()
{
global $icebb,$config,$db,$std;
if(isset($icebb->input['reorder']))
{
foreach($icebb->input['forum_sort'] as $k => $v)
{
$db->query("UPDATE icebb_forums SET sort='{$v}' WHERE fid='{$k}' LIMIT 1");
}
$this->recache_forums();
$icebb->admin->redirect("Forums reordered","{$icebb->base_url}act=forums");
}
// how many to sort by?
$db->query("SELECT COUNT(*) FROM icebb_forums WHERE parent='{$icebb->input['fid']}'");
$fr = $db->fetch_row();
$frsort = $fr['COUNT(*)'];
for($i=1; $i <= $frsort; $i++)
{
$sortlist[] = array($i,$i);
}
// parent forums
$parentq = $db->query("SELECT * FROM icebb_forums WHERE fid='{$icebb->input['fid']}' ORDER BY sort");
while($c = $db->fetch_row($parentq))
{
$elforums = array();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -