This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Building Online Communities
with phpBB 2
Stoyan Stefanov
Jeremy Rogers
Mike Lothar
BIRMINGHAM MUMBAI
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Building Online Communities with phpBB 2
Copyright © 2005 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers
or distributors will be held liable for any damages caused or alleged to be caused directly
or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
Technical Editors
Paramita Chakrabarti
Niranjan Jahagirdar
Proofreader
Chris Smith
Cover Designer
Helen Wood
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Foreword
phpBB is probably the most widely used Internet community software in the world. Some
reasons are obvious, some not so. It's free and very flexible. It has a solid community
filled with dedicated individuals behind it. It has a dedicated development team, with
constant development of new versions, patches for existing versions, and more. It is also
a quality script—a good product. These things, and more, have made phpBB the
immensely popular script that it is.
If you invest the time, this book can be your guide to making phpBB do what you want it
to. You will learn how to install and configure the script, use all of the standard features
and functions, customize the look and feel, install hacks, create hacks, program in
phpBB, and much more. This is accomplished through detailed explanations, step-by-step
guides, and visual examples.
With it's good and it's bad, the phpBB community is, overall, a good place. It is very
large and very international. There are not many people that have had as much first-hand
experience with the phpBB community as I have. I started phpBBHacks.com in early
April of 2001. Since then, we've grown to become a major part of the phpBB
community—the largest source of phpBB-related downloads, with a friendly and thriving
support community and the constant goal of being the ultimate phpBB resource.
Jeremy Rogers has been developing web-based applications in PHP and other
languages for a little more than six years. Shortly after discovering phpBB in early 2002
and deploying it on a video-game website, he began tinkering with and learning about
the internal workings of the software. Since then, he has authored dozens of expansions
and tutorials related to phpBB. Jeremy currently serves the phpBB community as a
phpBBHacks.com Support Team member, a capacity in which he has answered
thousands of questions regarding the software, its applications, and related topics.
I would like to thank Patrick O'Keefe, for opening the doors
to a wide world that led me here.
Mike Lothar has been around as a web designer for several years, both as a freelance
artist working for some of the major Danish advertising companies, and as a co-founder
of an independent web company. His interest in phpBB and its templates came fairly late.
At the time of this book's release, his templates had gained a wide recognition, used by a
variety of sites ranging from those of US presidential candidates to those of artists and
bands. Mike supports modification and personalization of phpBB skins at his community
forum, http://www.mikelothar.com.
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Table of Contents
Introduction
1
Chapter 1: Introduction to phpBB
Example phpBB Sites
A Standard phpBB Layout
Standard Sites with Different Templates
Sites with Standard Style and Modified Features
Modified phpBB Installations with Custom Templates
GaiaOnline
9
9
10
12
14
15
Summary
15
Chapter 2: Installing and Configuring phpBB
17
Pre-Installation
Requirements
The Attack Plan
Finishing Pre-Install Touch—The Database
phpBB Pre-Installation Checklist
17
17
Chapter 3: A Quick Tour of phpBB
Visitor Experience
Overview
Registration
Step 1
Step 2
Step 3
Logging In
Editing Your Profile
Posting
Anatomy of a Posting
Replying
Starting a New Topic
Formatting a Posting
Editing a Posting
Deleting a Posting
Searching
Sending and Receiving Private Messages (PM)
Voting in Polls
Staying Current with the Topics
Viewing Information about Other Users
Memberlist
Usergroups
Who Is Online
Moderator Experience
Managing Postings
Editing and Deleting
53
53
55
55
56
56
56
57
57
59
59
59
61
62
63
63
64
65
66
66
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Table of Contents
76
76
77
78
78
79
79
80
81
82
84
84
85
phpBB Styles
85
Structure of a Style
Style Elements
Style Storage
86
86
87
Editing phpBB Files
96
97
Editing Other Theme Components
Allowed Values
Commonly Used and Altered Elements
Changing CSS Styles to Change the Look of Your Site
Using External Stylesheets
97
99
100
102
104
iii
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Table of Contents
Customizing through Images
Installing New Images to Change the Look of Your Site
107
107
118
119
120
Example Modifications
Moving Elements
Adding New Elements to Your Forum
Adding New Languages
Summary
121
122
122
123
124
Chapter 5: Forum Administration
125
Making Your Board Multi-Lingual
125
Avatars: Enabling and Configuring
127
144
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Table of Contents
Usergroups and Group Permissions
Group Permissions
146
149
Second Look into Database Backups and Restore
Using phpMyAdmin
Using MySQL Command-Line Tools
151
151
155
The Board's Human Side: Flamewars and Banning
157
Chapter 6: Creating Your Own Template
159
174
Modifying the Forum Body in viewforum_body.tpl
Fixing the Size of the Jump Menu
190
198
And the Story Continues
Other Template Files
The Admin Folder
201
202
207
Icons and Images
207
Final Touches
207
Summary
208
Chapter 7: Creating a New MOD
Step 3—Choose Your Files
Step 4—File Editing and Creation
Pros and Cons of the Strike BBCode Methods
Step 5—Break It and Fix It
Make Your MOD Accessible to the World
Packaging Your MOD
Using the MOD Template Header
Creating the List of Actions
Using Other Actions
Adding the MOD Template Footer
The Completed Instruction File
Creating a ZIP File
Submitting Your Modification
Summary
Chapter 8: Programming phpBB
225
226
226
227
228
233
239
241
242
246
257
258
Using phpBB Messages
258
Using phpBB's Multi-Language System
260
Using phpBB Templates
A Simple Example
Using Loops in phpBB Templates
Using Conditions in phpBB Templates
262
263
265
267
User Authentication
Using the Authentication Function
Checking for Poll-Creation Privileges
269
270
272
Tips and Tricks
277
Create Links Automatically
Processing Smilies
Displaying a Posting Body
278
278
278
Coding Guidelines
279
Recent Postings MOD
The Challenge
The Template
The Code
279
279
281
283
Summary
290
Appendix A: Directory Structure
297
298
Optional Directories
Cached Pages
phpBB Documentation
Images
303
303
303
304
Other Directories of Note
Contributed Extras
Modification Files
304
304
304
Appendix B: phpBB Resources
307
vii
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
312
313
314
Permissions Cheatsheet
Permission Types
Permission Levels
Simple Mode Permissions
315
315
316
316
Appendix D: phpBB Database Structure
317
Index
337
viii
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Introduction
phpBB is a free, open-source Internet community application, with outstanding
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Introduction
Chapter 5 completes your mastery of phpBB administration. You will learn about
making your board multi-lingual, configuring avatars, managing smilies, forum, user, and
group permissions, as well as the human side of forum administration—moderation,
flamewars, and banning.
To give your forum a truly unique look, you will probably want to create your own
template. Creating your own template can be a very interesting process, but can also be
quite time consuming. Chapter 6 takes you through this process, from designing a new
template to realizing that design to create a new look for a forum. Starting with a rough
sketch on paper, we move through all the steps until we have a finished template.
As your community grows, you may find that you need to expand the capabilities of your
forum. Eventually you may need a feature and find yourself unable to locate an existing
modification for it! Chapter 7 shows you how to create a new modification (also known
as a hack) for yourself, to help you get that extra feature you are so missing. In this
chapter, you will start off by learning what modifications are, and the skills and tools
needed to create a modification. After that, we create a simple modification, and show
you how to make the modification available to other phpBB users.
Chapter 8 rounds things off with a look at what you need to know in order to program
new, custom phpBB features. The chapter starts with a simple phpBB script, before
moving on to working with the phpBB database, using phpBB messages and multiple
languages, working with the template engine and authenticating users. We build a new
phpBB extension at the end of the chapter, consolidating your phpBB programming
knowledge.
There are also four appendices, covering the phpBB file and directory structure, phpBB
resources, permission cheatsheets, and a guide to the phpBB database structure.
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
New terms and important words are introduced in a bold-type font. Words that you see
on the screen, in menus or dialog boxes for example, appear in our text like this:
"clicking the Next button moves you to the next screen".
Tips, suggestions, or important notes appear in a box like this.
Any command-line input and output is written as follows:
>\. mydump.sql
Query OK, 1 row affected (0.00 sec)
Reader Feedback
Feedback from our readers is always welcome. Let us know what you think about this
book, what you liked or may have disliked. Reader feedback is important for us to
develop titles that you really get the most out of.
To send us general feedback, simply drop an e-mail to [email protected], making
sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in
the SUGGEST A TITLE form on www.packtpub.com or e-mail [email protected].
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.
Customer Support
Now that you are the proud owner of a Packt book, we have a number of things to help
you to get the most from your purchase.
3
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
1
Introduction to phpBB
An online bulletin board in essence is an Internet-enabled version of the bulletin boards
found in stores and other public areas. It's basically just a place where people leave
messages for others to read. Well, the online bulletin board applications have become
much more powerful and sophisticated than that, but the general principle is the same.
phpBB is one of the most popular free software that implement the bulletin board idea
on the Web today.
In the first chapter of this phpBB book, you will learn about:
•
•
•
•
Online communities
phpBB history
phpBB development and where it's heading
What can be achieved with phpBB, and examples of existing phpBB sites
Online Communities
An online community is a group of people that gather together on a website for some
reason. This reason can be any subject of interest common to the group, like occupation,
hobby, passion, or location. Such online communities are very popular, and their
popularity is growing as more and more people start surfing the Web. Think about it—
everyone has something he or she is passionate about. And everybody likes meeting
people who share their interests. Historically, such computer-based communities existed
even before the Internet; using, for example, the modem-to-modem based bulletin board
systems (BBS).
An essential part of being in a community is sharing and contributing (for example,
extended the bulletin board systems (BBS) from the dark pre-Internet ages, adding a web
browser interface to them. phpBB belongs to the family of forum tools for building an
online community.
The Name
The name consists of two parts—"PHP" and "BB". PHP is the programming language in
which the software is written, and "BB" stands for "bulletin board"; it's a bulletin board
tool written in the PHP programming language.
PHP is also an abbreviation and it stands, or at least used to stand, for Personal Home
Page. PHP is no longer just a set of personal home page tools as it was in the beginning,
but has grown to become a true programming language. Its abbreviation has gone one
level deeper, and now recursively stands for "PHP Hypertext Preprocessor". But it's
really known simply as PHP.
6
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Chapter 1
The Environment
In technical terms, here's what you need in order to use phpBB:
•
•
•
•
The programming code to be executed
give you a few hints about how to deal with this fellow webmaster friend of yours that's
running vBulletin, Phorum, or another type of system.
•
phpBB is free. And it seems like it's going to stay this way. There have
already been offers from companies to buy phpBB, but those were refused.
7
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Introduction to phpBB
•
•
•
•
•
phpBB is one of the most popular forum software. All those webmasters out
there cannot be wrong. Continued usage of phpBB to power their web
communities is their best testimonial.
People know phpBB. Being so popular, it's very likely that your visitors have
seen and used it already. They don't have to learn an entirely new system,
and can start posting at once, feeling comfortable in a known environment.
8
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Chapter 1
Development
phpBB is an open-source project and has some specifics as such:
•
•
The developers are volunteers from around the world. phpBB is an example
of a successful open-source project. It has an impressive team list of about 50
people, when most open-source projects have two or three.
There's a community of users who often convert into collaborators.
You might be wondering how the community and the open-source nature of phpBB can
help its development. There are a lot of ways, but just to name the major ones:
•
•
•
•
•
•
Using and thus testing the software
Reporting bugs so they can be fixed by the developers
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Introduction to phpBB
intact. This is the site of Distributed Proofreaders (http://www.pgdp.net/phpBB2/), a
site that uses phpBB to provide a web-based method of easing the proofreading work
associated with the digitization of public-domain books into Project Gutenberg e-books.
By breaking the work into individual pages, many proofreaders can be working on the
same book at the same time.
Standard Sites with Different Templates
The next examples are phpBB installations with the default feature set, but with different
styles. You have a lot of options when it comes to the presentation of your board.
Instead of going with the default phpBB looks, you can find a pre-made template that
better suits your needs and layout/color preferences. Or, if you can't find a template you'd
like to use and you know some HTML, you can even create your own custom templates.
Here are some sites that use templates different than the default one.
Mike Lothar: The personal site of one of the authors of this book (http://community
.mikelothar.com/). His chapter (Chapter 6) guides you through the process of creating
your own custom templates:
10
This material is copyright and is licensed for the sole use by Jason on 25th September 2005
10465 Waterfowl Terrace, , Columbia, MD, 21044
Chapter 1