Differences

This shows you the differences between the selected revision and the current version of the page.

punbb13:integration 2009/03/27 05:13 punbb13:integration 2020/02/06 11:04 current
Line 4: Line 4:
===== General ===== ===== General =====
-In order to use PunBB user authentication within your scripts or to have access to the logged in user's information you have to include common.php which can be found in the include/ folder. You have also to define the FORUM_ROOT global variable in your script. It can be done like this: __**(Note it has to be added in the very top of your code)**__+In order to use PunBB user authentication within your scripts or to have access to the logged in user's information you have to include common.php which can be found in the include/ folder. You have also to define the FORUM_ROOT global variable in your script. For example, if your website front page is located in /home/user/public_html/ and your forums are located in /home/user/public_html/forums/, your FORUM_ROOT should be './forums/'. It can be done like this:
<code php> <code php>
<?php <?php
-define('FORUM_ROOT', 'forum/');+ 
 +// Add these lines in the very top of your code 
 +define('FORUM_ROOT', './forum/');
require FORUM_ROOT.'include/common.php'; require FORUM_ROOT.'include/common.php';
 +
?> ?>
</code> </code>
 +
 +===== URL schemes =====
 +PunBB 1.3 natively supports URL rewriting, including SEF URLs.
 +
 +How to enable URL rewriting:\\
 +  - Rename file ''.htaccess.dist'' in the root of your forum to ''.htaccess''.
 +  - Go to Administration => Settings (''/admin/settings.php?section=setup''), find ''URL Scheme'' section there.
 +  - Choose the URL scheme you like and save changes.
 +
 +
 +===== Template customization =====
 +==== How to include my file into *.tpl? ====
 +Use the ''forum_include "file.ext"'' substitute to include the file ''<FORUM_ROOT>/include/user/file.ext'':
 +<code php><!-- forum_include "file.ext" --></code>
===== Common tasks ===== ===== Common tasks =====
Line 62: Line 79:
{ {
if (utf8_strlen($cur_post['message']) > RECENT_POSTS_MAX_POST_LENGTH) if (utf8_strlen($cur_post['message']) > RECENT_POSTS_MAX_POST_LENGTH)
- $cur_post['message'] = utf8_substr($cur_post['message'], 0, RECENT_POSTS_MAX_POST_LENGTH).'…';+ $cur_post['message'] = utf8_substr($cur_post['message'], 0, RECENT_POSTS_MAX_POST_LENGTH).'...';
echo '<br />', "\n", $cur_post['message']; echo '<br />', "\n", $cur_post['message'];
Line 80: Line 97:
<code php> <code php>
<?php <?php
 +
 +header('Content-type: text/html; charset=utf-8');
if (!defined('FORUM_ROOT')) if (!defined('FORUM_ROOT'))
Line 126: Line 145:
</ul> </ul>
</code> </code>
 +
==== Showing active topics ==== ==== Showing active topics ====
-<code php>$topics_count = 5;+<code php><?php 
 + 
 +header('Content-type: text/html; charset=utf-8'); 
 + 
 +define('FORUM_ROOT', './'); 
 +require FORUM_ROOT.'include/common.php'; 
 + 
 +require FORUM_ROOT.'lang/'.$forum_user['language'].'/index.php'; 
 +require FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php'; 
 + 
 +$topics_count = 5;
$query_active_topics= array( $query_active_topics= array(
    'SELECT'    => 't.id AS tid, t.poster, t.subject, t.posted AS has_posted, t.last_post, t.last_post_id, t.num_replies, t.num_views, t.closed, t.sticky,     'SELECT'    => 't.id AS tid, t.poster, t.subject, t.posted AS has_posted, t.last_post, t.last_post_id, t.num_replies, t.num_views, t.closed, t.sticky,
Line 237: Line 267:
} }
 +</code>
 +
 +==== Login form outside the forum ====
 +
 +<code php><?php
 +
 +// Define the path to the forum root
 +define('FORUM_ROOT', './forum/');
 +require FORUM_ROOT.'include/common.php';
 +
 +// Where will we go after login?
 +$forum_page['redirect_url'] = 'http://your_site.com/forum/';
 +
 +$forum_page['form_action'] = forum_link($forum_url['login']);
 +
 +$forum_page['hidden_fields'] = array(
 + 'form_sent' => '<input type="hidden" name="form_sent" value="1" />',
 + 'redirect_url' => '<input type="hidden" name="redirect_url" value="'.forum_htmlencode($forum_page['redirect_url']).'" />',
 + 'csrf_token' => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
 +);
 +
 +?>
 +<form method="post" action="<?php echo $forum_page['form_action'] ?>">
 + <?php echo implode("\n\t\t", $forum_page['hidden_fields'])."\n" ?>
 +
 + Username:
 + <input type="text" id="fld1" name="req_username" value="" />
 + <br />
 +
 + Password:
 + <input type="password" id="fld2" name="req_password" value="" />
 + <br />
 +
 + <input type="checkbox" id="fld3" name="save_pass" value="1" />
 + <label for="fld3">Log me in automatically each time I visit.</label>
 + <br />
 +
 + <input type="submit" name="login" value="Login" />
 +</form>
 +</code>
 +
 +==== Using parser ====
 +
 +<code php>
 +<?php
 +
 +define('FORUM_ROOT', './');
 +require FORUM_ROOT.'include/common.php';
 +require FORUM_ROOT.'include/parser.php';
 +
 +$s = 'test [b]test[/b]';
 +
 +echo $s, parse_message($s, false);
</code> </code>

Personal Tools