}
     } else {
         $query = "ALTER TABLE {$wpdb->links} ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
         $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
         echo "<p>Added column link_updated...</p>\n";
     }
     echo "<p>Looking for column link_rel...</p>\n";
     $query = "SELECT link_rel FROM {$wpdb->links} LIMIT 1";
     $q = @mysql_query($query);
     if ($q != false) {
         if ($row = mysql_fetch_object($q)) {
             echo "<p>You have column link_rel. Good!</p>\n";
         }
     } else {
         $query = "ALTER TABLE {$wpdb->links} ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' ";
         $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
         echo "<p>Added column link_rel...</p>\n";
     }
     $got_links = true;
 }
 if ($got_links && $got_cats) {
     echo "<p>Looking for category 1...</p>\n";
     $sql = "SELECT * FROM {$wpdb->linkcategories} WHERE cat_id=1 ";
     $result = mysql_query($sql) or print "Can't query '{$wpdb->linkcategories}'.<br />" . $sql . "<br />" . mysql_error();
     if ($result != false) {
         if ($row = mysql_fetch_object($result)) {
             echo "<p>You have at least 1 category. Good!</p>\n";
             $got_row = true;
         } else {
             echo "<p>Gonna insert category 1...</p>\n";
             $sql = "INSERT INTO {$wpdb->linkcategories} (cat_id, cat_name) VALUES (1, 'General')";
Exemple #2
0
$q = mysql_query($query) or mysql_doh("doh, can't insert a first comment in the table \"{$tablecomments}\" in the database.", $query, mysql_error());
echo "comments: OK<br />";
// $query = "DROP TABLE IF EXISTS $tablesettings";
// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tablesettings\" in the database.");
$query = "CREATE TABLE {$tablesettings} ( ID tinyint(3) DEFAULT '1' NOT NULL, posts_per_page int(4) unsigned DEFAULT '7' NOT NULL, what_to_show varchar(5) DEFAULT 'days' NOT NULL, archive_mode varchar(10) DEFAULT 'weekly' NOT NULL, time_difference tinyint(4) DEFAULT '0' NOT NULL, AutoBR tinyint(1) DEFAULT '1' NOT NULL, time_format varchar(20) DEFAULT 'H:i:s' NOT NULL, date_format varchar(20) DEFAULT 'Y/m/d' NOT NULL, PRIMARY KEY (ID), KEY ID (ID) )";
$q = mysql_query($query) or mysql_doh("doh, can't create the table \"{$tablesettings}\" in the database.", $query, mysql_error());
$query = "INSERT INTO {$tablesettings} ( ID, posts_per_page, what_to_show, archive_mode, time_difference, AutoBR, time_format, date_format) VALUES ( '1', '20', 'posts', 'monthly', '0', '1', 'H:i:s', 'd.m.y')";
$q = mysql_query($query) or mysql_doh("doh, can't set the default settings in the table \"{$tablesettings}\" in the database.", $query, mysql_error());
echo "settings: OK<br />";
// $query = "DROP TABLE IF EXISTS $tableusers";
// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tableusers\" in the database.");
$query = "CREATE TABLE {$tableusers} ( ID int(10) unsigned NOT NULL auto_increment, user_login varchar(20) NOT NULL, user_pass varchar(20) NOT NULL, user_firstname varchar(50) NOT NULL, user_lastname varchar(50) NOT NULL, user_nickname varchar(50) NOT NULL, user_icq int(10) unsigned DEFAULT '0' NOT NULL, user_email varchar(100) NOT NULL, user_url varchar(100) NOT NULL, user_ip varchar(15) NOT NULL, user_domain varchar(200) NOT NULL, user_browser varchar(200) NOT NULL, dateYMDhour datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, user_level int(2) unsigned DEFAULT '0' NOT NULL, user_aim varchar(50) NOT NULL, user_msn varchar(100) NOT NULL, user_yim varchar(50) NOT NULL, user_idmode varchar(20) NOT NULL, PRIMARY KEY (ID), UNIQUE ID (ID), UNIQUE (user_login) )";
$q = mysql_query($query) or mysql_doh("doh, can't create the table \"{$tableusers}\" in the database.", $query, mysql_error());
$random_password = substr(md5(uniqid(microtime())), 0, 6);
$query = "INSERT INTO {$tableusers} (ID, user_login, user_pass, user_firstname, user_lastname, user_nickname, user_icq, user_email, user_url, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_aim, user_msn, user_yim, user_idmode) VALUES ( '1', 'admin', '{$random_password}', '', '', 'admin', '0', '{$admin_email}', '', '127.0.0.1', '127.0.0.1', '', '00-00-0000 00:00:01', '10', '', '', '', 'nickname')";
$q = mysql_query($query) or mysql_doh("doh, can't set the default user in the table \"{$tableusers}\" in the database.", $query, mysql_error());
echo "users: OK<br />";
?>

<br />
Installation successful !<br />
<br/ >
Now you can <a href="b2login.php">log in</a> with the login "admin" and password "<?php 
echo $random_password;
?>
".<br /><br />
<br />
Note that password carefully ! It is a <em>random</em> password that is given to you when you install b2. If you lose it, you will have to delete the tables from the database yourself, and re-install b2.

</body>
</html>