Log in with username/password: lyceum/lyceum

root/trunk/src/lyceum/wp-admin/upgrade-schema.php

Revision 1012, 16.1 kB (checked in by jjb, 3 years ago)

http://lyceum.ibiblio.org/2007/03/02/last-night-a-b-tree-saved-my-life-or-how-to-do-a-simple-index-audit-to-fix-a-slow-query/

Line 
1 <?php
2 // Here we keep the DB structure and option values
3
4 $wp_queries="CREATE TABLE $wpdb->categories (
5   cat_ID int unsigned NOT NULL auto_increment,
6   cat_name varchar(55) NOT NULL default '',
7   category_nicename varchar(200) NOT NULL default '',
8   category_description longtext NOT NULL default '',
9   category_parent int NOT NULL default '0',
10   category_count int NOT NULL default '0',
11   PRIMARY KEY  (cat_ID),
12   KEY category_nicename (category_nicename),
13   blog mediumint unsigned NOT NULL default '0',
14   KEY blog (blog,cat_ID),
15   KEY cat_name (cat_name)
16 ) ENGINE = InnoDB;
17 CREATE TABLE $wpdb->comments (
18   comment_ID int unsigned NOT NULL auto_increment,
19   comment_post_ID int unsigned NOT NULL default '0',
20   comment_author tinytext NOT NULL default '',
21   comment_author_email varchar(100) NOT NULL default '',
22   comment_author_url varchar(200) NOT NULL default '',
23   comment_author_IP varchar(100) NOT NULL default '',
24   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
25   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
26   comment_content text NOT NULL default '',
27   comment_karma int(11) NOT NULL default '0',
28   comment_approved enum('0','1','spam') NOT NULL default '1',
29   comment_agent varchar(255) NOT NULL default '',
30   comment_type varchar(20) NOT NULL default '',
31   comment_parent int NOT NULL default '0',
32   user_id int NOT NULL default '0',
33   PRIMARY KEY  (comment_ID),
34   KEY comment_approved (comment_approved),
35   KEY comment_post_ID (comment_post_ID)
36 ) ENGINE = InnoDB;
37 CREATE TABLE $wpdb->linkcategories (
38   cat_id int unsigned NOT NULL auto_increment,
39   cat_name tinytext NOT NULL default '',
40   auto_toggle enum('Y','N') NOT NULL default 'N',
41   show_images enum('Y','N') NOT NULL default 'Y',
42   show_description enum('Y','N') NOT NULL default 'N',
43   show_rating enum('Y','N') NOT NULL default 'Y',
44   show_updated enum('Y','N') NOT NULL default 'Y',
45   sort_order varchar(64) NOT NULL default 'rand',
46   sort_desc enum('Y','N') NOT NULL default 'N',
47   text_before_link varchar(128) NOT NULL default '<li>',
48   text_after_link varchar(128) NOT NULL default '<br />',
49   text_after_all varchar(128) NOT NULL default '</li>',
50   list_limit int(11) NOT NULL default '-1',
51   PRIMARY KEY  (cat_id),
52   blog mediumint unsigned NOT NULL default '0',
53   KEY blog (blog,cat_ID),
54   KEY cat_name (cat_name(5))
55 ) ENGINE = InnoDB;
56 CREATE TABLE $wpdb->links (
57   link_id int unsigned NOT NULL auto_increment,
58   link_url varchar(255) NOT NULL default '',
59   link_name varchar(255) NOT NULL default '',
60   link_image varchar(255) NOT NULL default '',
61   link_target varchar(25) NOT NULL default '',
62   link_category int NOT NULL default '0',
63   link_description varchar(255) NOT NULL default '',
64   link_visible enum('Y','N') NOT NULL default 'Y',
65   link_owner int(11) NOT NULL default '1',
66   link_rating int(11) NOT NULL default '0',
67   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
68   link_rel varchar(255) NOT NULL default '',
69   link_notes mediumtext NOT NULL default '',
70   link_rss varchar(255) NOT NULL default '',
71   PRIMARY KEY  (link_id),
72   KEY link_category (link_category),
73   KEY link_visible (link_visible)
74 ) ENGINE = InnoDB;
75 CREATE TABLE $wpdb->options (
76   option_id int unsigned NOT NULL auto_increment,
77   blog_id int unsigned NOT NULL default '0',
78   option_name varchar(64) NOT NULL default '',
79   option_can_override enum('Y','N') NOT NULL default 'Y',
80   option_type int(11) NOT NULL default '1',
81   option_value longtext NOT NULL default '',
82   option_width int(11) NOT NULL default '20',
83   option_height int(11) NOT NULL default '8',
84   option_description tinytext NOT NULL default '',
85   option_admin_level int(11) NOT NULL default '1',
86   autoload enum('yes','no') NOT NULL default 'yes',
87   PRIMARY KEY  (option_id,blog_id,option_name),
88   KEY option_name (option_name),
89   option_domain enum('system','blog') NOT NULL default 'blog',
90   blog mediumint unsigned NOT NULL default '0',
91   UNIQUE blogdomainindex (blog, autoload, option_name),
92   UNIQUE systemdomainindex (option_domain, option_name, blog)
93 ) ENGINE = InnoDB;
94 CREATE TABLE $wpdb->post2cat (
95   rel_id int unsigned NOT NULL auto_increment,
96   post_id int unsigned NOT NULL default '0',
97   category_id int unsigned NOT NULL default '0',
98   PRIMARY KEY  (rel_id),
99   UNIQUE post_id (post_id,category_id),
100     UNIQUE category_id (category_id,post_id)
101 ) ENGINE = InnoDB;
102 CREATE TABLE $wpdb->postmeta (
103   meta_id int unsigned NOT NULL auto_increment,
104   post_id int unsigned NOT NULL default '0',
105   meta_key varchar(255) default NULL default '',
106   meta_value longtext default '',
107   PRIMARY KEY  (meta_id),
108   KEY post_id (post_id),
109   KEY meta_key (meta_key),
110   KEY mainkey (post_id, meta_key)
111 ) ENGINE = InnoDB;
112 CREATE TABLE $wpdb->posts (
113   ID int unsigned NOT NULL auto_increment,
114   post_author mediumint unsigned NOT NULL default '0',
115   post_date datetime NOT NULL default '0000-00-00 00:00:00',
116   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
117   post_content longtext NOT NULL default '',
118   post_title text NOT NULL default '',
119   post_category int(4) NOT NULL default '0',
120   post_excerpt text NOT NULL default '',
121   post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
122   comment_status enum('open','closed','registered_only') NOT NULL default 'open',
123   ping_status enum('open','closed') NOT NULL default 'open',
124   post_password varchar(20) NOT NULL default '',
125   post_name varchar(200) NOT NULL default '',
126   to_ping text NOT NULL default '',
127   pinged text NOT NULL default '',
128   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
129   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
130   post_content_filtered text NOT NULL default '',
131   post_parent int NOT NULL default '0',
132   guid varchar(255) NOT NULL default '',
133   menu_order int(11) NOT NULL default '0',
134   post_type varchar(100) NOT NULL default '',
135   post_mime_type varchar(100) NOT NULL default '',
136   comment_count int NOT NULL default '0',
137   PRIMARY KEY  (ID),
138   KEY post_name (post_name),
139   page_blog mediumint unsigned default NULL,
140   KEY page_blog (page_blog),
141   KEY post_parent (post_parent),
142   KEY post_date (post_date),
143   KEY main (post_status, post_author, post_date_gmt),
144   KEY page (post_status, page_blog)
145 ) ENGINE = InnoDB;
146 CREATE TABLE $wpdb->users (
147   ID mediumint unsigned NOT NULL auto_increment,
148   user_login varchar(60) NOT NULL default '',
149   user_pass varchar(64) NOT NULL default '',
150   user_nicename varchar(50) NOT NULL default '',
151   user_email varchar(100) NOT NULL default '',
152   user_url varchar(100) NOT NULL default '',
153   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
154   user_activation_key varchar(60) NOT NULL default '',
155   user_status int(11) NOT NULL default '0',
156   display_name varchar(250) NOT NULL default '',
157   PRIMARY KEY  (ID),
158   UNIQUE user_login_key (user_login),
159   UNIQUE user_email (user_email),
160   user_locked enum('0','1') NOT NULL default '0',
161   user_admin enum('0','1') NOT NULL default '0'
162 ) ENGINE = InnoDB;
163 CREATE TABLE $wpdb->usermeta (
164   umeta_id int unsigned NOT NULL auto_increment,
165   user_id int unsigned NOT NULL default '0',
166   meta_key varchar(255) default NULL,
167   meta_value longtext default '',
168   PRIMARY KEY  (umeta_id),
169   KEY user_id (user_id),
170   KEY meta_key (meta_key),
171   meta_domain enum('system','blog') NOT NULL default 'blog',
172   blog mediumint unsigned default NULL,
173   UNIQUE blogindex (blog, user_id, meta_key),
174   KEY systemindex (meta_domain, user_id, meta_key)
175 ) ENGINE = InnoDB;
176 CREATE TABLE $wpdb->blogs (
177   `id` mediumint unsigned NOT NULL auto_increment,
178   `slug` varchar(60) unique NOT NULL default '',
179   `created` datetime NOT NULL default '0000-00-00 00:00:00',
180   `status` enum('active','deleted') NOT NULL default 'active',
181   PRIMARY KEY  (`id`),
182   UNIQUE mainkey (slug, id, status)
183 ) ENGINE = InnoDB;
184 CREATE TABLE $wpdb->postsearch (
185   `id` int unsigned NOT NULL auto_increment,
186   `post_id` int unsigned NOT NULL default '0',
187   `object_id` int unsigned NOT NULL default '0',
188   `component` enum('title', 'content','comment') NOT NULL,
189   `textdata` text NOT NULL default '',
190   PRIMARY KEY  (`id`),
191   KEY (`post_id`),
192   FULLTEXT (`textdata`)
193 ) ENGINE = MyIsam;
194 CREATE TABLE $wpdb->sessions (
195   id varchar(32) NOT NULL default '',
196   access int(10) unsigned,
197   data text,
198   PRIMARY KEY  (id)
199 ) ENGINE = InnoDB
200 ";
201
202 function populate_options() {
203     global $wpdb;
204     global $blog;
205     assert(isset($blog));
206     
207     $old_umask = umask(0);
208
209     $wpcontent = get_option('wp-content_file_path')."$blog/";
210
211     //add_option('themes_file_path', $wpcontent."themes/");
212     //add_option('themes_web_path', get_option('siteurl')."/wp-content/$blog/themes/");
213     //add_option('plugins_file_path', $wpcontent."plugins/");
214     add_option('uploads_file_path', $wpcontent."uploads/");
215     add_option('uploads_web_path', get_option('fileupload_base_url')."$blog/uploads/");
216
217     $stat = stat(get_option('wp-content_file_path'));
218     $mode = $stat['mode'] & 0000777;    // Get the permission bits.
219
220     if (!file_exists($wpcontent)){
221         mkdir($wpcontent);
222         chmod($wpcontent, $mode);
223     }
224     //mkdir(get_option('themes_file_path'));
225     //chmod(get_option('themes_file_path'), $mode);
226
227     //mkdir(get_option('plugins_file_path'));
228     //chmod(get_option('plugins_file_path'), $mode);
229
230     if (!file_exists(get_option('uploads_file_path'))){
231         mkdir(get_option('uploads_file_path'));
232         chmod(get_option('uploads_file_path'), $mode);
233     }
234
235     umask($old_umask);
236
237     $slug = $wpdb->get_var("SELECT slug FROM $wpdb->blogs WHERE id = '$blog'");
238     if (SUBDOMAINS)
239         $home = 'http://' . $slug . '.' . MAINDOMAIN;
240     else
241         $home = LURL . '/' . $slug;
242     add_option('home', $home);
243     add_option('blogname', __('My Weblog'), __('Blog title'));
244     add_option('blogdescription', __('Just another Lyceum weblog'), __('Short tagline'));
245     add_option('admin_email', 'you@example.com');
246     add_option('start_of_week', 1);
247     add_option('use_balanceTags', 0);
248     add_option('use_smilies', 1);
249     add_option('require_name_email', 1);
250     add_option('comments_notify', 1);
251     add_option('posts_per_rss', 10);
252     add_option('rss_excerpt_length', 50);
253     add_option('rss_use_excerpt', 0);
254     add_option('mailserver_url', 'mail.example.com');
255     add_option('mailserver_login', 'login@example.com');
256     add_option('mailserver_pass', 'password');
257     add_option('mailserver_port', 110);
258     add_option('default_category');
259     add_option('default_comment_status', 'open');
260     add_option('default_ping_status', 'open');
261     add_option('default_pingback_flag', 1);
262     add_option('default_post_edit_rows', 10);
263     add_option('posts_per_page', 10);
264     add_option('what_to_show', 'posts');
265     add_option('date_format', __('F j, Y'));
266     add_option('time_format', __('g:i a'));
267     add_option('links_updated_date_format', __('F j, Y g:i a'));
268     add_option('links_recently_updated_prepend', '<em>');
269     add_option('links_recently_updated_append', '</em>');
270     add_option('links_recently_updated_time', 120);
271     add_option('comment_moderation', 0);
272     add_option('moderation_notify', 1);
273     add_option('permalink_structure', DEFAULT_PS);
274     add_option('hack_file', 0);
275     add_option('blog_charset', 'UTF-8');
276     add_option('moderation_keys');
277     add_option('active_plugins');
278     add_option('category_base');
279     add_option('ping_sites', '');
280     add_option('advanced_edit', 0);
281     add_option('comment_max_links', 2);
282     add_option('gmt_offset', date('Z') / 3600);
283     // 1.5
284     add_option('default_email_category', 1, __('Posts by email go to this category'));
285     add_option('recently_edited');
286     add_option('use_linksupdate', 0);
287     add_option('template', DEFAULT_TEMPLATE);
288     add_option('stylesheet', DEFAULT_STYLESHEET);
289     add_option('comment_whitelist', 1);
290     add_option('page_uris');
291     add_option('blacklist_keys');
292     add_option('comment_registration', 0);
293     add_option('open_proxy_check', 0);
294     add_option('rss_language', 'en');
295     add_option('html_type', 'text/html');
296     // 1.5.1
297     add_option('use_trackback', 0);
298     // 2.0
299     add_option('default_role', 'subscriber');
300     add_option('rich_editing', 'true');
301     // 2.0.1
302 //    populate_roles();
303     
304     // Set up a few options not to load by default
305     $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
306     foreach ($fatoptions as $fatoption) :
307         $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE blog='$blog' AND option_name = '$fatoption'");
308     endforeach;
309
310     // Lyceum
311     add_option('default_link_category', 0);
312     add_option('comment_priviliges', 0);
313 }
314
315 function populate_system_options(){
316     global $optiondomain, $wp_db_version, $wp_rewrite;
317     $optiondomain = 'system';
318
319     add_option('siteurl', LURL);
320     add_option('users_can_register', 1);
321     add_option('gzipcompression', 0);
322     add_option('db_version', $wp_db_version);
323     add_option('wp-content_file_path', ABSPATH . "wp-content/blogs/");//lyceum administrator is responsible for creating this directory, and setting its permissions. the permissions of all subdirectories and files will mimick it.
324     add_option('fileupload_base_url', LURL . '/wp-content/blogs/');
325     add_option('email_structure', "/.*/");
326     add_option('admin_ips', $_SERVER['REMOTE_ADDR'].','.$_SERVER['SERVER_ADDR'].',127.0.0.1');
327     add_option('restrict_admin_ip', 0);
328     add_option('active_system_plugins');
329     add_option('blog_charset', 'UTF-8');
330     add_option('html_type', 'text/html');
331     add_option('presentation_tab', 1);
332     add_option('system_admin_email');
333     add_option('import_allowed', 1);
334     add_option('slug_blacklist', 'www,profile,login,register,index, availability,portal,private,readme,wp-atom, wp-blog-header,wp-comments-post,wp-commentsrss2, wp-feed,wp-login,wp-mail,wp-pass,wp-rdf,wp-register,wp-rss,wp-rss2,wp-trackback,xmlrpc');
335     add_option('username_blacklist', 'lyceum,root');
336     add_option('secret', md5(uniqid(microtime())));
337
338     //// this is a little ugly
339     $home_path = get_home_path();
340     //$wp_rewrite->permalink_structure = DEFAULT_PS;
341     $rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
342     insert_with_markers($home_path.'.htaccess', 'Lyceum', $rules);
343     //////////////
344 }
345
346 function populate_roles() {
347     populate_roles_160();   
348 }
349
350 function populate_roles_160() {
351     global $wp_roles;
352
353     // Add roles
354     add_role('administrator', __('Administrator'));
355     add_role('editor', __('Editor'));
356     add_role('author', __('Author'));
357     add_role('contributor', __('Contributor'));
358     add_role('subscriber', __('Subscriber'));
359     
360     // Add caps for Administrator role
361     $role = get_role('administrator');
362     $role->add_cap('switch_themes');
363     $role->add_cap('edit_themes');
364     $role->add_cap('activate_plugins');
365     $role->add_cap('edit_plugins');
366     $role->add_cap('edit_users');
367     $role->add_cap('edit_files');
368     $role->add_cap('manage_options');
369     $role->add_cap('moderate_comments');
370     $role->add_cap('manage_categories');
371     $role->add_cap('manage_links');
372     $role->add_cap('upload_files');
373     $role->add_cap('import');
374     $role->add_cap('unfiltered_html');
375     $role->add_cap('edit_posts');
376     $role->add_cap('edit_others_posts');
377     $role->add_cap('edit_published_posts');
378     $role->add_cap('publish_posts');
379     $role->add_cap('edit_pages');
380     $role->add_cap('read');
381     $role->add_cap('level_10');
382     $role->add_cap('level_9');
383     $role->add_cap('level_8');
384     $role->add_cap('level_7');
385     $role->add_cap('level_6');
386     $role->add_cap('level_5');
387     $role->add_cap('level_4');
388     $role->add_cap('level_3');
389     $role->add_cap('level_2');
390     $role->add_cap('level_1');
391     $role->add_cap('level_0');
392     
393     // Add caps for Editor role
394     $role = get_role('editor');
395     $role->add_cap('moderate_comments');
396     $role->add_cap('manage_categories');
397     $role->add_cap('manage_links');
398     $role->add_cap('upload_files');
399     $role->add_cap('unfiltered_html');
400     $role->add_cap('edit_posts');
401     $role->add_cap('edit_others_posts');
402     $role->add_cap('edit_published_posts');
403     $role->add_cap('publish_posts');
404     $role->add_cap('edit_pages');
405     $role->add_cap('read');
406     $role->add_cap('level_7');
407     $role->add_cap('level_6');
408     $role->add_cap('level_5');
409     $role->add_cap('level_4');
410     $role->add_cap('level_3');
411     $role->add_cap('level_2');
412     $role->add_cap('level_1');
413     $role->add_cap('level_0');
414     
415     // Add caps for Author role
416     $role = get_role('author');
417     $role->add_cap('upload_files');
418     $role->add_cap('edit_posts');
419     $role->add_cap('edit_published_posts');
420     $role->add_cap('publish_posts');
421     $role->add_cap('read');
422     $role->add_cap('level_2');
423     $role->add_cap('level_1');
424     $role->add_cap('level_0');
425     
426     // Add caps for Contributor role
427     $role = get_role('contributor');
428     $role->add_cap('edit_posts');
429     $role->add_cap('read');
430     $role->add_cap('level_1');
431     $role->add_cap('level_0');
432     
433     // Add caps for Subscriber role
434     $role = get_role('subscriber');
435     $role->add_cap('read');
436     $role->add_cap('level_0');
437 }
438
439 ?>
440
Note: See TracBrowser for help on using the browser.
Log in with username/password: lyceum/lyceum