<?php
require_once('config.php');
require_once('connect.php');
function return_sql()
{
$sql_tables = array();
$sql_insert = array();
$sql_tables[] = "CREATE TABLE `webzona_formorder` (
`id` int(5) NOT NULL auto_increment,
`name` varchar(20) NOT NULL default '',
`email` varchar(255) default NULL,
`description` text NOT NULL,
`price` varchar(20) NOT NULL default '',
`phone` varchar(50) NOT NULL default '',
`type` varchar(20) NOT NULL default '',
`ip` varchar(20) NOT NULL default '0',
`date` datetime default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_news` (
`id` int(5) NOT NULL auto_increment,
`title` text NOT NULL,
`description` text NOT NULL,
`date` datetime default NULL,
`show` int(10) default '1',
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_board_cat` (
`id` int(5) NOT NULL auto_increment,
`name` varchar(20) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_board` (
`details` int(11) NOT NULL auto_increment,
`cat` int(11) default NULL,
`name` varchar(255) default NULL,
`description` text,
`picture` varchar(30) default NULL,
`thumbnail` varchar(30) default NULL,
`action` int(11) NOT NULL default '0',
`avtor` varchar(255) default NULL,
`pwd` varchar(255) default NULL,
`city` int(11) default NULL,
`phone` varchar(255) default NULL,
`url` varchar(255) default NULL,
`email` varchar(255) default NULL,
`date` varchar(30) default NULL,
`cpo` varchar(30) default NULL,
`title` varchar(255) default NULL,
`view` int(11) default '0',
`photo` varchar(60) default NULL,
`ip` varchar(20) NOT NULL default '0',
`period` int(5) unsigned NOT NULL default '0',
`exp_date` date default NULL,
PRIMARY KEY (`details`),
UNIQUE KEY `ID` (`details`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_subscribe` (
`id` int(5) NOT NULL auto_increment,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`email` varchar(20) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_wish` (
`ids` varchar(70) default NULL,
`nums` text
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_data` (
`id` int(5) NOT NULL auto_increment,
`action` int(10) NOT NULL default '1',
`itash` varchar(20) NOT NULL default '',
`planiroivka` varchar(30) NOT NULL default '',
`sobsh` int(15) default NULL,
`sshila` int(15) default NULL,
`skux` int(15) default NULL,
`balkon` varchar(20) NOT NULL default '',
`soiduzel` varchar(20) NOT NULL default '',
`is_phone` varchar(10) default NULL,
`sostoynie` varchar(20) NOT NULL default '',
`proshee` text NOT NULL,
`region` varchar(30) NOT NULL default '',
`street` varchar(100) NOT NULL default '',
`nedvishimost` varchar(15) NOT NULL default '',
`viewbargain` varchar(20) NOT NULL default '',
`metro` varchar(20) NOT NULL default '',
`price` int(15) unsigned default NULL,
`seller` varchar(20) NOT NULL default '',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`floor` varchar(5) NOT NULL default '',
`mebel` varchar(100) NOT NULL default '',
`telephone` varchar(100) NOT NULL default '',
`settlement` varchar(100) NOT NULL default '',
`mater` varchar(100) default NULL,
`fio` varchar(255) default NULL,
`email` varchar(255) default NULL,
`img1` varchar(30) default NULL,
`t_img1` varchar(30) default NULL,
`ip` varchar(20) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_session` (
`id` text NOT NULL,
`user_id` bigint(20) NOT NULL default '0',
`user_name` text NOT NULL,
`user_pass` text NOT NULL,
`sess_update` bigint(20) NOT NULL default '0',
`sess_ip` text NOT NULL,
`sess_agent` text NOT NULL,
`sess_time` bigint(20) NOT NULL default '0'
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_users` (
`id` int(10) NOT NULL auto_increment,
`root` tinyint(1) NOT NULL default '0',
`name` tinytext NOT NULL,
`password` tinytext NOT NULL,
`email` tinytext NOT NULL,
`g_id` smallint(6) NOT NULL default '0',
`full_name` tinytext NOT NULL,
`cookie_login` tinyint(1) NOT NULL default '0',
`session_id` mediumtext NOT NULL,
`sess_updated` bigint(20) NOT NULL default '0',
`sess_ip` tinytext NOT NULL,
`sess_agent` mediumtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;";
$sql_tables[] = "CREATE TABLE `webzona_cityestate_permissions` (
`g_id` int(10) NOT NULL auto_increment,
`group_name` tinytext NOT NULL,
`useraction` tinyint(1) NOT NULL default '0',
`c_search_com` tinyint(1) NOT NULL default '0',
`passemail` tinyint(1) NOT NULL default '0',
`is_author` tinyint(1) NOT NULL default '0',
`is_mod` tinyint(1) NOT NULL default '0',
`is_admin` tinyint(4) NOT NULL default '0',
`access_root` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`g_id`)
) TYPE=MyISAM;";
$sql_insert[] = "INSERT INTO webzona_cityestate_permissions VALUES('1','Новичёк','0','0','0','0','0','0','0');";
$sql_insert[] = "INSERT INTO webzona_cityestate_permissions VALUES('3','Модератор','0','0','0','0','0','0','1');";
$sql_insert[] = "INSERT INTO webzona_cityestate_permissions VALUES('2','Админ','0','0','0','0','0','1','2');";
$sql_insert[] = "INSERT INTO webzona_cityestate_users VALUES('1','0','adminlogin','8f96e4f5fcff936298f13a4b8db8a242','admin@email.ru','2','Вася','0','','0','','');";
$sql_insert[] = "INSERT INTO webzona_cityestate_wish VALUES('1','1');";
return array ( 'tables' => $sql_tables, 'insert' => $sql_insert );
}
$sql = return_sql();
foreach($sql['tables'] as $table) {
preg_match("/CREATE TABLE(\s+)(\S+)(\s+)\(/", $table, $match);
if($match[2]) {
$del_query = "DROP TABLE if exists ".$match[2];
if (!@mysql_query($del_query) ) {
echo 'MySQL Ошибка: '.mysql_error().'<br>';
}
}
if(!@mysql_query($table)) {
echo 'Ошибка в table: '.mysql_error().'<br>';
}
}
foreach($sql['insert'] as $insert) {
if(!@mysql_query($insert)) {
echo 'Ошибка в insert: '.mysql_error().'<br>';
}
}
/*
INSERT
$sql_insert[] = "INSERT
);
);";
*/
?>