- •Table of Contents
- •Preface
- •What This Book Covers
- •Conventions
- •Reader Feedback
- •Customer Support
- •Downloading the Example Code for the Book
- •Errata
- •Questions
- •What is vBulletin?
- •Why Have a Discussion Board?
- •Benefits of a Discussion Board
- •Why vBulletin?
- •History
- •Development
- •The vBulletin Advantage
- •Versatile
- •Performance
- •Customizable
- •Easy to Maintain
- •Other Features
- •vBulletin Licensing Options
- •Leased License
- •Owned License
- •Choosing a License
- •Example vBulletin Sites
- •Summary
- •Requirements
- •Disk Space
- •Bandwidth
- •System Resources
- •Shared Hosting
- •Semi-Dedicated Hosting
- •Dedicated Hosting
- •Other Options
- •Installing vBulletin
- •Tools
- •Downloading the Installation Files
- •File Extraction
- •Upload Preparation
- •Creating the Database
- •Command-Line Database Creation
- •cPanel Database Creation
- •File Editing
- •Uploading the vBulletin Files
- •Running the vBulletin Installation Script
- •Troubleshooting
- •Database Access Issues
- •Images/Styling Not Showing
- •PHP Errors
- •The vBulletin Control Panel
- •Importing Data into vBulletin
- •Downloading the ImpEx Script
- •Compatibility
- •Preparing for Upload
- •Editing the Configuration File
- •Upload the ImpEx Script
- •Running the ImpEx Script
- •Default Usergroups
- •Securing vBulletin
- •Help & Support
- •Summary
- •The vBulletin User Experience
- •How to Get to the Board?
- •What the End Users See
- •Site Logo
- •Forum Title, Login Box, and Navbar
- •Welcome Banner
- •Main Body of the Forum
- •What's Going On
- •Footer
- •Touring the Main Forum—Unregistered Users
- •No "New Threads" for Unregistered Users
- •Registering on a vBulletin Board
- •Touring the Forum—Members
- •New Threads
- •Replying
- •Editing a Message
- •Private Messages
- •BB Code
- •User Tools
- •Display Modes
- •Navbar Changes for Members
- •The vBulletin Administrator Experience
- •Forum and Thread Tools
- •The AdminCP
- •Control Panel Home
- •Latest Version Information
- •vBulletin Options
- •Forum Management
- •Editing and Adding Forums
- •Editing Existing Forums
- •Moderation Options
- •Forum Styling
- •Access Control Options
- •Forum Posting Options
- •Enable/Disable Features
- •Branding
- •Changing the Logo
- •Undoing the Change
- •Summary
- •Types of Customization
- •CSS Modifications
- •Changing the Table Title Text
- •Viewing Changes
- •Undoing the Changes
- •Phrase Modifications
- •Searching for Phrases
- •Making Changes
- •Viewing the Changes
- •Undoing Changes
- •Template Modifications
- •Accessing Templates
- •Exploring a Template
- •Template Structure
- •Adding a FORUMHOME Sidebar
- •Two Changes
- •PHP Code Modifications
- •PayPal Modification
- •File Modification
- •Hacks
- •Pros and Cons of Hacking a vBulletin Board
- •Finding a Hack
- •Installing a Hack
- •Backing Up a Hack
- •Commercial Hacks
- •Summary
- •Setting Up a Forum
- •Creating the Forum
- •Forum Permissions
- •Viewing Permissions
- •Opening the Forum
- •Super Administrators
- •Creating a Super Administrator
- •Other Changes to the config.php File
- •Admin Log Viewing Permission
- •Admin Log Pruning Permission
- •Query Running Permission
- •Undeletable and Unalterable Users
- •Maintaining the Database
- •Backing Up the Database
- •Repairing and Optimizing the Database
- •Some Maintenance Issues
- •Smilies
- •Editing a Smilie
- •Adding a New Smilie
- •Uploading a Smilie
- •Creating Your Own Smilies
- •Avatars
- •Adding Avatars
- •Storing Avatars
- •Summary
- •When to Upgrade
- •Preparing for Upgrade
- •Migrating Changes
- •File Compare Utilities
- •Uploading the Files
- •Running the Upgrade Script
- •Testing the Upgrade
- •Unveiling the Upgrade
- •Summary
- •Styling vBulletin
- •Template Lifecycles
- •Lifecycle 1—Constant Change
- •Lifecycle 2—Working Behind the Scenes
- •Editing the Default Style
- •Changing Image Paths
- •Other Editable Elements
- •Some Tips about Editing Styles
- •Adding a New Style
- •Editing the Style
- •Saving the Style
- •Downloading the Style
- •Making the New Style into the Default
- •Distributing a Style
- •Installing a New Style
- •Summary
- •Hacking vBulletin
- •Making the Changes
- •Locating the Template
- •Hacking the pm_newpm Template
- •Testing the Hack
- •Hack Distribution
- •Tips for Hack Distribution
- •Plugins and Products
- •Getting Plugins and Products
- •Adding a Product
- •Adding a Plugin
- •What If Things Go Wrong?
- •Summary
- •Default Usergroup Settings
- •(COPPA) Users Awaiting Moderation
- •Administrators
- •Moderators
- •Registered Users
- •Super Moderators
- •Unregistered / Not Logged In
- •Users Awaiting Email Confirmation
- •Banned Users
- •Default vBulletin Database Tables
- •Moving Servers in Six Easy Steps
- •Cookie Check
- •Back up Database
- •Download the vBulletin Files
- •Transfer to New Server
- •Database Restoration
- •Back Online
- •Graphics
- •Global Post Text Find and Replace
- •Programming Standards
- •Braces
- •Indenting
- •Give Operators Space
- •String Quoting
- •Return Values
- •SQL Queries
- •Naming Conventions for Functions
- •Summary
- •vBulletin Directory Structure
- •Notes
- •Official vBulletin Sites
- •Main vBulletin Hack Site
- •vBulletin Styles and Templates
- •vBulletin Add-Ons
- •Index
Chapter 9
This SQL query looks through the posts for instances of Vbulletin and replaces them with vBulletin. The WHERE clause is used to optimize the find and replace as this allows MySQL to take advantages of indexes, which speeds things up.
If you get an error running this query then check to see if you are using a table prefix in the database for the tables (such as vb_) and add this to the query. This would change the query to the following:
UPDATE vb_post SET pagetext = REPLACE (pagetext,'Vbulletin','vBulletin') WHERE pagetext LIKE '% Vbulletin%';
If you wanted to carry out a similar find and replace within PMs, you'd use the following query:
UPDATE pmtext SET message = REPLACE (message,'Vbulletin','vBulletin') WHERE message LIKE '%Vbulletin%';
By using MySQL queries you are taking total control over the data held in the database. We don't have the time or scope here to cover MySQL queries in detail, so for more information visit http://dev.mysql.com. Alternatively, you can read Mastering phpMyAdmin for Effective MySQL Management by Marc Delisle, published by Packt Publishing (ISBN 1-904811-03-5).
Programming Standards
Good programming is clear, unambiguous programming. Let's run through a few tips to help make your code more readable, easier to debug, and easier to make changes to later on.
Braces
For clarity each brace should be placed on its own line in the code:
if ($condition)
{
// code goes here
}
Don't be tempted to condense code like this:
if ($condition)
{// code goes here }
Indenting
Indent code between braces:
if ($condition)
{
// code goes here
}
Code between braces within braces should have deeper indenting:
if ($condition)
{
if ($condition2)
{
// code goes here
}
// some more code goes here
}
201
Programmer's Reference
Give Operators Space
All operators (except -- and ++) should have a space either side.
$a = $b + $c;
String Quoting
All strings should be quoted with single quotes when they don't contain variables or control characters. Otherwise always use double quotes:
$a = 'Hello, World!'; $b = "Hello,\nWorld!"; $c = "$hello,\nWorld!";
Return Values
Use only lower-case true and false for return values. Upper-case should be reserved for custom constants.
if ($condition)
{
return true;
}
else
{
return false;
}
AND and OR
Always use AND rather than and or &&, and OR rather than or or || in your code.
if ($num1 AND $num2 OR $num3)
AS
Similarly, AS in foreach statements should be capitalized.
foreach ($array AS $num => $var)
{
// code goes here
}
SQL Queries
Under all circumstances, make sure that you double quote all SQL queries.
$DB_site->query("SELECT field FROM " . TABLE_PREFIX . "table ORDER BY field");
It may be better to write long queries on more than one line.
202
Chapter 9
Naming Conventions for Functions
Custom names for functions you add should all adhere to the following naming conventions:
Prefix |
Description |
|
|
build_ |
Save data back to the database. |
cache_ |
Read data from the database and create a temporary PHP cache variables to reduce |
|
SQL database load. |
can_ |
Return true or false based on permissions. |
construct_ |
Return variables containing HTML. |
convert_ |
Convert the data format of input variables. |
delete_ |
Delete data from the database. |
exec_ |
Perform an action. |
fetch_ |
Return arrays, strings, integers, etc. |
file_ |
Deal directly with the file system. |
handle_ |
Called by the bbcode parser to deal with a specific bbcode type. |
import_ |
Take an array of data and import it into the database. |
is_, contains_ |
Return true or false based on conditions. |
js_ |
JavaScript functions defined within the PHP code. |
log_ |
Append to the vBulletin logs. |
parse_ |
Initialize the bbcode parsing process. |
print_ |
Print code out to browser or buffer. |
process_ |
Prepare an array for later reference. |
sanitize_ |
Check and clear data (such as removing illegal characters) for later processing. |
sort_ |
Sort data. |
strip_ |
Strip elements from strings. |
undelete_ |
Functions that undo a soft deletion. |
vb_, vb |
Replace built-in vBulletin PHP functions with replacements designed to increase |
|
functionality or alter the behavior of the built-in function. |
verify_ |
Check conditions and generate an error message if particular conditions are satisfied. |
xml_ |
Read or output XML. |
|
|
203