Location: PHPKode > projects > Kwalbum > kwalbum/setup.php
<?php
/**
 * @version 2.2
 * @package kwalbum
 * @since 2.0
 */

/**********************
 * Start editing here *
 **********************/
define('ADMIN_NAME', ''); // name for logging into main account with
define('ADMIN_TITLE', ''); // title for account when show on contributor page
define('ADMIN_EMAIL', ''); // email in case of lost password
define('ADMIN_PASSWORD', ''); // password to protect account
/********************
 * End editing here *
 ********************/

require_once 'include/config.php';
if (!MYSQL_HOST or !MYSQL_USER_NAME or !MYSQL_USER_PASSWORD or !MYSQL_DB_NAME or
		!ADMIN_PASSWORD or !ADMIN_EMAIL or !ADMIN_TITLE or !ADMIN_NAME)
{
	echo 'Please edit "include/config.php" and "setup.php" before loading this page.';
	exit;
}

require_once 'include/DBConnection.php';
$DB = new DBConnection();


// create item directory
if (@mkdir(PICS_PATH))
  echo PICS_PATH." created<br />";
else if (@file_exists(PICS_PATH))
  echo "<div class='fullwarning'>Warning: ".PICS_PATH." already exists</div>";
else
  echo "<div class='fullwarning'>Warning: ".PICS_PATH." NOT created.  Kwalbum may not function correctly; however, it is possible to create the directory and set permissions by hand so installation will continue.</div>";
if (@chmod(PICS_PATH, 0775))
  echo PICS_PATH." permissions changed to 0775<br />";
else
  echo "<div class='fullwarning'>Warning: ".PICS_PATH." permissions NOT changed</div>";
flush();

// Users with max of 65,535
$query = "DROP TABLE IF EXISTS " . USER_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . USER_TABLE . "(" .
"UserId SMALLINT unsigned NOT NULL auto_increment," .
"UserName TINYTEXT," .
"UserTitle TINYTEXT," .
"UserEmail TINYTEXT," .
"UserNewEmail TINYTEXT," .
"UserPassword CHAR(40)," .
"UserVisitDt DATETIME," .
"UserIsAdmin TINYINT unsigned NOT NULL default '0'," .
"UserCanAdd TINYINT unsigned NOT NULL default '0'," .
"UserCanView TINYINT unsigned NOT NULL default '0'," .
"UserVerifier VARCHAR(32)," .
"PRIMARY KEY(UserId)," .
"FULLTEXT INDEX(UserName, UserPassword)" .
") ENGINE=MyISAM";
$DB->query($query);

$insertData = array (
	'UserName' => ADMIN_NAME,
	'UserTitle' => ADMIN_TITLE,
	'UserEmail' => ADMIN_EMAIL,
	'UserIsAdmin' => 1,
	'UserPassword' => sha1(ADMIN_PASSWORD)
);
$DB->Insert(USER_TABLE, $insertData);

// Items with max of 16,777,215
$query = "DROP TABLE IF EXISTS " . ITEM_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . ITEM_TABLE . " (" .
"ItemId MEDIUMINT unsigned NOT NULL auto_increment," .
"ItemTypeId TINYINT unsigned NOT NULL default 0," .
"ItemUserIdFk SMALLINT NOT NULL," .
"ItemLocationIdFk SMALLINT unsigned NOT NULL default 0," .
"ItemDate date default NULL," .
"ItemTime time default NULL," .
"ItemOrderBy datetime default NULL," .
"ItemLatitude DECIMAL(14,10) default NULL," .
"ItemLongitude DECIMAL(14,10) default NULL," .
"ItemDescription TEXT," .
"ItemPath TINYTEXT," .
"ItemFilename TINYTEXT," .
"ItemHasComments TINYINT unsigned NOT NULL default '0'," .
"ItemIsHidden TINYINT unsigned NOT NULL default '0'," .
"ItemUpdateDt DATETIME default NULL," . // only when comment added or change made to description
"ItemAddedTs TIMESTAMP DEFAULT CURRENT_TIMESTAMP," .
"ItemCount SMALLINT unsigned NOT NULL default 0," .
"PRIMARY KEY  (ItemId)," .
"INDEX (ItemUserIdFk)," .
"INDEX (ItemLocationIdFk)," .
"INDEX (ItemLatitude)," .
"INDEX (ItemLongitude)," .
"INDEX (ItemDate)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . DATE_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . DATE_TABLE . "(" .
"DateYear SMALLINT NOT NULL," .
"DateMonth TINYINT NOT NULL," .
"DateCount SMALLINT UNSIGNED NOT NULL default 0," .
"PRIMARY KEY (DateYear, DateMonth)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . LOCATION_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . LOCATION_TABLE . "(" .
"LocationId SMALLINT unsigned NOT NULL auto_increment," .
"Location TINYTEXT NOT NULL," .
"LocationLatitude DECIMAL(14,10) default NULL," .
"LocationLongitude DECIMAL(14,10) default NULL," .
"LocationCount SMALLINT NOT NULL default 0," .
"PRIMARY KEY (LocationId)," .
"FULLTEXT INDEX (Location)," .
"INDEX (LocationLatitude)," .
"INDEX (LocationLongitude)," .
"INDEX (LocationCount)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . TAG_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . TAG_TABLE . "(" .
"TagId SMALLINT unsigned NOT NULL auto_increment," .
"Tag TINYTEXT NOT NULL," .
"TagCount SMALLINT NOT NULL," .
"PRIMARY KEY (TagId)," .
"FULLTEXT INDEX (Tag)," .
"INDEX (TagCount)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . TAG_MAP_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . TAG_MAP_TABLE . "(" .
"ItemIdFk MEDIUMINT unsigned NOT NULL," .
"TagIdFk SMALLINT unsigned NOT NULL," .
"INDEX (ItemIdFk)," .
"INDEX (TagIdFk)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . PEOPLE_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . PEOPLE_TABLE . "(" .
"PeopleId SMALLINT unsigned NOT NULL auto_increment," .
"PeopleName TINYTEXT NOT NULL," .
"PeopleCount SMALLINT NOT NULL," .
"PRIMARY KEY (PeopleId)," .
"FULLTEXT INDEX (PeopleName)" .
") ENGINE=MyISAM";
$DB->query($query);

$query = "DROP TABLE IF EXISTS " . PEOPLE_MAP_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . PEOPLE_MAP_TABLE . "(" .
"ItemIdFk MEDIUMINT unsigned NOT NULL," .
"PeopleIdFk SMALLINT unsigned NOT NULL," .
"INDEX (ItemIdFk)," .
"INDEX (PeopleIdFk)" .
") ENGINE=MyISAM";
$DB->query($query);

// Comments with max of 16,777,215
$query = "DROP TABLE IF EXISTS " . COMMENT_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . COMMENT_TABLE . "(" .
"CommentId MEDIUMINT unsigned NOT NULL auto_increment," .
"CommentItemIdFk MEDIUMINT unsigned NOT NULL," .
"CommentName TINYTEXT," .
"CommentText TEXT," .
"CommentDt DATETIME," .
"CommentIp CHAR(15)," .
"PRIMARY KEY (CommentId)," .
"INDEX (CommentItemIdFk)" .
") ENGINE=MyISAM";
$DB->query($query);

// Favorite items for each user
$query = "DROP TABLE IF EXISTS " . FAVORITE_TABLE;
$DB->query($query);
$query = "CREATE TABLE " . FAVORITE_TABLE . "(" .
"FavoriteItemIdFk MEDIUMINT unsigned NOT NULL," .
"FavoriteUserIdFk SMALLINT unsigned NOT NULL," .
"FavoriteAdded TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," .
"INDEX (FavoriteUserIdFk)" .
") ENGINE=MyISAM";
$DB->query($query);
echo "Database has been set up!  You should now delete setup.php to avoid having the database reset again.  You can also safely delete readme.txt if you are finished reading it.  Any warning messages above should be looked into before continuing.";
Return current item: Kwalbum