ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Mon Dec 10, 2007 7:36 am ����ͧ: ��˹�Һ��� |
|
|
����¹�� php ��������
�ѹ�����Ӥ����¹ query �ͧ�� �٨ҡ�ç���ҧ���ҧ�ͧ phpbb
����ѡ� ����
- ���ҧ phpbb_topics ����������´�ͧ topic Ẻ id , �����˹, ������Ǣ��, �ʵ��ѹ��, �դ���ҹ��褹, �դ��ʵ� (�ͺ) ��褹 (���������������´ content 㹡�з���鹹�)
- ���ҧ phpbb_posts ������������´�ͧ����ʵ����Ф��� �����駡���ʵ��Դ��з������á���� �ѹ���բ����ŷ���ͧ��ô֧��� ��з�����ʵ���� user ��ҹ�˹ �������Ҫԡ���촡�Т���� poster_id ��ͧ仴֧��������´�ҡ���ҧ phpbb_users �ա�� �����������Ҫԡ�Т���繪��ͷ�� post_username
- ���ҧ phpbb_users �ѹ�������ª�����Ҫԡ����
������ç���ҧ�¤����� ��� query ���������͢����Ţͧ���е��ҧ��Ҵ��¡ѹ
������� query ��ǹ��
������ѹ���§��� id �ͧ����ʵ�����ش >> order by T.topic_last_post_id desc
�������ʴ��� 10 record >> limit 10
Code:
$qboard='select T.topic_id, T.topic_title, U.username, T.topic_time, T.topic_replies, T.topic_poster, P.post_username, T.topic_views, T.topic_replies
from phpbb_topics as T
left join phpbb_posts as P on T.topic_first_post_id=P.post_id
left join phpbb_users as U on U.user_id=T.topic_poster
order by T.topic_last_post_id desc limit 10';
�ѹ�����Ҩ������������Ѻ column Topic, Post, Read/Reply
--------------------------------------------------------------------------------
�չ����Ҩ��ѧ�Ҵ�������ա�ͧ��ǹ��� �ѹ����ʵ�ͺ����ش��Ф�����ʵ�ͺ�������ش
��ǹ�����ҡ��ͧ�֧�ҡ���ҧ phpbb_post �����֧੾���ѹ����ش�ͧ���� topic ������ query �ѹ������� loop �ͧ����á
Code:
$qboard2='select U.username, P.post_time, P.poster_id, P.post_username
from phpbb_posts as P
left join phpbb_users as U on U.user_id=P.poster_id
where P.topic_id='.$rowb[0].' order by P.post_time desc limit 1';
------------------------------------------------------------------------------
�ѹ�����������
��������䢵��������Сѹ
Code:
<?
$qboard='select T.topic_id, T.topic_title, U.username, T.topic_time, T.topic_replies, T.topic_poster, P.post_username, T.topic_views, T.topic_replies
from phpbb_topics as T
left join phpbb_posts as P on T.topic_first_post_id=P.post_id
left join phpbb_users as U on U.user_id=T.topic_poster
order by T.topic_last_post_id desc limit 10';
$rboard=mysql_query($qboard, $db) or die("Error".mysql_error());
?>
<table width="470" align="center">
<tr>
<td align="center">Topic</td>
<td align="center">Post</td>
<td align="center">Rd/Rply</td>
<td align="center">Reply</td>
<td align="center">Date</td>
</tr>
<?
while ($rowb=mysql_fetch_array($rboard)) {
echo '<tr>';
//echo '<td>'.$rowb[0].'</td>';
echo '<td><a href="board/viewtopic.php?t='.$rowb[0].'" target="_blank">'.substr($rowb[1], 0, 100).'</a></td>';
if($rowb[5]==-1) echo '<td><strong>'.$rowb[6].'</strong></td>';
else echo '<td><strong>'.$rowb[2].'</strong></td>';
echo '<td>'.$rowb[7].'/'.$rowb[8].'</td>';
if ($rowb[4]!=0) {
$qboard2='select U.username, P.post_time, P.poster_id, P.post_username
from phpbb_posts as P
left join phpbb_users as U on U.user_id=P.poster_id
where P.topic_id='.$rowb[0].' order by P.post_time desc limit 1';
$rboard2=mysql_query($qboard2, $db);
$rowb2=mysql_fetch_array($rboard2);
if($rowb2[2]==-1) echo '<td><strong>'.$rowb2[3].'</strong></td>';
else echo '<td><strong>'.$rowb2[0].'</strong></td>';
echo '<td>'.date("d.m.y", $rowb2[1]).' </td>';
}
else {
echo '<td>N/A</td>';
echo '<td>'.date("d.m.y", $rowb[3]).'</td>';
}
echo '</tr>';
}
?>
</table>
------------------------------------------------------------------------------------
1. error �ç $db ��������
$db �ѹ�Ҩҡ
Code:
$host="localhost";
$user="root";
$pass="";
$db=mysql_connect ($host,$user,$pass) or die ("Error!");
mysql_select_db("mydb");
2. �ѹ�������Ѻ��ҵ�� prefix �����ҧ��鹵鹴��� phpbb_ �������Ҵ���
������ҷ������������������ phpbb_ ������ default �ͧ�ѹ
�ѹ�繤���觵Դ��Ͱҹ����������
�����
- ���Ͱҹ�����ŷ���ͧ��õԴ���
- ���� username
- password �ͧ username ���
���ç�Ѻ�ҹ�����ŷ����������ҹ���ͧ
Code: |
$dbhost = 'localhost'; // ��÷Ѵ����֤�����¡�ҹ�����Ũҡ����ͧ�˹
$dbname = 'database'; //��÷Ѵ��������Ͱҹ�����ŷ��ŧ phpbb
$dbuser = 'root'; // ��÷Ѵ������ username
$dbpasswd = ''; // ��÷Ѵ������ password
$db=mysql_connect ($dbhost,$dbuser,$dbpasswd) or die ("Error!");
mysql_select_db("$dbname"); |
--------------------------------------------------------------------------------------------------------------------------
���Ẻ������ ���¡����á�ҡ config.php �ͧ phpbb
��� path ��� include ���١�Сѹ
Code:
<?
include("phpbb/config.php"); // ��� path �ç������١
$db=mysql_connect ($dbhost,$dbuser,$dbpasswd) or die ("Error!");
mysql_select_db("$dbname");
$qboard='select T.topic_id, T.topic_title, U.username, T.topic_time, T.topic_replies, T.topic_poster, P.post_username, T.topic_views, T.topic_replies
from '.$table_prefix.'topics as T
left join '.$table_prefix.'posts as P on T.topic_first_post_id=P.post_id
left join '.$table_prefix.'users as U on U.user_id=T.topic_poster
order by T.topic_last_post_id desc limit 10';
$rboard=mysql_query($qboard, $db) or die("Error".mysql_error());
?>
<table width="470" align="center">
<tr>
<td align="center">Topic</td>
<td align="center">Post</td>
<td align="center">Rd/Rply</td>
<td align="center">Reply</td>
<td align="center">Date</td>
</tr>
<?
while ($rowb=mysql_fetch_array($rboard)) {
echo '<tr>';
//echo '<td>'.$rowb[0].'</td>';
echo '<td><a href="board/viewtopic.php?t='.$rowb[0].'" target="_blank">'.substr($rowb[1], 0, 100).'</a></td>';
if($rowb[5]==-1) echo '<td><strong>'.$rowb[6].'</strong></td>';
else echo '<td><strong>'.$rowb[2].'</strong></td>';
echo '<td>'.$rowb[7].'/'.$rowb[8].'</td>';
if ($rowb[4]!=0) {
$qboard2='select U.username, P.post_time, P.poster_id, P.post_username
from '.$table_prefix.'posts as P
left join '.$table_prefix.'users as U on U.user_id=P.poster_id
where P.topic_id='.$rowb[0].' order by P.post_time desc limit 1';
$rboard2=mysql_query($qboard2, $db);
$rowb2=mysql_fetch_array($rboard2);
if($rowb2[2]==-1) echo '<td><strong>'.$rowb2[3].'</strong></td>';
else echo '<td><strong>'.$rowb2[0].'</strong></td>';
echo '<td>'.date("d.m.y", $rowb2[1]).' </td>';
}
else {
echo '<td>N/A</td>';
echo '<td>'.date("d.m.y", $rowb[3]).'</td>';
}
echo '</tr>';
}
?>
</table> |
|
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Mon Dec 10, 2007 8:02 am ����ͧ: |
|
|
Topics Anywhere
http://www.phpbb.com/phpBB/viewtopic.php?t=72782
http://www.afsvlaanderen.be/topics_anywhere/download.php
�͹��� �������� ��
- Mod Attath �Ѿ��Ŵ���
- Super Quick Reply �ͺ��ѺẺ��ǹ���
- Member Online, Offline & Hidden �ʴ�ʶҹ���Ҫԡ
- Gallery Album Mod ����������ٻ
- Topic AnyWhere �ʴ���з������ش
- Today at/ Yesterday at ���ҧ��ҧ��
��Ŵ���� http://www.traincenter-kk.com/mc/phpBB.rar
�ԸյԴ��駤�͹��ҧ���ҡ ��ͧ�ѹ����� SQL ���� ������� phpMyAdmin �� ������ջÑ��
�Դ��駺��� �ҡ����ѹ Attath Mod �����¹ФѺ
Attath Mod. ::
���¡�ѹ�� http://www.yourdomain.com/phpBB/install/mod_table_inst.php
������ѹ�����������ź������ install �Ѻ Contrib ��¹Ф�Ѻ
��Ƿ�� 2 ��� Super Quick Reply :: ����� SQL �ѹ� phpMyAdmin �Ч��·���ش
��ҧ�ԧ�ҡ:
ALTER TABLE phpbb_users ADD user_show_quickreply TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_quickreply_mode TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_open_quickreply TINYINT(1) DEFAULT '1' NOT NULL;
UPDATE phpbb_users SET user_show_quickreply=0 WHERE user_id=-1;
UPDATE phpbb_users SET user_quickreply_mode=0 WHERE user_id=-1;
UPDATE phpbb_users SET user_open_quickreply=0 WHERE user_id=-1;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_quickreply', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('anonymous_show_sqr', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('anonymous_sqr_mode', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('anonymous_open_sqr', '0');
��Ƿ�� 3 ��� Gallery Album ��ǹ���ͧ���¡�ѹ��
http://www.yourdomain.com/phpBB/album_db_install.php
�ҡ������ź��� album_db_install.php ��� album_mysql.sql ���
��ǹ Topics_Anywhere ���¡��ҹ��
http://www.yourdomain.com/phpBB/topics_anywhere.php
�ҡ��鹡��ͻ����鴷����������ҧ��� ���˹�ҷ���ͧ�������¤Ѻ
����բ��ʧ��¡��ʵ������Ѻ �� �����ѧ� �͡���¹Ф�Ѻ |
|
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Tue Jul 15, 2008 2:19 am ����ͧ: |
|
|
����괹��仴� Save ���� show.php
...................
<?
include("config.php"); // ��� path �ç������١
$db=mysql_connect ($dbhost,$dbuser,$dbpasswd) or die ("Error!");
mysql_select_db("$dbname");
$qboard='select T.topic_id, T.topic_title, U.username, T.topic_time, T.topic_replies, T.topic_poster, P.post_username, T.topic_views, T.topic_replies
from '.$table_prefix.'topics as T
left join '.$table_prefix.'posts as P on T.topic_first_post_id=P.post_id
left join '.$table_prefix.'users as U on U.user_id=T.topic_poster
order by T.topic_last_post_id desc limit 12';
$rboard=mysql_query($qboard, $db) or die("Error".mysql_error());
?>
<table width="100%" align="center">
<tr>
<td class="header">��Ǣ��</td>
<td class="header">�����</td>
<td class="header">��/�ͺ</td>
<td class="header">���ͺ</td>
<td class="header">�ѹ���</td>
</tr>
<?
while ($rowb=mysql_fetch_array($rboard)) {
echo '<tr>';
//echo '<td>'.$rowb[0].'</td>';
echo '<td><a href="ryuozero-ftopic.html'.$rowb[0].'" target="_blank">'.substr($rowb[1], 0, 100).'</a></td>';
if($rowb[5]==-1) echo '<td><strong>'.$rowb[6].'</strong></td>';
else echo '<td><strong>'.$rowb[2].'</strong></td>';
echo '<td>'.$rowb[7].'/'.$rowb[8].'</td>';
if ($rowb[4]!=0) {
$qboard2='select U.username, P.post_time, P.poster_id, P.post_username
from '.$table_prefix.'posts as P
left join '.$table_prefix.'users as U on U.user_id=P.poster_id
where P.topic_id='.$rowb[0].' order by P.post_time desc limit 1';
$rboard2=mysql_query($qboard2, $db);
$rowb2=mysql_fetch_array($rboard2);
if($rowb2[2]==-1) echo '<td><strong>'.$rowb2[3].'</strong></td>';
else echo '<td><strong>'.$rowb2[0].'</strong></td>';
echo '<td>'.date("d.m.y", $rowb2[1]).' </td>';
}
else {
echo '<td>N/A</td>';
echo '<td>'.date("d.m.y", $rowb[3]).'</td>';
}
echo '</tr>';
}
?>
�ͧ�ٹ����������� ����Ѻ phpbb ��������
soce |
|
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Tue Jul 15, 2008 2:28 am ����ͧ: �աẺ |
|
|
Code: |
<?
// ################################################
// ���������з�����ӹǹ����ͧ��� (�Ѳ�ҵ�ͨҡ BallkunG)
//
// ����������괷�� BallkunG ��������һ�Ѻ��ا���������ҹ���¢��
// �������դ��������§�Ѻ ����ǻ���� �ҡ����ش �������ʹ���ͧ�Ѻ Show10.php
// �ͧ����ʹ���¤�Ѻ..
//
// �ҹ����ͧ�͢ͺ�س��� ����ʹ ��й�ͧ BallkunG ���� ��� ��� ���
// ################################################
// ��ù�����Ѻ ������鴵ç���������˹�ҷ���ͧ�����¤�Ѻ �ѧࡵ��÷Ѵ include �� � ��͹�Ф�Ѻ ��� path �������ͧʤ�Ի�����١�������
// include("./webboard/show10.php");
// showTop(10);
//
// ��ҹ�Ըա�õԴ������������з��˹���á������ ����з��˹���á.txt
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-874">
<style type=text/css>
body {font-family : MS Sans Serif; font-size : 10pt; color : #000000;}
td {font-size : 10pt; font-family : MS Sans Serif; color : #000000;}
.size3 {font-size : 12pt; font-family : MS Sans Serif;}
A:link {text-decoration: none; color: blue }
A:visited {text-decoration: none; color: #6495ED }
A:active {text-decoration: none; color: blue }
A:hover {text-decoration: none; color: red }
</style>
</head>
<?
function showTop($NumShow) {
// �Ҹ�ͧ��纺��� (������ç�Ѻ�Ҹ�ǻ���촷��س�� ���ҵ���� webboard �������ǡ�����ͧ���������)
$Path = "./webboard"; // ��䢨ش�����§�ش���� ���Թ��
include("$Path/config.inc.php");
// ��ҹ�����Ũҡ "�����Ǣ�ͤӶ��"
if(file_exists("$Path/$fileQuestion")) { //��Ǩ�ͺ���������������������
$datawb = file("$Path/$fileQuestion") ; // $fileQuestion �������� Config.inc.php
// ��Ҩӹǹ����ͧ����ʴ� �ҡ���� �ӹǹ�Ӷ������� ����դ����ҡѺ �ӹǹ�Ӷ�������
if($NumShow > sizeof($datawb)) $NumShow=sizeof($datawb);
// ǹ�ͺ�͢�����
for ( $i=0 ; $i<$NumShow ; $i++ ){
// ���͡�ҷ����ä���� (�¡����������к�÷Ѵ �͡�繿�Ŵ�����)
list ( $numQuestion , $Question , $Name , $Date ) = explode ( "|X|" , $datawb[$i] ) ;
// �����Ţ �ٹ�� ˹�������Ţ�Ӷ�� 4 ���
$No = sprintf("%04d",$numQuestion);
// ��ҤӶ����ǡ��� 45 ����ѡ�� ���Ѵ������� 45 ���
if(strlen($Question)>45) {
// �ӡѴ������Ǣͧ��з���� 45 ����ѡ��
$Question = substr($Question,0,45)."...";
}
// ��Ҫ��ͼ���駤Ӷ����ǡ��� 10 ����ѡ�� ���Ѵ������� 10 ���
if(strlen($Name)>10) {
// �ӡѴ������Ǣͧ���ͷ�� 10 ����ѡ��
$Name = substr($Name,0,10)."..";
}
// ǹ�ٻ��ҹ����������ӵͺ �����Ҩӹǹ�ӵͺ ** (������ԧ) ** ������
$fileReply = "$Path/$dataDir/R$numQuestion.txt";
$countR=0; // �繵�Ǻ͡����ըӹǹ���ͺ��褹 ��˹����ٹ���͹
if(file_exists($fileReply)) {
$Reply = file($fileReply);
for ($j=0 ; $j<sizeof($Reply) ; $j++) {
// �¡����������к�÷Ѵ �͡�繿�Ŵ�����
$chk = explode("||",$Reply[$j]);
// ��ҿ�Ŵ��� 0 �ͧ�����ŷ�����͡�� ��ҡѺ "IS_reply" (����������Ţ�Ӷ��) ���������� $countR
if(substr($chk[0],0,8) == "IS_reply"){ $countR++; }
}// ���ٻ for j
}//�� if
// ǹ�ٻ��ҹ�������Ҩӹǹ�����Ҫ� ����ѹ�������ش���ͺ�Ӷ��
$fileVisitor = "$Path/$dataDir/$numQuestion.dat";
if(file_exists($fileVisitor)) {
$lineVisitor = file($fileVisitor);
$chkVisitor = explode("||",$lineVisitor[0]); // �¡����������к�÷Ѵ �͡�繿�Ŵ�����
$ReplyDate = $chkVisitor[2]; //�ѹ���ͺ�Ӷ������ش
}//�� if
// ��˹��Ҿ icon ˹�������Ţ��з��
// ��ҵ�ͧ������ icon �ͧ�Ӷ���͵ �ʴ����ӹǹ���ͺ ���������������¹����Ţ�ͧ�Ф�Ѻ (㹷�����͵ͺ����� 10 ������)
if($ReplyDate!="-") {
$icon = ($countR>=10) ? "<img src='$Path/pic/hotfd.gif'>" : "<img src='$Path/pic/openfd.gif'>";
}
else {
$icon = ($Date==$mdate) ? "<img src='$Path/pic/newfd.gif'>" : "<img src='$Path/pic/closefd.gif'>";
}
// ��������� ����Ŵ (�ʴ��Ӷ��)
echo "$icon <font color=#666666>$No</font> <a href='$Path/view.php?No=$numQuestion' target=\"_blank\">$Question</a> <font color='#666666'>$Name [$Date]</font> :: (<font color=red>$countR</font>)<br>";
}// �� for ��Ѻ
}else { // �������������Ǣ�ͤӶ��
echo "<br><br><font color=red class=size3><b>\n";
echo "<p align=center>�ѧ������õ�駤Ӷ����¤�Ѻ<br></p></b>\n";
echo "</font> <br><br>\n\n";
}
}// ����ǹ�ͧ�ѧ����
?>
</html> |
http://smf.rcweb.net/index.php?topic=982.0 |
|