Location: PHPKode > projects > EZphotopress > ezphotopress-1.0.0/install/installdb.php
<?php
$dbc = new MySQL($_SESSION['dbhost'],$_SESSION['dbusername'],$_SESSION['dbpassword'],$_SESSION['dbname'],null) or die('Unable to establish connection ');
echo '<p class="installMessage">';

$prefix = $_SESSION['dbprefix'];
//session
$dbc->query("CREATE TABLE ".$prefix."session (
  uid char(32) NOT NULL default '',
  user_id int(10) unsigned NOT NULL default '0',
  creation_date int(10) unsigned NOT NULL default '0',
  KEY uid (uid)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die("create session error<br>");
echo "<p>- create table ".$prefix."session</p><br>";

/* TBALE USER ADMIN */
$dbc->query("CREATE TABLE ".$prefix."useradmin (
  id int(10) unsigned NOT NULL auto_increment,
  username varchar(255) NOT NULL default '',
  password varchar(32) NOT NULL default '',
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die("create users error<br>");
echo "<p>- create table ".$prefix."useradmin</p><br>";

//categories

$dbc->query("CREATE TABLE ".$prefix."categories (
  id int(10) unsigned NOT NULL auto_increment,
  name varchar(255),
  path_img varchar(255),
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  deleted int not null default 0,
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die(mysql_error());
echo "<p>- create table ".$prefix."categories</p><br>";

//project

$dbc->query("CREATE TABLE ".$prefix."projects (
  id int(10) unsigned NOT NULL auto_increment,
  id_category int not null,
  title varchar(255),
  body text,
  path_thumb varchar(255),
  path_img varchar(255),
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  deleted int not null default 0,
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die(mysql_error());
echo "<p>- create table ".$prefix."projects</p><br>";

//blog
$dbc->query("CREATE TABLE ".$prefix."blog (
  id int(10) unsigned NOT NULL auto_increment,
  code varchar(255) not null,
  title varchar(255),
  body text,
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  published int not null default 0,
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die(mysql_error());
echo "<p>- create table ".$prefix."blog</p><br>";

//pages
$dbc->query("CREATE TABLE ".$prefix."pages (
  id int(10) unsigned NOT NULL auto_increment,
  code varchar(255) not null,
  title varchar(255),
  body text,
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die(mysql_error());
echo "<p>- create table ".$prefix."pages</p><br>";

//settings
$dbc->query("CREATE TABLE ".$prefix."settings (
  id int(10) unsigned NOT NULL auto_increment,
  setting_name varchar(255),
  setting_value text NOT NULL default '',
  create_date datetime not null default '0000-00-00 00:00',
  last_modify datetime not null default '0000-00-00 00:00',
  PRIMARY KEY  (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8") or die(mysql_error());
echo "<p>- create table ".$prefix."settings</p><br>";

/* start insert */
//useradmin
$s = "insert into ".$prefix."useradmin(username,password,create_date,last_modify) values('".$username."',md5('".$password."'),NOW(),NOW())";
$dbc->query($s);
echo "<p>- created admin user</p><br>";


$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('title','".addslashes($title)."',NOW(),NOW())";
$dbc->query($s);
echo "<p>- saved title</p><br>";
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('motto','".addslashes($motto)."',NOW(),NOW())";
$dbc->query($s);
echo "<p>- saved motto</p><br>";
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('site_url','".addslashes($siteUrl)."',NOW(),NOW())";
$dbc->query($s);
echo "<p>- saved site url</p><br>";
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('email','".addslashes($email)."',NOW(),NOW())";
$dbc->query($s);
echo "<p>- saved email</p><br>";
//facebook
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('facebook','',NOW(),NOW())";
$dbc->query($s);
//twitter
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('twitter','',NOW(),NOW())";
$dbc->query($s);
//linkedin
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('linkedin','',NOW(),NOW())";
$dbc->query($s);
//flickr
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('flickr','',NOW(),NOW())";
$dbc->query($s);
//myspace
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('myspace','',NOW(),NOW())";
$dbc->query($s);
//google maps
$s = "insert into ".$prefix."settings(setting_name,setting_value,create_date,last_modify) values('gmaps','',NOW(),NOW())";
$dbc->query($s);

//about me page
$s = "insert into ".$prefix."pages(code,title,body,create_date,last_modify) values('about_me','About me','',NOW(),NOW())";
$dbc->query($s);
unset($dbc);
?>
Return current item: EZphotopress