PluginProbe
UpdraftCentral Dashboard / 0.3.5
UpdraftCentral Dashboard v0.3.5
0.8.33 0.7.2 0.7.3 0.7.4 0.8.0 0.8.1 0.8.10 0.8.11 0.8.12 0.8.13 0.8.14 0.8.15 0.8.16 0.8.17 0.8.18 0.8.19 0.8.2 0.8.20 0.8.21 0.8.22 0.8.23 0.8.24 0.8.25 0.8.26 0.8.27 All 51 releases
updraftcentral / classes / activation.php

activation.php in UpdraftCentral Dashboard 0.3.5, at classes/activation.php

85 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('UD_CENTRAL_DIR')) die('Security check');
4
5 class UpdraftCentral_Activation {
6
7 private $table_prefix;
8
9 public function __construct() {
10 $this->table_prefix = defined('UPDRAFTCENTRAL_TABLE_PREFIX') ? UPDRAFTCENTRAL_TABLE_PREFIX : 'updraftcentral_';
11 $this->create_tables();
12 }
13
14 public function create_tables() {
15 global $wpdb;
16
17 // $wpdb->hide_errors();
18
19 $our_prefix = $wpdb->prefix.$this->table_prefix;
20 $collate = '';
21
22 if ( $wpdb->has_cap( 'collation' ) ) {
23 if ( ! empty($wpdb->charset ) ) {
24 $collate .= "DEFAULT CHARACTER SET $wpdb->charset";
25 }
26 if ( ! empty($wpdb->collate ) ) {
27 $collate .= " COLLATE $wpdb->collate";
28 }
29 }
30
31 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
32
33 // Important: obey the magical/arbitrary rules for formatting this stuff: https://codex.wordpress.org/Creating_Tables_with_Plugins
34 // Otherwise, you get SQL errors and unwanted header output warnings when activating
35
36 $create_tables = "CREATE TABLE ".$our_prefix."sites (
37 site_id bigint(20) NOT NULL auto_increment,
38 user_id bigint(20) NOT NULL,
39 url varchar(300) NOT NULL,
40 key_local_private blob,
41 key_remote_public blob,
42 key_name_indicator varchar(200) NOT NULL,
43 description text,
44 sequence_id bigint(20) DEFAULT 0,
45 remote_user_id bigint(20) NOT NULL,
46 remote_user_login varchar(60),
47 remote_site_id bigint(20) DEFAULT 0,
48 connection_method varchar(30),
49 send_cors_headers tinyint(1) DEFAULT 1,
50 PRIMARY KEY (site_id),
51 KEY user_id (user_id),
52 KEY url (url)
53 ) $collate;
54 ";
55 // KEY attribute_name (attribute_name)
56 dbDelta($create_tables);
57
58 $create_tables = "CREATE TABLE ".$our_prefix."site_temporary_keys (
59 key_id bigint(20) NOT NULL auto_increment,
60 key_local_private blob,
61 key_remote_public blob,
62 created bigint(20),
63 PRIMARY KEY (key_id),
64 KEY created (created)
65 ) $collate;
66 ";
67
68 dbDelta($create_tables);
69
70 $max_index_length = 191;
71 $create_tables = "CREATE TABLE ".$our_prefix."sitemeta (
72 meta_id bigint(20) NOT NULL auto_increment,
73 site_id bigint(20) NOT NULL default '0',
74 meta_key varchar(255) default NULL,
75 meta_value longtext,
76 PRIMARY KEY (meta_id),
77 KEY meta_key (meta_key($max_index_length)),
78 KEY site_id (site_id)
79 ) $collate;
80 ";
81
82 dbDelta($create_tables);
83 }
84 }
85