📄 install.php
字号:
<?php
$_wp_installing = 1;
if (!file_exists('../wp-config.php'))
die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='wp-admin/setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
require_once('../wp-config.php');
require('upgrade-functions.php');
if (isset($_GET['step']))
$step = $_GET['step'];
else
$step = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>WordPress › Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style media="screen" type="text/css">
<!--
body {
background-color: white;
color: black;
font-family: Georgia, "Times New Roman", Times, serif;
margin-left: 15%;
margin-right: 15%;
}
#logo {
margin: 0;
padding: 0;
background-image: url(http://wordpress.org/images/wordpress.gif);
background-repeat: no-repeat;
height: 60px;
border-bottom: 4px solid #333;
}
#logo a {
display: block;
height: 60px;
}
#logo a span {
display: none;
}
p, li {
line-height: 140%;
}
-->
</style>
</head>
<body>
<h1 id="logo"><a href="http://wordpress.org"><span>WordPress</span></a></h1>
<?php
// Let's check to make sure WP isn't already installed.
$wpdb->hide_errors();
$installed = $wpdb->get_results("SELECT * FROM $tableusers");
if ($installed) die(__('<p>You appear to already have WordPress installed. If you would like to reinstall please clear your old database files first.</p></body></html>'));
$wpdb->show_errors();
switch($step) {
case 0:
?>
<p>Welcome to WordPress. We’re now going to go through a few steps to get
you up and running with the latest in personal publishing platforms. Before
we get started, remember that we require a PHP version of at least 4.1.0, you
have <?php echo phpversion(); ?>. Look good? You also need to set up the database
connection information in <code>wp-config.php</code>. Have you looked at the
<a href="../readme.html">readme</a>? If you’re all ready, <a href="install.php?step=1">let's
go</a>! </p>
<?php
break;
case 1:
?>
<h1>Step 1</h1>
<p>Okay first we’re going to set up the links database. This will allow you to host your own blogroll, complete with Weblogs.com updates.</p>
<?php
$got_links = false;
$got_cats = false;
$got_row = false;
?>
<p>Installing WP-Links.</p>
<p>Checking for tables...</p>
<?php
$result = mysql_list_tables(DB_NAME);
if (!$result) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
if ($row[0] == $tablelinks)
$got_links = true;
if ($row[0] == $tablelinkcategories)
$got_cats = true;
//print "Table: $row[0]<br />\n";
}
if (!$got_cats) {
echo "<p>Can't find table '$tablelinkcategories', gonna create it...</p>\n";
$sql = "CREATE TABLE $tablelinkcategories ( " .
" cat_id int(11) NOT NULL auto_increment, " .
" cat_name tinytext NOT NULL, ".
" auto_toggle enum ('Y','N') NOT NULL default 'N', ".
" show_images enum ('Y','N') NOT NULL default 'Y', " .
" show_description enum ('Y','N') NOT NULL default 'Y', " .
" show_rating enum ('Y','N') NOT NULL default 'Y', " .
" show_updated enum ('Y','N') NOT NULL default 'Y', " .
" sort_order varchar(64) NOT NULL default 'name', " .
" sort_desc enum('Y','N') NOT NULL default 'N', " .
" text_before_link varchar(128) not null default '<li>', " .
" text_after_link varchar(128) not null default '<br />'," .
" text_after_all varchar(128) not null default '</li>', " .
" list_limit int not null default '-1', " .
" PRIMARY KEY (cat_id) ".
") ";
$result = mysql_query($sql) or print ("Can't create the table '$tablelinkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
echo "<p>Table '$tablelinkcategories' created OK</p>\n";
$got_cats = true;
}
} else {
echo "<p>Found table '$tablelinkcategories', don't need to create it...</p>\n";
$got_cats = true;
}
if (!$got_links) {
echo "<p>Can't find '$tablelinks', gonna create it...</p>\n";
$sql = "CREATE TABLE $tablelinks ( " .
" link_id int(11) NOT NULL auto_increment, " .
" link_url varchar(255) NOT NULL default '', " .
" link_name varchar(255) NOT NULL default '', " .
" link_image varchar(255) NOT NULL default '', " .
" link_target varchar(25) NOT NULL default '', " .
" link_category int(11) NOT NULL default 0, " .
" link_description varchar(255) NOT NULL default '', " .
" link_visible enum ('Y','N') NOT NULL default 'Y', " .
" link_owner int NOT NULL DEFAULT '1', " .
" link_rating int NOT NULL DEFAULT '0', " .
" link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
" link_rel varchar(255) NOT NULL default '', " .
" link_notes MEDIUMTEXT NOT NULL default '', " .
" PRIMARY KEY (link_id) " .
") ";
$result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database.<br />" . $sql . "<br />" . mysql_error());
$links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
$links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
$links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://zed1.com/journalized/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
$links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://www.alexking.org/', 'Alex', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
$links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://dougal.gunters.org/', 'Dougal', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
if ($result != false) {
echo "<p>Table '$tablelinks' created OK</p>\n";
$got_links = true;
}
} else {
echo "<p>Found table '$tablelinks', don't need to create it...</p>\n";
$got_links = true;
}
if ($got_links && $got_cats) {
echo "<p>Looking for category 1...</p>\n";
$sql = "SELECT * FROM $tablelinkcategories WHERE cat_id=1 ";
$result = mysql_query($sql) or print ("Can't query '$tablelinkcategories'.<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 $tablelinkcategories (cat_id, cat_name) VALUES (1, 'Links')";
$result = mysql_query($sql) or print ("Can't query insert category.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
echo "<p>Inserted category Ok</p>\n";
$got_row = true;
}
}
}
}
if ($got_row) {
echo "<p>All done!</p>\n";
}
?>
<p>Did you defeat the boss monster at the end? Great! You’re ready for <a href="install.php?step=2">Step
2</a>.</p>
<?php
break;
case 2:
?>
<h1>Step 2</h1>
<p>First we’re going to create the necessary blog tables in the database...</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -