Let s Start from the Very Beginning


Let's Start from the Very Beginning

Somewhere in all the PHP-Nuke filesoften in a folder named HTMLyou'll find index.php, the main page that loads up when someone visits your PHP-Nuke Web site. Open a copy of Windows Notepad, and drag index.php into it. If you're a pretty hardcore kind of technology person, what you see will look interesting, or even fun. If you're not, it'll look terrifying. Don't worry; you don't need to learn any of this stuff. It's just fun to know. Here's what's at the top of my index.php file:

[View full width]

require_once("mainfile.php"); $_SERVER['PHP_SELF'] = "modules.php"; $row = $db->sql_fetchrow($db->sql_query("SELECT main_module from ".$prefix."_main")); $name = $row['main_module']; $home = 1; if ($httpref==1) { $referer = $_SERVER["HTTP_REFERER"]; $referer = check_html($referer, nohtml); if ($referer=="" OR eregi("^unknown", $referer) OR substr("$referer",0,strlen ($nukeurl))==$nukeurl OR eregi("^bookmark",$referer)) { } else { $result = $db->sql_query("INSERT INTO ".$prefix."_referer VALUES (NULL, '$referer')"); } $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_referer")); if($numrows>=$httprefmax) { $result2 = $db->sql_query("DELETE FROM ".$prefix."_referer"); } }

Cool, huh? This is the PHP language that PHP-Nuke is written in. Notice that the very first line instructs PHP to include, through the require_once function, a file named mainfil.php. You'll notice the user of require_once() and its companion, include(), throughout PHP-Nuke. In fact, for every single PHP-Nuke page, it's good odds that there were actually a half-dozen or more files involved. When index.php loads up for a Web browser, the server also reads inor includesany file mentioned in a require_once() or include() directive. This technique of including multiple files makes PHP-Nuke very modular and is, in fact, a key to its flexibility.

You'll also see a lot of database work going on inside a PHP-Nuke file. That's all that $db->sql_query stuff you see going on in that excerpt I showed you: queries from the database. Just about every piece of PHP-Nuke's configuration is contained in its database, including what theme your site is using, what modules are displayed on the pages, the actual content you add to the site, and more. PHP-Nuke without a database is like a Las Vegas casino without playing cards or dice: useless.

Scrolling down a bit in the index.php file, you'll see something like this:

     if (is_admin($admin)) {         echo "<center><font class=\"\"><b>"._HOMEPROBLEM."</b></font><br><br> [ <a href=\"admin.php?op=modules\">"._ADDAHOME."</a> ]</center>";     } else {         echo "<center>"._HOMEPROBLEMUSER."</center>";     } 

That echo statement actually writes out text and HTML that your Web browser will see. You'll notice that it's outputting some HTML tags, like <center> and <font>. What you don't see is any actual text, and you can stop looking because you won't find much of it in any PHP-Nuke file. That's because PHP-Nuke is fully localized, meaning that its user interface has been translated into more than 30 other languages. In the previous snippet, ._HOMEPROBLEM and ._HOMEPROBLEMUSER represent two strings of text that need to be displayed. These are replaced by actual text in whatever language PHP-Nuke is set up to use. So, for an English user, they might say something like "There's a problem with the home page, buddy." For a Thai user, on the other hand, they'd say something similar in Thai, using the appropriate character set and everything. Individual users on your sitewith your permissioncan specify their preferred language, and your site will automatically display in that language. That does not, by the way, mean your content will be automagically translated. PHP-Nuke is nice, but it's not magic. Setting a language preference displays the PHP-Nuke interface in the specified language; it's up to you to provide translations for any content you add.



    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