Chapter 64. Working with the PHP-Nuke Database


Do you care about databases? Can't get enough? This is the chapter for you. However, if you couldn't care less, feel free to skip this chapter. Under normal circumstances, you'll never need to mess around directly with the database, and doing so is a little bit like pulling on random wires under the hood of your car: You can break stuff. But if you're comfortable with databases, it might be useful for you to understand how PHP-Nuke's is laid out.

For the purposes of illustration, I'm going to assume some things about you. First, you're using MySQL as your database engine. That's common enough to be a good assumption, although if it's not true for you, you'll still understand and be able to use most of what follows. Second, you're accessing your database through a Web-based graphical interface like phpMyAdmin, which is shown in Figure 64.1. Most hosting providers will offer this to you as a part of their service.

Figure 64.1. Accessing MySQL via phpMyAdmin.


PHP-Nuke has about a ton of tables. Each table has a prefix, usually "nuke_," and then a main table name. Here's what they do:

  • Authors contains the administrators for your site, including their permissions.

  • Autonews contains news items that are scheduled to be published but haven't been published. These items are copied into the Stories table when published.

  • Banner stores banners defined on your site.

  • Bannerclient lists the banner clients for your site.

  • Bb_auth_access includes authorization and access information for the forums.

  • Bbbanlist lists users banned from the forums.

  • Bbcategories lists the forum categories.

  • Bbconfig contains the forums configuration.

  • Bbdisallow lists disallowed users in the forums.

  • Bbforum_prune lists the forums pruning schedule, which is used to remove old topics from the forums.

  • Bbforums lists the forums in the forums.

  • Bbgroups lists the user groups in the forums.

  • Bbposts contains the header information about each forum post.

  • Bbposts_text contains the text of each forum post.

  • Bbprivmsgs lists private message headers.

  • Bbprivmsgs_text lists the text for private messages.

  • Bbranks lists the various user ranks you set up, based on the number of posts a user has contributed.

  • Bbsearch_results, Bbsearch_wordlist, and Bbsearch_workdmatch list data for searches in the forums.

  • Bbsessions lists the current users accessing the forums.

  • Bbsmilies lists the "smilies" available in the forums.

  • Bbthemes lists the themes available in the forumsargely overruled by PHP-Nuke's own theme system.

  • Bbthemes_name lists the names of the themes in the forums (see Bbthemes, above).

  • Bbtopics lists the topics in the forums.

  • Bbtopics_watch lists the topic watches that users have defined for themselves in the forums. This list allows the forums to notify a user when someone posts to a "watched" topic.

  • Bbuser_group defines the users who belong to specific forums groups.

  • Bbvote_desc holds the polls that can be attached to forums posts.

  • Bbvote_results holds the results of forums polls.

  • Bbvote_voters holds the users who have responded to forums polls.

  • Bbwords lists words that aren't to be used in the forums.

  • Blocks defines the active blocks on the site, along with their location.

  • Comments holds comments to news stories.

  • Config holds the basic PHP-Nuke configuration parameters.

  • Confirm holds confirmation codes for users.

  • Counter holds basic statistics for the Statistics module.

  • Downloads_categories lists the categories you define for the Downloads module.

  • Downloads_downloads lists the actual downloads in the Downloads module.

  • Downloads_editorials holds editorials added to the Downloads module.

  • Downloads_modrequest lists modification requests for the Downloads module.

  • Downloads_newdownload lists user-submitted downloads to the Downloads module.

  • Downloads_votedata lists user ratings of downloads in the Downloads module.

  • Encyclopedia lists categories for the Encyclopedia module.

  • Encyclopedia_text lists the actual Encyclopedia module entries.

  • Ephem holds ephemerals for the Ephemerals module.

  • Faqanswer lists entries for the FAQ module.

  • Faqcategories lists FAQ categories for the FAQ module.

  • Groups defines the user groups and their point levels.

  • Groups_points defines the points awarded for specific actions on the site.

  • Headlines stores RSS newsfeeds so that PHP-Nuke doesn't have to pull them down for each user.

  • Journal stores Journal module entries.

  • Journal_comments stores user comments for journal entries.

  • Journal_stats stores use ratings for journal entries.

  • Links_categories stores categories for the Web Links module.

  • Links_editorials stores editors you add to the Web Links module.

  • Links_links stores entries in the Web Links module.

  • Links_modrequest contains modification requests for the Web Links module.

  • Links_newlink contains user-submitted entries for the Web Links module.

  • Links_votedata contains user ratings for the Web Links module.

  • Message stores the messages you define in the Administration menu.

  • Modules lists the available modules, their access permission, and so forth.

  • Pages contains the entries for the Content module.

  • Pages_categories contains the categories for the Content module.

  • Poll_check lists the IP address and time for each poll response.

  • Poll_data lists responses for polls.

  • Poll_desc lists the description for polls.

  • Pollcomments lists user comments for polls.

  • Popsettings is used by the now-defunct Webmail module.

  • Public_messages lists public broadcast messages.

  • Queue contains user-submitted news stories.

  • Referrer is used to store referrers to your site.

  • Related lists stories that are related to other stories.

  • Reviews holds all content for the Reviews module.

  • Reviews_add lists user-submitted entries for the Reviews module.

  • Reviews_comments lists comments for the Reviews module.

  • Reviews_main defines the name and description of the Reviews module.

  • Seccont contains the content of the Sections module.

  • Sections lists the categories in the Sections module.

  • Session lists currently active sessions on the site.

  • Stats_date, Stats_hour, Stats_month, and Stats_year hold statistics for the Statistics module.

  • Stories holds the News module's content.

  • Stories_cat defines news categories.

  • Subscriptions holds information on expired usersspecifically, their expiration date.

  • Topics defines the topics used by the News module.

  • Users lists all active users of the site.

  • Users_temp lists all users awaiting confirmation to become active.

Whew. Obviously, this is for version 7.3 as upgraded from v6.9; your list of tables may vary slightly. Also, as you add modules like the Event Calendar or add-ins like the NSN Your Account Tweak, they'll add more tables for their own purposes. Few modules will modify existing PHP-Nuke tables, though, which is a good thing since it helps keep PHP-Nuke "pure" and prevents problems with future PHP-Nuke upgrades, which will assume the PHP-Nuke tables are at their defaults.

So what good is this information? Here's an example: Every month, I reset the group points earned by all of my users. Right now, I'm doing that manually by running a query, as shown in Figure 64.2. This resets the point totals for the following month's point-earning contest.

Figure 64.2. Running a query in phpMyAdmin.




    PHP-Nuke Garage
    PHP-Nuke Garage
    ISBN: 0131855166
    EAN: 2147483647
    Year: 2006
    Pages: 235
    Authors: Don Jones

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net