update.php 32.4 KB
Newer Older
1
<?php
Dries's avatar
 
Dries committed
2 3 4 5 6 7 8 9
/*
** USAGE:
**
** - Point your browser to "http://www.site.com/update.php" and follow
**   the instructions.
**
*/

10 11 12 13 14 15
if (!get_cfg_var("safe_mode")) {
  set_time_limit(180);
}

// Define the various updates in an array("date : comment" => "function");
$mysql_updates = array(
Dries's avatar
 
Dries committed
16 17
  "2001-10-10: first update after Drupal 3.0.0 release" => "update_1",
  "2001-10-12" => "update_2",
18 19 20 21 22 23 24
  "2001-10-14" => "update_3",
  "2001-10-16" => "update_4",
  "2001-10-17" => "update_5",
  "2001-10-22" => "update_6",
  "2001-11-01" => "update_7",
  "2001-11-02" => "update_8",
  "2001-11-04" => "update_9",
Dries's avatar
 
Dries committed
25
  "2001-11-17" => "update_10",
Dries's avatar
 
Dries committed
26
  "2001-12-01" => "update_11",
Dries's avatar
 
Dries committed
27
  "2001-12-06" => "update_12",
Dries's avatar
 
Dries committed
28
  "2001-12-09" => "update_13",
Dries's avatar
 
Dries committed
29
  "2001-12-16" => "update_14",
Dries's avatar
 
Dries committed
30
  "2001-12-24" => "update_15",
Dries's avatar
 
Dries committed
31
  "2001-12-30" => "update_16",
Dries's avatar
 
Dries committed
32
  "2001-12-31" => "update_17",
Dries's avatar
 
Dries committed
33
  "2002-01-05" => "update_18",
Dries's avatar
 
Dries committed
34
  "2002-01-17" => "update_19",
35
  "2002-01-27" => "update_20",
Dries's avatar
 
Dries committed
36
  "2002-01-30" => "update_21",
Kjartan's avatar
Kjartan committed
37
  "2002-02-19" => "update_22",
Dries's avatar
 
Dries committed
38
  "2002-03-05" => "update_23",
39
  "2002-04-08" => "update_24",
Dries's avatar
 
Dries committed
40 41
  "2002-04-14" => "update_25",
  "2002-04-14" => "update_26",
Steven Wittens's avatar
Steven Wittens committed
42
  "2002-04-16" => "update_27",
43
  "2002-04-20" => "update_28",
Dries's avatar
 
Dries committed
44
  "2002-04-23" => "update_29",
Kjartan's avatar
Kjartan committed
45
  "2002-05-02" => "update_30",
Dries's avatar
 
Dries committed
46
  "2002-05-15" => "update_31",
Dries's avatar
 
Dries committed
47
  "2002-06-22: first update after Drupal 4.0.0 release" => "update_32",
48
  "2002-07-07" => "update_33",
Dries's avatar
 
Dries committed
49
  "2002-07-31" => "update_34",
Dries's avatar
 
Dries committed
50
  "2002-08-10" => "update_35",
Dries's avatar
 
Dries committed
51
  "2002-08-16" => "update_36",
Dries's avatar
 
Dries committed
52
  "2002-08-19" => "update_37",
Dries's avatar
 
Dries committed
53
  "2002-08-26" => "update_38",
Dries's avatar
 
Dries committed
54
  "2002-09-15" => "update_39",
Dries's avatar
 
Dries committed
55
  "2002-09-17" => "update_40",
Kjartan's avatar
Kjartan committed
56
  "2002-10-13" => "update_41",
Dries's avatar
 
Dries committed
57
  "2002-10-17" => "update_42",
Dries's avatar
 
Dries committed
58
  "2002-10-26" => "update_43",
Dries's avatar
 
Dries committed
59
  "2002-11-08" => "update_44",
Dries's avatar
 
Dries committed
60
  "2002-11-20" => "update_45",
Dries's avatar
 
Dries committed
61
  "2002-12-10" => "update_46",
Dries's avatar
 
Dries committed
62
  "2002-12-22" => "update_47",
Dries's avatar
 
Dries committed
63
  "2002-12-29" => "update_48",
Dries's avatar
 
Dries committed
64
  "2003-01-03" => "update_49",
Dries's avatar
Dries committed
65 66
  "2003-01-05" => "update_50",
  "2003-01-15" => "update_51"
67 68 69 70
);

// Update functions
function update_1() {
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
  update_sql("ALTER TABLE users DROP INDEX real_email");
  update_sql("ALTER TABLE users DROP fake_email");
  update_sql("ALTER TABLE users DROP nodes");
  update_sql("ALTER TABLE users DROP bio");
  update_sql("ALTER TABLE users DROP hash");
  update_sql("ALTER TABLE users ADD jabber varchar(128) DEFAULT '' NULL");
  update_sql("ALTER TABLE users ADD drupal varchar(128) DEFAULT '' NULL");
  update_sql("ALTER TABLE users ADD init varchar(64) DEFAULT '' NULL");
  update_sql("ALTER TABLE users CHANGE passwd pass varchar(32) DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE users CHANGE real_email mail varchar(64) DEFAULT '' NULL");
  update_sql("ALTER TABLE users CHANGE id uid int(10) unsigned DEFAULT '0' NOT NULL auto_increment");
  update_sql("ALTER TABLE users CHANGE url homepage varchar(128) DEFAULT '' NOT NULL");
  update_sql("UPDATE users SET status = 1 WHERE status = 2");
  update_sql("UPDATE users SET name = userid");
  update_sql("ALTER TABLE users DROP userid");
  update_sql("UPDATE users SET init = mail");
  update_sql("DROP TABLE access");
  update_sql("CREATE TABLE access (aid tinyint(10) DEFAULT '0' NOT NULL auto_increment, mask varchar(255) DEFAULT '' NOT NULL, type varchar(255) DEFAULT '' NOT NULL, status tinyint(2) DEFAULT '0' NOT NULL, UNIQUE mask (mask), PRIMARY KEY (aid))");
  update_sql("CREATE TABLE moderate (cid int(10) DEFAULT '0' NOT NULL, nid int(10) DEFAULT '0' NOT NULL, uid int(10) DEFAULT '0' NOT NULL, score int(2) DEFAULT '0' NOT NULL, timestamp int(11) DEFAULT '0' NOT NULL, INDEX (cid), INDEX (nid) )");
  update_sql("ALTER TABLE comments DROP score");
  update_sql("ALTER TABLE comments DROP votes");
  update_sql("ALTER TABLE comments DROP users");
93 94 95
}

function update_2() {
96 97 98 99
  update_sql("ALTER TABLE users CHANGE pass pass varchar(32) DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE rating CHANGE user userid int(10) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE layout CHANGE user userid int(10) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE blocks CHANGE offset delta tinyint(2) DEFAULT '0' NOT NULL");
100 101 102 103 104
  foreach (module_list() as $name) {
    if (module_hook($name, "node", "name")) {
      $output .= "$name ...";
      db_query("DROP TABLE IF EXISTS ". $name ."_seq");
      db_query("CREATE TABLE ". $name ."_seq (id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY(id))");
105
      $result = db_query("SELECT MAX(". ($name == "node" ? "nid" : "lid") .") FROM $name");
106 107 108 109 110 111 112 113 114
      $count = $result ? db_result($result, 0) : 0;
      db_query("INSERT INTO ". $name ."_seq (id) VALUES ('$count')");
      $output .= "done ($count)<br />";
    }
  }
  print $output;
}

function update_3() {
115 116 117 118
  update_sql("ALTER TABLE user RENAME users");
  update_sql("ALTER TABLE locales CHANGE id lid int(10) DEFAULT '0' NOT NULL auto_increment");
  update_sql("ALTER TABLE layout CHANGE userid uid int(10) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE rating CHANGE userid uid int(10) DEFAULT '0' NOT NULL");
119 120 121
}

function update_4() {
Kjartan's avatar
Kjartan committed
122
  print "remove the \"auto_increment\"s:<br />";
123 124 125 126 127
  update_sql("ALTER TABLE story CHANGE nid nid int(10) unsigned DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE blog CHANGE nid nid int(10) unsigned DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE page CHANGE nid nid int(10) unsigned DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE forum CHANGE nid nid int(10) unsigned DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE book CHANGE nid nid int(10) unsigned DEFAULT '0' NOT NULL");
128

Kjartan's avatar
Kjartan committed
129
  print "drop the \"lid\"s:<br />";
130 131 132 133 134
  update_sql("ALTER TABLE story DROP lid");
  update_sql("ALTER TABLE blog DROP lid");
  update_sql("ALTER TABLE page DROP lid");
  update_sql("ALTER TABLE forum DROP lid");
  update_sql("ALTER TABLE book DROP lid");
135

Kjartan's avatar
Kjartan committed
136
  print "rename \"author\" to \"uid\":<br />";
137 138 139 140
  update_sql("ALTER TABLE comments CHANGE author uid int(10) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node CHANGE author uid int(10) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node DROP KEY author");
  update_sql("ALTER TABLE node ADD KEY uid (uid)");
141

Kjartan's avatar
Kjartan committed
142
  print "resize some \"id\"s:<br />";
143 144 145 146 147 148 149
  update_sql("ALTER TABLE feed CHANGE fid fid int(10) NOT NULL auto_increment");
  update_sql("ALTER TABLE bundle CHANGE bid bid int(10) NOT NULL auto_increment");
  update_sql("ALTER TABLE item CHANGE iid iid int(10) NOT NULL auto_increment");
  update_sql("ALTER TABLE item CHANGE fid fid int(10) NOT NULL");
  update_sql("ALTER TABLE comments CHANGE cid cid int(10) NOT NULL auto_increment");
  update_sql("ALTER TABLE comments CHANGE pid pid int(10) NOT NULL");
  update_sql("ALTER TABLE comments CHANGE lid lid int(10) NOT NULL");
150 151 152
}

function update_5() {
Kjartan's avatar
Kjartan committed
153
  print "add primary keys:<br />";
154 155 156 157 158
  update_sql("ALTER TABLE story ADD PRIMARY KEY nid (nid)");
  update_sql("ALTER TABLE blog ADD PRIMARY KEY nid (nid)");
  update_sql("ALTER TABLE page ADD PRIMARY KEY nid (nid)");
  update_sql("ALTER TABLE forum ADD PRIMARY KEY nid (nid)");
  update_sql("ALTER TABLE book ADD PRIMARY KEY nid (nid)");
159 160 161 162

}

function update_6() {
Kjartan's avatar
Kjartan committed
163
  print "add new field to blocks:<br />";
164
  update_sql("ALTER TABLE blocks ADD path varchar(255) NOT NULL DEFAULT ''");
165 166 167
}

function update_7() {
Kjartan's avatar
Kjartan committed
168
  print "updating the story table:<br />";
Dries's avatar
 
Dries committed
169 170
  update_sql("UPDATE story SET body = CONCAT(abstract, '\n\n', body)");

Kjartan's avatar
Kjartan committed
171
  print "rename the body fields:<br />";
172 173 174 175 176
  update_sql("ALTER TABLE story CHANGE body body_old TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE page CHANGE body body_old TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE blog CHANGE body body_old TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE forum CHANGE body body_old TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE book CHANGE body body_old TEXT DEFAULT '' NOT NULL");
177

Kjartan's avatar
Kjartan committed
178
  print "update the node table:<br />";
179 180 181 182 183 184 185 186 187 188 189 190 191 192
  update_sql("ALTER TABLE node DROP lid");
  update_sql("ALTER TABLE node ADD teaser TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE node ADD body TEXT DEFAULT '' NOT NULL");
  update_sql("ALTER TABLE node ADD changed int(11) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node CHANGE timestamp created int(11) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node CHANGE comment comment int(2) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node CHANGE promote promote int(2) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node CHANGE moderate moderate int(2) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE node DROP timestamp_posted");
  update_sql("ALTER TABLE node DROP timestamp_queued");
  update_sql("ALTER TABLE node DROP timestamp_hidden");
  update_sql("UPDATE node SET status = 0 WHERE status = 1");
  update_sql("UPDATE node SET status = 0 WHERE status = 2");
  update_sql("UPDATE node SET status = 1 WHERE status = 3");
193

194 195
  $result = db_query("SELECT nid,type FROM node WHERE type = 'story' OR type = 'page' OR type = 'blog' OR type = 'forum' OR type = 'book'");
  include_once("modules/node.module");
196 197 198

  while ($object = db_fetch_object($result)) {

199
    include_once("modules/$object->type.module");
200 201
    $node = node_load(array("nid" => $object->nid));

Kjartan's avatar
Kjartan committed
202
    $old = db_fetch_object(db_query("SELECT * FROM $node->type WHERE nid = $node->nid"));
203 204 205 206 207 208 209

    switch ($node->type) {
      case "forum":
      case "story":
      case "book":
      case "page":
      case "blog":
Kjartan's avatar
Kjartan committed
210
        node_save($node, array("nid", "body" => $old->body_old, "teaser" => ($old->abstract ? $old->abstract : node_teaser($old->body_old))));
211 212 213 214 215 216 217 218 219 220
        print "updated node $node->nid '$node->title' ($node->type)<br />";
        break;
      default:
        print "unknown node $node->nid '$node->title' ($node->type)<br />";
    }

    unset($node);
    unset($body);
  }

221 222 223
  update_sql("UPDATE node SET changed = created");
  update_sql("ALTER TABLE story DROP abstract");
  update_sql("ALTER TABLE book DROP section");
224 225 226
}

function update_8() {
227
  update_sql("ALTER TABLE node ADD revisions TEXT DEFAULT '' NOT NULL");
228 229 230
}

function update_9() {
231 232 233
  update_sql("ALTER TABLE book ADD revision int(2) DEFAULT '1' NOT NULL");
  update_sql("ALTER TABLE book DROP log");
  update_sql("ALTER TABLE book DROP pid");
234 235 236 237 238 239 240 241 242 243 244

  // remove book pages that used to be 'expired':
  $result = db_query("SELECT n.nid, n.title FROM node n WHERE n.type = 'book' AND n.status = 0");
  while ($node = db_fetch_object($result)) {
    print "removing node $node->nid '$node->title' (dumped node)<br />";
    db_query("DELETE FROM node WHERE nid = '$node->nid'");
    db_query("DELETE FROM book WHERE nid = '$node->nid'");
    db_query("DELETE FROM comments WHERE lid = '$node->nid'");
  }
}

Dries's avatar
 
Dries committed
245 246 247 248 249 250 251 252 253
function update_10() {
  // create a new table:
  update_sql("CREATE TABLE authmap (
      aid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
      uid int(10) DEFAULT '' NOT NULL,
      authname varchar(128) DEFAULT '' NOT NULL,
      module varchar(128) DEFAULT '' NOT NULL,
      UNIQUE authname (authname),
      PRIMARY KEY (aid)
254
    )");
Dries's avatar
 
Dries committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273

  // populate the new table:
  $result = db_query("SELECT uid, name, jabber, drupal FROM users WHERE jabber != '' || drupal != ''");
  while ($user = db_fetch_object($result)) {
    if ($user->jabber) {
      update_sql("INSERT INTO authmap (uid, authname, module) VALUES ('$user->uid', '$user->jabber', 'jabber')");
    }
    if ($user->drupal) {
      update_sql("INSERT INTO authmap (uid, authname, module) VALUES ('$user->uid', '$user->drupal', 'drupal')");
    }
  }

  // remove the old user-table leftovers:
  update_sql("DELETE FROM variable WHERE name = 'user_jabber'");
  update_sql("DELETE FROM variable WHERE name = 'user_drupal'");
  update_sql("ALTER TABLE users DROP drupal");
  update_sql("ALTER TABLE users DROP jabber");

  // remove the old node-table leftovers:
274 275 276 277 278
  update_sql("ALTER TABLE forum DROP body_old");
  update_sql("ALTER TABLE story DROP body_old");
  update_sql("ALTER TABLE book DROP body_old");
  update_sql("ALTER TABLE page DROP body_old");
  update_sql("ALTER TABLE blog DROP body_old");
Dries's avatar
 
Dries committed
279 280
}

Dries's avatar
 
Dries committed
281
function update_11() {
282 283
  update_sql("ALTER TABLE users ADD session TEXT");
  update_sql("ALTER TABLE users ADD sid varchar(32) DEFAULT '' NOT NULL");
Dries's avatar
 
Dries committed
284 285
}

Dries's avatar
 
Dries committed
286
function update_12() {
287 288
  update_sql("ALTER TABLE book DROP revision");
  update_sql("ALTER TABLE book ADD format tinyint(2) DEFAULT '0'");
Dries's avatar
 
Dries committed
289 290
}

Dries's avatar
 
Dries committed
291
function update_13() {
292 293 294 295
  update_sql("ALTER TABLE referer RENAME AS referrer");
  update_sql("DROP TABLE blog");
  update_sql("DROP TABLE story");
  update_sql("DROP TABLE forum");
Dries's avatar
 
Dries committed
296 297
}

Dries's avatar
 
Dries committed
298 299 300 301 302 303 304 305 306
function update_14() {
  update_sql("CREATE TABLE directory (
    link varchar(255) DEFAULT '' NOT NULL,
    name varchar(128) DEFAULT '' NOT NULL,
    mail varchar(128) DEFAULT '' NOT NULL,
    slogan text NOT NULL,
    mission text NOT NULL,
    timestamp int(11) DEFAULT '0' NOT NULL,
    PRIMARY KEY (link)
307
  )");
Dries's avatar
 
Dries committed
308 309
}

Dries's avatar
 
Dries committed
310
function update_15() {
311
  update_sql("ALTER TABLE feed DROP uncache");
Dries's avatar
 
Dries committed
312 313
}

Dries's avatar
 
Dries committed
314
function update_16() {
315
  update_sql("ALTER TABLE comments CHANGE lid nid int(10) NOT NULL");
Dries's avatar
 
Dries committed
316 317
}

Dries's avatar
 
Dries committed
318 319 320 321 322 323
function update_17() {
  update_sql("CREATE TABLE history (
    uid int(10) DEFAULT '0' NOT NULL,
    nid int(10) DEFAULT '0' NOT NULL,
    timestamp int(11) DEFAULT '0' NOT NULL,
    PRIMARY KEY (uid, nid)
324
  )");
Dries's avatar
 
Dries committed
325 326
}

Dries's avatar
 
Dries committed
327
function update_18() {
328 329
  update_sql("ALTER TABLE cache CHANGE timestamp expire int(11) DEFAULT '0' NOT NULL");
  update_sql("ALTER TABLE cache CHANGE url cid varchar(255) DEFAULT '' NOT NULL");
Dries's avatar
 
Dries committed
330 331
}

Dries's avatar
 
Dries committed
332
function update_19() {
333
  update_sql("ALTER TABLE users ADD data TEXT");
Dries's avatar
 
Dries committed
334 335
}

336
function update_20() {
337
  update_sql("INSERT INTO blocks SET name='User information', module='user', delta='0', status='2', weight='0', region='1', remove='0', path=''");
338 339
}

340
function update_21() {
341
  update_sql("ALTER TABLE node ADD static int(2) DEFAULT '0' NOT NULL");
342 343
}

Dries's avatar
 
Dries committed
344
function update_22() {
345
  update_sql("ALTER TABLE cache MODIFY data MEDIUMTEXT");
Dries's avatar
 
Dries committed
346 347
}

Kjartan's avatar
Kjartan committed
348
function update_23() {
349
  update_sql("CREATE TABLE search_index (word varchar(50) default NOT NULL, lno int(10) unsigned default NOT NULL, type varchar(16) default NOT NULL, count int(10) unsigned default NOT NULL, KEY lno (lno), KEY word (word))");
Kjartan's avatar
Kjartan committed
350 351
}

Dries's avatar
 
Dries committed
352
function update_24() {
353 354 355 356
  update_sql("ALTER TABLE site ADD refresh int(11) NOT NULL");
  update_sql("ALTER TABLE site ADD threshold int(11) NOT NULL");
  update_sql("UPDATE site SET refresh = '7200'");
  update_sql("UPDATE site SET threshold = '60'");
Dries's avatar
 
Dries committed
357 358
}

359
function update_25() {
360
  update_sql("UPDATE users SET theme = LOWER(theme)");
Dries's avatar
 
Dries committed
361 362 363 364 365 366 367 368 369 370 371 372
}

function update_26() {
  update_sql("CREATE TABLE vocabulary (
    vid int UNSIGNED NOT NULL PRIMARY KEY auto_increment,
    name varchar(255) NOT NULL,
    description TEXT,
    relations TINYINT UNSIGNED NOT NULL,
    hierarchy TINYINT UNSIGNED NOT NULL,
    multiple TINYINT UNSIGNED NOT NULL,
    required TINYINT UNSIGNED NOT NULL,
    types TEXT,
373
    weight TINYINT NOT NULL)");
Dries's avatar
 
Dries committed
374 375 376 377 378 379

  update_sql("CREATE TABLE term_data (
    tid int UNSIGNED NOT NULL PRIMARY KEY auto_increment,
    vid int UNSIGNED NOT NULL,
    name varchar(255) NOT NULL,
    description TEXT,
380
    weight TINYINT NOT NULL)");
Dries's avatar
 
Dries committed
381 382 383 384

  update_sql("CREATE TABLE term_hierarchy (
    tid int UNSIGNED NOT NULL,
    parent int UNSIGNED NOT NULL
385
  )");
Dries's avatar
 
Dries committed
386 387 388 389

  update_sql("CREATE TABLE term_relation (
    tid1 int UNSIGNED NOT NULL,
    tid2 int UNSIGNED NOT NULL
390
  )");
Dries's avatar
 
Dries committed
391 392 393 394

  update_sql("CREATE TABLE term_synonym (
    tid int UNSIGNED NOT NULL,
    name varchar(255) NOT NULL
395
  )");
Dries's avatar
 
Dries committed
396 397 398 399

  update_sql("CREATE TABLE term_node (
    nid int UNSIGNED NOT NULL,
    tid int UNSIGNED NOT NULL
400 401 402 403 404 405 406 407 408 409 410
  )");

  update_sql("ALTER TABLE term_data ADD INDEX (vid)");
  update_sql("ALTER TABLE term_hierarchy ADD INDEX (tid)");
  update_sql("ALTER TABLE term_hierarchy ADD INDEX (parent)");
  update_sql("ALTER TABLE term_relation ADD INDEX (tid1)");
  update_sql("ALTER TABLE term_relation ADD INDEX (tid2)");
  update_sql("ALTER TABLE term_synonym ADD INDEX (tid)");
  update_sql("ALTER TABLE term_synonym ADD INDEX (name(3))");
  update_sql("ALTER TABLE term_node ADD INDEX (nid)");
  update_sql("ALTER TABLE term_node ADD INDEX (tid)");
411
  update_sql("UPDATE node SET comment = 2 WHERE comment = 1");
412 413
}

414
function update_27() {
415
  update_sql("ALTER TABLE book ADD log TEXT");
416 417
}

Steven Wittens's avatar
Steven Wittens committed
418
function update_28() {
419
  update_sql("ALTER TABLE poll DROP lid");
Steven Wittens's avatar
Steven Wittens committed
420 421
}

422 423 424 425 426
function update_29() {
  update_sql("INSERT INTO permission (rid, perm) SELECT rid, perm FROM role");

  $result = db_query("SELECT rid, name FROM role");
  while ($role = db_fetch_object($result)) {
Kjartan's avatar
Kjartan committed
427
    update_sql("UPDATE users SET rid = ". $role->rid ." WHERE role = '". $role->name ."'");
428 429 430 431 432 433
  }

  update_sql("ALTER TABLE users DROP role");
  update_sql("ALTER TABLE role DROP perm");
}

434
function update_30() {
435 436 437 438
  update_sql("ALTER TABLE blocks ADD custom tinyint(2) not null");
  update_sql("UPDATE blocks SET module = 'block' WHERE module = 'boxes'");
  update_sql("UPDATE blocks SET status = 1, custom = 1 WHERE status = 1");
  update_sql("UPDATE blocks SET status = 1, custom = 0 WHERE status = 2");
439 440
}

Kjartan's avatar
Kjartan committed
441 442
function update_31() {
  include_once("modules/taxonomy.module");
Dries's avatar
 
Dries committed
443

Kjartan's avatar
Kjartan committed
444
  print "Wiping tables.<br />";
Kjartan's avatar
Kjartan committed
445
  /*db_query("DELETE FROM vocabulary");
Kjartan's avatar
Kjartan committed
446 447
  db_query("DELETE FROM term_data");
  db_query("DELETE FROM term_node");
Kjartan's avatar
Kjartan committed
448
  db_query("DELETE FROM term_hierarchy");**/
Dries's avatar
 
Dries committed
449

Kjartan's avatar
Kjartan committed
450
  print "Creating collections.<br />";
Kjartan's avatar
Kjartan committed
451
  $offset = db_result(db_query("SELECT MAX(vid) AS high FROM vocabulary"), 0);
Kjartan's avatar
Kjartan committed
452 453
  $result = db_query("SELECT * FROM collection");
  while ($c = db_fetch_object($result)) {
Kjartan's avatar
Kjartan committed
454 455 456
    $offset++;
    $collections[$c->name] = $offset;
    db_query("INSERT INTO vocabulary SET vid = '$offset', name = '$c->name', types = '". str_replace(" ", "", $c->types) ."'");
Kjartan's avatar
Kjartan committed
457
  }
Dries's avatar
 
Dries committed
458

Kjartan's avatar
Kjartan committed
459 460
  print "Creating terms.<br />";
  $result = db_query("SELECT * FROM tag");
Kjartan's avatar
Kjartan committed
461
  $i = db_result(db_query("SELECT MAX(tid) AS high FROM term_data"), 0) + 1;
Kjartan's avatar
Kjartan committed
462 463 464 465 466 467 468 469 470 471
  while ($t = db_fetch_object($result)) {
    foreach (explode(", ", $t->collections) as $c) {
      if ($collections[$c]) {
        db_query("INSERT INTO term_data SET tid = '$i', vid = '$collections[$c]', name = '$t->name'");
        db_query("INSERT INTO term_hierarchy SET tid = '$i', parent = '0'");
        $terms[$t->name] = $i;
        $i++;
      }
    }
  }
Dries's avatar
 
Dries committed
472

Kjartan's avatar
Kjartan committed
473 474 475
  print "Linking nodes with terms.<br />";
  $result = db_query("SELECT nid,attributes FROM node WHERE attributes != ''");
  while ($node = db_fetch_object($result)) {
476 477 478 479 480
    $tag = db_fetch_object(db_query("SELECT name FROM tag WHERE attributes = '$node->attributes'"));
    $tag = trim($tag->name);
    if ($tag) {
      if ($terms[$tag]) {
        db_query("INSERT INTO term_node SET nid = '$node->nid', tid = '$terms[$tag]'");
Kjartan's avatar
Kjartan committed
481
      }
482 483 484 485
      else {
        $errors[$tag] = "$tag";
      }
    }
Kjartan's avatar
Kjartan committed
486
  }
Dries's avatar
 
Dries committed
487

Kjartan's avatar
Kjartan committed
488 489 490 491
  if (count($errors)) {
    asort($errors);
    print "<br /><br />Terms not found:<br /><pre>  ". implode("\n  ", $errors) ."</pre>";
  }
Dries's avatar
 
Dries committed
492

Kjartan's avatar
Kjartan committed
493
  // Clean up meta tag system
494
  update_sql("DROP TABLE collection");
Kjartan's avatar
Kjartan committed
495
  update_sql("DROP TABLE tag");
496
  update_sql("ALTER TABLE node DROP attributes");
Kjartan's avatar
Kjartan committed
497 498
}

Dries's avatar
 
Dries committed
499
function update_32() {
500 501
  update_sql("ALTER TABLE users ADD index (sid(4))");
  update_sql("ALTER TABLE users ADD index (timestamp)");
Dries's avatar
 
Dries committed
502
  update_sql("ALTER TABLE users ADD UNIQUE KEY name (name)");
Dries's avatar
 
Dries committed
503 504
}

Dries's avatar
 
Dries committed
505
function update_33() {
506
  $result = db_query("SELECT * FROM variable WHERE value NOT LIKE 's:%;'");
507
  // NOTE: the "WHERE"-part of the query above avoids variables to get serialized twice.
Dries's avatar
 
Dries committed
508 509 510 511 512
  while ($variable = db_fetch_object($result)) {
    variable_set($variable->name, $variable->value);
  }
}

513
function update_34() {
514 515
  update_sql("ALTER TABLE feed MODIFY refresh int(10) NOT NULL default '0'");
  update_sql("ALTER TABLE feed MODIFY timestamp int (10) NOT NULL default '0'");
Dries's avatar
 
Dries committed
516
  update_sql("ALTER TABLE users CHANGE session session TEXT");
517 518
}

Dries's avatar
 
Dries committed
519
function update_35() {
520
  update_sql("ALTER TABLE poll_choices ADD INDEX (nid)");
Dries's avatar
 
Dries committed
521 522
}

Dries's avatar
 
Dries committed
523
function update_36() {
524 525
  update_sql("ALTER TABLE rating CHANGE old previous int(6) NOT NULL default '0'");
  update_sql("ALTER TABLE rating CHANGE new current int(6) NOT NULL default '0'");
Dries's avatar
 
Dries committed
526 527
}

Dries's avatar
 
Dries committed
528 529
function update_37() {

530
  update_sql("DROP TABLE IF EXISTS sequences");
Dries's avatar
 
Dries committed
531 532

  update_sql("CREATE TABLE sequences (
Dries's avatar
 
Dries committed
533
    name VARCHAR(255) NOT NULL PRIMARY KEY,
Dries's avatar
 
Dries committed
534
    id INT UNSIGNED NOT NULL
535
  ) TYPE=MyISAM");
Dries's avatar
 
Dries committed
536

537 538
  if ($max = db_result(db_query("SELECT MAX(nid) FROM node"))) {
    update_sql("REPLACE INTO sequences VALUES ('node', $max)");
Dries's avatar
 
Dries committed
539 540
  }

541 542
  if ($max = db_result(db_query("SELECT MAX(cid) FROM comments"))) {
    update_sql("REPLACE INTO sequences VALUES ('comments', $max)");
Dries's avatar
 
Dries committed
543 544 545
  }
  // NOTE: move the comments bit down as soon as we switched to use the new comment module!

546 547
  if ($max = db_result(db_query("SELECT MAX(tid) FROM term_data"))) {
    update_sql("REPLACE INTO sequences VALUES ('term_data', $max)");
Dries's avatar
 
Dries committed
548 549 550
  }
}

Dries's avatar
 
Dries committed
551
function update_38() {
552
  update_sql("ALTER TABLE watchdog CHANGE message message text NOT NULL default ''");
Dries's avatar
 
Dries committed
553 554
}

Dries's avatar
 
Dries committed
555 556 557
function update_39() {
  update_sql("DROP TABLE moderate");

558 559 560
  update_sql("ALTER TABLE comments ADD score MEDIUMINT NOT NULL");
  update_sql("ALTER TABLE comments ADD status TINYINT UNSIGNED NOT NULL");
  update_sql("ALTER TABLE comments ADD users MEDIUMTEXT");
Dries's avatar
 
Dries committed
561 562 563 564 565

  update_sql("CREATE TABLE moderation_votes (
    mid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    vote VARCHAR(255),
    weight TINYINT NOT NULL
566
  )");
Dries's avatar
 
Dries committed
567 568 569 570 571

  update_sql("CREATE TABLE moderation_roles (
    rid INT UNSIGNED NOT NULL,
    mid INT UNSIGNED NOT NULL,
    value TINYINT NOT NULL
572
  )");
Dries's avatar
 
Dries committed
573

574 575
  update_sql("ALTER TABLE moderation_roles ADD INDEX (rid)");
  update_sql("ALTER TABLE moderation_roles ADD INDEX (mid)");
Dries's avatar
 
Dries committed
576 577 578 579 580

  update_sql("CREATE TABLE moderation_filters (
    fid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    filter VARCHAR(255) NOT NULL,
    minimum SMALLINT NOT NULL
581
  )");
Dries's avatar
 
Dries committed
582

583 584 585
  update_sql("DELETE FROM moderation_votes");
  update_sql("INSERT INTO moderation_votes VALUES (1, '+1', 0)");
  update_sql("INSERT INTO moderation_votes VALUES (2, '-1', 1)");
Dries's avatar
 
Dries committed
586

587 588 589
  update_sql("DELETE FROM moderation_roles");
  update_sql("INSERT INTO moderation_roles VALUES (2, 1, 1)");
  update_sql("INSERT INTO moderation_roles VALUES (2, 2, -1)");
Dries's avatar
 
Dries committed
590 591 592 593 594

  update_sql("CREATE TABLE forum (
    nid int unsigned not null primary key,
    icon varchar(255) not null,
    shadow int unsigned not null
595
  )");
Dries's avatar
 
Dries committed
596 597
}

Dries's avatar
 
Dries committed
598
function update_40() {
599 600
  if ($max = db_result(db_query("SELECT MAX(cid) FROM comments"))) {
    update_sql("REPLACE INTO sequences VALUES ('comments', $max)");
Dries's avatar
 
Dries committed
601 602 603
  }
}

Dries's avatar
 
Dries committed
604
function update_41() {
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
  update_sql("CREATE TABLE statistics (
    nid int(11) NOT NULL,
    totalcount bigint UNSIGNED DEFAULT '0' NOT NULL,
    daycount mediumint UNSIGNED DEFAULT '0' NOT NULL,
    timestamp int(11) UNSIGNED DEFAULT '0' NOT NULL,
    PRIMARY KEY (nid),
    INDEX (totalcount),
    INDEX (daycount),
    INDEX (timestamp)
  )");

  update_sql("CREATE TABLE accesslog (
    nid int(11) UNSIGNED DEFAULT '0',
    url varchar(255),
    hostname varchar(128),
    uid int(10) UNSIGNED DEFAULT '0',
    timestamp int(11) UNSIGNED NOT NULL
  )");
Dries's avatar
 
Dries committed
623 624
}

Kjartan's avatar
Kjartan committed
625 626 627 628 629 630
function update_42() {
  update_sql("DROP TABLE modules");
  update_sql("DROP TABLE layout");
  update_sql("DROP TABLE referrer");
}

Dries's avatar
 
Dries committed
631 632 633
function update_43() {
  update_sql("ALTER TABLE blocks DROP remove");
  update_sql("ALTER TABLE blocks DROP name");
Kjartan's avatar
Kjartan committed
634 635
  update_sql("UPDATE boxes SET type = 0 WHERE type = 1");
  update_sql("UPDATE boxes SET type = 1 WHERE type = 2");
Dries's avatar
 
Dries committed
636 637
}

Dries's avatar
 
Dries committed
638 639 640 641
function update_44() {
  update_sql("UPDATE system SET filename = CONCAT('modules/', filename) WHERE type = 'module'");
}

Dries's avatar
 
Dries committed
642 643 644 645
function update_45() {
  update_sql("ALTER TABLE page ADD description varchar(128) NOT NULL default ''");
}

Dries's avatar
 
Dries committed
646 647 648 649
function update_46() {
  update_sql("ALTER TABLE cache ADD created int(11) NOT NULL default '0'");
}

Dries's avatar
 
Dries committed
650 651 652 653 654 655 656
function update_47() {
  update_sql("CREATE TABLE menu (
    name varchar(255) NOT NULL default '',
    link varchar(255) NOT NULL default '',
    help TEXT default '',
    title varchar(255) NOT NULL default '',
    parent varchar(255) NOT NULL default '',
Dries's avatar
 
Dries committed
657
    weight tinyint(4) DEFAULT '0' NOT NULL
Dries's avatar
 
Dries committed
658 659 660
  );");
}

Dries's avatar
 
Dries committed
661
function update_48() {
Dries's avatar
 
Dries committed
662
  if ($max = db_result(db_query("SELECT MAX(vid) FROM vocabulary"))) {
Dries's avatar
 
Dries committed
663 664 665 666
    update_sql("REPLACE INTO sequences VALUES ('vocabulary', $max)");
  }
}

Dries's avatar
 
Dries committed
667 668 669 670
function update_49() {
  update_sql("ALTER TABLE watchdog ADD link varchar(255) DEFAULT '' NULL");
}

Dries's avatar
 
Dries committed
671 672 673 674 675 676
function update_50() {
  update_content("%admin.php%");
  update_content("%module.php%");
  update_content("%node.php%");
}

Dries's avatar
Dries committed
677 678 679 680 681 682 683 684 685
function update_51() {
  update_sql("ALTER TABLE form ADD tid INT UNSIGNED NOT NULL");
  $result = db_queryd("SELECT n.nid, t.tid FROM node n, term_node t WHERE n.nid = t.nid AND type = 'forum'");
  while ($node = db_fetch_object($result)) {
    db_queryd("UPDATE forum SET tid = '%d' WHERE nid = '%d'", $node->tid, $node->nid);
  }
  update_sql("ALTER TABLE forum ADD INDEX (tid)");
}

Kjartan's avatar
Kjartan committed
686
function update_upgrade3() {
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
  update_sql("INSERT INTO system VALUES ('archive.module','archive','module','',1)");
  update_sql("INSERT INTO system VALUES ('block.module','block','module','',1)");
  update_sql("INSERT INTO system VALUES ('blog.module','blog','module','',1)");
  update_sql("INSERT INTO system VALUES ('book.module','book','module','',1)");
  update_sql("INSERT INTO system VALUES ('cloud.module','cloud','module','',1)");
  update_sql("INSERT INTO system VALUES ('comment.module','comment','module','',1)");
  update_sql("INSERT INTO system VALUES ('forum.module','forum','module','',1)");
  update_sql("INSERT INTO system VALUES ('help.module','help','module','',1)");
  update_sql("INSERT INTO system VALUES ('import.module','import','module','',1)");
  update_sql("INSERT INTO system VALUES ('locale.module','locale','module','',1)");
  update_sql("INSERT INTO system VALUES ('node.module','node','module','',1)");
  update_sql("INSERT INTO system VALUES ('page.module','page','module','',1)");
  update_sql("INSERT INTO system VALUES ('poll.module','poll','module','',1)");
  update_sql("INSERT INTO system VALUES ('queue.module','queue','module','',1)");
  update_sql("INSERT INTO system VALUES ('rating.module','rating','module','',1)");
  update_sql("INSERT INTO system VALUES ('search.module','search','module','',1)");
  update_sql("INSERT INTO system VALUES ('statistics.module','statistics','module','',1)");
  update_sql("INSERT INTO system VALUES ('story.module','story','module','',1)");
  update_sql("INSERT INTO system VALUES ('taxonomy.module','taxonomy','module','',1)");
  update_sql("INSERT INTO system VALUES ('themes/example/example.theme','example','theme','Internet explorer, Netscape, Opera, Lynx',1)");
  update_sql("INSERT INTO system VALUES ('themes/goofy/goofy.theme','goofy','theme','Internetexplorer, Netscape, Opera',1)");
  update_sql("INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1)");
  update_sql("INSERT INTO system VALUES ('themes/unconed/unconed.theme','unconed','theme','Internet explorer, Netscape, Opera',1)");
  update_sql("INSERT INTO system VALUES ('tracker.module','tracker','module','',1)");
  update_sql("REPLACE variable SET value = 'marvin', name = 'theme_default'");
  update_sql("REPLACE blocks SET name = 'User information', module = 'user', delta = '0', status = '1'");
  update_sql("REPLACE blocks SET name = 'Log in', module = 'user', delta = '1', status = '1'");
Kjartan's avatar
Kjartan committed
714 715
}

Dries's avatar
 
Dries committed
716 717 718 719
/*
** System functions
*/

720 721
function update_sql($sql) {
  global $edit;
Kjartan's avatar
Kjartan committed
722
  print nl2br(htmlentities($sql)) ." ";
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
  $result = db_query($sql);
  if ($result) {
    print "<font color=\"green\">OK</font>\n";
    return 1;
  }
  else {
    print "<font color=\"red\">FAILED</font>\n";
    if ($edit["bail"]) {
      die("Fatal error. Bailing");
    }
    return 0;
  }
}

function update_data($start) {
  global $mysql_updates;
  $mysql_updates = array_slice($mysql_updates, ($start-- ? $start : 0));
740
  foreach ($mysql_updates as $date => $func) {
741 742 743 744 745 746 747 748 749 750 751 752 753
    print "<b>$date</b><br />\n<pre>\n";
    $func();
    variable_set("update_start", $date);
    print "</pre>\n";
  }
}

function update_page() {
  global $op, $edit, $user, $mysql_updates;

  switch ($op) {
    case "Update":
      // make sure we have updates to run.
Dries's avatar
 
Dries committed
754
      print "<html><h1>Drupal database update</h1>";
Kjartan's avatar
Kjartan committed
755
      print "<b>&raquo; <a href=\"index.php\">home</a></b><br />\n";
Dries's avatar
 
Dries committed
756
      print "<b>&raquo; ". l("administer", "admin"). "</b><br />\n";
757 758 759 760 761 762
      if ($edit["start"] == -1) {
        print "No updates to perform.";
      }
      else {
        update_data($edit["start"]);
      }
Dries's avatar
 
Dries committed
763 764
      print "<br />Updates were attempted. If you see no failures above, you may proceed happily to the ". l("admin pages", "admin"). ".";
      print " Otherwise, you may need to update your database manually.";
765
      print "</html>";
766
      break;
Kjartan's avatar
Kjartan committed
767 768 769 770
    case "upgrade3":
      // make sure we have updates to run.
      print "<html><h1>Drupal upgrade</h1>";
      print "<b>&raquo; <a href=\"index.php\">home</a></b><br />\n";
Dries's avatar
 
Dries committed
771
      print "<b>&raquo; ". l("admin pages", "admin"). "</b><br /><br />\n";
Kjartan's avatar
Kjartan committed
772 773 774 775 776 777 778 779 780 781 782
      if ($edit["start"] == -1) {
        print "No updates to perform.";
      }
      else {
        update_data($edit["start"]);
      }
      print "<pre>\n";
      update_upgrade3();
      print "</pre>\n";
      print "</html>";
      break;
Dries's avatar
 
Dries committed
783 784 785
    case "upgrade4":
      variable_set("update_start", "2002-05-15");
      // fall through:
786 787 788 789
    default:
      $start = variable_get("update_start", 0);
      $dates[] = "All";
      $i = 1;
790
      foreach ($mysql_updates as $date => $sql) {
791 792 793 794 795
        $dates[$i++] = $date;
        if ($date == $start) {
          $selected = $i;
        }
      }
Dries's avatar
 
Dries committed
796
      $dates[$i] = "No updates available";
797 798 799

      // make update form and output it.
      $form .= form_select("Perform updates since", "start", (isset($selected) ? $selected : -1), $dates);
Kjartan's avatar
Kjartan committed
800
      $form .= form_select("Stop on errors", "bail", 0, array("Disabled", "Enabled"), "Don't forget to backup your database before performing an update.");
801
      $form .= form_submit("Update");
Dries's avatar
 
Dries committed
802
      print "<html><h1>Drupal database update</h1>";
803
      print form($form);
804
      print "</html>";
805 806 807 808
      break;
  }
}

Dries's avatar
 
Dries committed
809 810 811 812 813 814 815 816 817 818 819 820 821
function update_content($pattern) {

  $result = db_query("SELECT n.nid, c.cid, c.subject FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE c.comment LIKE '%s'", $pattern);
  while ($comment = db_fetch_object($result)) {
    watchdog("special", "upgrade possibly affects comment '$comment->subject'", "<a href=\"node.php?id=$comment->nid&cid=$comment->cid#$comment->cid\">view post</a>");
  }

  $result = db_query("SELECT nid, title FROM node WHERE teaser LIKE '%s' OR body LIKE '%s'", $pattern, $pattern);
  while ($node = db_fetch_object($result)) {
    watchdog("special", "upgrade possibly affects node '$node->title'", "<a href=\"node.php?id=$node->nid\">view post</a>");
  }
}

822
function update_info() {
Dries's avatar
 
Dries committed
823 824

  print "<html><h1>Drupal database update</h1>";
Kjartan's avatar
Kjartan committed
825
  print "<ol>\n";
Dries's avatar
 
Dries committed
826
  print "<li>Use this script to <b>upgrade an existing Drupal installation</b>.  You don't need this script when installing Drupal from scratch.</li>";
Dries's avatar
 
Dries committed
827 828
  print "<li>Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.</li>\n";
  print "<li>Don't run this script twice as it may cause problems.</p></li>\n";
Dries's avatar
 
Dries committed
829 830 831 832 833
  print "<li>";
  print "Click the proper link below:<br />";
  print "<p><b>&raquo; <a href=\"update.php?op=upgrade4\">Upgrade 4.0.x to 4.1.x</a></b></p>\n";
  print "<p><b>&raquo; <a href=\"update.php?op=update\">Upgrade to CVS</a></b></p>\n";
  print "<p><b>&raquo; <a href=\"update.php?op=upgrade3\">Upgrade 3.0.x to 4.0.0</a></b> (Warning: clicking this link will update your database without confirmation.)</p>\n";
Dries's avatar
 
Dries committed
834
  print "<p>If you are upgrading from <b>Drupal 3.0.x</b>, you'll want to run these queries manually <b>before proceeding to step 5</b>:</p>\n";
835
  print "<pre>\n";
Dries's avatar
 
Dries committed
836 837 838 839 840 841 842 843 844 845 846 847 848
  print "  ALTER TABLE watchdog CHANGE user uid int(10) DEFAULT '0' NOT NULL;\n";
  print "  ALTER TABLE watchdog CHANGE id wid int(5) DEFAULT '0' NOT NULL auto_increment;\n";
  print "  ALTER TABLE users ADD sid varchar(32) DEFAULT '' NOT NULL;\n";
  print "  ALTER TABLE users ADD session TEXT;\n";
  print "  ALTER TABLE users CHANGE last_host hostname varchar(128) DEFAULT '' NOT NULL;\n";
  print "  ALTER TABLE users CHANGE last_access timestamp int(11) DEFAULT '0' NOT NULL;\n";
  print "  CREATE TABLE system (filename varchar(255) NOT NULL default '', name varchar(255) NOT NULL default '', type varchar(255) NOT NULL default '', description varchar(255) NOT NULL default '', status int(2) NOT NULL default '0', PRIMARY KEY (filename));\n";
  print "  CREATE TABLE permission (rid INT UNSIGNED NOT NULL, perm TEXT, tid INT UNSIGNED NOT NULL, KEY (rid));\n";
  print "  INSERT INTO permission (rid, perm) SELECT rid, perm FROM role;\n";
  print "  ALTER TABLE users ADD rid INT UNSIGNED NOT NULL;\n";
  print "</pre>\n";
  print "</li>";
  print "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n";
Kjartan's avatar
Kjartan committed
849
  print "</ol>";
850
  print "</html>";
851
}
852

Kjartan's avatar
Kjartan committed
853 854
if ($op) {
  include_once "includes/common.inc";
Dries's avatar
 
Dries committed
855

Dries's avatar
 
Dries committed
856 857
  // Access check:
  if ($user->uid == 1) {
Dries's avatar
 
Dries committed
858

Kjartan's avatar
Kjartan committed
859 860 861
    update_page();
  }
  else {
Dries's avatar
 
Dries committed
862
    print "Access denied.  You are not authorized to access to this page.  Please log in as the user with user ID #1 or edit <code>update.php</code> to by-pass this access check; search for <code>\$user->uid == 1</code> near the bottom of the file.";
Kjartan's avatar
Kjartan committed
863 864 865 866
  }
}
else {
  update_info();
867
}
Dries's avatar
 
Dries committed
868
?>