Oracle/PHP 常见问题解答
[ 2004/12/25 23:53 | by ipaddr ]
文章来源:http://www.oracle.com/technology/global/cn/tech/opensource/php_faq.html
>>
>>
PHPBB的安装和精华功能的实现
[ 2004/12/25 23:50 | by ipaddr ]
最近网站上要弄个论坛,
找了好久,发现,在PHP环境下,免费的,好用的论坛确实不多,最后决定用PHPBB.
上传程序,上传文件,安装,安装界面,一切很顺利,
最后发现,基本安装的PHPBB没有上传功能,:(,真是不如意呀。
后来,不得不安装了一个 Attachment Mod[2.0.10],还真烦琐,更新数据库,上传了一些新的文件,还更新了几十个文件,终于搞定。
后来网站编辑要求加一个精华功能,找了好久也没找到插件,原来国外的论坛,大多数都没有精华功能的,最后不得不手工改PHPBB,新增一个精华功能,以下是过程。
最近网站上要弄个论坛,
找了好久,发现,在PHP环境下,免费的,好用的论坛确实不多,最后决定用PHPBB.
上传程序,上传文件,安装,安装界面,一切很顺利,
最后发现,基本安装的PHPBB没有上传功能,:(,真是不如意呀。
后来,不得不安装了一个 Attachment Mod[2.0.10],还真烦琐,更新数据库,上传了一些新的文件,还更新了几十个文件,终于搞定。
后来网站编辑要求加一个精华功能,找了好久也没找到插件,原来国外的论坛,大多数都没有精华功能的,最后不得不手工改PHPBB,新增一个精华功能,以下是过程。
1.修改数据库
在Topics表格中新增一字段topic_pink tinyint(1) UNSIGNED 默认为0,为1时表示为精华帖。
2.改资源文件
includes/contants.php
在define('POST_GLOBAL_ANNOUNCE', 3);后加入define('POST_PINK', 1);
language/lang_chinese_simplified/lang_main.php
在$lang['Topic_Sticky'] = "置顶:";后加入$lang['Topic_Pink'] = "精华:";
在$lang['Topics_Locked'] = "选择的主题已经成功的被锁定";后加入$lang['Topics_Pinked'] = "选择的主题已经成功的被设为精华";
在$lang['Topics_Unlocked'] = "选择的主题已经成功的被解锁";后加入$lang['Topics_Unpinked'] = "选择的主题已经成功的取消精华";
templates/xxxxxx/viewforum_body.tpl
在图示后面,加入精华帖的图示。
templates/xxxxxx/xxxx.cfg
在$images['folder_sticky'] = "$current_template_images/folder_sticky.gif";
后面加入$images['folder_pink'] = "$current_template_images/folder_pink.gif";
$images['folder_pink_new'] = "$current_template_images/folder_pink_new.gif";
templates/xxxxxx/images/
做两个图标,folder_pink.gif:精华帖的图标,folder_pink_new.gif有新帖时的精华帖图标
3.实现显示
a.viewforum.php
在$topic_type = $topic_rowset[$i]['topic_type'];后加入$topic_pink = $topic_rowset[$i]['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $topic_rowset[$i]['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
b.search.php
在$topic_type = $searchset[$i]['topic_type'];后加入$topic_pink = $searchset[$i]['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $searchset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $searchset[$i]['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
//注意,与viewforum.php有一点点不同,就是$searchset不同。
c.modcp.php
在$topic_type = $row['topic_type'];后加入$topic_pink = $row['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $row['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $row['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
//注意,与search.php也有不同,就是$searchset[$i]变成了$row。
基本也就这三个地方要显示精华帖。改法都相似,就是在相应的地方加入一些语句
4.实现操作
实现设置精华和取消精华的操作,只需修改两个地方,
a.viewtopic.php增加一个操作界面(链接)
在148行的"$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, "后面加入"t.topic_pink, ",从数据库里读取topic_pink字段,便于判断
在if ( $is_auth['auth_mod'] ) {}段里的$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) 行后面加入:
$topic_mod .= ( $forum_topic_data['topic_pink'] == POST_PINK ) ? "
b.修改modcp.php实现这个功能
1.在$unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;加入
$pink = ( isset($HTTP_POST_VARS['pink']) ) ? TRUE : FALSE;$unpink = ( isset($HTTP_POST_VARS['unpink']) ) ? TRUE : FALSE;
2.在
else if ( $unlock )
{
$mode = 'unlock';
}
后加入
else if ( $pink )
{
$mode = 'pink';
}
else if ( $unpink )
{
$mode = 'unpink';
}
3.在case 'unlock':.........break;那后面加上:
case 'pink':
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++)
{
$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_pink = 1
WHERE topic_id IN ($topic_id_sql)
AND forum_id = $forum_id
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '', '');
}
else
{
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '', '');
}
$message = $message . '
' . sprintf($lang['Click_return_forum'], '
$template->assign_vars(array(
'META' => '')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Pinked'] . '
' . $message);
break;
case 'unpink':
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++)
{
$topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_pink = 0
WHERE topic_id IN ($topic_id_sql)
AND forum_id = $forum_id
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '', '');
}
else
{
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '', '');
}
$message = $message . '
' . sprintf($lang['Click_return_forum'], '
$template->assign_vars(array(
'META' => '')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Unpinked'] . '
' . $message);
break;
//可以拷贝lock那段的内容,将SQL语句和最后面的message_die()那句改改就可以了。
到此,基本完工了!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
找了好久,发现,在PHP环境下,免费的,好用的论坛确实不多,最后决定用PHPBB.
上传程序,上传文件,安装,安装界面,一切很顺利,
最后发现,基本安装的PHPBB没有上传功能,:(,真是不如意呀。
后来,不得不安装了一个 Attachment Mod[2.0.10],还真烦琐,更新数据库,上传了一些新的文件,还更新了几十个文件,终于搞定。
后来网站编辑要求加一个精华功能,找了好久也没找到插件,原来国外的论坛,大多数都没有精华功能的,最后不得不手工改PHPBB,新增一个精华功能,以下是过程。
最近网站上要弄个论坛,
找了好久,发现,在PHP环境下,免费的,好用的论坛确实不多,最后决定用PHPBB.
上传程序,上传文件,安装,安装界面,一切很顺利,
最后发现,基本安装的PHPBB没有上传功能,:(,真是不如意呀。
后来,不得不安装了一个 Attachment Mod[2.0.10],还真烦琐,更新数据库,上传了一些新的文件,还更新了几十个文件,终于搞定。
后来网站编辑要求加一个精华功能,找了好久也没找到插件,原来国外的论坛,大多数都没有精华功能的,最后不得不手工改PHPBB,新增一个精华功能,以下是过程。
1.修改数据库
在Topics表格中新增一字段topic_pink tinyint(1) UNSIGNED 默认为0,为1时表示为精华帖。
2.改资源文件
includes/contants.php
在define('POST_GLOBAL_ANNOUNCE', 3);后加入define('POST_PINK', 1);
language/lang_chinese_simplified/lang_main.php
在$lang['Topic_Sticky'] = "置顶:";后加入$lang['Topic_Pink'] = "精华:";
在$lang['Topics_Locked'] = "选择的主题已经成功的被锁定";后加入$lang['Topics_Pinked'] = "选择的主题已经成功的被设为精华";
在$lang['Topics_Unlocked'] = "选择的主题已经成功的被解锁";后加入$lang['Topics_Unpinked'] = "选择的主题已经成功的取消精华";
templates/xxxxxx/viewforum_body.tpl
在图示后面,加入精华帖的图示。
templates/xxxxxx/xxxx.cfg
在$images['folder_sticky'] = "$current_template_images/folder_sticky.gif";
后面加入$images['folder_pink'] = "$current_template_images/folder_pink.gif";
$images['folder_pink_new'] = "$current_template_images/folder_pink_new.gif";
templates/xxxxxx/images/
做两个图标,folder_pink.gif:精华帖的图标,folder_pink_new.gif有新帖时的精华帖图标
3.实现显示
a.viewforum.php
在$topic_type = $topic_rowset[$i]['topic_type'];后加入$topic_pink = $topic_rowset[$i]['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $topic_rowset[$i]['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
b.search.php
在$topic_type = $searchset[$i]['topic_type'];后加入$topic_pink = $searchset[$i]['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $searchset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $searchset[$i]['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
//注意,与viewforum.php有一点点不同,就是$searchset不同。
c.modcp.php
在$topic_type = $row['topic_type'];后加入$topic_pink = $row['topic_pink'];
在
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
后加入
else if( $topic_pink == POST_PINK )
{
$topic_type = $lang['Topic_Pink'] . ' ';
}
在
else if( $row['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
后加入
else if( $row['topic_pink'] == POST_PINK )
{
$folder = $images['folder_pink'];
$folder_new = $images['folder_pink_new'];
}
//注意,与search.php也有不同,就是$searchset[$i]变成了$row。
基本也就这三个地方要显示精华帖。改法都相似,就是在相应的地方加入一些语句
4.实现操作
实现设置精华和取消精华的操作,只需修改两个地方,
a.viewtopic.php增加一个操作界面(链接)
在148行的"$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, "后面加入"t.topic_pink, ",从数据库里读取topic_pink字段,便于判断
在if ( $is_auth['auth_mod'] ) {}段里的$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) 行后面加入:
$topic_mod .= ( $forum_topic_data['topic_pink'] == POST_PINK ) ? "
b.修改modcp.php实现这个功能
1.在$unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;加入
$pink = ( isset($HTTP_POST_VARS['pink']) ) ? TRUE : FALSE;$unpink = ( isset($HTTP_POST_VARS['unpink']) ) ? TRUE : FALSE;
2.在
else if ( $unlock )
{
$mode = 'unlock';
}
后加入
else if ( $pink )
{
$mode = 'pink';
}
else if ( $unpink )
{
$mode = 'unpink';
}
3.在case 'unlock':.........break;那后面加上:
case 'pink':
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++)
{
$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_pink = 1
WHERE topic_id IN ($topic_id_sql)
AND forum_id = $forum_id
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '', '');
}
else
{
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '', '');
}
$message = $message . '
' . sprintf($lang['Click_return_forum'], '
$template->assign_vars(array(
'META' => '')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Pinked'] . '
' . $message);
break;
case 'unpink':
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = '';
for($i = 0; $i < count($topics); $i++)
{
$topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_pink = 0
WHERE topic_id IN ($topic_id_sql)
AND forum_id = $forum_id
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_topic'], '', '');
}
else
{
$redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'];
$message = sprintf($lang['Click_return_modcp'], '', '');
}
$message = $message . '
' . sprintf($lang['Click_return_forum'], '
$template->assign_vars(array(
'META' => '')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Unpinked'] . '
' . $message);
break;
//可以拷贝lock那段的内容,将SQL语句和最后面的message_die()那句改改就可以了。
到此,基本完工了!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>