From d30fed14c7a112762e2255690302394b8771f40f Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 12 Jul 2005 18:58:58 +0000 Subject: Updating svn:eol-style git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@13 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- index.php | 782 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 391 insertions(+), 391 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index ff6925f..3d4b01f 100644 --- a/index.php +++ b/index.php @@ -1,391 +1,391 @@ - - - - WordPress › Installation - - - - - -

-Welcome to WordPress MU, the Multi User Weblog System built on WordPress.

-'; -} - -function check_writeable_dir( $dir, $ret ) -{ - if( is_writeable( $dir ) == false ) - { - print $dir." : FAILED
Quick Fix: chmod 777 $dir
"; - return false; - } - else - { - if( $ret == true ) - { - return true; - } - else - { - return false; - } - } -} - -function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url ) -{ - // remove ending slash from $base and $url - $htaccess = ''; - if( substr($base, -1 ) == '/') { - $base = substr($base, 0, -1); - } - - if( substr($url, -1 ) == '/') { - $url = substr($url, 0, -1); - } - if( is_file( $oldfilename ) ) - { - $fp = fopen( $oldfilename, "r" ); - if( $fp ) - { - while( !feof( $fp ) ) - { - $htaccess .= fgets( $fp, 4096 ); - } - fclose( $fp ); - $htaccess = str_replace( "REALPATH", $realpath, $htaccess ); - $htaccess = str_replace( "BASE", $base, $htaccess ); - $htaccess = str_replace( "HOST", $url, $htaccess ); - $fp = fopen( $newfilename, "w" ); - fwrite( $fp, $htaccess ); - fclose( $fp ); - } - } -} - -function checkdirs() { - $ret = true; - $ret = check_writeable_dir( dirname(__FILE__), $ret ); - $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst", $ret ); - $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/", $ret ); - $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates", $ret ); - - if( $ret == false ) - { - print "

Warning!

"; - print "
"; - print "

One or more of the above directories must be made writeable by the webserver.
"; - print "Please chmod 777 directory-name or chown that directory to the user the web server runs as (usually nobody, apache, or www-data)
"; - print "Refresh this page when you're done!

"; - print "
"; - } - - return $ret; -} - -function step1() { - print "You're probably seeing this message because you're installing WPMU!

"; - print "If it's already installed, then mod_rewrite is disabled. Ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.

"; - if( checkdirs() == false ) { - return false; - } - - // Create default template cache dirs - @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-cache" , 0777 ); - @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates_c" , 0777 ); - - // Create Blogs living area. - @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/blogs.dir", 0777 ); - - - $url = "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ); - if( substr( $url, -1 ) == '/' ) - $url = substr( $url, 0, -1 ); - $base = dirname( $_SERVER["SCRIPT_NAME"] ); - if( $base == "/") - { - $base = ""; - } - $realpath = dirname(__FILE__); - - if( is_file( dirname(__FILE__) . "./wp-inst/wpmu-settings.php" ) == false ) - { - $configfile = ''; - $fp = fopen( "./wp-inst/wpmu-settings.php.dist", "r" ); - if( $fp ) - { - while( !feof( $fp ) ) - { - $configfile .= fgets( $fp, 4096 ); - } - fclose( $fp ); - } - $configfile = str_replace( "BASE", $base."/", $configfile ); - $fp = fopen( "./wp-inst/wpmu-settings.php", "w" ); - fwrite( $fp, $configfile ); - fclose( $fp ); - } - return true; -} - -function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $prefix = 'wp_' ) { - print " -
- -

Virtual Server Support

-

Do you want to enable virtual server support?   Yes No

-

If you do, your blog addresses will appear like http://joesblog.example.com/ instead of http://www.example.com/joesblog/ but you need to do a few more things to Apache and your DNS settings before it'll work.
- If this is your first time installing WPMU then leave this at No.

-
-

Database

-

We need some information on the database. You will need to know the following items before proceeding.

-
    -
  1. Database name
  2. -
  3. Database username
  4. -
  5. Database password
  6. -
  7. Database host
  8. -
  9. Table prefix (if you want to run more than one WordPress in a single database)
  10. -
-

If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php.

- -

Below you should enter your database connection details. If you're not sure about these, contact your host.

- - - - - - - - - - - - - - - - - - - - - - - - - - -
Database NameThe name of the database you want to run WP in.
User NameYour MySQL username
Password...and MySQL password.
Database Host99% chance you won't need to change this value.
Table PrefixIf you want to run multiple WordPress installations in a single database, change this.
- -
"; -} - -function step2() { - $dbname = $_POST['dbname']; - $uname = $_POST['uname']; - $passwrd = $_POST['pwd']; - $dbhost = $_POST['dbhost']; - $vhost = $_POST['vhost' ]; - $prefix = $_POST['prefix']; - if (empty($prefix)) $prefix = 'wp_'; - - // Test the db connection. - define('DB_NAME', $dbname); - define('DB_USER', $uname); - define('DB_PASSWORD', $passwrd); - define('DB_HOST', $dbhost); - - if (!file_exists('wp-inst/wp-config-sample.php')) - die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); - - $configFile = file('wp-inst/wp-config-sample.php'); - // We'll fail here if the values are no good. - require_once('wp-inst/wp-includes/wp-db.php'); - printheader(); - - print "Creating Database Config File: "; - - $handle = fopen('wp-inst/wp-config.php', 'w'); - - foreach ($configFile as $line_num => $line) { - switch (substr($line,0,16)) { - case "define('DB_NAME'": - fwrite($handle, str_replace("wordpress", $dbname, $line)); - break; - case "define('DB_USER'": - fwrite($handle, str_replace("'username'", "'$uname'", $line)); - break; - case "define('DB_PASSW": - fwrite($handle, str_replace("'password'", "'$passwrd'", $line)); - break; - case "define('DB_HOST'": - fwrite($handle, str_replace("localhost", $dbhost, $line)); - break; - case "define('VHOST', ": - fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line)); - break; - case '$table_prefix =': - fwrite($handle, str_replace('wp_', $prefix, $line)); - break; - default: - fwrite($handle, $line); - } - } - fclose($handle); - chmod('wp-inst/wp-config.php', 0666); - print "DONE
"; -} - -function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) { - print " -
- -

To finish setting up your blog, please fill in the folling form and click Submit.

- - - - - - - - - - - -
Weblog TitleWhat would you like to call your weblog?
EmailYour email address.
- -
-
- You will be sent an email with your password and login links and details."; -} - -function step3() { - global $wpdb; - $base = dirname( $_SERVER["SCRIPT_NAME"] ); - $domain = $_SERVER[ 'HTTP_HOST' ]; - - $hostname = $_SERVER["HTTP_HOST"]; - - $email = $wpdb->escape( $_POST[ 'email' ] ); - $weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] ); - - // set up site tables - $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (1, 1, 'admin_email', '".$email."')"; - $wpdb->query( $query ); - $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (2, 1, 'admin_user_id', '1')"; - $wpdb->query( $query ); - - - $res = create_blog( $domain, $base, 'admin', $weblog_title, $email); - if( $res == 'ok' ) { - if( $base == '/' ) { - $url = "http://".$_SERVER["HTTP_HOST"] . '/'; - } else { - $url = "http://".$_SERVER["HTTP_HOST"] . $base . '/'; - } - $realpath = dirname(__FILE__); - do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url ); - do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url ); - - print "

Well Done! Your blog has been set up and you have been sent details of your login and password in an email.

"; - print "

You may view your new blog by visiting ".$url."!

"; - } else { - if( $res == 'error: problem creating blog entry' ) { - print "The main blog has already been created. Edit your blogs table and delete the entry for this domain!"; - } elseif( $res == 'error: username used' ) { - print "The username you chose is already in use, please select another one."; - } - print "
result: $res
"; - printuserdetailsform( $_POST[ 'weblog_title' ], $_POST[ 'username' ], $_POST[ 'email' ] ); - } -} - -switch( $_POST[ 'action' ] ) { - case "step2": - // get blog username - // create wp-inst/wp-config.php - step2(); - printuserdetailsform(); - break; - case "step3": - // call createBlog(); - // create .htaccess - // print login info and links. - require_once('./wp-inst/wp-config.php'); - require_once('./wp-inst/wp-admin/upgrade-functions.php'); - make_db_current_silent(); - populate_options(); - printheader(); - step3(); - break; - default: - // check that directories are writeable. - // create wp-inst/wpmu-settings.php - // get db auth info. - printheader(); - if( step1() ) { - printstep1form(); - } - break; -} -?> -

-
-WPMU | Support Forums -
- - + + + + WordPress › Installation + + + + + +

+Welcome to WordPress MU, the Multi User Weblog System built on WordPress.

+'; +} + +function check_writeable_dir( $dir, $ret ) +{ + if( is_writeable( $dir ) == false ) + { + print $dir." : FAILED
Quick Fix: chmod 777 $dir
"; + return false; + } + else + { + if( $ret == true ) + { + return true; + } + else + { + return false; + } + } +} + +function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url ) +{ + // remove ending slash from $base and $url + $htaccess = ''; + if( substr($base, -1 ) == '/') { + $base = substr($base, 0, -1); + } + + if( substr($url, -1 ) == '/') { + $url = substr($url, 0, -1); + } + if( is_file( $oldfilename ) ) + { + $fp = fopen( $oldfilename, "r" ); + if( $fp ) + { + while( !feof( $fp ) ) + { + $htaccess .= fgets( $fp, 4096 ); + } + fclose( $fp ); + $htaccess = str_replace( "REALPATH", $realpath, $htaccess ); + $htaccess = str_replace( "BASE", $base, $htaccess ); + $htaccess = str_replace( "HOST", $url, $htaccess ); + $fp = fopen( $newfilename, "w" ); + fwrite( $fp, $htaccess ); + fclose( $fp ); + } + } +} + +function checkdirs() { + $ret = true; + $ret = check_writeable_dir( dirname(__FILE__), $ret ); + $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst", $ret ); + $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/", $ret ); + $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates", $ret ); + + if( $ret == false ) + { + print "

Warning!

"; + print "
"; + print "

One or more of the above directories must be made writeable by the webserver.
"; + print "Please chmod 777 directory-name or chown that directory to the user the web server runs as (usually nobody, apache, or www-data)
"; + print "Refresh this page when you're done!

"; + print "
"; + } + + return $ret; +} + +function step1() { + print "You're probably seeing this message because you're installing WPMU!

"; + print "If it's already installed, then mod_rewrite is disabled. Ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.

"; + if( checkdirs() == false ) { + return false; + } + + // Create default template cache dirs + @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-cache" , 0777 ); + @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates_c" , 0777 ); + + // Create Blogs living area. + @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/blogs.dir", 0777 ); + + + $url = "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ); + if( substr( $url, -1 ) == '/' ) + $url = substr( $url, 0, -1 ); + $base = dirname( $_SERVER["SCRIPT_NAME"] ); + if( $base == "/") + { + $base = ""; + } + $realpath = dirname(__FILE__); + + if( is_file( dirname(__FILE__) . "./wp-inst/wpmu-settings.php" ) == false ) + { + $configfile = ''; + $fp = fopen( "./wp-inst/wpmu-settings.php.dist", "r" ); + if( $fp ) + { + while( !feof( $fp ) ) + { + $configfile .= fgets( $fp, 4096 ); + } + fclose( $fp ); + } + $configfile = str_replace( "BASE", $base."/", $configfile ); + $fp = fopen( "./wp-inst/wpmu-settings.php", "w" ); + fwrite( $fp, $configfile ); + fclose( $fp ); + } + return true; +} + +function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $prefix = 'wp_' ) { + print " +
+ +

Virtual Server Support

+

Do you want to enable virtual server support?   Yes No

+

If you do, your blog addresses will appear like http://joesblog.example.com/ instead of http://www.example.com/joesblog/ but you need to do a few more things to Apache and your DNS settings before it'll work.
+ If this is your first time installing WPMU then leave this at No.

+
+

Database

+

We need some information on the database. You will need to know the following items before proceeding.

+
    +
  1. Database name
  2. +
  3. Database username
  4. +
  5. Database password
  6. +
  7. Database host
  8. +
  9. Table prefix (if you want to run more than one WordPress in a single database)
  10. +
+

If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php.

+ +

Below you should enter your database connection details. If you're not sure about these, contact your host.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Database NameThe name of the database you want to run WP in.
User NameYour MySQL username
Password...and MySQL password.
Database Host99% chance you won't need to change this value.
Table PrefixIf you want to run multiple WordPress installations in a single database, change this.
+ +
"; +} + +function step2() { + $dbname = $_POST['dbname']; + $uname = $_POST['uname']; + $passwrd = $_POST['pwd']; + $dbhost = $_POST['dbhost']; + $vhost = $_POST['vhost' ]; + $prefix = $_POST['prefix']; + if (empty($prefix)) $prefix = 'wp_'; + + // Test the db connection. + define('DB_NAME', $dbname); + define('DB_USER', $uname); + define('DB_PASSWORD', $passwrd); + define('DB_HOST', $dbhost); + + if (!file_exists('wp-inst/wp-config-sample.php')) + die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); + + $configFile = file('wp-inst/wp-config-sample.php'); + // We'll fail here if the values are no good. + require_once('wp-inst/wp-includes/wp-db.php'); + printheader(); + + print "Creating Database Config File: "; + + $handle = fopen('wp-inst/wp-config.php', 'w'); + + foreach ($configFile as $line_num => $line) { + switch (substr($line,0,16)) { + case "define('DB_NAME'": + fwrite($handle, str_replace("wordpress", $dbname, $line)); + break; + case "define('DB_USER'": + fwrite($handle, str_replace("'username'", "'$uname'", $line)); + break; + case "define('DB_PASSW": + fwrite($handle, str_replace("'password'", "'$passwrd'", $line)); + break; + case "define('DB_HOST'": + fwrite($handle, str_replace("localhost", $dbhost, $line)); + break; + case "define('VHOST', ": + fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line)); + break; + case '$table_prefix =': + fwrite($handle, str_replace('wp_', $prefix, $line)); + break; + default: + fwrite($handle, $line); + } + } + fclose($handle); + chmod('wp-inst/wp-config.php', 0666); + print "DONE
"; +} + +function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) { + print " +
+ +

To finish setting up your blog, please fill in the folling form and click Submit.

+ + + + + + + + + + + +
Weblog TitleWhat would you like to call your weblog?
EmailYour email address.
+ +
+
+ You will be sent an email with your password and login links and details."; +} + +function step3() { + global $wpdb; + $base = dirname( $_SERVER["SCRIPT_NAME"] ); + $domain = $_SERVER[ 'HTTP_HOST' ]; + + $hostname = $_SERVER["HTTP_HOST"]; + + $email = $wpdb->escape( $_POST[ 'email' ] ); + $weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] ); + + // set up site tables + $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (1, 1, 'admin_email', '".$email."')"; + $wpdb->query( $query ); + $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (2, 1, 'admin_user_id', '1')"; + $wpdb->query( $query ); + + + $res = create_blog( $domain, $base, 'admin', $weblog_title, $email); + if( $res == 'ok' ) { + if( $base == '/' ) { + $url = "http://".$_SERVER["HTTP_HOST"] . '/'; + } else { + $url = "http://".$_SERVER["HTTP_HOST"] . $base . '/'; + } + $realpath = dirname(__FILE__); + do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url ); + do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url ); + + print "

Well Done! Your blog has been set up and you have been sent details of your login and password in an email.

"; + print "

You may view your new blog by visiting ".$url."!

"; + } else { + if( $res == 'error: problem creating blog entry' ) { + print "The main blog has already been created. Edit your blogs table and delete the entry for this domain!"; + } elseif( $res == 'error: username used' ) { + print "The username you chose is already in use, please select another one."; + } + print "
result: $res
"; + printuserdetailsform( $_POST[ 'weblog_title' ], $_POST[ 'username' ], $_POST[ 'email' ] ); + } +} + +switch( $_POST[ 'action' ] ) { + case "step2": + // get blog username + // create wp-inst/wp-config.php + step2(); + printuserdetailsform(); + break; + case "step3": + // call createBlog(); + // create .htaccess + // print login info and links. + require_once('./wp-inst/wp-config.php'); + require_once('./wp-inst/wp-admin/upgrade-functions.php'); + make_db_current_silent(); + populate_options(); + printheader(); + step3(); + break; + default: + // check that directories are writeable. + // create wp-inst/wpmu-settings.php + // get db auth info. + printheader(); + if( step1() ) { + printstep1form(); + } + break; +} +?> +

+
+WPMU | Support Forums +
+ + -- cgit