[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/wp-admin/ -> upgrade-schema.php (source)

   1  <?php
   2  // Here we keep the DB structure and option values
   3  
   4  $wp_queries="CREATE TABLE $wpdb->categories (
   5    cat_ID bigint(20) 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,
   9    category_parent bigint(20) NOT NULL default '0',
  10    category_count bigint(20) NOT NULL default '0',
  11    link_count bigint(20) NOT NULL default '0',
  12    posts_private tinyint(1) NOT NULL default '0',
  13    links_private tinyint(1) NOT NULL default '0',
  14    PRIMARY KEY  (cat_ID),
  15    KEY category_nicename (category_nicename)
  16  );
  17  CREATE TABLE $wpdb->comments (
  18    comment_ID bigint(20) unsigned NOT NULL auto_increment,
  19    comment_post_ID int(11) NOT NULL default '0',
  20    comment_author tinytext NOT NULL,
  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,
  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 bigint(20) NOT NULL default '0',
  32    user_id bigint(20) NOT NULL default '0',
  33    PRIMARY KEY  (comment_ID),
  34    KEY comment_approved (comment_approved),
  35    KEY comment_post_ID (comment_post_ID)
  36  );
  37  CREATE TABLE $wpdb->link2cat (
  38    rel_id bigint(20) NOT NULL auto_increment,
  39    link_id bigint(20) NOT NULL default '0',
  40    category_id bigint(20) NOT NULL default '0',
  41    PRIMARY KEY  (rel_id),
  42    KEY link_id (link_id,category_id)
  43  );
  44  CREATE TABLE $wpdb->links (
  45    link_id bigint(20) NOT NULL auto_increment,
  46    link_url varchar(255) NOT NULL default '',
  47    link_name varchar(255) NOT NULL default '',
  48    link_image varchar(255) NOT NULL default '',
  49    link_target varchar(25) NOT NULL default '',
  50    link_category bigint(20) NOT NULL default '0',
  51    link_description varchar(255) NOT NULL default '',
  52    link_visible enum('Y','N') NOT NULL default 'Y',
  53    link_owner int(11) NOT NULL default '1',
  54    link_rating int(11) NOT NULL default '0',
  55    link_updated datetime NOT NULL default '0000-00-00 00:00:00',
  56    link_rel varchar(255) NOT NULL default '',
  57    link_notes mediumtext NOT NULL,
  58    link_rss varchar(255) NOT NULL default '',
  59    PRIMARY KEY  (link_id),
  60    KEY link_category (link_category),
  61    KEY link_visible (link_visible)
  62  );
  63  CREATE TABLE $wpdb->options (
  64    option_id bigint(20) NOT NULL auto_increment,
  65    blog_id int(11) NOT NULL default '0',
  66    option_name varchar(64) NOT NULL default '',
  67    option_can_override enum('Y','N') NOT NULL default 'Y',
  68    option_type int(11) NOT NULL default '1',
  69    option_value longtext NOT NULL,
  70    option_width int(11) NOT NULL default '20',
  71    option_height int(11) NOT NULL default '8',
  72    option_description tinytext NOT NULL,
  73    option_admin_level int(11) NOT NULL default '1',
  74    autoload enum('yes','no') NOT NULL default 'yes',
  75    PRIMARY KEY  (option_id,blog_id,option_name),
  76    KEY option_name (option_name)
  77  );
  78  CREATE TABLE $wpdb->post2cat (
  79    rel_id bigint(20) NOT NULL auto_increment,
  80    post_id bigint(20) NOT NULL default '0',
  81    category_id bigint(20) NOT NULL default '0',
  82    PRIMARY KEY  (rel_id),
  83    KEY post_id (post_id,category_id)
  84  );
  85  CREATE TABLE $wpdb->postmeta (
  86    meta_id bigint(20) NOT NULL auto_increment,
  87    post_id bigint(20) NOT NULL default '0',
  88    meta_key varchar(255) default NULL,
  89    meta_value longtext,
  90    PRIMARY KEY  (meta_id),
  91    KEY post_id (post_id),
  92    KEY meta_key (meta_key)
  93  );
  94  CREATE TABLE $wpdb->posts (
  95    ID bigint(20) unsigned NOT NULL auto_increment,
  96    post_author bigint(20) NOT NULL default '0',
  97    post_date datetime NOT NULL default '0000-00-00 00:00:00',
  98    post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  99    post_content longtext NOT NULL,
 100    post_title text NOT NULL,
 101    post_category int(4) NOT NULL default '0',
 102    post_excerpt text NOT NULL,
 103    post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
 104    comment_status enum('open','closed','registered_only') NOT NULL default 'open',
 105    ping_status enum('open','closed') NOT NULL default 'open',
 106    post_password varchar(20) NOT NULL default '',
 107    post_name varchar(200) NOT NULL default '',
 108    to_ping text NOT NULL,
 109    pinged text NOT NULL,
 110    post_modified datetime NOT NULL default '0000-00-00 00:00:00',
 111    post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
 112    post_content_filtered text NOT NULL,
 113    post_parent bigint(20) NOT NULL default '0',
 114    guid varchar(255) NOT NULL default '',
 115    menu_order int(11) NOT NULL default '0',
 116    post_type varchar(20) NOT NULL default 'post',
 117    post_mime_type varchar(100) NOT NULL default '',
 118    comment_count bigint(20) NOT NULL default '0',
 119    PRIMARY KEY  (ID),
 120    KEY post_name (post_name),
 121    KEY type_status_date (post_type,post_status,post_date,ID)
 122  );
 123  CREATE TABLE $wpdb->users (
 124    ID bigint(20) unsigned NOT NULL auto_increment,
 125    user_login varchar(60) NOT NULL default '',
 126    user_pass varchar(64) NOT NULL default '',
 127    user_nicename varchar(50) NOT NULL default '',
 128    user_email varchar(100) NOT NULL default '',
 129    user_url varchar(100) NOT NULL default '',
 130    user_registered datetime NOT NULL default '0000-00-00 00:00:00',
 131    user_activation_key varchar(60) NOT NULL default '',
 132    user_status int(11) NOT NULL default '0',
 133    display_name varchar(250) NOT NULL default '',
 134    PRIMARY KEY  (ID),
 135    KEY user_login_key (user_login)
 136  );
 137  CREATE TABLE $wpdb->usermeta (
 138    umeta_id bigint(20) NOT NULL auto_increment,
 139    user_id bigint(20) NOT NULL default '0',
 140    meta_key varchar(255) default NULL,
 141    meta_value longtext,
 142    PRIMARY KEY  (umeta_id),
 143    KEY user_id (user_id),
 144    KEY meta_key (meta_key)
 145  );";
 146  
 147  function populate_options() {
 148      global $wpdb, $wp_db_version;
 149  
 150      $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
 151      $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 152      add_option('siteurl', $guessurl, __('WordPress web address'));
 153      add_option('blogname', __('My Weblog'), __('Blog title'));
 154      add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
 155      add_option('new_users_can_blog', 0);
 156      add_option('users_can_register', 0);
 157      add_option('admin_email', 'you@example.com');
 158      add_option('start_of_week', 1);
 159      add_option('use_balanceTags', 0);
 160      add_option('use_smilies', 1);
 161      add_option('require_name_email', 1);
 162      add_option('comments_notify', 1);
 163      add_option('posts_per_rss', 10);
 164      add_option('rss_excerpt_length', 50);
 165      add_option('rss_use_excerpt', 0);
 166      add_option('mailserver_url', 'mail.example.com');
 167      add_option('mailserver_login', 'login@example.com');
 168      add_option('mailserver_pass', 'password');
 169      add_option('mailserver_port', 110);
 170      add_option('default_category', 1);
 171      add_option('default_comment_status', 'open');
 172      add_option('default_ping_status', 'open');
 173      add_option('default_pingback_flag', 1);
 174      add_option('default_post_edit_rows', 10);
 175      add_option('posts_per_page', 10);
 176      add_option('what_to_show', 'posts');
 177      add_option('date_format', __('F j, Y'));
 178      add_option('time_format', __('g:i a'));
 179      add_option('links_updated_date_format', __('F j, Y g:i a'));
 180      add_option('links_recently_updated_prepend', '<em>');
 181      add_option('links_recently_updated_append', '</em>');
 182      add_option('links_recently_updated_time', 120);
 183      add_option('comment_moderation', 0);
 184      add_option('moderation_notify', 1);
 185      add_option('permalink_structure');
 186      add_option('gzipcompression', 0);
 187      add_option('hack_file', 0);
 188      add_option('blog_charset', 'UTF-8');
 189      add_option('moderation_keys');
 190      add_option('active_plugins');
 191      add_option('home', $guessurl);
 192      // in case it is set, but blank, update "home"
 193      if ( !__get_option('home') ) update_option('home', $guessurl);
 194      add_option('category_base');
 195      add_option('ping_sites', 'http://rpc.pingomatic.com/');
 196      add_option('advanced_edit', 0);
 197      add_option('comment_max_links', 2);
 198      add_option('gmt_offset', date('Z') / 3600);
 199      // 1.5
 200      add_option('default_email_category', 1, __('Posts by email go to this category'));
 201      add_option('recently_edited');
 202      add_option('use_linksupdate', 0);
 203      add_option('template', 'default');
 204      add_option('stylesheet', 'default');
 205      add_option('comment_whitelist', 1);
 206      add_option('page_uris');
 207      add_option('blacklist_keys');
 208      add_option('comment_registration', 0);
 209      add_option('rss_language', 'en');
 210      add_option('html_type', 'text/html');
 211      // 1.5.1
 212      add_option('use_trackback', 0);
 213      // 2.0
 214      add_option('default_role', 'subscriber');
 215      add_option('db_version', $wp_db_version);
 216      // 2.0.1
 217      if ( ini_get('safe_mode') ) {
 218          // Safe mode screws up mkdir(), so we must use a flat structure.
 219          add_option('uploads_use_yearmonth_folders', 0);
 220          add_option('upload_path', 'wp-content');
 221      } else {
 222          add_option('uploads_use_yearmonth_folders', 1);
 223          add_option('upload_path', 'wp-content/uploads');
 224      }
 225  
 226      // 2.0.3
 227      add_option('secret', md5(uniqid(microtime())));
 228  
 229      // 2.1
 230      add_option('blog_public', '1');
 231      add_option('default_link_category', 2);
 232      add_option('show_on_front', 'posts');
 233  
 234      // Delete unused options
 235      $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
 236      foreach ($unusedoptions as $option) :
 237          delete_option($option);
 238      endforeach;
 239  
 240      // Set up a few options not to load by default
 241      $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
 242      foreach ($fatoptions as $fatoption) :
 243          $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
 244      endforeach;
 245  }
 246  
 247  function populate_roles() {
 248      populate_roles_160();
 249      populate_roles_210();
 250  }
 251  
 252  function populate_roles_160() {
 253      global $wp_roles;
 254  
 255      // Add roles
 256      add_role('administrator', __('Administrator'));
 257      add_role('editor', __('Editor'));
 258      add_role('author', __('Author'));
 259      add_role('contributor', __('Contributor'));
 260      add_role('subscriber', __('Subscriber'));
 261  
 262      // Add caps for Administrator role
 263      $role = get_role('administrator');
 264      $role->add_cap('switch_themes');
 265      $role->add_cap('edit_themes');
 266      $role->add_cap('activate_plugins');
 267      $role->add_cap('edit_plugins');
 268      $role->add_cap('edit_users');
 269      $role->add_cap('edit_files');
 270      $role->add_cap('manage_options');
 271      $role->add_cap('moderate_comments');
 272      $role->add_cap('manage_categories');
 273      $role->add_cap('manage_links');
 274      $role->add_cap('upload_files');
 275      $role->add_cap('import');
 276      $role->add_cap('unfiltered_html');
 277      $role->add_cap('edit_posts');
 278      $role->add_cap('edit_others_posts');
 279      $role->add_cap('edit_published_posts');
 280      $role->add_cap('publish_posts');
 281      $role->add_cap('edit_pages');
 282      $role->add_cap('read');
 283      $role->add_cap('level_10');
 284      $role->add_cap('level_9');
 285      $role->add_cap('level_8');
 286      $role->add_cap('level_7');
 287      $role->add_cap('level_6');
 288      $role->add_cap('level_5');
 289      $role->add_cap('level_4');
 290      $role->add_cap('level_3');
 291      $role->add_cap('level_2');
 292      $role->add_cap('level_1');
 293      $role->add_cap('level_0');
 294  
 295      // Add caps for Editor role
 296      $role = get_role('editor');
 297      $role->add_cap('moderate_comments');
 298      $role->add_cap('manage_categories');
 299      $role->add_cap('manage_links');
 300      $role->add_cap('upload_files');
 301      $role->add_cap('unfiltered_html');
 302      $role->add_cap('edit_posts');
 303      $role->add_cap('edit_others_posts');
 304      $role->add_cap('edit_published_posts');
 305      $role->add_cap('publish_posts');
 306      $role->add_cap('edit_pages');
 307      $role->add_cap('read');
 308      $role->add_cap('level_7');
 309      $role->add_cap('level_6');
 310      $role->add_cap('level_5');
 311      $role->add_cap('level_4');
 312      $role->add_cap('level_3');
 313      $role->add_cap('level_2');
 314      $role->add_cap('level_1');
 315      $role->add_cap('level_0');
 316  
 317      // Add caps for Author role
 318      $role = get_role('author');
 319      $role->add_cap('upload_files');
 320      $role->add_cap('edit_posts');
 321      $role->add_cap('edit_published_posts');
 322      $role->add_cap('publish_posts');
 323      $role->add_cap('read');
 324      $role->add_cap('level_2');
 325      $role->add_cap('level_1');
 326      $role->add_cap('level_0');
 327  
 328      // Add caps for Contributor role
 329      $role = get_role('contributor');
 330      $role->add_cap('edit_posts');
 331      $role->add_cap('read');
 332      $role->add_cap('level_1');
 333      $role->add_cap('level_0');
 334  
 335      // Add caps for Subscriber role
 336      $role = get_role('subscriber');
 337      $role->add_cap('read');
 338      $role->add_cap('level_0');
 339  }
 340  
 341  function populate_roles_210() {
 342      $roles = array('administrator', 'editor');
 343      foreach ($roles as $role) {
 344          $role = get_role($role);
 345          if ( empty($role) )
 346              continue;
 347  
 348          $role->add_cap('edit_others_pages');
 349          $role->add_cap('edit_published_pages');
 350          $role->add_cap('publish_pages');
 351          $role->add_cap('delete_pages');
 352          $role->add_cap('delete_others_pages');
 353          $role->add_cap('delete_published_pages');
 354          $role->add_cap('delete_posts');
 355          $role->add_cap('delete_others_posts');
 356          $role->add_cap('delete_published_posts');
 357          $role->add_cap('delete_private_posts');
 358          $role->add_cap('edit_private_posts');
 359          $role->add_cap('read_private_posts');
 360          $role->add_cap('delete_private_pages');
 361          $role->add_cap('edit_private_pages');
 362          $role->add_cap('read_private_pages');
 363      }
 364  
 365      $role = get_role('administrator');
 366      if ( ! empty($role) ) {
 367          $role->add_cap('delete_users');
 368          $role->add_cap('create_users');
 369      }
 370  
 371      $role = get_role('author');
 372      if ( ! empty($role) ) {
 373          $role->add_cap('delete_posts');
 374          $role->add_cap('delete_published_posts');
 375      }
 376  
 377      $role = get_role('contributor');
 378      if ( ! empty($role) ) {
 379          $role->add_cap('delete_posts');
 380      }
 381  }
 382  
 383  ?>


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7