4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 11, 2016, 10:56:13 AM

Login with username, password and session length
Search:     Advanced search
You're looking for some 4images templates and styles? Then visit this thread to show websites with 4images templates to download.
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Requests & Discussions) (Moderators: mawenzi, Rembrandt)
| | |-+  [MOD] Last topics from phpBB3 forum to index page (php) version 2
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: [MOD] Last topics from phpBB3 forum to index page (php) version 2  (Read 22214 times)
alekseyn1
Full Member
***
Offline Offline

Posts: 102

Thank You
-Given: 13
-Receive: 9


View Profile WWW
« on: December 15, 2009, 10:50:37 AM »

Dear all,

this MOD is inspired by Joss in his mod

[MOD] Last topics from phpBB3 forum to index page (php)
http://www.4homepages.de/forum/index.php?topic=26170.0

here is my version: I took the PHPBB hack from one of the forums and made this...

Step 1.

make new file and call it for example recent_phpbb.php

this should be the content of this file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/*-------------------------------------------------------------------------
|  PHPBB 3.x.x Last Posts Table with Permissions 0.1 (for center block) 10.12.2009 
|  for 4images 1.7.7 with bridge to PHPBB 3.x.x
|  by alekseyn1 <Aleksey Napolskih>
|  http://www.napolskih.com
|  Base on the following code by visiblesoul
/*-------------------------------------------------------------------------
|  MKPortal PHPBB 3.x.x Last Posts Table with Permissions 0.1 (for center block) 26.07.2008 
|  for MKP C 1.x with PHPBB 3.x.x
|  by mike16os <Khan-Cin Hau>
|  http://www.yamc.info/
|  Base on the following code by visiblesoul
/*-------------------------------------------------------------------------
|  MKPortal IPB 2.1.x Last Posts Table with Permissions 2.1 (for center block) 17.05.2006 
|  for MKP 1.1 x IPB 2.1.x
|  by visiblesoul <visiblesoul.net>
|  Support: http://www.visiblesoul.net/resources/forum/
+--------------------------------------------------------------------------*/

global $db$config;

/*---------------------------------------------------------------------------
Config:
--------------------------------------------------------------------------*/
$limit         10 // Number of forum posts to show in block 
$cutoff        60 // Number of characters to display in title
/*------------------------------------------------------------------------
Forum images Config:
--------------------------------------------------------------------------*/
$img_first_topic    ="";
$img_last_topic     ="";
//empty images canbe used by "" eg: $img_first_topic ="";
  
/*-------------------------------------------------------------------------
Language Setting:
--------------------------------------------------------------------------*/
$lang_topic_title        ="Topic Title";
$lang_last_post          ="Last Post";
$lang_last_post_date     ="posted on";
$lang_views              ="Views";
$lang_replies            ="Replies";
$lang_go_to_last_post    ="go to last post...";
$lang_topic_started_by   ="Topic started by";
$lang_on                 ="on";
$lang_by                 ="by";
$lang_last_poster        ="Last poster:";
/*------------------------------------------------------------------------*/

$content "
<tr>
  <td>

    <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
      <tr>
<td valign=\"top\" class=\"head1\">
$lang_topic_title</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_last_post</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_last_post_date</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_views</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_replies</td>
      </tr>
"
;

$sql "SELECT forum_id, forum_password FROM ".FORUMS_TABLE."";
 
$result $db->sql_query($sql);

while($f $db->sql_fetchrow($result)) {
 
if ($f['forum_password'] != "" ) {
            
$bad[] = $f['forum_id'];
        
} else {
         
$good[] = $f['forum_id'];
        
}
    
}

 
if ( count($bad) > ) {
     
$qe " AND forum_id NOT IN(".implode(','$bad ).") ";
    
}

$sql1 "SELECT t.topic_last_post_id, t.topic_id, t.topic_title, t.topic_views, t.topic_replies, t.topic_time, t.topic_last_post_time, t.topic_first_poster_name, t.topic_last_poster_name, topic_poster, t.forum_id
    FROM "
.TOPICS_TABLE." t
    LEFT JOIN "
.FORUMS_TABLE." f ON (t.forum_id = f.forum_id)
    WHERE topic_approved != 0 AND topic_approved = 1 AND (topic_moved_id = 0 or topic_moved_id='') 
$qe
    GROUP BY t.topic_title
    ORDER BY t.topic_last_post_id DESC LIMIT 0,
$limit";

$result1 $db->sql_query($sql1);
while ( $post $db->sql_fetchrow($result1)) {
$post['title'] = strip_tags($post['title']);
$post['topic_title'] = str_replace"!" "!" $post['topic_title'] );
$post['topic_title'] = str_replace"&quot;""\""$post['topic_title'] );
if (strlen($post['topic_title']) > $cutoff) {
$post['topic_title'] = substr$post['topic_title'],0,($cutoff 3) ) . "...";
$post['topic_title'] = preg_replace'/&(#(\d+;?)?)?(\.\.\.)?$/''...',$post['topic_title'] );


$title utf8_to_cp1251($post['topic_title']);
 
$tid utf8_to_cp1251($post['topic_id']);
$tlastid utf8_to_cp1251($post['topic_last_post_id']);
                
$views $post['topic_views'];
$posts $post['topic_replies'];
$starter $post['topic_first_poster_name'];
$lastname $post['topic_last_poster_name'];
$lastid $post['topic_poster'];
$forum_id $post['forum_id'];
$startdate  $post['topic_time'];
$lastdate  $post['topic_last_post_time'];

$content .= "
<!-- topic begin -->
      <tr>
<td class=\"row1\" align=\"left\">
  
$img_first_topic <a href=\"./forum/viewtopic.php?f=$forum_id&t=$tid\" title=\"$lang_topic_started_by $starter $lang_on ".format_date($config['date_format']." ".$config['time_format'], $startdate)."\" target = \"_blank\">$title</a>
</td>
<td class=\"row2\" align=\"center\">
  <a href=\"./forum/viewtopic.php?f=
$forum_id&t=$tid&p=$tlastid#p$tlastid\" title=\"$lang_go_to_last_post\" target = \"_blank\">$img_last_topic $lang_last_post</a> $lang_by <a href=\"./forum/memberlist.php?mode=viewprofile&u=$lastid\" title=\"$lang_last_poster $lastname\" target = \"_blank\"><b>$lastname</b></a>
</td>
<td class=\"row1\" align=\"center\">"
.format_date($config['date_format']." ".$config['time_format'], $lastdate)."</td>
<td class=\"row2\" align=\"center\"> 
$views </td>
<td class=\"row1\" align=\"center\"> 
$posts </td>     
</td>
      </tr>
<!-- topic end -->   
"
;
}

$content .= "
    </table>

  </td>
</tr>
"
;  

        
          unset(
$limit);
          unset(
$cutoff);
          unset(
$perms);
          unset(
$good);
          unset(
$bad);
          unset(
$qe);
          unset(
$post);
          unset(
$tid);
          unset(
$title);
          unset(
$views);
          unset(
$posts);
          unset(
$startdate);
          unset(
$lastdate);
          unset(
$starter);
          unset(
$lastname);
          unset(
$lastid);
          unset(
$tlastid);
          unset(
$forum_id);
          unset(
$img_last_topic);
          unset(
$img_first_topic);
          unset(
$lang_topic_title);
          unset(
$lang_last_post);
          unset(
$lang_last_post_date);
          unset(
$lang_views);
          unset(
$lang_replies);
          unset(
$lang_go_to_last_post);
          unset(
$lang_topic_started_by);
          unset(
$lang_on);
          unset(
$lang_by);
          unset(
$lang_last_poster);
                     
echo 
$content;

function 
utf8_to_cp1251($s)
        {
            for (
$c=0;$c<strlen($s);$c++)
            {
               
$i=ord($s[$c]);
               if (
$i<=127$out.=$s[$c];
                   if (
$byte2){
                       
$new_c2=($c1&3)*64+($i&63);
                       
$new_c1=($c1>>2)&5;
                       
$new_i=$new_c1*256+$new_c2;
                   if (
$new_i==1025){
                       
$out_i=168;
                   } else {
                       if (
$new_i==1105){
                           
$out_i=184;
                       } else {
                           
$out_i=$new_i-848;
                       }
                   }
                   
$out.=chr($out_i);
                   
$byte2=false;
                   }
               if ((
$i>>5)==6) {
                   
$c1=$i;
                   
$byte2=true;
               }
            }
            return 
$out;
}

?>

Step 2.


in your home.html file (in your template directory) include this string in the place where you want your table to show up:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 <!--last forum posts -->

 <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr>
                            <td class="head1" valign="top" colspan="5">Last forum posts</td>
                          </tr>
 
 <tr>
                            <td class="row1" valign="top" colspan="5"><?php include(ROOT_PATH."/recent_phpbb.php"); ?></td>
                          </tr>

                        </table>
                      </td>
                    </tr>
                  </table>
                  <br />
<!--end last forum posts -->


Notes:

1. In include/constants.php you must set the value to "1" in this define:  define('EXEC_PHP_CODE', 1);
2. This particular version of the code is designed for the database in UTF8 and your 4images site in other encoding (cp1251 in my case). I have only included the function to recode utf8 into windows 1251 - russian encoding. I am sure you can find other functions to recode into your codepage if required
3. you need to modify all occurrences of this code
1
<a href=\"./forum/
to reflect the correct path of your phpBB3 installation
4. of course you are more than welcom to improve and modify this code. Please post your improvements here for everybody's benefit.

see attachment for demo...

* forum_posts.JPG (51.01 KB - downloaded 29 times.)

Follow members gave a thank to your post:
Sumale.my

For this post, 1 member gave a thank you!
« Last Edit: December 15, 2009, 11:03:30 AM by alekseyn1 » Logged

V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 564

mmm PHP...


View Profile WWW
« Reply #1 on: December 15, 2009, 03:57:19 PM »

As far as I can tell this addon will only work if your 4images is integrated with phpBB3, correct?
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
alekseyn1
Full Member
***
Offline Offline

Posts: 102

Thank You
-Given: 13
-Receive: 9


View Profile WWW
« Reply #2 on: December 15, 2009, 04:01:14 PM »

As far as I can tell this addon will only work if your 4images is integrated with phpBB3, correct?

correct. only with this MOD

http://www.4homepages.de/forum/index.php?topic=26013.0
Logged

bergblume
Sr. Member
****
Offline Offline

Posts: 463

Thank You
-Given: 37
-Receive: 11

on to the top!


View Profile
« Reply #3 on: May 22, 2015, 05:44:17 PM »

for last forum posts of phpbb2 forums this code works (just as addition)

create recent.php with

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
    
// ############         Edit below         ########################################
    
$topic_length '20';   // length of topic title
    
$topic_limit '5';   // limit of displayed topics
    
$special_forums '0';   // specify forums ('0' = no; '1' = yes)
    
$forum_ids '3,5,6,7';      // IDs of forums; separate them with a comma

    
$config_path '/';   // path to config.php
    
$root_path 'INSERTYOURURLHERE';      // link path
    // ############         Edit above         #######################################

    
$path dirname(__FILE__);
    include_once(
$path.$config_path .'config.php');
    
mysql_connect($dbhost$dbuser$dbpasswd) OR die('Unable to select server.');
    
mysql_select_db($dbname) OR die('Unable to select database.');

    
// ############## output ##############
    
echo '<table border="0" cellpadding="0" cellspacing="0" style="width: 100%" id="Table_DSF-Top5">
    <body text="#000000" link="#000000" vlink="#333333" alink="#333333">
             <tr>
               <td colspan="4"><span class="small"><font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">
               Die '
$topic_limit .' letzten Themen im Forum</font></span></td><br>
             </tr>
             <tr>

                <td style="width: 20%"><span class="small">
                <strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">Foren</font></strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:9px"></font
                </strong></span></td>
                <td style="width: 20%"><span class="small">
                <strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">User</font>
                </strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:9px"></font
                </strong></span></td>
                <td style="width: 20%"><span class="small">
                <strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">Datum</font>
                </strong></span></td> 
                <td style="width: 20%"><span class="small"><strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">Thema</font>
                </strong>
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:9px"></font
                </strong></span></td>

             </tr>'
;
    
// ############## output ##############

    
$where_forums = ( $special_forums == '0' ) ? '' 't.forum_id NOT IN ('$forum_ids .') AND ';
    
$sql "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time
       FROM "
$table_prefix ."topics t, "$table_prefix ."forums f, "$table_prefix ."users u, "$table_prefix ."posts p, "$table_prefix ."posts p2, "$table_prefix ."users u2
       WHERE 
$where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id
       ORDER BY t.topic_last_post_id DESC LIMIT 
$topic_limit";
    
$result mysql_query($sql);
    if( !
$result )
    {
       die(
'SQL Statement Error: 'mysql_error());
       exit();
    }

    
$line = array();
    while( 
$row mysql_fetch_array($result) )
    {
       
$line[] = $row;
    }

    for( 
$i 0$i count($line); $i++ )
    {
       
$forum_id $line[$i]['forum_id'];
       
$forum_url $root_path .'viewforum.php?f='$forum_id;
       
$topic_id $line[$i]['topic_id'];
       
$topic_url $root_path .'viewtopic.php?t='$topic_id;

       
$topic_title = ( strlen($line[$i]['topic_title']) < $topic_length ) ? $line[$i]['topic_title'] : substr(stripslashes($line[$i]['topic_title']), 0$topic_length) .'...';

       
$topic_type =  ( $line[$i]['topic_type'] == '2' ) ? 'Announcement ''';
       
$topic_type .= ( $line[$i]['topic_type'] == '3' ) ? 'Global Announcement ''';
       
$topic_type .= ( $line[$i]['topic_type'] == '1' ) ? 'Sticky ''';
       
$topic_type .= ( $line[$i]['topic_vote'] ) ? 'Poll ''';

       
$views $line[$i]['topic_views'];
       
$replies $line[$i]['topic_replies'];

       
$first_time date('d.m.Y'$line[$i]['topic_time']);
       
$first_author = ( $line[$i]['first_poster_id'] != '-1' ) ? '<a href="'$root_path .'profile.php?mode=viewprofile&amp;u='$line[$i]['first_poster_id'] .'" target="_blank">'$line[$i]['first_poster'] .'</a>' : ( ($line[$i]['first_poster_name'] != '' ) ? $line[$i]['first_poster_name'] : 'guest' );
       
$last_time date('d.m.Y'$line[$i]['post_time']);
       
$last_author = ( $line[$i]['last_poster_id'] != '-1' ) ? $line[$i]['last_poster'] : ( ($line[$i]['last_poster_name'] != '' ) ? $line[$i]['last_poster_name'] : 'guest' );
       
$last_url '<a href="'$root_path .'viewtopic.php?p='$line[$i]['topic_last_post_id'] .'#'$line[$i]['topic_last_post_id'] .'" target="_blank">'$last_author .'</a>';

       
// ############## output ##############
       
echo '<tr>

               <td style="width: 20%"><a href="'
$forum_url .'" target="_blank">
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">'
$line[$i]['forum_name'] .'</font></a></td>
                <td style="width: 20%">
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">'
$last_url .'</font></td>
                <td style="width: 20%">
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">'
$last_time .'</font></td> 
                <td style="width: 20%"><a href="'
$topic_url .'" target="_blank">
                <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size:11px">'
$topic_title .'</font></a></td>

            </tr>'
;

       
// ############## output ##############
    
}

    echo 
'</table>';
    
mysql_close();
    
?>

save recent.php in your forum directory

and then embed with this line your latest posts somewhere within your 4images (best in the sidebar) with this code:

1
<?php include(ROOT_PATH."forum/recent.php"); ?>
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.075 seconds with 22 queries.