Example #1
0
 public static function update_003()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES \r\n\t\t\t(NULL,'glb_dest','ftp','Manual destination','Manual destination',1,'',0,0,'')");
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t    (NULL, 'logger',1,1,'',0,'System logger','')\r\n\t\t  ;");
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES \r\n\t\t\t(NULL,'force_update','0','Force Update','Force Update',1,'',0,0,'')");
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES \r\n\t\t\t(NULL,'safe_update','1','Safe Update','Safe Update',1,'',0,0,'')");
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES \r\n\t\t\t(NULL,'replace_newer','1','Replace Newer','Replace newer files or not',1,'',0,0,'')");
 }
Example #2
0
 public static function update_005()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'files_per_stack')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t\t(NULL,'files_per_stack','300','How much files will be added in stack file','How much files will be added in stack file',1,'',0,0,'')");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'max_file_size_in_stack_mb')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t\t(NULL,'max_file_size_in_stack_mb','30','Max size of file, which will be added in stack file','Max size of file, which will be added in stack file',1,'',0,0,'')");
     }
 }
Example #3
0
 public static function get($query, $get = 'all', $outputType = ARRAY_A)
 {
     global $wpdb;
     $get = strtolower($get);
     $res = NULL;
     $query = self::prepareQuery($query);
     self::$query = $query;
     switch ($get) {
         case 'one':
             $res = $wpdb->get_var($query);
             break;
         case 'row':
             $res = $wpdb->get_row($query, $outputType);
             break;
         case 'col':
             $res = $wpdb->get_col($query);
             break;
         case 'all':
         default:
             $res = $wpdb->get_results($query, $outputType);
             break;
     }
     return $res;
 }
Example #4
0
 /**
  * Delete record(s)
  * @param mixed $where condition to use in query, if numeric givven - use delete by ID column
  * @return query result
  */
 public function delete($where = '')
 {
     $q = 'DELETE FROM ' . $this->_table;
     if ($where) {
         if (is_numeric($where)) {
             $where = array($this->_id => $where);
         }
         $q .= ' WHERE ' . $this->_getQueryString($where, 'AND');
     }
     return dbBup::query($q);
 }
Example #5
0
 public static function init()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $current_version = get_option(BUP_DB_PREF . 'db_version', 0);
     $installed = (int) get_option(BUP_DB_PREF . 'db_installed', 0);
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "htmltype")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "htmltype` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(32) NOT NULL,\r\n\t\t\t  `description` varchar(255) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  UNIQUE INDEX `label` (`label`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "htmltype` VALUES\r\n\t\t\t\t(1, 'text', 'Text'),\r\n\t\t\t\t(2, 'password', 'Password'),\r\n\t\t\t\t(3, 'hidden', 'Hidden'),\r\n\t\t\t\t(4, 'checkbox', 'Checkbox'),\r\n\t\t\t\t(5, 'checkboxlist', 'Checkboxes'),\r\n\t\t\t\t(6, 'datepicker', 'Date Picker'),\r\n\t\t\t\t(7, 'submit', 'Button'),\r\n\t\t\t\t(8, 'img', 'Image'),\r\n\t\t\t\t(9, 'selectbox', 'Drop Down'),\r\n\t\t\t\t(10, 'radiobuttons', 'Radio Buttons'),\r\n\t\t\t\t(11, 'countryList', 'Countries List'),\r\n\t\t\t\t(12, 'selectlist', 'List'),\r\n\t\t\t\t(13, 'countryListMultiple', 'Country List with posibility to select multiple countries'),\r\n\t\t\t\t(14, 'block', 'Will show only value as text'),\r\n\t\t\t\t(15, 'statesList', 'States List'),\r\n\t\t\t\t(16, 'textFieldsDynamicTable', 'Dynamic table - multiple text options set'),\r\n\t\t\t\t(17, 'textarea', 'Textarea'),\r\n\t\t\t\t(18, 'checkboxHiddenVal', 'Checkbox with Hidden field')");
     }
     /**
      * modules
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "modules` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) NOT NULL,\r\n\t\t\t  `active` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `type_id` smallint(3) NOT NULL DEFAULT '0',\r\n\t\t\t  `params` text,\r\n\t\t\t  `has_tab` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `label` varchar(128) DEFAULT NULL,\r\n\t\t\t  `description` text,\r\n\t\t\t  `ex_plug_dir` varchar(255) DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8;");
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t\t\t(NULL, 'adminmenu',1,1,'',0,'Admin Menu',''),\r\n\t\t\t\t(NULL, 'options',1,1,'',1,'Options',''),\r\n\t\t\t\t(NULL, 'log', 1, 1, '', 1, 'Log', 'Internal system module to log some actions on server'),\r\n\t\t\t\t(NULL, 'templates',1,1,'',0,'Templates for Plugin',''),\r\n\t\t\t\t(NULL, 'backup', 1, 1, '', 1, 'Backup by Supsystic!', 'Backup by Supsystic!'),\r\n\t\t\t\t(NULL, 'storage', 1, 1, '', 1, 'Storage', 'Storage'),\r\n\t\t\t\t(NULL, 'gdrive', 1, 1, '', 1, 'gdrive', 'gdrive'),\r\n\t\t\t\t(NULL, 'onedrive', 1, 1, '', 1, 'onedrive', 'onedrive'),\r\n\t\t\t\t(NULL, 'amazon', 1, 1, '', 1, 'amazon', 'amazon'),\r\n\t\t\t\t(NULL, 'dropbox', 1, 1, '', 1, 'dropbox', 'dropbox')");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules", 'code', 'gdrive')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t    (NULL, 'gdrive', 1, 1, '', 1, 'gdrive', 'gdrive')");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules", 'code', 'dropbox')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n            (NULL, 'dropbox', 1, 1, '', 1, 'dropbox', 'dropbox')");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules", 'code', 'amazon')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t    (NULL, 'amazon', 1, 1, '', 1, 'amazon', 'amazon')");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules", 'code', 'onedrive')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t    (NULL, 'onedrive', 1, 1, '', 1, 'onedrive', 'onedrive')");
     }
     /**
      *  modules_type
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules_type")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "modules_type` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(64) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`)\r\n\t\t\t) AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;");
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules_type` VALUES\r\n\t\t\t\t(1,'system'),\r\n\t\t\t\t(2,'addons')");
     }
     /**
      * options
      */
     $eol = "\n";
     $warehouse = '/' . BUP_WP_CONTENT_DIR . '/upsupsystic/';
     $msgText = 'We apologize, but at this time our site does not work. But we promise you, very soon we will resume work. ' . $eol . 'We just want to improve our site for your comfort.Be among the first to see our new website! Just send your email using the form below and we will inform you.';
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "options` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) CHARACTER SET latin1 NOT NULL,\r\n\t\t\t  `value` longtext NULL,\r\n\t\t\t  `label` varchar(128) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  `description` text CHARACTER SET latin1,\r\n\t\t\t  `htmltype_id` smallint(2) NOT NULL DEFAULT '1',\r\n\t\t\t  `params` text NULL,\r\n\t\t\t  `cat_id` mediumint(3) DEFAULT '0',\r\n\t\t\t  `sort_order` mediumint(3) DEFAULT '0',\r\n\t\t\t  `value_type` varchar(16) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t\t(NULL,'full','1','Full backup','on/off full backup',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'wp_core','1','Wordpress core backup','on/off Wordpress core backup',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'plugins','1','Plugins','on/off backup plugins',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'themes','1','Themes','on/off backup themes',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'uploads','1','Uploads','on/off backup uploads',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'database','1','Database','on/off backup database',1,'',0,0,'db_backup'),\r\n\t\t\t\t(NULL,'any_directories','1','Any','Any other directories found inside wp-content',1,'',0,0,'dest_backup'),\r\n\t\t\t\t(NULL,'warehouse','" . $warehouse . "','Warehouse','path to storage',1,'',0,0,''),\r\n\t\t\t\t(NULL,'warehouse_ignore','upsupsystic','Warehouse_ignore','Name ignore directory storage',1,'',0,0,''),\r\n\t\t\t\t(NULL,'safe_array','','Safe array','Safe file array',1,'',0,0,''),\r\n\t\t\t\t(NULL,'dropbox_model','','Dropbox model','Module uses two models: for PHP 5.2.x and for PHP >= 5.3.x', '1','', '', '',''),\r\n\t\t\t\t(NULL,'aws_access_key','','AWS Access Key','Amazon Web Services Access Key to work with the Amazon S3', '1','', '', '',''),\r\n\t\t\t\t(NULL,'aws_secret_key','','AWS Secret Key','Amazon Web Services Secret Key to work with Amazon S3', '1','', '', '',''),\r\n\t\t\t\t(NULL,'aws_s3_bucket','','S3 Bucket','Name of bucket to upload backups', '1','', '', '','');");
     }
     //(NULL,'exclude','upgrade,cache','Exclude','Exclude directories',1,'',0,0,'')
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'dropbox_model')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'dropbox_model','','Dropbox model','Module uses two models: for PHP 5.2.x and for PHP >= 5.3.x', '1','', '', '','');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'gdrive_refresh_token')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'gdrive_refresh_token','','Google Refresh Token','GoogleDrive refresh token using for automatically extend token time', '1','', '', '','');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'aws_access_key')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'aws_access_key','','AWS Access Key','Amazon Web Services Access Key to work with the Amazon S3', '1','', '', '','');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'aws_secret_key')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'aws_secret_key','','AWS Secret Key','Amazon Web Services Secret Key to work with Amazon S3', '1','', '', '','');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'aws_s3_bucket')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'aws_s3_bucket','','S3 Bucket','Name of bucket to upload backups', '1','', '', '','');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'wp_core')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'wp_core','1','Wordpress core backup','on/off Wordpress core backup',1,'',0,0,'dest_backup');");
     }
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options", 'code', 'serialized_backups_path')) {
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t    (NULL,'serialized_backups_path','','Serialized backups path','Store all backups path in serialized data',0,'',0,0,'');");
     }
     /* options categories */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options_categories")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "options_categories` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(128) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options_categories` VALUES\r\n\t\t\t\t(1, 'General'),\r\n\t\t\t\t(2, 'Template'),\r\n\t\t\t\t(3, 'Subscribe'),\r\n\t\t\t\t(4, 'Social');");
     }
     /**
      * Log table - all logs in project
      */
     // I didn't see that it was used somwhere - all log's was done in log files for backups, is this correct?
     /*if(!dbBup::exist($wpPrefix.BUP_DB_PREF."log")) {
     			dbDelta("CREATE TABLE `".$wpPrefix.BUP_DB_PREF."log` (
     			  `id` int(11) NOT NULL AUTO_INCREMENT,
     			  `type` varchar(64) NOT NULL,
     			  `data` text,
     			  `date_created` int(11) NOT NULL DEFAULT '0',
     			  `uid` int(11) NOT NULL DEFAULT 0,
     			  PRIMARY KEY (`id`)
     			) DEFAULT CHARSET=utf8");
     		}*/
     installerDbUpdaterBup::runUpdate();
     update_option(BUP_DB_PREF . 'db_version', BUP_VERSION);
     add_option(BUP_DB_PREF . 'db_installed', 1);
     dbBup::query("UPDATE `" . $wpPrefix . BUP_DB_PREF . "options` SET value = '" . BUP_VERSION . "' WHERE code = 'version' LIMIT 1");
     $warehouse = ABSPATH . $warehouse;
     if (!file_exists($warehouse)) {
         utilsBup::createDir($warehouse, $params = array('chmod' => 0755, 'httpProtect' => 2));
     }
 }
Example #6
0
 public static function init()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $current_version = get_option(BUP_DB_PREF . 'db_version', 0);
     $installed = (int) get_option(BUP_DB_PREF . 'db_installed', 0);
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "htmltype")) {
         $q = "CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "htmltype` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(32) NOT NULL,\r\n\t\t\t  `description` varchar(255) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  UNIQUE INDEX `label` (`label`)\r\n\t\t\t) DEFAULT CHARSET=utf8";
         dbDelta($q);
     }
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "htmltype` VALUES\r\n\t\t\t(1, 'text', 'Text'),\r\n\t\t\t(2, 'password', 'Password'),\r\n\t\t\t(3, 'hidden', 'Hidden'),\r\n\t\t\t(4, 'checkbox', 'Checkbox'),\r\n\t\t\t(5, 'checkboxlist', 'Checkboxes'),\r\n\t\t\t(6, 'datepicker', 'Date Picker'),\r\n\t\t\t(7, 'submit', 'Button'),\r\n\t\t\t(8, 'img', 'Image'),\r\n\t\t\t(9, 'selectbox', 'Drop Down'),\r\n\t\t\t(10, 'radiobuttons', 'Radio Buttons'),\r\n\t\t\t(11, 'countryList', 'Countries List'),\r\n\t\t\t(12, 'selectlist', 'List'),\r\n\t\t\t(13, 'countryListMultiple', 'Country List with posibility to select multiple countries'),\r\n\t\t\t(14, 'block', 'Will show only value as text'),\r\n\t\t\t(15, 'statesList', 'States List'),\r\n\t\t\t(16, 'textFieldsDynamicTable', 'Dynamic table - multiple text options set'),\r\n\t\t\t(17, 'textarea', 'Textarea'),\r\n\t\t\t(18, 'checkboxHiddenVal', 'Checkbox with Hidden field')");
     /**
      * modules
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules")) {
         $q = "CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "modules` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) NOT NULL,\r\n\t\t\t  `active` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `type_id` smallint(3) NOT NULL DEFAULT '0',\r\n\t\t\t  `params` text,\r\n\t\t\t  `has_tab` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `label` varchar(128) DEFAULT NULL,\r\n\t\t\t  `description` text,\r\n\t\t\t  `ex_plug_dir` varchar(255) DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8;";
         dbDelta($q);
     }
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t  (NULL, 'adminmenu',1,1,'',0,'Admin Menu',''),\r\n\t\t  (NULL, 'options',1,1,'',1,'Options',''),\r\n\t\t  (NULL, 'log', 1, 1, '', 1, 'Log', 'Internal system module to log some actions on server'),\r\n\t\t  (NULL, 'templates',1,1,'',0,'Templates for Plugin',''),\r\n\t\t  (NULL, 'backup', 1, 1, '', 1, 'Backup ready!', 'Backup ready!'),\r\n\t\t  (NULL, 'schedule', 1, 1, '', 1, 'Schedule', 'Schedule'),\r\n\t\t  (NULL, 'storage', 1, 1, '', 1, 'Storage', 'Storage')\r\n\t\t  ");
     /**
      *  modules_type
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "modules_type")) {
         $q = "CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "modules_type` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(64) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`)\r\n\t\t\t) AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;";
         dbDelta($q);
     }
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "modules_type` VALUES\r\n\t\t  (1,'system'),\r\n\t\t  (2,'addons')\r\n\t\t  ");
     /**
      * options
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options")) {
         $q = "CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "options` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) CHARACTER SET latin1 NOT NULL,\r\n\t\t\t  `value` longtext NULL,\r\n\t\t\t  `label` varchar(128) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  `description` text CHARACTER SET latin1,\r\n\t\t\t  `htmltype_id` smallint(2) NOT NULL DEFAULT '1',\r\n\t\t\t  `params` text NULL,\r\n\t\t\t  `cat_id` mediumint(3) DEFAULT '0',\r\n\t\t\t  `sort_order` mediumint(3) DEFAULT '0',\r\n\t\t\t  `value_type` varchar(16) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8";
         dbDelta($q);
     }
     $eol = "\n";
     $warehouse = "/wp-content/upready/";
     $msgText = 'We apologize, but at this time our site does not work. But we promise you, very soon we will resume work. ' . $eol . 'We just want to improve our site for your comfort.Be among the first to see our new website! Just send your email using the form below and we will inform you.';
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options` (`id`,`code`,`value`,`label`,`description`,`htmltype_id`,`params`,`cat_id`,`sort_order`,`value_type`) VALUES\r\n\t\t\t(NULL,'full','1','Full backup','on/off full backup',1,'',0,0,'dest_backup'),\r\n\t\t\t(NULL,'plugins','0','Plugins','on/off backup plugins',1,'',0,0,'dest_backup'),\r\n\t\t\t(NULL,'themes','0','Themes','on/off backup themes',1,'',0,0,'dest_backup'),\r\n\t\t\t(NULL,'uploads','0','Uploads','on/off backup uploads',1,'',0,0,'dest_backup'),\r\n\t\t\t(NULL,'database','0','Database','on/off backup database',1,'',0,0,'db_backup'),\r\n\t\t\t(NULL,'any_directories','0','Any','Any other directories found inside wp-content',1,'',0,0,'dest_backup'),\r\n\t\t\t(NULL,'warehouse','" . $warehouse . "','Warehouse','path to storage',1,'',0,0,''),\r\n\t\t\t(NULL,'warehouse_ignore','upready','Warehouse_ignore','Name ignore directory storage',1,'',0,0,''),\r\n\t\t\t(NULL,'safe_array','','Safe array','Safe file array',1,'',0,0,'');");
     //(NULL,'exclude','upgrade,cache','Exclude','Exclude directories',1,'',0,0,'')
     /* options categories */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "options_categories")) {
         $q = "CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "options_categories` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(128) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8";
         dbDelta($q);
     }
     dbBup::query("INSERT INTO `" . $wpPrefix . BUP_DB_PREF . "options_categories` VALUES\r\n\t\t\t(1, 'General'),\r\n\t\t\t(2, 'Template'),\r\n\t\t\t(3, 'Subscribe'),\r\n\t\t\t(4, 'Social');");
     /**
      * Log table - all logs in project
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "log")) {
         dbDelta("CREATE TABLE `" . $wpPrefix . BUP_DB_PREF . "log` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `type` varchar(64) NOT NULL,\r\n\t\t\t  `data` text,\r\n\t\t\t  `date_created` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t  `uid` int(11) NOT NULL DEFAULT 0,\r\n\t\t\t  PRIMARY KEY (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
     }
     /**
      * Files
      */
     if (!dbBup::exist($wpPrefix . BUP_DB_PREF . "files")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . BUP_DB_PREF . "files` (\r\n\t\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t `pid` int(11) NOT NULL,\r\n\t\t\t `name` varchar(255) NOT NULL,\r\n\t\t\t `path` varchar(255) NOT NULL,\r\n\t\t\t `mime_type` varchar(255) DEFAULT NULL,\r\n\t\t\t `size` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t `active` tinyint(1) NOT NULL,\r\n\t\t\t `date` datetime DEFAULT NULL,\r\n\t\t\t `download_limit` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t `period_limit` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t `description` text NOT NULL,\r\n\t\t\t `type_id` SMALLINT(5) NOT NULL DEFAULT 1,\r\n\t\t\t PRIMARY KEY (`id`)\r\n\t\t   ) DEFAULT CHARSET=utf8");
     }
     installerDbUpdaterBup::runUpdate();
     update_option(BUP_DB_PREF . 'db_version', BUP_VERSION);
     add_option(BUP_DB_PREF . 'db_installed', 1);
     dbBup::query("UPDATE `" . $wpPrefix . BUP_DB_PREF . "options` SET value = '" . BUP_VERSION . "' WHERE code = 'version' LIMIT 1");
     $warehouse = ABSPATH . $warehouse;
     if (!file_exists($warehouse)) {
         utilsBup::createDir($warehouse, $params = array('chmod' => 0755, 'httpProtect' => 2));
     }
 }