--
-- Host: localhost    Database: espresso
-- ------------------------------------------------------


--
-- Table structure for table `config_host_headers`
--

CREATE TABLE `config_host_headers` (
  `pid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `host_header` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`host_header`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `config_host_headers`
--

INSERT INTO `config_host_headers` (`pid`, `host_header`) VALUES (1015,'control.espresso-reklam-eu.localhost'),(1015,'control.espresso-reklam.eu');

--
-- Table structure for table `config_name`
--

CREATE TABLE `config_name` (
  `id` bigint(20) unsigned NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `is_default` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `config_name`
--

INSERT INTO `config_name` (`id`, `name`, `is_default`) VALUES (1015,'main',0);

--
-- Table structure for table `content`
--

CREATE TABLE `content` (
  `ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `ID_CATEGORY` bigint(20) unsigned NOT NULL DEFAULT '0',
  `OWNER_ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `CREATE_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `CODE` varchar(32) NOT NULL DEFAULT '',
  `CHILD_CODE` varchar(32) DEFAULT NULL,
  `ON_TOP` int(11) DEFAULT NULL,
  `STAT` tinyint(4) NOT NULL DEFAULT '0',
  `TITLE` varchar(500) NOT NULL DEFAULT '',
  `CONTENT_DATE` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SHOW_IN_MENU` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `SHOW_IN_MENU_FOR_AUTH` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `DISPLAY_IF_IN_FUTURE` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `CHANGER_ID` bigint(20) unsigned NOT NULL DEFAULT '1',
  `ORDER_BY` varchar(64) NOT NULL DEFAULT 'is_folder desc, id',
  `GROUP_ID` bigint(20) unsigned NOT NULL DEFAULT '6',
  `PERMISSION` int(11) unsigned NOT NULL DEFAULT '0',
  `IS_FOLDER` tinyint(4) NOT NULL DEFAULT '1',
  `ANNOUNCE` varchar(1024) NOT NULL DEFAULT '',
  `TEXT` mediumtext,
  `EXTRA_FIELDS` text,
  `EXTRA_FILES` text,
  `META_TITLE` varchar(200) NOT NULL DEFAULT '',
  `META_DESCRIPTION` varchar(200) NOT NULL DEFAULT '',
  `META_KEYWORDS` varchar(200) NOT NULL DEFAULT '',
  `TO_DO` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `i_id_category` (`ID_CATEGORY`),
  KEY `i_order_by` (`ORDER_BY`),
  KEY `k_folder` (`STAT`,`IS_FOLDER`),
  KEY `i_stat` (`STAT`),
  KEY `i_pid_stat` (`ID_CATEGORY`,`STAT`),
  FULLTEXT KEY `i_full` (`TITLE`,`TEXT`,`ANNOUNCE`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `content`
--

INSERT INTO `content` (`ID`, `ID_CATEGORY`, `OWNER_ID`, `CREATE_DATE`, `CODE`, `CHILD_CODE`, `ON_TOP`, `STAT`, `TITLE`, `CONTENT_DATE`, `SHOW_IN_MENU`, `SHOW_IN_MENU_FOR_AUTH`, `DISPLAY_IF_IN_FUTURE`, `CHANGER_ID`, `ORDER_BY`, `GROUP_ID`, `PERMISSION`, `IS_FOLDER`, `ANNOUNCE`, `TEXT`, `EXTRA_FIELDS`, `EXTRA_FILES`, `META_TITLE`, `META_DESCRIPTION`, `META_KEYWORDS`, `TO_DO`) VALUES (1,0,1,'2017-02-18 21:51:37','','#id#',0,1,'EspressoAdmin','0000-00-00 00:00:00',0,1,0,1,'is_folder desc, my_order desc, id',6,0,1,'','','[]','[]','','','',''),(2,1,1,'2017-02-18 21:31:42','admin','#id#',0,1,'Admin','0000-00-00 00:00:00',0,1,0,1,'id',4,1,0,'','','[{\"TOPF\":[\"top\",\"1\"]}]','[]','','','',''),(1017,1013,1,'2017-02-18 22:59:14','record','#id#',0,1,'Billing Record Info','2017-02-19 01:58:25',1,1,0,1,'is_folder desc, my_order desc, id',6,1,0,'','','[]','[]','','','','BillingRecord'),(4,2,1,'2017-02-18 21:31:04','users','#id#',0,1,'Users','0000-00-00 00:00:00',0,1,0,1,'id',6,1,1,'','','[]','[]','','','','UsersAdmin'),(3,2,1,'2008-01-27 19:12:09','cms','#id#',0,1,'CMS','0000-00-00 00:00:00',0,1,0,39,'id',6,1,1,'','text ','a:0:{}','a:0:{}','','','','CMS'),(5,1,1,'2017-01-12 13:17:30','error404','#id#',0,1,'Page Not Found','0000-00-00 00:00:00',0,1,0,1,'id',6,0,0,'','<p>The page not found. There is no Internet, it is honey, only very bad.</p>','[]','[]','','','',''),(6,1,1,'2017-01-12 13:16:54','auth','#id#',0,1,'Auth','2007-07-10 16:38:55',0,1,0,1,'is_folder desc, my_order desc, id',4,0,0,'','','[]','[]','','','','Config'),(7,2,1,'2017-02-18 21:31:15','groups','#id#',0,1,'User groups','2007-07-11 11:46:13',0,1,0,1,'id',6,1,1,'','','[]','[]','','','','GroupsAdmin'),(8,3,1,'2008-08-01 15:18:27','constrain','#id#',0,1,'Привязка одного документа к другому','2008-08-01 19:14:31',0,1,0,1,'id',6,1,0,'','','a:0:{}','a:0:{}','','','','ConstrainedContentAdmin'),(9,2,1,'2017-02-18 21:31:31','config','#id#',0,1,'Sites configuration','2008-12-14 17:22:36',0,1,0,1,'id',4,1,1,'','','[{\"TOPF\":[\"top\",\"\"]}]','[]','','','','Config'),(1009,1,1,'2017-02-19 11:24:32','users','#id#',0,1,'Users','2017-02-19 00:42:59',0,1,0,1,'is_folder desc, my_order desc, id',6,1,1,'','','[]','[]','','','','UsersAdminPublic'),(10,2,1,'2008-12-17 12:01:30','files','#id#',0,1,'Файловый менеджер','2008-12-16 18:14:23',0,1,0,1,'id',6,1,0,'','','a:1:{i:0;a:1:{s:4:\"TOPF\";a:2:{i:0;s:3:\"top\";i:1;s:0:\"\";}}}','a:0:{}','','','','FileManager'),(11,2,1,'2014-06-15 11:12:40','media','#id#',0,1,'Медиа','2014-06-15 15:12:12',1,1,0,1,'id',6,1,0,'','','a:1:{i:0;a:1:{s:4:\"TOPF\";a:2:{i:0;s:3:\"top\";i:1;s:0:\"\";}}}','a:0:{}','','','','Media(admin)'),(1011,1,1,'2017-02-18 23:14:54','banners','#id#',0,1,'Banners','2017-02-19 00:43:18',0,1,0,1,'is_folder desc, my_order desc, id',6,1,1,'','','[]','[]','','','','Banners'),(1013,1,1,'2017-02-18 22:47:59','billing','#id#',0,1,'Billing Log','2017-02-19 00:44:02',0,1,0,1,'is_folder desc, my_order desc, id',6,1,1,'','','[]','[]','','','','Billing'),(1027,1009,1,'2017-02-19 12:09:12','login-as','#id#',0,1,'Login As','2017-02-19 15:08:47',1,1,0,1,'is_folder desc, my_order desc, id',6,1,0,'','','[]','[]','','','','UserLoginAs');

--
-- Table structure for table `content_constraint`
--

CREATE TABLE `content_constraint` (
  `master_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `slave_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `INT_PATH` varchar(255) DEFAULT '',
  `TEXT_PATH` varchar(255) DEFAULT '',
  `TEXT_PATH_HASH` int(11) unsigned DEFAULT '0',
  `MY_ORDER` int(11) DEFAULT '0',
  `IS_REF` tinyint(1) unsigned DEFAULT '0',
  PRIMARY KEY (`master_id`,`slave_id`),
  KEY `i_slave_id` (`slave_id`),
  KEY `i_path_hash` (`TEXT_PATH_HASH`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `content_constraint`
--

INSERT INTO `content_constraint` (`master_id`, `slave_id`, `INT_PATH`, `TEXT_PATH`, `TEXT_PATH_HASH`, `MY_ORDER`, `IS_REF`) VALUES (0,1,'1','/',2043925204,0,0),(1,2,'2,1','/admin',152366123,0,0),(2,4,'4,2,1','/admin/users',3313262808,0,0),(2,3,'3,2,1','/admin/cms',174214763,0,0),(1,5,'5,1','/error404',429104458,0,0),(1,6,'6,1','/auth',1546199181,0,0),(2,7,'7,2,1','/admin/groups',2707605135,0,0),(3,8,'8,3,2,1','/admin/cms/constrain',4100701102,0,0),(2,9,'9,2,1','/admin/config',2240139395,0,0),(2,10,'10,2,1','/admin/files',3620373864,0,0),(2,11,'11,2,1','/admin/media',3151193149,0,0),(1,1009,'1009,1','/users',2509849780,0,0),(1,1011,'1011,1','/banners',4246164869,0,0),(1,1013,'1013,1','/billing',876231751,0,0),(1013,1017,'1017,1013,1','/billing/record',3903056841,0,0),(1009,1027,'1027,1009,1','/users/login-as',285883520,0,0);

--
-- Table structure for table `content_lang`
--

CREATE TABLE `content_lang` (
  `ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `LANG_ID` varchar(3) NOT NULL DEFAULT '',
  `TITLE` varchar(255) NOT NULL DEFAULT '',
  `ANNOUNCE` text NOT NULL,
  `TEXT` mediumtext NOT NULL,
  PRIMARY KEY (`ID`,`LANG_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `content_lang`
--


--
-- Table structure for table `content_tag`
--

CREATE TABLE `content_tag` (
  `content_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `tag_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  KEY `i_cid` (`content_id`),
  KEY `i_tid` (`tag_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `content_tag`
--


--
-- Table structure for table `file_to_content`
--

CREATE TABLE `file_to_content` (
  `file_id` bigint(20) unsigned DEFAULT '0',
  `content_id` bigint(20) unsigned DEFAULT '0',
  `order_index` int(11) DEFAULT '0',
  KEY `i_file_id` (`file_id`),
  KEY `i_content_id` (`content_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `file_to_content`
--


--
-- Table structure for table `files_category`
--

CREATE TABLE `files_category` (
  `id` bigint(20) unsigned NOT NULL,
  `pid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `files_category`
--


--
-- Table structure for table `files_data`
--

CREATE TABLE `files_data` (
  `id` bigint(20) unsigned NOT NULL,
  `pid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '',
  `ext` varchar(10) NOT NULL DEFAULT '',
  `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `revision` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `i_pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `files_data`
--


--
-- Table structure for table `media_files`
--

CREATE TABLE `media_files` (
  `id` int(11) unsigned NOT NULL,
  `pid` int(11) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `filename` varchar(128) NOT NULL DEFAULT '',
  `filesize` bigint(18) NOT NULL DEFAULT '0',
  `original_url` varchar(100) DEFAULT '',
  `image_url` varchar(100) NOT NULL DEFAULT '',
  `thumb_url` varchar(100) NOT NULL DEFAULT '',
  `preview_url` varchar(100) NOT NULL DEFAULT '',
  `type` tinyint(1) NOT NULL DEFAULT '0',
  `big_text` text NOT NULL,
  `my_order` int(11) DEFAULT '0',
  `is_default` int(11) DEFAULT '0',
  `author` varchar(64) NOT NULL DEFAULT '',
  `copyright` varchar(64) NOT NULL DEFAULT '',
  `create_at` datetime DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  KEY `i_pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `media_files`
--


--
-- Table structure for table `sec_group_permiss`
--

CREATE TABLE `sec_group_permiss` (
  `cid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `gid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `for_admin` tinyint(2) NOT NULL DEFAULT '0',
  `permiss` varchar(5) NOT NULL DEFAULT '',
  KEY `i_gid` (`gid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `sec_group_permiss`
--

INSERT INTO `sec_group_permiss` (`cid`, `gid`, `for_admin`, `permiss`) VALUES (11,6,0,'1'),(10,6,0,'1'),(7,6,0,'1'),(4,6,0,'1'),(8,6,0,'1'),(3,6,0,'1'),(2,6,0,'1'),(1009,1019,0,'1'),(1027,1019,0,'1'),(1011,1019,0,'1'),(1013,1019,0,'1'),(1017,1019,0,'1');

--
-- Table structure for table `sec_groups`
--

CREATE TABLE `sec_groups` (
  `id` bigint(20) unsigned NOT NULL,
  `pid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `name` varchar(100) NOT NULL DEFAULT '',
  `is_deletable` smallint(2) NOT NULL DEFAULT '1',
  `blocked` tinyint(1) NOT NULL DEFAULT '0',
  `comment` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `sec_groups`
--

INSERT INTO `sec_groups` (`id`, `pid`, `name`, `is_deletable`, `blocked`, `comment`) VALUES (4,0,'root',0,0,'супервизор'),(1,6,'usual user',1,0,'обыкновенный'),(6,5,'content',1,0,'контент-манагер'),(5,4,'admin',1,0,'admin'),(1005,6,'global ads trader',1,0,'global ads trader'),(1007,6,'global ads publisher',1,0,'global ads publisher'),(1019,5,'users owner',1,0,'Custom users owner'),(1021,1019,'owner ads trader',1,0,'Custom user trader');

--
-- Table structure for table `sec_groups_user`
--

CREATE TABLE `sec_groups_user` (
  `uid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `gid` bigint(20) unsigned NOT NULL DEFAULT '0',
  KEY `i_uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `sec_groups_user`
--

INSERT INTO `sec_groups_user` (`uid`, `gid`) VALUES (1,5),(1,6),(1,1),(1025,1021);

--
-- Table structure for table `sequence`
--

CREATE TABLE `sequence` (
  `name` varchar(16) NOT NULL,
  `current_value` bigint(11) unsigned NOT NULL DEFAULT '1',
  `increment` int(11) NOT NULL DEFAULT '1'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `sequence`
--

INSERT INTO `sequence` (`name`, `current_value`, `increment`) VALUES ('default',1027,2);

--
-- Table structure for table `tags`
--

CREATE TABLE `tags` (
  `id` bigint(20) unsigned NOT NULL,
  `tag_hash` char(32) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `i_hash` (`tag_hash`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tags`
--


--
-- Table structure for table `users_ext`
--

CREATE TABLE `users_ext` (
  `uid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `first_name` varchar(100) NOT NULL DEFAULT '',
  `last_name` varchar(100) NOT NULL DEFAULT '',
  `phone` varchar(100) NOT NULL DEFAULT '',
  `org` varchar(100) NOT NULL DEFAULT '',
  `address` varchar(100) NOT NULL DEFAULT '',
  `city` varchar(100) NOT NULL DEFAULT '',
  `is_physic` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `users_ext`
--

INSERT INTO `users_ext` (`uid`, `first_name`, `last_name`, `phone`, `org`, `address`, `city`, `is_physic`) VALUES (2,'Alex','G','','Dir.BG','','',1),(4,'vladimir','Jeglov','','','','',1),(8,'az','az','','','','',0),(11,'Klementina','Stambolova','','','','',0),(18,'Kiril','Lefterov','','','','',0),(20,'Nikolay','Marinov','','','','',0),(21,'Mo','Mcho','','','','',0),(22,'Pik','News','','','','',0),(1,'Zemoda.BG','','','Zemoda.BG','','',0),(3,'жоро','жоро','','','','',0),(5,'kjsd','dsak','','','','',0),(6,'alex','g','','','','',0),(7,'george','','','','','',0),(9,'vlad','iva','','','','',0),(10,'Ivailo','Zheglov','','','','',0),(12,'Zastrahovalnik','Zastrahovalnik','','','Sofia','Sofia',0),(13,'Biostore','Spirala','','','','',0),(14,'Boris','Hadzhistoyanov','','','','',0),(15,'Eva','Angelis','','','','',0),(16,'Smart','Bio','','','','',0),(17,'Georgi','Baldzhiev','','','','',0),(19,'Techno','Market','','','','',0),(23,'a','b','','','','',0),(24,'Sevex','Pharma','','','','',0);

--
-- Table structure for table `users_online`
--

CREATE TABLE `users_online` (
  `uid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `start_time` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`uid`),
  KEY `i_time` (`start_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `users_online`
--

INSERT INTO `users_online` (`uid`, `start_time`) VALUES (1,1487528167);

--
-- Table structure for table `users_referals`
--

CREATE TABLE `users_referals` (
  `referal_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  KEY `referal_id` (`referal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `users_referals`
--


--
-- Dumping routines for database 'espresso'
--
/*!50003 DROP FUNCTION IF EXISTS `currval` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `currval`(`seq_name` VARCHAR(16)) RETURNS bigint(20)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
		DECLARE value INTEGER;
		SET value = 0;
		SELECT current_value INTO value
		FROM sequence
		WHERE name = seq_name;
		RETURN value;
	END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `nextval` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `nextval`(`seq_name` VARCHAR(16)) RETURNS bigint(20)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
		UPDATE sequence
		SET current_value = current_value + increment
		WHERE name = seq_name;
		RETURN currval(seq_name);
	END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `setval` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `setval`(`seq_name` VARCHAR(16), `value` INT) RETURNS bigint(20)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
		UPDATE sequence
		SET current_value = value
		WHERE name = seq_name;
		RETURN currval(seq_name);
	END ;;
DELIMITER ;


