topical media & game development
basic-php-16-setup.php / php
<?php
require_once <conn.php>;
adminpass = "admin";
***** Access Levels Table ****************************************
sql = <<<EOS
CREATE TABLE forum_access_levels (
access_lvl tinyint(4) NOT NULL auto_increment,
access_name varchar(50) NOT NULL default '',
PRIMARY KEY (access_lvl)
)
EOS;
sql);
switch(mysql_errno()) {
case 1050:
break;
case 0:
result = mysql_query(sql = "INSERT IGNORE INTO forum_access_levels " .
"VALUES (2,'Moderator')";
sql)
or die(mysql_error());
result = mysql_query(a_tables[] = "forum_access_levels";
***** Admin Table ************************************************
result = mysql_query(sql = "INSERT INTO forum_admin " .
"VALUES (NULL, 'Board Title', " .
"'Comic Book Appreciation Forums', 'title')";
sql)
or die(mysql_error());
result = mysql_query(sql = "INSERT INTO forum_admin " .
"VALUES (NULL,'Admin Email', 'result = mysql_query(sql = "INSERT INTO forum_admin " .
"VALUES (NULL, 'Copyright', ".
"'©2003 CBA Inc. All rights reserved.', 'copyright')";
sql)
or die(mysql_error());
result = mysql_query(sql = "INSERT INTO forum_admin " .
"VALUES (NULL, 'Pagination Limit', '10', 'pageLimit')";
sql)
or die(mysql_error());
result = mysql_query(a_tables[] = "forum_admin";
***** BBcode Table ***********************************************
result = mysql_query(a_tables[] = "forum_bbcode";
***** Forum Table ************************************************
result = mysql_query(sql = "INSERT INTO forum_forum VALUES (NULL, 'New Forum', " .
"'This is the initial forum created when installing the " .
"database. Change the name and the description after " .
"installation.', 1)";
sql)
or die(mysql_error());
break;
default:
die(mysql_error());
break;
}
***** Post Count Table *******************************************
sql = <<<EOS
CREATE TABLE forum_postcount (
user_id int(11) NOT NULL default '0',
count int(9) NOT NULL default '0',
PRIMARY KEY (user_id)
)
EOS;
sql);
switch(mysql_errno()) {
case 1050:
break;
case 0:
result = mysql_query(a_tables[] = "forum_postcount";
***** Posts Table ************************************************
result = mysql_query(sql = "INSERT INTO forum_posts VALUES (NULL, 0, 1, 1, 0, '" .
date("Y-m-d H:i:s", time())."', 0, 'Welcome', 'Welcome " .
"to your new Bulletin Board System. Do not forget to " .
"change your admin password after installation. " .
"Have fun!')";
sql)
or die(mysql_error());
break;
default:
die(mysql_error());
break;
}
***** Users Table ************************************************
sql = <<<EOS
CREATE TABLE forum_users (
id int(11) NOT NULL auto_increment,
email varchar(255) NOT NULL default '',
passwd varchar(50) NOT NULL default '',
name varchar(100) NOT NULL default '',
access_lvl tinyint(4) NOT NULL default '1',
signature varchar(255) NOT NULL default '',
date_joined datetime NOT NULL default '0000-00-00 00:00:00',
last_login datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id),
UNIQUE KEY uniq_email (email)
)
EOS;
sql);
switch(mysql_errno()) {
case 1050:
break;
case 0:
sql = "INSERT IGNORE INTO forum_users VALUES (NULL, " .
"'adminpass', 'datetime', 0)";
sql)
or die(mysql_error());
break;
default:
die(mysql_error());
break;
}
***** Display Results ********************************************
echo "<html><head><title>Forum Tables Created</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" ";
echo "href=\"forum_styles.css\">";
echo "</head><body>";
echo "<div class=\"bodysmall\">";
echo "<h1>Comic Book Appreciation Forums</h1>";
echo "<h3>Forum Tables created:</h3>\n<ul>";
foreach (a_tables as table = str_replace("forum_","",table = str_replace("_", " ",table = ucWords(table</li>\n";
}
echo "</ul>\n<h3>Here is your initial login information:</h3>\n";
echo "<ul><li><strong>login</strong>: " . adminpass . "</li></ul>\n";
echo "<h3><a href=\"login.php?e=" .
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.