summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php782
-rw-r--r--wp-inst/mm-newblog.php340
-rw-r--r--wp-inst/wp-admin/admin-db.php178
-rw-r--r--wp-inst/wp-admin/dbx-key.js88
-rw-r--r--wp-inst/wp-admin/dbx.js10
-rw-r--r--wp-inst/wp-admin/upgrade-schema.php752
-rw-r--r--wp-inst/wp-includes/registration-functions.php62
-rw-r--r--wp-inst/wp-includes/wpmu-functions.php1888
-rw-r--r--wp-inst/wp-settings.php432
9 files changed, 2266 insertions, 2266 deletions
diff --git a/index.php b/index.php
index ff6925f..3d4b01f 100644
--- a/index.php
+++ b/index.php
@@ -1,391 +1,391 @@
-<?php
-define('WP_INSTALLING', true);
-
-function printheader() {
- print '
-<!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">
-<head>
- <title>WordPress &rsaquo; Installation</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <style media="screen" type="text/css">
- <!--
- html {
- background: #eee;
- }
- body {
- background: #fff;
- color: #000;
- font-family: Georgia, "Times New Roman", Times, serif;
- margin-left: 20%;
- margin-right: 20%;
- padding: .2em 2em;
- }
-
- h1 {
- color: #006;
- font-size: 18px;
- font-weight: lighter;
- }
-
- h2 {
- font-size: 16px;
- }
-
- p, li, dt {
- line-height: 140%;
- padding-bottom: 2px;
- }
-
- ul, ol {
- padding: 5px 5px 5px 20px;
- }
- #logo {
- margin-bottom: 2em;
- }
-.step a, .step input {
- font-size: 2em;
-}
-.step, th {
- text-align: right;
-}
-#footer {
-text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
-}
-.fakelink {
- color: #00a;
- text-decoration: underline;
-}
- -->
- </style>
-</head>
-<body>
-
-<div align="center"><img src="wp-inst/wp-images/wordpress-mu.png"></div><br>
-Welcome to WordPress MU, the Multi User Weblog System built on WordPress.<br><br>
-';
-}
-
-function check_writeable_dir( $dir, $ret )
-{
- if( is_writeable( $dir ) == false )
- {
- print $dir." : <b style='color: #f55'>FAILED</b><br>Quick Fix: <code>chmod 777 $dir</code><br>";
- 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 "<h2>Warning!</h2>";
- print "<div style='border: 1px solid #ccc'>";
- print "<p style='font-weight: bold; padding-left: 10px'>One or more of the above directories must be made writeable by the webserver.<br>";
- print "Please <code>chmod 777 <q>directory-name</q></code> or <code>chown</code> that directory to the user the web server runs as (usually nobody, apache, or www-data)<br>";
- print "Refresh this page when you're done!<br></p>";
- print "</div>";
- }
-
- return $ret;
-}
-
-function step1() {
- print "You're probably seeing this message because you're installing WPMU!<br><br>";
- print "If it's already installed, then <b>mod_rewrite</b> is disabled. Ask your administrator to enable that module, or look at the <a href='http://httpd.apache.org/docs/mod/mod_rewrite.html'>Apache documentation</a> or <a href='http://www.google.com/search?q=apache+mod_rewrite'>elsewhere</a> for help setting it up.<br><br>";
- 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 "
- <form method='post' action='index.php'>
- <input type='hidden' name='action' value='step2'>
- <h1>Virtual Server Support</h1>
- <p><strong>Do you want to enable virtual server support?&nbsp;&nbsp;&nbsp;Yes <input type='radio' name='vhost' value='yes'> No <input type='radio' name='vhost' value='no' checked></strong></p>
- <p>If you do, your blog addresses will appear like <span class='fakelink'>http://joesblog.example.com/</span> instead of <span class='fakelink'>http://www.example.com/joesblog/</span> but you need to do a few more things to Apache and your DNS settings before it'll work.<br />
- If this is your first time installing WPMU then leave this at <em>No</em>.</p>
- <br />
- <h1>Database</h1>
-<p>We need some information on the database. You will need to know the following items before proceeding.</p>
-<ol>
- <li>Database name</li>
- <li>Database username</li>
- <li>Database password</li>
- <li>Database host</li>
- <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
-</ol>
-<p><strong>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 <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
-
- <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
- <table>
- <tr>
- <th scope='row'>Database Name</th>
- <td><input name='dbname' type='text' size='45' value='".$dbname."' /></td>
- <td>The name of the database you want to run WP in. </td>
- </tr>
- <tr>
- <th scope='row'>User Name</th>
- <td><input name='uname' type='text' size='45' value='".$uname."' /></td>
- <td>Your MySQL username</td>
- </tr>
- <tr>
- <th scope='row'>Password</th>
- <td><input name='pwd' type='text' size='45' value='".$pwd."' /></td>
- <td>...and MySQL password.</td>
- </tr>
- <tr>
- <th scope='row'>Database Host</th>
- <td><input name='dbhost' type='text' size='45' value='".$dbhost."' /></td>
- <td>99% chance you won't need to change this value.</td>
- </tr>
- <tr>
- <th scope='row'>Table Prefix</th>
- <td><input name='prefix' type='text' id='prefix' value='".$prefix."' size='45' /></td>
- <td>If you want to run multiple WordPress installations in a single database, change this.</td>
- </tr>
- </table>
- <input name='submit' type='submit' value='Submit' />
-</form> ";
-}
-
-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 "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />";
-}
-
-function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) {
- print "
- <form method='post' action='index.php'>
- <input type='hidden' name='action' value='step3'>
- <p>To finish setting up your blog, please fill in the folling form and click <q>Submit</q>.</p>
- <table width='100%'>
- <tr>
- <th scope='row'>Weblog&nbsp;Title</th>
- <td><input name='weblog_title' type='text' size='45' value='".$weblog_title."' /></td>
- <td>What would you like to call your weblog? </td>
- </tr>
- <tr>
- <th scope='row'>Email</th>
- <td><input name='email' type='text' size='45' value='".$email."' /></td>
- <td>Your email address.</td>
- </tr>
- </table>
- <input name='submit' type='submit' value='Submit' />
- </form>
- <br />
- 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 "<p>Well Done! Your blog has been set up and you have been sent details of your login and password in an email.</p>";
- print "<p>You may view your new blog by visiting <a href='".$url."'>".$url."</a>!</p>";
- } else {
- if( $res == 'error: problem creating blog entry' ) {
- print "The <q>main</q> 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 "<br>result: $res<br>";
- 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;
-}
-?>
-<br /><br />
-<div align='center'>
-<a href="http://mu.wordpress.org/">WPMU</a> | <a href="http://mu.wordpress.org/forums/">Support Forums</a>
-</div>
-</body>
-</html>
+<?php
+define('WP_INSTALLING', true);
+
+function printheader() {
+ print '
+<!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">
+<head>
+ <title>WordPress &rsaquo; Installation</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+.step a, .step input {
+ font-size: 2em;
+}
+.step, th {
+ text-align: right;
+}
+#footer {
+text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
+}
+.fakelink {
+ color: #00a;
+ text-decoration: underline;
+}
+ -->
+ </style>
+</head>
+<body>
+
+<div align="center"><img src="wp-inst/wp-images/wordpress-mu.png"></div><br>
+Welcome to WordPress MU, the Multi User Weblog System built on WordPress.<br><br>
+';
+}
+
+function check_writeable_dir( $dir, $ret )
+{
+ if( is_writeable( $dir ) == false )
+ {
+ print $dir." : <b style='color: #f55'>FAILED</b><br>Quick Fix: <code>chmod 777 $dir</code><br>";
+ 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 "<h2>Warning!</h2>";
+ print "<div style='border: 1px solid #ccc'>";
+ print "<p style='font-weight: bold; padding-left: 10px'>One or more of the above directories must be made writeable by the webserver.<br>";
+ print "Please <code>chmod 777 <q>directory-name</q></code> or <code>chown</code> that directory to the user the web server runs as (usually nobody, apache, or www-data)<br>";
+ print "Refresh this page when you're done!<br></p>";
+ print "</div>";
+ }
+
+ return $ret;
+}
+
+function step1() {
+ print "You're probably seeing this message because you're installing WPMU!<br><br>";
+ print "If it's already installed, then <b>mod_rewrite</b> is disabled. Ask your administrator to enable that module, or look at the <a href='http://httpd.apache.org/docs/mod/mod_rewrite.html'>Apache documentation</a> or <a href='http://www.google.com/search?q=apache+mod_rewrite'>elsewhere</a> for help setting it up.<br><br>";
+ 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 "
+ <form method='post' action='index.php'>
+ <input type='hidden' name='action' value='step2'>
+ <h1>Virtual Server Support</h1>
+ <p><strong>Do you want to enable virtual server support?&nbsp;&nbsp;&nbsp;Yes <input type='radio' name='vhost' value='yes'> No <input type='radio' name='vhost' value='no' checked></strong></p>
+ <p>If you do, your blog addresses will appear like <span class='fakelink'>http://joesblog.example.com/</span> instead of <span class='fakelink'>http://www.example.com/joesblog/</span> but you need to do a few more things to Apache and your DNS settings before it'll work.<br />
+ If this is your first time installing WPMU then leave this at <em>No</em>.</p>
+ <br />
+ <h1>Database</h1>
+<p>We need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+ <li>Database name</li>
+ <li>Database username</li>
+ <li>Database password</li>
+ <li>Database host</li>
+ <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
+</ol>
+<p><strong>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 <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
+
+ <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
+ <table>
+ <tr>
+ <th scope='row'>Database Name</th>
+ <td><input name='dbname' type='text' size='45' value='".$dbname."' /></td>
+ <td>The name of the database you want to run WP in. </td>
+ </tr>
+ <tr>
+ <th scope='row'>User Name</th>
+ <td><input name='uname' type='text' size='45' value='".$uname."' /></td>
+ <td>Your MySQL username</td>
+ </tr>
+ <tr>
+ <th scope='row'>Password</th>
+ <td><input name='pwd' type='text' size='45' value='".$pwd."' /></td>
+ <td>...and MySQL password.</td>
+ </tr>
+ <tr>
+ <th scope='row'>Database Host</th>
+ <td><input name='dbhost' type='text' size='45' value='".$dbhost."' /></td>
+ <td>99% chance you won't need to change this value.</td>
+ </tr>
+ <tr>
+ <th scope='row'>Table Prefix</th>
+ <td><input name='prefix' type='text' id='prefix' value='".$prefix."' size='45' /></td>
+ <td>If you want to run multiple WordPress installations in a single database, change this.</td>
+ </tr>
+ </table>
+ <input name='submit' type='submit' value='Submit' />
+</form> ";
+}
+
+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 "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />";
+}
+
+function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) {
+ print "
+ <form method='post' action='index.php'>
+ <input type='hidden' name='action' value='step3'>
+ <p>To finish setting up your blog, please fill in the folling form and click <q>Submit</q>.</p>
+ <table width='100%'>
+ <tr>
+ <th scope='row'>Weblog&nbsp;Title</th>
+ <td><input name='weblog_title' type='text' size='45' value='".$weblog_title."' /></td>
+ <td>What would you like to call your weblog? </td>
+ </tr>
+ <tr>
+ <th scope='row'>Email</th>
+ <td><input name='email' type='text' size='45' value='".$email."' /></td>
+ <td>Your email address.</td>
+ </tr>
+ </table>
+ <input name='submit' type='submit' value='Submit' />
+ </form>
+ <br />
+ 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 "<p>Well Done! Your blog has been set up and you have been sent details of your login and password in an email.</p>";
+ print "<p>You may view your new blog by visiting <a href='".$url."'>".$url."</a>!</p>";
+ } else {
+ if( $res == 'error: problem creating blog entry' ) {
+ print "The <q>main</q> 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 "<br>result: $res<br>";
+ 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;
+}
+?>
+<br /><br />
+<div align='center'>
+<a href="http://mu.wordpress.org/">WPMU</a> | <a href="http://mu.wordpress.org/forums/">Support Forums</a>
+</div>
+</body>
+</html>
diff --git a/wp-inst/mm-newblog.php b/wp-inst/mm-newblog.php
index 11332d4..f79a53e 100644
--- a/wp-inst/mm-newblog.php
+++ b/wp-inst/mm-newblog.php
@@ -1,171 +1,171 @@
-<?php
-require('wp-config.php');
-
-get_header();
-?>
-<div id="content" class="widecolumn">
-<style type="text/css">
-form { margin-top: 2em; }
-td input {
- width: 90%;
- font-size: 24px;
-}
-.error {
- background-color: #FF6666;
-}
-</style>
-<?php
-
-if ($_POST) {
-
-$username = $_POST['username'];
-$email = $_POST['email' ];
-$blogname = stripslashes($_POST['blogname']);
-
-$username = sanitize_title($username);
-
-$user_error = $email_error = $blog_error = false;
-
-if ( empty( $username ) )
- $user_error = true;
-if ( $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$username'") )
- $user_error = true;
-
-if ( !is_email($email ) )
- $email_error = true;
-
-if ( empty( $blogname ) )
- $blog_error = true;
-
-if ( $user_error || $email_error || $blog_error ) {
-?>
-<h2>There was an error</h2>
-<form method="post" action="">
-<?php if ( !$user_error || !$email_error || !$blog_error ) : ?>
-<p>This info was fine:</p>
-<ul>
-<?php if ( !$user_error ) : ?>
- <li><strong>Username:</strong> <?php echo $username; ?><input name="username" type="hidden" id="username" value="<?php echo $username; ?>" /></li>
-<?php endif; ?>
-<?php if ( !$blog_error ) : ?>
- <li><strong>Blog Name:</strong> <?php echo $blogname; ?><input name="blogname" type="hidden" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" /></li>
-<?php endif; ?>
-<?php if ( !$email_error ) : ?>
- <li><strong>Email Address:</strong>
- <?php echo $email; ?><input name="email" type="hidden" value="<?php echo wp_specialchars($email, 1); ?>" /></li>
-<?php endif; ?>
-</ul>
-<?php endif; ?>
-
-<p>There was a problem with the following, please correct it below and try again.</p>
-
- <table width="100%" >
-<?php if ( $user_error ) : ?>
- <tr class="error">
- <th valign="top" scope="row">Username: </th>
- <td>
- <input name="username" type="text" id="username" value="<?php echo $username; ?>" maxlength="50" />
- <br />
- (This will also be your blog address. Letters and numbers only, please.)
- </td>
- </tr>
-<?php endif; ?>
-
-<?php if ( $blog_error ) : ?>
- <tr class="error">
- <th valign="top" scope="row">Blog Name: </th>
- <td><input name="blogname" type="text" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" />
- <br>
- (Don't worry, you can change it later.) </td>
- </tr>
-<?php endif; ?>
-
-<?php if ( $email_error ) : ?>
- <tr class="error">
- <th valign="top" scope="row">Email Address: </th>
- <td><p>
- <input name="email" type="text" maxlength="200" value="<?php echo wp_specialchars($email, 1); ?>" />
- <br />
- (Did you type in your address wrong?)
- </p>
- </td>
- </tr>
-<?php endif; ?>
- <tr>
- <th scope="row">&nbsp;</th>
- <td><input type="submit" class="submit" name="Submit" value="Try Again &raquo;" /></td>
- </tr>
- </table>
-</form>
-<?php
-} else {
-
-$main_host = $_SERVER['HTTP_HOST'];
-$main_host = str_replace('www.', '', $main_host);
-
-$base_path = dirname( $_SERVER['SCRIPT_NAME'] );
-$base_path = str_replace('wp-inst', '',$result);
-if( strlen( $base_path > 1 ) && substr($base_path, -1 ) == '/')
- $base_path = substr($base_path, 0, -1);
-
-define( 'WP_INSTALLING', true );
-require_once('./wp-config.php');
-$setup = true;
-
-if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- $host = $username . '.' . $main_host;
- $path = '/';
-} else {
- $host = $main_host;
- $path = $base_path . '/' . $username;
-}
-
-$err = create_blog( $host, $path, $username, $blogname, $email );
-
-?>
-<h2>You've got a new blog</h2>
-<h3>Your new address is <a href="http://<?php echo $host . $path; ?>"><?php echo $host . $path; ?></a></h3>
-<p>You should receive an email with the login details shortly.</p>
-<?php
-} // if error
-} else {
-?>
-
-<h2>Get your own blog</h2>
-
-<form method="post" action="">
- <table width="100%" >
- <tr>
- <th valign="top" scope="row">Username: </th>
- <td>
- <input name="username" type="text" id="username" maxlength="50" />
- <br />
- (This will also be your blog address. Letters and numbers only, please.)
- </td>
- </tr>
- <tr>
- <th valign="top" scope="row">Blog Name: </th>
- <td><input name="blogname" type="text" id="blogname">
- <br>
- (Don't worry, you can change it later.) </td>
- </tr>
- <tr>
- <th valign="top" scope="row">Email Address: </th>
- <td><p>
- <input name="email" type="text" maxlength="200" />
- <br />
- (We'll send a password to this address, so double-check it.)
- </p>
- </td>
- </tr>
- <tr>
- <th scope="row">&nbsp;</th>
- <td><input type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td>
- </tr>
- </table>
-</form>
-<?php
-} // if post
-?>
-</div>
+<?php
+require('wp-config.php');
+
+get_header();
+?>
+<div id="content" class="widecolumn">
+<style type="text/css">
+form { margin-top: 2em; }
+td input {
+ width: 90%;
+ font-size: 24px;
+}
+.error {
+ background-color: #FF6666;
+}
+</style>
+<?php
+
+if ($_POST) {
+
+$username = $_POST['username'];
+$email = $_POST['email' ];
+$blogname = stripslashes($_POST['blogname']);
+
+$username = sanitize_title($username);
+
+$user_error = $email_error = $blog_error = false;
+
+if ( empty( $username ) )
+ $user_error = true;
+if ( $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$username'") )
+ $user_error = true;
+
+if ( !is_email($email ) )
+ $email_error = true;
+
+if ( empty( $blogname ) )
+ $blog_error = true;
+
+if ( $user_error || $email_error || $blog_error ) {
+?>
+<h2>There was an error</h2>
+<form method="post" action="">
+<?php if ( !$user_error || !$email_error || !$blog_error ) : ?>
+<p>This info was fine:</p>
+<ul>
+<?php if ( !$user_error ) : ?>
+ <li><strong>Username:</strong> <?php echo $username; ?><input name="username" type="hidden" id="username" value="<?php echo $username; ?>" /></li>
+<?php endif; ?>
+<?php if ( !$blog_error ) : ?>
+ <li><strong>Blog Name:</strong> <?php echo $blogname; ?><input name="blogname" type="hidden" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" /></li>
+<?php endif; ?>
+<?php if ( !$email_error ) : ?>
+ <li><strong>Email Address:</strong>
+ <?php echo $email; ?><input name="email" type="hidden" value="<?php echo wp_specialchars($email, 1); ?>" /></li>
+<?php endif; ?>
+</ul>
+<?php endif; ?>
+
+<p>There was a problem with the following, please correct it below and try again.</p>
+
+ <table width="100%" >
+<?php if ( $user_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Username: </th>
+ <td>
+ <input name="username" type="text" id="username" value="<?php echo $username; ?>" maxlength="50" />
+ <br />
+ (This will also be your blog address. Letters and numbers only, please.)
+ </td>
+ </tr>
+<?php endif; ?>
+
+<?php if ( $blog_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Blog Name: </th>
+ <td><input name="blogname" type="text" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" />
+ <br>
+ (Don't worry, you can change it later.) </td>
+ </tr>
+<?php endif; ?>
+
+<?php if ( $email_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Email Address: </th>
+ <td><p>
+ <input name="email" type="text" maxlength="200" value="<?php echo wp_specialchars($email, 1); ?>" />
+ <br />
+ (Did you type in your address wrong?)
+ </p>
+ </td>
+ </tr>
+<?php endif; ?>
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><input type="submit" class="submit" name="Submit" value="Try Again &raquo;" /></td>
+ </tr>
+ </table>
+</form>
+<?php
+} else {
+
+$main_host = $_SERVER['HTTP_HOST'];
+$main_host = str_replace('www.', '', $main_host);
+
+$base_path = dirname( $_SERVER['SCRIPT_NAME'] );
+$base_path = str_replace('wp-inst', '',$result);
+if( strlen( $base_path > 1 ) && substr($base_path, -1 ) == '/')
+ $base_path = substr($base_path, 0, -1);
+
+define( 'WP_INSTALLING', true );
+require_once('./wp-config.php');
+$setup = true;
+
+if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ $host = $username . '.' . $main_host;
+ $path = '/';
+} else {
+ $host = $main_host;
+ $path = $base_path . '/' . $username;
+}
+
+$err = create_blog( $host, $path, $username, $blogname, $email );
+
+?>
+<h2>You've got a new blog</h2>
+<h3>Your new address is <a href="http://<?php echo $host . $path; ?>"><?php echo $host . $path; ?></a></h3>
+<p>You should receive an email with the login details shortly.</p>
+<?php
+} // if error
+} else {
+?>
+
+<h2>Get your own blog</h2>
+
+<form method="post" action="">
+ <table width="100%" >
+ <tr>
+ <th valign="top" scope="row">Username: </th>
+ <td>
+ <input name="username" type="text" id="username" maxlength="50" />
+ <br />
+ (This will also be your blog address. Letters and numbers only, please.)
+ </td>
+ </tr>
+ <tr>
+ <th valign="top" scope="row">Blog Name: </th>
+ <td><input name="blogname" type="text" id="blogname">
+ <br>
+ (Don't worry, you can change it later.) </td>
+ </tr>
+ <tr>
+ <th valign="top" scope="row">Email Address: </th>
+ <td><p>
+ <input name="email" type="text" maxlength="200" />
+ <br />
+ (We'll send a password to this address, so double-check it.)
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><input type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td>
+ </tr>
+ </table>
+</form>
+<?php
+} // if post
+?>
+</div>
<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php
index b657edd..e6c8584 100644
--- a/wp-inst/wp-admin/admin-db.php
+++ b/wp-inst/wp-admin/admin-db.php
@@ -1,90 +1,90 @@
-<?php
-
-function get_users_drafts( $user_id ) {
- global $wpdb;
- $user_id = (int) $user_id;
- $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
- $query = apply_filters('get_users_drafts', $query);
- return $wpdb->get_results( $query );
-}
-
-function get_others_drafts( $user_id ) {
- global $wpdb;
- $user = get_userdata( $user_id );
- $level_key = $wpdb->prefix . 'user_level';
- if ( 1 < $user->user_level ) {
- $editable = get_editable_user_ids( $user_id );
-
- if( !$editable ) {
- $other_drafts = '';
- } else {
- $editable = join(',', $editable);
- $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
- }
- } else {
- $other_drafts = false;
- }
- return apply_filters('get_others_drafts', $other_drafts);
-}
-
-function get_editable_authors( $user_id ) {
- global $wpdb;
- $user = get_userdata( $user_id );
- $level_key = $wpdb->prefix . 'user_level';
-
- if ( 7 > $user->user_level ) // TODO: ROLE SYSTEM
- return false;
-
- $editable = get_editable_user_ids( $user_id );
-
- if( !$editable )
- return false;
- else {
- $editable = join(',', $editable);
- $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" );
- }
-
- return apply_filters('get_editable_authors', $authors);
-}
-
-function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
- global $wpdb;
- $user = get_userdata( $user_id );
- $level_key = $wpdb->prefix . 'user_level';
-
- $query = "SELECT * FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
- if ( $exclude_zeros )
- $query .= " AND meta_value != '0'";
- $possible = $wpdb->get_results( $query );
-
- if ( !$possible )
- return false;
-
- $user_ids = array();
- foreach ( $possible as $mark )
- if ( intval($mark->meta_value) <= $user->user_level )
- $user_ids[] = $mark->user_id;
- if ( empty( $user_ids ) )
- return false;
- return $user_ids;
-}
-
-function get_author_user_ids() {
- global $wpdb;
- $level_key = $wpdb->prefix . 'user_level';
-
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'";
-
- return $wpdb->get_col( $query );
-}
-
-function get_nonauthor_user_ids() {
- global $wpdb;
- $level_key = $wpdb->prefix . 'user_level';
-
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'";
-
- return $wpdb->get_col( $query );
-}
-
+<?php
+
+function get_users_drafts( $user_id ) {
+ global $wpdb;
+ $user_id = (int) $user_id;
+ $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
+ $query = apply_filters('get_users_drafts', $query);
+ return $wpdb->get_results( $query );
+}
+
+function get_others_drafts( $user_id ) {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+ if ( 1 < $user->user_level ) {
+ $editable = get_editable_user_ids( $user_id );
+
+ if( !$editable ) {
+ $other_drafts = '';
+ } else {
+ $editable = join(',', $editable);
+ $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
+ }
+ } else {
+ $other_drafts = false;
+ }
+ return apply_filters('get_others_drafts', $other_drafts);
+}
+
+function get_editable_authors( $user_id ) {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ if ( 7 > $user->user_level ) // TODO: ROLE SYSTEM
+ return false;
+
+ $editable = get_editable_user_ids( $user_id );
+
+ if( !$editable )
+ return false;
+ else {
+ $editable = join(',', $editable);
+ $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" );
+ }
+
+ return apply_filters('get_editable_authors', $authors);
+}
+
+function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT * FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
+ if ( $exclude_zeros )
+ $query .= " AND meta_value != '0'";
+ $possible = $wpdb->get_results( $query );
+
+ if ( !$possible )
+ return false;
+
+ $user_ids = array();
+ foreach ( $possible as $mark )
+ if ( intval($mark->meta_value) <= $user->user_level )
+ $user_ids[] = $mark->user_id;
+ if ( empty( $user_ids ) )
+ return false;
+ return $user_ids;
+}
+
+function get_author_user_ids() {
+ global $wpdb;
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_nonauthor_user_ids() {
+ global $wpdb;
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'";
+
+ return $wpdb->get_col( $query );
+}
+
?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/dbx-key.js b/wp-inst/wp-admin/dbx-key.js
index a68ff66..b020b22 100644
--- a/wp-inst/wp-admin/dbx-key.js
+++ b/wp-inst/wp-admin/dbx-key.js
@@ -1,44 +1,44 @@
-
-
-//initialisation function
-window.onload = function()
-{
- //initialise the docking boxes manager
- var manager = new dbxManager('postmeta'); //session ID [/-_a-zA-Z0-9/]
-
-
- //create new docking boxes group
- var meta = new dbxGroup(
- 'grabit', // container ID [/-_a-zA-Z0-9/]
- 'vertical', // orientation ['vertical'|'horizontal']
- '7', // drag threshold ['n' pixels]
- 'no', // restrict drag movement to container axis ['yes'|'no']
- '10', // animate re-ordering [frames per transition, or '0' for no effect]
- 'yes', // include open/close toggle buttons ['yes'|'no']
- 'closed', // default state ['open'|'closed']
- 'open', // word for "open", as in "open this box"
- 'close', // word for "close", as in "close this box"
- 'click-down and drag to move this box', // sentence for "move this box" by mouse
- 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
- 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
- ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
- '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
- );
-
- var advanced = new dbxGroup(
- 'advancedstuff', // container ID [/-_a-zA-Z0-9/]
- 'vertical', // orientation ['vertical'|'horizontal']
- '7', // drag threshold ['n' pixels]
- 'yes', // restrict drag movement to container axis ['yes'|'no']
- '10', // animate re-ordering [frames per transition, or '0' for no effect]
- 'yes', // include open/close toggle buttons ['yes'|'no']
- 'closed', // default state ['open'|'closed']
- 'open', // word for "open", as in "open this box"
- 'close', // word for "close", as in "close this box"
- 'click-down and drag to move this box', // sentence for "move this box" by mouse
- 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
- 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
- ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
- '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
- );
-};
+
+
+//initialisation function
+window.onload = function()
+{
+ //initialise the docking boxes manager
+ var manager = new dbxManager('postmeta'); //session ID [/-_a-zA-Z0-9/]
+
+
+ //create new docking boxes group
+ var meta = new dbxGroup(
+ 'grabit', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '7', // drag threshold ['n' pixels]
+ 'no', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+
+ var advanced = new dbxGroup(
+ 'advancedstuff', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '7', // drag threshold ['n' pixels]
+ 'yes', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+};
diff --git a/wp-inst/wp-admin/dbx.js b/wp-inst/wp-admin/dbx.js
index 2cb73f9..17db1b7 100644
--- a/wp-inst/wp-admin/dbx.js
+++ b/wp-inst/wp-admin/dbx.js
@@ -1,6 +1,6 @@
-// DBX2.0[beta] :: Docking Boxes (dbx)
-// *****************************************************
-// DOM scripting by brothercake -- http://www.brothercake.com/
-// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
-//******************************************************
+// DBX2.0[beta] :: Docking Boxes (dbx)
+// *****************************************************
+// DOM scripting by brothercake -- http://www.brothercake.com/
+// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
+//******************************************************
var dbx;function dbxManager(sid){dbx=this;if(!/^[-_a-z0-9]+$/i.test(sid)){alert('Error from dbxManager:\n"'+sid+'" is an invalid session ID'); return;}this.supported=!(document.getElementsByTagName('*').length==0||(navigator.vendor=='KDE'&&typeof window.sidebar=='undefined'));if(!this.supported){return;}this.etype=typeof document.addEventListener!='undefined'?'addEventListener':typeof document.attachEvent!='undefined'?'attachEvent':'none';this.eprefix=(this.etype=='attachEvent'?'on':'');if(typeof window.opera!='undefined'&&parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0],10) < 7.5){this.etype='none';}if(this.etype=='none'){this.supported=false; return;}this.running=0;this.gc=[];this.sid=sid;this.savedata={};this.cookiestate=this.getCookieState();};dbxManager.prototype.setCookieState=function(){var now=new Date();now.setTime(now.getTime()+(365*24*60*60*1000));var str='';for(j in this.savedata){str+=j+'='+this.savedata[j]+'&'}this.state=str.replace(/^(.+)&$/,'$1');if(typeof this.onstatechange=='undefined'||this.onstatechange()){document.cookie='dbx-'+this.sid+'='+this.state+'; expires='+now.toGMTString()+'; path=/';}};dbxManager.prototype.getCookieState=function(){this.cookiestate=null;if(document.cookie){if(document.cookie.indexOf('dbx-'+this.sid)!=-1){this.cookie=document.cookie.split('dbx-'+this.sid+'=')[1].split('&');for(var i in this.cookie){this.cookie[i]=this.cookie[i].split('=');this.cookie[i][1]=this.cookie[i][1].split(',');}this.cookiestate={};for(i in this.cookie){this.cookiestate[this.cookie[i][0]]=this.cookie[i][1];}}}return this.cookiestate;};dbxManager.prototype.addDataMember=function(gid,order){this.savedata[gid]=order;};dbxManager.prototype.createElement=function(tag){return typeof document.createElementNS!='undefined'?document.createElementNS('http://www.w3.org/1999/xhtml',tag):document.createElement(tag);};dbxManager.prototype.getTarget=function(e,pattern,node){if(typeof node!='undefined'){var target=node;}else{target=typeof e.target!='undefined'?e.target:e.srcElement;}var regex=new RegExp(pattern,'');while(!regex.test(target.className)){target=target.parentNode;}return target;};function dbxGroup(gid,dir,thresh,fix,ani,togs,def,open,close,move,toggle,kmove,ktoggle,syntax){if(!/^[-_a-z0-9]+$/i.test(gid)){alert('Error from dbxGroup:\n"'+gid+'" is an invalid container ID'); return;}this.container=document.getElementById(gid);if(this.container==null||!dbx.supported){return;}var self=this;this.gid=gid;this.dragok=false;this.box=null;this.vertical=dir=='vertical';this.threshold=parseInt(thresh,10);this.restrict=fix=='yes';this.resolution=parseInt(ani,10);this.toggles=togs=='yes';this.defopen=def!='closed';this.vocab={'open':open,'close':close,'move':move, 'toggle':toggle,'kmove':kmove, 'ktoggle':ktoggle,'syntax':syntax};this.container.style.position='relative';this.container.style.display='block';if(typeof window.opera!='undefined'){this.container.style.display='run-in';}this.boxes=[];this.buttons=[];this.order=[];this.eles=this.container.getElementsByTagName('*');for(var i=0;i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className)&&!/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position='relative';this.eles[i].style.display='block';this.boxes.push(this.eles[i]);this.eles[i].className+=' dbx-box-open';this.eles[i].className+=' dbxid'+this.order.length;this.order.push(this.order.length.toString()+'+');this.eles[i][dbx.etype](dbx.eprefix+'mousedown',function(e){if(!e){e=window.event;}self.mousedown(e,dbx.getTarget(e,'dbx\-box'));},false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position='relative';this.eles[i].style.display='block';this.eles[i].className+=' dbx-handle-cursor';this.eles[i].setAttribute('title',this.eles[i].getAttribute('title')==null||this.eles[i].title==''?this.vocab.move:this.vocab.syntax.replace('%mytitle%',this.eles[i].title).replace('%dbxtitle%',this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix+'key'+(typeof document.uniqueID!='undefined'||navigator.vendor=='Apple Computer, Inc.'?'down':'press'),function(e) {if(!e){e=window.event;}return self.keypress(e,dbx.getTarget(e,'dbx\-handle'));},false);this.eles[i][dbx.etype](dbx.eprefix+'focus',function(e){if(!e){e=window.event;}self.createTooltip(null,dbx.getTarget(e,'dbx\-handle'));},false);this.eles[i][dbx.etype](dbx.eprefix+'blur',function(){self.removeTooltip();},false);}}}dbx.addDataMember(this.gid,this.order.join(','));var dummy=this.container.appendChild(dbx.createElement('span'));dummy.className='dbx-box dbx-dummy';dummy.style.display='block';dummy.style.width='0';dummy.style.height='0';dummy.style.overflow='hidden';if(this.vertical){dummy.className+=' dbx-offdummy';}this.boxes.push(dummy);if(dbx.cookiestate!=null&&typeof dbx.cookiestate[this.gid]!='undefined'){var num=dbx.cookiestate[this.gid].length;if(num==this.boxes.length - 1){for(i=0;i<num; i++){var index=parseInt(dbx.cookiestate[this.gid][i],10);this.container.insertBefore(this.boxes[index],dummy);if(this.toggles&&dbx.cookiestate[this.gid][i].charAt(1)=='-'){this.toggleBoxState(this.buttons[index],false);}}this.getBoxOrder();}}else if(!this.defopen&&this.toggles){var len=this.buttons.length;for(i=0;i<len; i++){this.toggleBoxState(this.buttons[i],true);}}document[dbx.etype](dbx.eprefix+'mouseout',function(e){if(typeof e.target=='undefined'){e=window.event; e.relatedTarget=e.toElement;}if(e.relatedTarget==null){self.mouseup(e);}},false);document[dbx.etype](dbx.eprefix+'mousemove',function(e){self.mousemove(e);},false);document[dbx.etype](dbx.eprefix+'mouseup',function(e){self.mouseup(e);},false);this.keydown=false;document[dbx.etype](dbx.eprefix+'keydown',function(){self.keydown=true;},false);document[dbx.etype](dbx.eprefix+'keyup',function(){self.keydown=false;},false);};dbxGroup.prototype.addToggleBehavior=function(){var self=this;var button=arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor='pointer';button.href='javascript:void(null)';button.className='dbx-toggle dbx-toggle-open';button.setAttribute('title',this.vocab.toggle.replace('%toggle%',this.vocab.close));button.hasfocus=typeof window.opera!='undefined'||navigator.vendor=='Apple Computer, Inc.'?null:false;this.tooltip=null;button.onclick=function(){if(this.hasfocus===true||this.hasfocus===null){self.removeTooltip();self.toggleBoxState(this,true);}};button['onkey'+(typeof document.uniqueID!='undefined'||navigator.vendor=='Apple Computer, Inc.'?'down':'press')]=function(e){if(!e){e=window.event;}return self.keypress(e,this);};button.onfocus=function(){var len=self.buttons.length;for(var i=0;i<len; i++){self.buttons[i].className=self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/,'');}var isopen=(/dbx\-toggle\-open/.test(this.className));this.className+=' dbx-toggle-hilite-'+(isopen?'open':'closed');self.createTooltip(isopen,this);this.isactive=true;if(this.hasfocus!==null){this.hasfocus=true;}};button.onblur=function(){this.className=this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/,'');self.removeTooltip();if(this.hasfocus!==null){this.hasfocus=false;}};return button;};dbxGroup.prototype.toggleBoxState=function(button,regen){var isopen=(/dbx\-toggle\-open/.test(button.className));var parent=dbx.getTarget(null,'dbx\-box',button);dbx.box=parent;dbx.toggle=button;if(typeof dbx.container=='undefined'){dbx.group=dbx.getTarget(null,'dbx\-group',parent);}else{dbx.group=dbx.container;}if((!isopen&&(typeof dbx.onboxopen=='undefined'||dbx.onboxopen()))||(isopen&&(typeof dbx.onboxclose=='undefined'||dbx.onboxclose()))){button.className='dbx-toggle dbx-toggle-'+(isopen?'closed':'open');button.title=this.vocab.toggle.replace('%toggle%',isopen?this.vocab.open:this.vocab.close);if(typeof button.isactive!='undefined'){button.className+=' dbx-toggle-hilite-'+(isopen?'closed':'open')}parent.className=parent.className.replace(/[ ](dbx-box-)(open|closed)/,' $1'+(isopen?'closed':'open'));if(regen){this.getBoxOrder();}}};dbxGroup.prototype.shiftBoxPosition=function(e,anchor,positive){var parent=dbx.getTarget(null,'dbx\-box',anchor);dbx.group=this.container;dbx.box=parent;dbx.event=e;if(typeof dbx.onboxdrag=='undefined'||dbx.onboxdrag()){var positions=[];var len=this.boxes.length;for(var i=0;i<len; i++){positions[i]=[i,this.boxes[i][this.vertical?'offsetTop':'offsetLeft']];if(parent==this.boxes[i]){this.idref=i;}}positions.sort(this.compare);for(i=0;i<len; i++){if(positions[i][0]==this.idref){if((positive&&i < len - 2)||(!positive&&i > 0)){var sibling=this.boxes[positions[i+(positive?1:-1)][0]];if(this.resolution > 0){var visipos={'x':parent.offsetLeft,'y':parent.offsetTop};var siblingpos={'x':sibling.offsetLeft,'y':sibling.offsetTop};}var obj={'insert':(positive?sibling:parent),'before':(positive?parent:sibling)};this.container.insertBefore(obj.insert,obj.before);if(this.resolution > 0){var animators={'sibling':new dbxAnimator(this,sibling,siblingpos,this.resolution,true,anchor),'parent':new dbxAnimator(this,parent,visipos,this.resolution,true,anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare=function(a,b){return a[1] - b[1];};dbxGroup.prototype.createTooltip=function(isopen,anchor){if(this.keydown){this.tooltip=this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility='hidden';this.tooltip.className='dbx-tooltip';if(isopen!=null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove+this.vocab.ktoggle.replace('%toggle%',isopen?this.vocab.close:this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent=dbx.getTarget(null,'dbx\-box',anchor);this.tooltip.style.left=parent.offsetLeft+'px';this.tooltip.style.top=parent.offsetTop+'px';var tooltip=this.tooltip;window.setTimeout(function(){if(tooltip!=null){tooltip.style.visibility='visible';}},500);}};dbxGroup.prototype.removeTooltip=function(){if(this.tooltip!=null){this.tooltip.parentNode.removeChild(this.tooltip); this.tooltip=null;}};dbxGroup.prototype.mousedown=function(e,box){var node=typeof e.target!='undefined'?e.target:e.srcElement;if(node.nodeName=='#text'){node=node.parentNode;}if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node=node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released=false;this.initial={'x':e.clientX,'y':e.clientY};this.current={'x':0,'y':0};this.createCloneBox(box);if(typeof e.preventDefault!='undefined' ){e.preventDefault();}if(typeof document.onselectstart!='undefined'){document.onselectstart=function(){return false;}}}};dbxGroup.prototype.mousemove=function(e){if(this.dragok&&this.box!=null){this.positive=this.vertical?(e.clientY > this.current.y?true:false):(e.clientX > this.current.x?true:false);this.current={'x':e.clientX,'y':e.clientY};var overall={'x':this.current.x - this.initial.x,'y':this.current.y - this.initial.y};if(((overall.x>=0&&overall.x<=this.threshold)||(overall.x<=0&&overall.x>=0 - this.threshold))&&((overall.y>=0&&overall.y<=this.threshold)||(overall.y<=0&&overall.y>=0 - this.threshold))){this.current.x-=overall.x; this.current.y-=overall.y;}if(this.released||overall.x > this.threshold||overall.x < (0 - this.threshold)||overall.y > this.threshold||overall.y < (0 - this.threshold)){dbx.group=this.container;dbx.box=this.box;dbx.event=e;if(typeof dbx.onboxdrag=='undefined'||dbx.onboxdrag()){this.released=true;if(!this.restrict||!this.vertical){this.boxclone.style.left=(this.current.x - this.difference.x)+'px';}if(!this.restrict||this.vertical){this.boxclone.style.top=(this.current.y - this.difference.y)+'px';}this.moveOriginalToPosition(this.current.x,this.current.y);if(typeof e.preventDefault!='undefined' ){e.preventDefault();}}}}return true;};dbxGroup.prototype.mouseup=function(e){if(this.box!=null){this.moveOriginalToPosition(e.clientX,e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart!='undefined'){document.onselectstart=function(){return true;}}}this.dragok=false;};dbxGroup.prototype.keypress=function(e,anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical&&/^(38|40)$/.test(e.keyCode))||(!this.vertical&&/^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e,anchor,/^[3][78]$/.test(e.keyCode)?false:true);if(typeof e.preventDefault!='undefined'){e.preventDefault();}else{return false;}typeof e.stopPropagation!='undefined'?e.stopPropagation():e.cancelBubble=true;this.keydown=false;}}return true;};dbxGroup.prototype.getBoxOrder=function(){this.order=[];var len=this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className)&&!/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1]+(/dbx\-box\-open/i.test(this.eles[j].className)?'+':'-'));}}dbx.savedata[this.gid]=this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone=function(){var clone=this.container.appendChild(arguments[0].cloneNode(true));clone.className+=' dbx-clone';clone.style.position='absolute';clone.style.visibility='hidden';clone.style.zIndex=arguments[1];clone.style.left=arguments[2].x+'px';clone.style.top=arguments[2].y+'px';clone.style.width=arguments[0].offsetWidth+'px';clone.style.height=arguments[0].offsetHeight+'px';return clone;};dbxGroup.prototype.createCloneBox=function(box){this.box=box;this.position={'x':this.box.offsetLeft,'y':this.box.offsetTop};this.difference={'x':(this.initial.x - this.position.x),'y':(this.initial.y - this.position.y)};this.boxclone=this.createClone(this.box,30000,this.position);this.boxclone.style.cursor='move';this.dragok=true;};dbxGroup.prototype.removeCloneBox=function(){this.container.removeChild(this.boxclone);this.box.style.visibility='visible';this.box=null;};dbxGroup.prototype.moveOriginalToPosition=function(clientX,clientY){var cloneprops={'xy':this.vertical?clientY - this.difference.y:clientX - this.difference.x,'wh':this.vertical?this.boxclone.offsetHeight:this.boxclone.offsetWidth};this.box.style.visibility='hidden';this.boxclone.style.visibility='visible';var len=this.boxes.length;for(var i=0;i<len; i++){var boxprops={'xy':this.vertical?this.boxes[i].offsetTop:this.boxes[i].offsetLeft,'wh':this.vertical?this.boxes[i].offsetHeight:this.boxes[i].offsetWidth};if((this.positive&&cloneprops.xy+cloneprops.wh > boxprops.xy&&cloneprops.xy < boxprops.xy)||(!this.positive&&cloneprops.xy < boxprops.xy&&cloneprops.xy+cloneprops.wh > boxprops.xy)){if(this.boxes[i]==this.box){return;}var sibling=this.box.nextSibling;while(sibling.className==null||!/dbx\-box/.test(sibling.className)){sibling=sibling.nextSibling;}if(this.boxes[i]==sibling){return;}if(this.resolution > 0){if(this.box[this.vertical?'offsetTop':'offsetLeft'] < boxprops.xy){var visibox=this.boxes[i].previousSibling;while(visibox.className==null||!/dbx\-box/.test(visibox.className)){visibox=visibox.previousSibling;}}else{visibox=this.boxes[i];}var visipos={'x':visibox.offsetLeft,'y':visibox.offsetTop};}var prepos={'x':this.box.offsetLeft,'y':this.box.offsetTop};this.container.insertBefore(this.box,this.boxes[i]);this.initial.x+=(this.box.offsetLeft - prepos.x);this.initial.y+=(this.box.offsetTop - prepos.y);if(this.resolution > 0&&visibox!=this.box){var animator=new dbxAnimator(this,visibox,visipos,this.resolution,false,null);}else{}break;}}};function dbxAnimator(caller,box,pos,res,kbd,anchor){this.caller=caller;this.box=box;this.timer=null;var before=pos[this.caller.vertical?'y':'x'];var after=this.box[this.caller.vertical?'offsetTop':'offsetLeft'];if(before!=after){if(dbx.running > this.caller.boxes.length - 1){return;}var clone=this.caller.createClone(this.box,29999,arguments[2]);clone.style.visibility='visible';this.box.style.visibility='hidden';this.animateClone(clone,before,after > before?after - before:0 - (before - after),this.caller.vertical?'top':'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone=function(clone,current,change,dir,res,kbd,anchor){var self=this;var count=0;dbx.running ++;this.timer=window.setInterval(function(){count ++;current+=change / res;clone.style[dir]=current+'px';if(count==res){window.clearTimeout(self.timer);self.timer=null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility='visible';if(kbd){if(anchor!=null&&anchor.parentNode.style.visibility!='hidden'){anchor.focus();}else if(self.caller.toggles){var button=self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button!=null&&typeof button.isactive!='undefined'){button.focus();}}}}},20);};if(typeof window.attachEvent!='undefined'){window.attachEvent('onunload',function(){var ev=['mousedown','mousemove','mouseup','mouseout','click','keydown','keyup','focus','blur','selectstart','statechange','boxdrag','boxopen','boxclose'];var el=ev.length;var dl=document.all.length;for(var i=0;i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on'+ev[j]]=null;}}});} \ No newline at end of file
diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php
index bf0e80b..1117edd 100644
--- a/wp-inst/wp-admin/upgrade-schema.php
+++ b/wp-inst/wp-admin/upgrade-schema.php
@@ -1,376 +1,376 @@
-<?php
-// Here we keep the DB structure and option values
-
-$wp_queries="CREATE TABLE $wpdb->categories (
- cat_ID bigint(20) NOT NULL auto_increment,
- cat_name varchar(55) NOT NULL default '',
- category_nicename varchar(200) NOT NULL default '',
- category_description longtext NOT NULL,
- category_parent bigint(20) NOT NULL default '0',
- category_count bigint(20) NOT NULL default '0',
- PRIMARY KEY (cat_ID),
- KEY category_nicename (category_nicename)
-);
-CREATE TABLE $wpdb->comments (
- comment_ID bigint(20) unsigned NOT NULL auto_increment,
- comment_post_ID int(11) NOT NULL default '0',
- comment_author tinytext NOT NULL,
- comment_author_email varchar(100) NOT NULL default '',
- comment_author_url varchar(200) NOT NULL default '',
- comment_author_IP varchar(100) NOT NULL default '',
- comment_date datetime NOT NULL default '0000-00-00 00:00:00',
- comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- comment_content text NOT NULL,
- comment_karma int(11) NOT NULL default '0',
- comment_approved enum('0','1','spam') NOT NULL default '1',
- comment_agent varchar(255) NOT NULL default '',
- comment_type varchar(20) NOT NULL default '',
- comment_parent bigint(20) NOT NULL default '0',
- user_id bigint(20) NOT NULL default '0',
- PRIMARY KEY (comment_ID),
- KEY comment_approved (comment_approved),
- KEY comment_post_ID (comment_post_ID)
-);
-CREATE TABLE $wpdb->linkcategories (
- cat_id bigint(20) 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 'N',
- 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 'rand',
- 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(11) NOT NULL default '-1',
- PRIMARY KEY (cat_id)
-);
-CREATE TABLE $wpdb->links (
- link_id bigint(20) 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(11) NOT NULL default '1',
- link_rating int(11) 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,
- link_rss varchar(255) NOT NULL default '',
- PRIMARY KEY (link_id),
- KEY link_category (link_category),
- KEY link_visible (link_visible)
-);
-CREATE TABLE $wpdb->options (
- option_id bigint(20) NOT NULL auto_increment,
- blog_id int(11) NOT NULL default '0',
- option_name varchar(64) NOT NULL default '',
- option_can_override enum('Y','N') NOT NULL default 'Y',
- option_type int(11) NOT NULL default '1',
- option_value longtext NOT NULL,
- option_width int(11) NOT NULL default '20',
- option_height int(11) NOT NULL default '8',
- option_description tinytext NOT NULL,
- option_admin_level int(11) NOT NULL default '1',
- autoload enum('yes','no') NOT NULL default 'yes',
- PRIMARY KEY (option_id,blog_id,option_name),
- KEY option_name (option_name)
-);
-CREATE TABLE $wpdb->post2cat (
- rel_id bigint(20) NOT NULL auto_increment,
- post_id bigint(20) NOT NULL default '0',
- category_id bigint(20) NOT NULL default '0',
- PRIMARY KEY (rel_id),
- KEY post_id (post_id,category_id)
-);
-CREATE TABLE $wpdb->postmeta (
- meta_id bigint(20) NOT NULL auto_increment,
- post_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (meta_id),
- KEY post_id (post_id),
- KEY meta_key (meta_key)
-);
-CREATE TABLE $wpdb->posts (
- ID bigint(20) unsigned NOT NULL auto_increment,
- post_author bigint(20) NOT NULL default '0',
- post_date datetime NOT NULL default '0000-00-00 00:00:00',
- post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- post_content longtext NOT NULL,
- post_title text NOT NULL,
- post_category int(4) NOT NULL default '0',
- post_excerpt text NOT NULL,
- post_status enum('publish','draft','private','static','object') NOT NULL default 'publish',
- comment_status enum('open','closed','registered_only') NOT NULL default 'open',
- ping_status enum('open','closed') NOT NULL default 'open',
- post_password varchar(20) NOT NULL default '',
- post_name varchar(200) NOT NULL default '',
- to_ping text NOT NULL,
- pinged text NOT NULL,
- post_modified datetime NOT NULL default '0000-00-00 00:00:00',
- post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- post_content_filtered text NOT NULL,
- post_parent bigint(20) NOT NULL default '0',
- guid varchar(255) NOT NULL default '',
- menu_order int(11) NOT NULL default '0',
- PRIMARY KEY (ID),
- KEY post_name (post_name)
-);
-CREATE TABLE $wpdb->users (
- ID bigint(20) unsigned NOT NULL auto_increment,
- user_login varchar(60) NOT NULL default '',
- user_pass varchar(64) NOT NULL default '',
- user_nicename varchar(50) NOT NULL default '',
- user_email varchar(100) NOT NULL default '',
- user_url varchar(100) NOT NULL default '',
- user_registered datetime NOT NULL default '0000-00-00 00:00:00',
- user_activation_key varchar(60) NOT NULL default '',
- user_status int(11) NOT NULL default '0',
- display_name varchar(250) NOT NULL default '',
- PRIMARY KEY (ID),
- UNIQUE KEY user_login (user_login)
-);
-CREATE TABLE $wpdb->usermeta (
- umeta_id bigint(20) NOT NULL auto_increment,
- user_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (umeta_id),
- KEY user_id (user_id),
- KEY meta_key (meta_key)
-);
-CREATE TABLE $wpdb->blogs (
- blog_id bigint(20) NOT NULL auto_increment,
- site_id bigint(20) NOT NULL default '0',
- blogname varchar(50) NOT NULL default '',
- domain varchar(255) NOT NULL default '',
- path varchar(255) NOT NULL default '',
- registered datetime NOT NULL default '0000-00-00 00:00:00',
- last_updated datetime NOT NULL default '0000-00-00 00:00:00',
- is_public enum('yes','no') NOT NULL default 'yes',
- blog_status enum('public', 'private', 'archived') NOT NULL default 'public',
- PRIMARY KEY (blog_id),
- KEY site_id (site_id),
- KEY domain (domain)
-);
-CREATE TABLE $wpdb->site (
- id bigint(20) NOT NULL auto_increment,
- domain varchar(255) NOT NULL default '',
- path varchar(255) NOT NULL default '',
- PRIMARY KEY (id),
- KEY domain (domain),
- KEY path (path)
-);
-CREATE TABLE $wpdb->sitemeta (
- meta_id bigint(20) NOT NULL auto_increment,
- site_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (meta_id),
- KEY meta_key (meta_key),
- KEY site_id (site_id)
-);
-CREATE TABLE `referer_blacklist` (
- `ID` int(11) NOT NULL auto_increment,
- `blogID` varchar(32) NOT NULL default '',
- `URL` varchar(250) NOT NULL default '',
- `t` timestamp(14) NOT NULL,
- PRIMARY KEY (`ID`),
- KEY `blogID` (`blogID`,`URL`),
- KEY `URL` (`URL`)
-);
-CREATE TABLE `referer_visitLog` (
-`blogID` char( 32 ) default NULL ,
-`visitID` int( 11 ) NOT NULL AUTO_INCREMENT ,
-`visitTime` timestamp( 14 ) NOT NULL ,
-`visitURL` char( 250 ) default NULL ,
-`referingURL` char( 250 ) default NULL ,
-`baseDomain` char( 250 ) default NULL ,
-`refpost` int( 11 ) NOT NULL default '0',
-`visitTimes` int( 10 ) NOT NULL default '0',
-`dayofmonth` smallint( 2 ) NOT NULL default '0',
-PRIMARY KEY ( `visitID` ) ,
-KEY `blogID` ( `blogID` ) ,
-KEY `refpost` ( `refpost` ) ,
-KEY `dayofmonth` ( `dayofmonth` )
-);
-CREATE TABLE `wp_linkclicks` (
- `blogID` varchar(11) default NULL,
- `link_id` int(11) NOT NULL auto_increment,
- `link_url` text NOT NULL,
- `link_clicks` int(11) NOT NULL default '0',
- `link_date` datetime NOT NULL default '0000-00-00 00:00:00',
- `link_title` text NOT NULL,
- UNIQUE KEY `link_id` (`link_id`),
- KEY `blogID` (`blogID`)
-);
-";
-
-function populate_options() {
- global $wpdb, $wpblog;
-
- $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
- add_option('siteurl', $guessurl, __('WordPress web address'));
- add_option('blogname', __('My Weblog'), __('Blog title'));
- add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
- add_option('new_users_can_blog', 0);
- add_option('users_can_register', 0);
- add_option('admin_email', 'you@example.com');
- add_option('start_of_week', 1);
- add_option('use_balanceTags', 1);
- add_option('use_smilies', 1);
- add_option('require_name_email', 1);
- add_option('comments_notify', 1);
- add_option('posts_per_rss', 10);
- add_option('rss_excerpt_length', 50);
- add_option('rss_use_excerpt', 0);
- add_option('use_fileupload', 1);
- add_option('fileupload_realpath', ABSPATH . 'wp-content/blogs.dir/'.$wpdb->blogid.'/files');
- add_option('fileupload_url', get_option('siteurl') . '/files');
- add_option('fileupload_allowedtypes', 'jpg jpeg gif png');
- add_option('fileupload_maxk', 300);
- add_option('fileupload_minlevel', 6);
- add_option('mailserver_url', 'mail.example.com');
- add_option('mailserver_login', 'login@example.com');
- add_option('mailserver_pass', 'password');
- add_option('mailserver_port', 110);
- add_option('default_category', 1);
- add_option('default_comment_status', 'open');
- add_option('default_ping_status', 'open');
- add_option('default_pingback_flag', 1);
- add_option('default_post_edit_rows', 9);
- add_option('posts_per_page', 10);
- add_option('what_to_show', 'posts');
- add_option('date_format', __('F j, Y'));
- add_option('time_format', __('g:i a'));
- add_option('links_updated_date_format', __('F j, Y g:i a'));
- add_option('links_recently_updated_prepend', '<em>');
- add_option('links_recently_updated_append', '</em>');
- add_option('links_recently_updated_time', 120);
- add_option('comment_moderation', 1);
- add_option('moderation_notify', 0);
- add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
- add_option('gzipcompression', 0);
- add_option('hack_file', 0);
- add_option('blog_charset', 'UTF-8');
- add_option('moderation_keys');
- add_option('active_plugins');
- add_option('home');
- add_option('category_base');
- add_option('ping_sites', 'http://rpc.pingomatic.com/');
- add_option('advanced_edit', 0);
- add_option('comment_max_links', 2);
- // 1.5
- add_option('default_email_category', 1, __('Posts by email go to this category'));
- add_option('recently_edited');
- add_option('use_linksupdate', 0);
- add_option('template', 'default');
- add_option('stylesheet', 'default');
- add_option('comment_whitelist', 1);
- add_option('page_uris');
- add_option('blacklist_keys');
- add_option('comment_registration', 0);
- add_option('open_proxy_check', 1);
- add_option('rss_language', 'en');
- add_option('html_type', 'text/html');
- // 1.5.1
- add_option('use_trackback', 0);
-
- populate_roles();
-
- // Delete unused options
- $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');
- foreach ($unusedoptions as $option) :
- delete_option($option);
- endforeach;
-
- // Set up a few options not to load by default
- $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
- foreach ($fatoptions as $fatoption) :
- $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
- endforeach;
-}
-
-function populate_roles() {
- global $table_prefix;
-
- $roles = array ('administrator' =>
- array('name' => __('Administrator'),
- 'capabilities' => array(
- 'edit_posts' => true,
- 'edit_others_posts' => true,
- 'edit_published_posts' => true,
- 'publish_posts' => true,
- 'edit_pages' => true,
- 'manage_categories' => true,
- 'manage_links' => true,
- 'upload_images' => true,
- 'manage_options' => true,
- 'switch_themes' => true,
- 'edit_themes' => true,
- 'activate_plugins' => true,
- 'edit_plugins' => true,
- 'edit_users' => true,
- 'edit_files' => true,
- 'read' => true,
- 'level_10' => true,
- 'level_9' => true,
- 'level_8' => true
- )),
-
- 'editor' =>
- array('name' => __('Editor'),
- 'capabilities' => array(
- 'edit_posts' => true,
- 'edit_others_posts' => true,
- 'edit_published_posts' => true,
- 'publish_posts' => true,
- 'edit_pages' => true,
- 'manage_categories' => true,
- 'manage_links' => true,
- 'upload_images' => true,
- 'read' => true,
- 'level_7' => true,
- 'level_6' => true,
- 'level_5' => true
- )),
-
- 'author' =>
- array('name' => __('Author'),
- 'capabilities' => array(
- 'edit_posts' => true,
- 'publish_posts' => true,
- 'upload_images' => true,
- 'read' => true,
- 'level_2' => true
- )),
-
- 'contributor' =>
- array('name' => __('Contributor'),
- 'capabilities' => array(
- 'edit_posts' => true,
- 'read' => true,
- 'level_1' => true
- )),
-
- 'subscriber' =>
- array('name' => __('Subscriber'),
- 'capabilities' => array(
- 'read' => true,
- 'level_0' => true
- )),
-
- 'inactive' =>
- array('name' => __('Inactive'),
- 'capabilities' => array())
- );
-
- add_option($table_prefix . 'user_roles', $roles);
-}
-?>
+<?php
+// Here we keep the DB structure and option values
+
+$wp_queries="CREATE TABLE $wpdb->categories (
+ cat_ID bigint(20) NOT NULL auto_increment,
+ cat_name varchar(55) NOT NULL default '',
+ category_nicename varchar(200) NOT NULL default '',
+ category_description longtext NOT NULL,
+ category_parent bigint(20) NOT NULL default '0',
+ category_count bigint(20) NOT NULL default '0',
+ PRIMARY KEY (cat_ID),
+ KEY category_nicename (category_nicename)
+);
+CREATE TABLE $wpdb->comments (
+ comment_ID bigint(20) unsigned NOT NULL auto_increment,
+ comment_post_ID int(11) NOT NULL default '0',
+ comment_author tinytext NOT NULL,
+ comment_author_email varchar(100) NOT NULL default '',
+ comment_author_url varchar(200) NOT NULL default '',
+ comment_author_IP varchar(100) NOT NULL default '',
+ comment_date datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_content text NOT NULL,
+ comment_karma int(11) NOT NULL default '0',
+ comment_approved enum('0','1','spam') NOT NULL default '1',
+ comment_agent varchar(255) NOT NULL default '',
+ comment_type varchar(20) NOT NULL default '',
+ comment_parent bigint(20) NOT NULL default '0',
+ user_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (comment_ID),
+ KEY comment_approved (comment_approved),
+ KEY comment_post_ID (comment_post_ID)
+);
+CREATE TABLE $wpdb->linkcategories (
+ cat_id bigint(20) 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 'N',
+ 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 'rand',
+ 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(11) NOT NULL default '-1',
+ PRIMARY KEY (cat_id)
+);
+CREATE TABLE $wpdb->links (
+ link_id bigint(20) 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(11) NOT NULL default '1',
+ link_rating int(11) 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,
+ link_rss varchar(255) NOT NULL default '',
+ PRIMARY KEY (link_id),
+ KEY link_category (link_category),
+ KEY link_visible (link_visible)
+);
+CREATE TABLE $wpdb->options (
+ option_id bigint(20) NOT NULL auto_increment,
+ blog_id int(11) NOT NULL default '0',
+ option_name varchar(64) NOT NULL default '',
+ option_can_override enum('Y','N') NOT NULL default 'Y',
+ option_type int(11) NOT NULL default '1',
+ option_value longtext NOT NULL,
+ option_width int(11) NOT NULL default '20',
+ option_height int(11) NOT NULL default '8',
+ option_description tinytext NOT NULL,
+ option_admin_level int(11) NOT NULL default '1',
+ autoload enum('yes','no') NOT NULL default 'yes',
+ PRIMARY KEY (option_id,blog_id,option_name),
+ KEY option_name (option_name)
+);
+CREATE TABLE $wpdb->post2cat (
+ rel_id bigint(20) NOT NULL auto_increment,
+ post_id bigint(20) NOT NULL default '0',
+ category_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (rel_id),
+ KEY post_id (post_id,category_id)
+);
+CREATE TABLE $wpdb->postmeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ post_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY post_id (post_id),
+ KEY meta_key (meta_key)
+);
+CREATE TABLE $wpdb->posts (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ post_author bigint(20) NOT NULL default '0',
+ post_date datetime NOT NULL default '0000-00-00 00:00:00',
+ post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content longtext NOT NULL,
+ post_title text NOT NULL,
+ post_category int(4) NOT NULL default '0',
+ post_excerpt text NOT NULL,
+ post_status enum('publish','draft','private','static','object') NOT NULL default 'publish',
+ comment_status enum('open','closed','registered_only') NOT NULL default 'open',
+ ping_status enum('open','closed') NOT NULL default 'open',
+ post_password varchar(20) NOT NULL default '',
+ post_name varchar(200) NOT NULL default '',
+ to_ping text NOT NULL,
+ pinged text NOT NULL,
+ post_modified datetime NOT NULL default '0000-00-00 00:00:00',
+ post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content_filtered text NOT NULL,
+ post_parent bigint(20) NOT NULL default '0',
+ guid varchar(255) NOT NULL default '',
+ menu_order int(11) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ KEY post_name (post_name)
+);
+CREATE TABLE $wpdb->users (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ user_login varchar(60) NOT NULL default '',
+ user_pass varchar(64) NOT NULL default '',
+ user_nicename varchar(50) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ user_url varchar(100) NOT NULL default '',
+ user_registered datetime NOT NULL default '0000-00-00 00:00:00',
+ user_activation_key varchar(60) NOT NULL default '',
+ user_status int(11) NOT NULL default '0',
+ display_name varchar(250) NOT NULL default '',
+ PRIMARY KEY (ID),
+ UNIQUE KEY user_login (user_login)
+);
+CREATE TABLE $wpdb->usermeta (
+ umeta_id bigint(20) NOT NULL auto_increment,
+ user_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (umeta_id),
+ KEY user_id (user_id),
+ KEY meta_key (meta_key)
+);
+CREATE TABLE $wpdb->blogs (
+ blog_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ blogname varchar(50) NOT NULL default '',
+ domain varchar(255) NOT NULL default '',
+ path varchar(255) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ is_public enum('yes','no') NOT NULL default 'yes',
+ blog_status enum('public', 'private', 'archived') NOT NULL default 'public',
+ PRIMARY KEY (blog_id),
+ KEY site_id (site_id),
+ KEY domain (domain)
+);
+CREATE TABLE $wpdb->site (
+ id bigint(20) NOT NULL auto_increment,
+ domain varchar(255) NOT NULL default '',
+ path varchar(255) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY domain (domain),
+ KEY path (path)
+);
+CREATE TABLE $wpdb->sitemeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY meta_key (meta_key),
+ KEY site_id (site_id)
+);
+CREATE TABLE `referer_blacklist` (
+ `ID` int(11) NOT NULL auto_increment,
+ `blogID` varchar(32) NOT NULL default '',
+ `URL` varchar(250) NOT NULL default '',
+ `t` timestamp(14) NOT NULL,
+ PRIMARY KEY (`ID`),
+ KEY `blogID` (`blogID`,`URL`),
+ KEY `URL` (`URL`)
+);
+CREATE TABLE `referer_visitLog` (
+`blogID` char( 32 ) default NULL ,
+`visitID` int( 11 ) NOT NULL AUTO_INCREMENT ,
+`visitTime` timestamp( 14 ) NOT NULL ,
+`visitURL` char( 250 ) default NULL ,
+`referingURL` char( 250 ) default NULL ,
+`baseDomain` char( 250 ) default NULL ,
+`refpost` int( 11 ) NOT NULL default '0',
+`visitTimes` int( 10 ) NOT NULL default '0',
+`dayofmonth` smallint( 2 ) NOT NULL default '0',
+PRIMARY KEY ( `visitID` ) ,
+KEY `blogID` ( `blogID` ) ,
+KEY `refpost` ( `refpost` ) ,
+KEY `dayofmonth` ( `dayofmonth` )
+);
+CREATE TABLE `wp_linkclicks` (
+ `blogID` varchar(11) default NULL,
+ `link_id` int(11) NOT NULL auto_increment,
+ `link_url` text NOT NULL,
+ `link_clicks` int(11) NOT NULL default '0',
+ `link_date` datetime NOT NULL default '0000-00-00 00:00:00',
+ `link_title` text NOT NULL,
+ UNIQUE KEY `link_id` (`link_id`),
+ KEY `blogID` (`blogID`)
+);
+";
+
+function populate_options() {
+ global $wpdb, $wpblog;
+
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ add_option('siteurl', $guessurl, __('WordPress web address'));
+ add_option('blogname', __('My Weblog'), __('Blog title'));
+ add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
+ add_option('new_users_can_blog', 0);
+ add_option('users_can_register', 0);
+ add_option('admin_email', 'you@example.com');
+ add_option('start_of_week', 1);
+ add_option('use_balanceTags', 1);
+ add_option('use_smilies', 1);
+ add_option('require_name_email', 1);
+ add_option('comments_notify', 1);
+ add_option('posts_per_rss', 10);
+ add_option('rss_excerpt_length', 50);
+ add_option('rss_use_excerpt', 0);
+ add_option('use_fileupload', 1);
+ add_option('fileupload_realpath', ABSPATH . 'wp-content/blogs.dir/'.$wpdb->blogid.'/files');
+ add_option('fileupload_url', get_option('siteurl') . '/files');
+ add_option('fileupload_allowedtypes', 'jpg jpeg gif png');
+ add_option('fileupload_maxk', 300);
+ add_option('fileupload_minlevel', 6);
+ add_option('mailserver_url', 'mail.example.com');
+ add_option('mailserver_login', 'login@example.com');
+ add_option('mailserver_pass', 'password');
+ add_option('mailserver_port', 110);
+ add_option('default_category', 1);
+ add_option('default_comment_status', 'open');
+ add_option('default_ping_status', 'open');
+ add_option('default_pingback_flag', 1);
+ add_option('default_post_edit_rows', 9);
+ add_option('posts_per_page', 10);
+ add_option('what_to_show', 'posts');
+ add_option('date_format', __('F j, Y'));
+ add_option('time_format', __('g:i a'));
+ add_option('links_updated_date_format', __('F j, Y g:i a'));
+ add_option('links_recently_updated_prepend', '<em>');
+ add_option('links_recently_updated_append', '</em>');
+ add_option('links_recently_updated_time', 120);
+ add_option('comment_moderation', 1);
+ add_option('moderation_notify', 0);
+ add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
+ add_option('gzipcompression', 0);
+ add_option('hack_file', 0);
+ add_option('blog_charset', 'UTF-8');
+ add_option('moderation_keys');
+ add_option('active_plugins');
+ add_option('home');
+ add_option('category_base');
+ add_option('ping_sites', 'http://rpc.pingomatic.com/');
+ add_option('advanced_edit', 0);
+ add_option('comment_max_links', 2);
+ // 1.5
+ add_option('default_email_category', 1, __('Posts by email go to this category'));
+ add_option('recently_edited');
+ add_option('use_linksupdate', 0);
+ add_option('template', 'default');
+ add_option('stylesheet', 'default');
+ add_option('comment_whitelist', 1);
+ add_option('page_uris');
+ add_option('blacklist_keys');
+ add_option('comment_registration', 0);
+ add_option('open_proxy_check', 1);
+ add_option('rss_language', 'en');
+ add_option('html_type', 'text/html');
+ // 1.5.1
+ add_option('use_trackback', 0);
+
+ populate_roles();
+
+ // Delete unused options
+ $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');
+ foreach ($unusedoptions as $option) :
+ delete_option($option);
+ endforeach;
+
+ // Set up a few options not to load by default
+ $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
+ foreach ($fatoptions as $fatoption) :
+ $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
+ endforeach;
+}
+
+function populate_roles() {
+ global $table_prefix;
+
+ $roles = array ('administrator' =>
+ array('name' => __('Administrator'),
+ 'capabilities' => array(
+ 'edit_posts' => true,
+ 'edit_others_posts' => true,
+ 'edit_published_posts' => true,
+ 'publish_posts' => true,
+ 'edit_pages' => true,
+ 'manage_categories' => true,
+ 'manage_links' => true,
+ 'upload_images' => true,
+ 'manage_options' => true,
+ 'switch_themes' => true,
+ 'edit_themes' => true,
+ 'activate_plugins' => true,
+ 'edit_plugins' => true,
+ 'edit_users' => true,
+ 'edit_files' => true,
+ 'read' => true,
+ 'level_10' => true,
+ 'level_9' => true,
+ 'level_8' => true
+ )),
+
+ 'editor' =>
+ array('name' => __('Editor'),
+ 'capabilities' => array(
+ 'edit_posts' => true,
+ 'edit_others_posts' => true,
+ 'edit_published_posts' => true,
+ 'publish_posts' => true,
+ 'edit_pages' => true,
+ 'manage_categories' => true,
+ 'manage_links' => true,
+ 'upload_images' => true,
+ 'read' => true,
+ 'level_7' => true,
+ 'level_6' => true,
+ 'level_5' => true
+ )),
+
+ 'author' =>
+ array('name' => __('Author'),
+ 'capabilities' => array(
+ 'edit_posts' => true,
+ 'publish_posts' => true,
+ 'upload_images' => true,
+ 'read' => true,
+ 'level_2' => true
+ )),
+
+ 'contributor' =>
+ array('name' => __('Contributor'),
+ 'capabilities' => array(
+ 'edit_posts' => true,
+ 'read' => true,
+ 'level_1' => true
+ )),
+
+ 'subscriber' =>
+ array('name' => __('Subscriber'),
+ 'capabilities' => array(
+ 'read' => true,
+ 'level_0' => true
+ )),
+
+ 'inactive' =>
+ array('name' => __('Inactive'),
+ 'capabilities' => array())
+ );
+
+ add_option($table_prefix . 'user_roles', $roles);
+}
+?>
diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php
index 9299d01..73092e0 100644
--- a/wp-inst/wp-includes/registration-functions.php
+++ b/wp-inst/wp-includes/registration-functions.php
@@ -1,32 +1,32 @@
-<?php
-
-function username_exists( $username ) {
- global $wpdb;
- $username = sanitize_user( $username );
- $query = "SELECT user_login FROM $wpdb->users WHERE user_login = '$username'";
- $query = apply_filters('username_exists', $query);
- return $wpdb->get_var( $query );
-}
-
-function create_user( $username, $password, $email, $user_level ) {
- global $wpdb;
- $username = $wpdb->escape( $username );
- $email = $wpdb->escape( $email );
- $password = md5( $password );
- $user_nicename = sanitize_title( $username );
- $now = gmdate('Y-m-d H:i:s');
-
- $query = "INSERT INTO $wpdb->users
- (user_login, user_pass, user_email, user_registered, user_nicename, display_name)
- VALUES
- ('$username', '$password', '$email', '$now', '$user_nicename', '$username')";
- $query = apply_filters('create_user_query', $query);
- $wpdb->query( $query );
- $user_id = $wpdb->insert_id;
-
- $user_level = (int) $user_level;
- update_usermeta( $user_id, $wpdb->prefix . 'user_level', $user_level);
- return $user_id;
-}
-
+<?php
+
+function username_exists( $username ) {
+ global $wpdb;
+ $username = sanitize_user( $username );
+ $query = "SELECT user_login FROM $wpdb->users WHERE user_login = '$username'";
+ $query = apply_filters('username_exists', $query);
+ return $wpdb->get_var( $query );
+}
+
+function create_user( $username, $password, $email, $user_level ) {
+ global $wpdb;
+ $username = $wpdb->escape( $username );
+ $email = $wpdb->escape( $email );
+ $password = md5( $password );
+ $user_nicename = sanitize_title( $username );
+ $now = gmdate('Y-m-d H:i:s');
+
+ $query = "INSERT INTO $wpdb->users
+ (user_login, user_pass, user_email, user_registered, user_nicename, display_name)
+ VALUES
+ ('$username', '$password', '$email', '$now', '$user_nicename', '$username')";
+ $query = apply_filters('create_user_query', $query);
+ $wpdb->query( $query );
+ $user_id = $wpdb->insert_id;
+
+ $user_level = (int) $user_level;
+ update_usermeta( $user_id, $wpdb->prefix . 'user_level', $user_level);
+ return $user_id;
+}
+
?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php
index fded787..5f769ac 100644
--- a/wp-inst/wp-includes/wpmu-functions.php
+++ b/wp-inst/wp-includes/wpmu-functions.php
@@ -1,944 +1,944 @@
-<?PHP
-/*
- Helper functions for WPMU
- 4th March 2005
-
- There are 2 types of helper functions; those that use hooks (do_action, apply_filters hooks) and those that support WPMU the Administration plugin.
-
- Where possible - existing hooks have been used, but occasionally - extra hooks have been implemented in the WP Core.
-*/
-
-/**
- * Retrieves a list of client blogs
- *
- * @return array
- */
-function wpmu_getBlogs(){
- $blogs = array();
-
- $link = opendir(ABSPATH . 'wp-content/blogs.dir/');
- while(false !== ($dir = readdir($link))){
- if(is_dir(ABSPATH . 'wp-content/blogs.dir/' . $dir)) {
- switch($dir){
- case '.':
- case '..':
- case 'DEFAULT':
- break;
- case 'main':
- array_unshift($blogs, $dir);
- break;
-
- default:
- $blogs[] = $dir;
- break;
- }
- }
- }
-
- closedir($link);
-
- return $blogs;
-}
-
-
-// Cache clearing
-/**
- * Clears the smarty cache when post/comments occur
- *
- */
-function wpmu_clear_cache() {
- // for future use.
-}
-add_action('comment_post', 'wpmu_clear_cache');
-add_action('delete_post', 'wpmu_clear_cache');
-add_action('delete_comment', 'wpmu_clear_cache');
-add_action('private_to_published', 'wpmu_clear_cache');
-add_action('publish_phone', 'wpmu_clear_cache');
-add_action('publish_post', 'wpmu_clear_cache');
-add_action('trackback_post', 'wpmu_clear_cache');
-add_action('wp_set_comment_status', 'wpmu_clear_cache');
-
-function wpmu_update_blogs_date() {
- global $wpdb;
-
- $query = "UPDATE ".$wpdb->blogs."
- SET last_updated = NOW()
- WHERE blog_id = '".$wpdb->blogid."'";
- $wpdb->query( $query );
-}
-add_action('comment_post', 'wpmu_update_blogs_date');
-add_action('delete_post', 'wpmu_update_blogs_date');
-add_action('delete_comment', 'wpmu_update_blogs_date');
-add_action('private_to_published', 'wpmu_update_blogs_date');
-add_action('publish_phone', 'wpmu_update_blogs_date');
-add_action('publish_post', 'wpmu_update_blogs_date');
-add_action('trackback_post', 'wpmu_update_blogs_date');
-add_action('wp_set_comment_status', 'wpmu_update_blogs_date');
-
-
-/**
- * Cleans the passed path.
- * Removes the wpmu & the blog name from the path
- * This should only be used for display filters
- *
- * @param unknown $path
- * @return unknown
- */
-function wpmu_tidypath($path) {
- global $wpblog;
-
- $path = str_replace('/wpmu/','/',$path);
- $path = str_replace("/{$wpblog}/",'/',$path);
-
- return $path;
-}
-add_filter('wpmu_display_get_page_string','wpmu_tidypath',10);
-add_filter('wpmu_display_get_permalink','wpmu_tidypath',10);
-
-/**
- * Wrapper for querying the databse
- *
- * @param string $query
- * @return object
- */
-function wpmu_adminDatabaseQuery($query) {
- /* @var $wpdb wpdb */
- global $wpdb;
-
- $result = $wpdb->get_row($query);
-
- return $result;
-}
-
-/**
- * Set an option in the Master Blog 'main' options table
- *
- * @param string $optionName
- * @param mixed $optionValue
- */
-function wpmu_adminOptionSet($optionName, $optionValue) {
- wpmu_blogOption_set('main',$optionName, $optionValue);
-}
-
-/**
- * Retrieve a setting from the Master Blog Tables
- *
- * @param string $optionName
- * @param mixed $default
- * @return mixed
- */
-function wpmu_adminOption_get($optionName, $default=null) {
- return wpmu_blogOption_get('main',$optionName, $default);
-}
-
-/**
- * Retrives a setting from a specific client blog
- *
- * @param string $blogName
- * @param string $optionName
- * @param mixed $default
- * @return mixed
- */
-function wpmu_blogOption_get($blogName, $optionName, $default=null) {
- global $wpdb;
-
- // check if options table exists
- if( defined('WP_INSTALLING') )
- return null;
-
- $query = wpmu_adminDatabaseQuery("SELECT * FROM ".$wpdb->options." WHERE option_name = '{$optionName}'");
- if (!isset($query) || is_null($query)) {
- $result = $default;
- } else {
- $result = $query->option_value;
- if (!(unserialize($result)===false)) {
- $result = unserialize($result);
- }
- }
-
- return $result;
-}
-
-
-/**
- * Sets an option for a specific client blog
- *
- * @param string $blogName
- * @param string $optionName
- * @param mixed $optionValue
- */
-function wpmu_blogOption_set($blogName, $optionName, $optionValue) {
-
- global $wpdb;
-
- $isExisting = wpmu_blogOption_get($blogName,$optionName,null);
-
- if (is_array($optionValue) || is_object($optionValue)) {
- $optionValue = serialize($optionValue);
- }
-
- if (is_null($isExisting)) {
- wpmu_adminDatabaseQuery("INSERT INTO ".$wpdb->options." (option_name, option_value) values ('{$optionName}', '{$optionValue}')");
- } else {
- wpmu_adminDatabaseQuery("UPDATE ".$wpdb->options." set option_value = '{$optionValue}' where option_name = '{$optionName}'");
- }
-}
-
-/*
- Determines if the available space defined by the admin has been exceeded by the user
-*/
-/**
- * Returns how much space is available (also shows a picture) for the current client blog, retrieving the value from the master blog 'main' option table
- *
- * @param string $action
- * @return string
- */
-function wpmu_checkAvailableSpace($action) {
- // Using the action.
- // Set the action to 'not-writable' to block the upload
- global $wpblog, $blog_id;
-
- // Default space allowed is 10 MB
- $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", 10485760 );
-
- $dirName = ABSPATH."wp-content/blogs.dir/".$blog_id."/files/";
-
- $dir = dir($dirName);
- $size = 0;
-
- while($file = $dir->read()) {
- if ($file != '.' && $file != '..') {
- if (is_dir($file)) {
- $size += dirsize($dirName . '/' . $file);
- } else {
- $size += filesize($dirName . '/' . $file);
- }
- }
- }
- $dir->close();
-
- ?>
- <table align="center" width="20%" cellpadding="0" cellspacing="0">
- <tr>
- <td>Space Available (<?php print $spaceAllowed-$size ?><i>bytes)</i></td>
- </tr>
- <tr>
- <td bgcolor="<?php echo ((($size/$spaceAllowed)*100)<70)?"Green":"Red"; ?>">&nbsp;</td><td bgcolor="Black" width="<?php echo (($size/$spaceAllowed)*100); ?>%"></td>
- </tr>
- </table>
- <?
-
- if (($spaceAllowed-$size)>0) {
- return $action;
- } else {
- // No space left
- return 'not-writable';
- }
-}
-add_filter('fileupload_init','wpmu_checkAvailableSpace');
-
-
-/**
- * Retrieves a list of all plugins - and flags those that have been enabled
- *
- * @param array $args ByRef Array of plugins
- */
-function wpmu_allBlogPlugins_get($args) {
-
- $allPlugins = get_plugins();
-
- $enabledPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',array());
- $enabledPlugins = unserialize($enabledPlugins);
- if (!is_array($enabledPlugins)) {
- $enabledPlugins = array();
- }
-
- foreach ($enabledPlugins as $thisPlugin) {
- if (isset($allPlugins[$thisPlugin])) {
- $allPlugins[$thisPlugin]['enabled']='1';
- }
- }
-
- $args[] = array(
- 'caption'=>'Plugins Enabled',
- 'name'=>'wpmu_global_blog_plugins',
- 'value'=>$allPlugins,
- 'type'=>'checkbox'
- );
-}
-add_action('wpmu_options_admin_get','wpmu_allBlogPlugins_get');
-
-/**
- * Sets global plugins for all blogs
- *
- * @param array $args The plugins to configure
- */
-function wpmu_allBlogPlugins_set($args) {
-
- // obtain the list of Admin Plugins to work with
- $activePlugins = $args['wpmu_global_blog_plugins'];
-
- // Process the array - turn it into something that is similar to the active_plugins array
- // and work out if the plugin has an installation phase
- $adminPlugins = array();
- $pluginsThatNeedInstalling = array();
- foreach ($activePlugins as $filename => $value) {
- $adminPlugins[] = $filename;
- // Check if the plugin has an install stage - by looking for AutoInstall in the plugin header
- if (wpmu_checkPluginForInstallStages($filename)) {
- $pluginsThatNeedInstalling[$filename]=true;
- } else {
- //
- }
- }
-
- // Store the setting first in the main blog settings for wpmu
- wpmu_adminOptionSet('wpmu_global_blog_plugins',serialize($adminPlugins));
-
- // Now rotate through the client blogs and apply the setting
- $allBlogs = wpmu_getBlogs();
- foreach ($allBlogs as $thisBlog) {
- // Exclude the 'main' blog
- if ($allBlogs!='main') {
- $currentClientPlugings = wpmu_blogOption_get($thisBlog,'active_plugins',array());
-
- if (!(unserialize($currentClientPlugings)===false)) {
- $currentClientPlugings = unserialize($currentClientPlugings);
- }
-
- // Deal with the case when we don't get back a serialized array
- if (!is_array($currentClientPlugings)) {
- $currentClientPlugings = array();
- }
-
- // Work through the currently setup plugins for this blog
- foreach ($adminPlugins as $thisAdminPlugin) {
- // If the client blog doesn't already has the plugin
- if (!in_array($thisAdminPlugin, $currentClientPlugings)) {
- $currentClientPlugings[] = $thisAdminPlugin;
- if (isset($pluginsThatNeedInstalling[$thisAdminPlugin])) {
- $clientPluginsThatNeedInstalling[] = $thisAdminPlugin;
- } else {
- //
- }
- } else {
- //
- }
- }
-
- // Store the new plugins for this blog
- wpmu_blogOption_set($thisBlog,'active_plugins',serialize($currentClientPlugings));
- if (count($clientPluginsThatNeedInstalling)>0) {
- wpmu_blogOption_set($thisBlog,'wpmu_plugins_pending',serialize($clientPluginsThatNeedInstalling));
- }
- }
- }
-}
-add_action('wpmu_options_admin_set','wpmu_allBlogPlugins_set');
-
-/**
- * Determines if a plugin contains auto-install instructions
- *
- * @param string $plugin_file
- * @return string|false Returns the install instructions or false
- */
-function wpmu_checkPluginForInstallStages($plugin_file) {
-
- if (file_exists(ABSPATH.'wp-content/plugins/'.$plugin_file)) {
- $plugin_file = ABSPATH.'wp-content/plugins/'.$plugin_file;
- } else {
- die("{$plugin_file}");
- }
-
- $plugin_data = implode('', file($plugin_file));
- preg_match("|AutoInstall:(.*)|i", $plugin_data, $pluginAutoInstall);
-
- if (is_array($pluginAutoInstall)) {
- $pluginAutoInstall = $pluginAutoInstall[0];
- } else {
- $pluginAutoInstall = "";
- }
-
- if (isset($pluginAutoInstall) && !is_null($pluginAutoInstall)) {
- $pluginAutoInstall = str_replace('AutoInstall:','',$pluginAutoInstall);
- $pluginAutoInstall = str_replace('<code>','',$pluginAutoInstall);
- $pluginAutoInstall = str_replace('</code>','',$pluginAutoInstall);
- return $pluginAutoInstall;
- }
- return false;
-}
-
-/**
- * Evaluates an expression
- *
- * @param unknown $string
- * @return unknown
- */
-function wpmu_eval($string) {
-
- $result = eval($string);
-
- if ($result===false || is_null($result)) {
- return false;
- }
- return true;
-}
-
-/**
- * Auto installs plugins
- *
- */
-function wpmu_autoInstallPlugins($pendingPlugins) {
- global $wpblog;
-
- foreach ($pendingPlugins as $key => $filename) {
- $installOptions = wpmu_checkPluginForInstallStages($filename);
- if ($installOptions) {
- // Include the file
- require_once(ABSPATH.'wp-content/plugins/'.$filename);
- $result = wpmu_eval($installOptions);
- } else {
- $result = true;
- }
- if ($result==true) {
- // Everything worked ok
- unset($pendingPlugins[$key]);
- } else {
- // There was a problem - should be logged
- }
- }
- wpmu_blogOption_set($wpblog,'wpmu_plugins_pending',serialize($pendingPlugins));
-}
-
-/*
- Determine if there are any plugins that need installing or configuring
- This will enable not just the auto install/configure of plugins - but updates (to plugins or plugin data) as well
-*/
-$pendingPlugins = wpmu_blogOption_get($wpblog,'wpmu_plugins_pending', null);
-
-if (is_null($pendingPlugins)) {
- // If null is returned - then this is a brand new blog
- $adminPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',null);
- if (!is_null($adminPlugins)) {
- // We've something to do
- wpmu_autoInstallPlugins($adminPlugins);
- }
-} else {
- if (count($pendingPlugins)>0) {
- wpmu_autoInstallPlugins($pendingPlugins);
- }
-}
-
-function createBlog( $hostname, $domain, $path, $blogname, $weblog_title, $admin_email, $username='' ) {
- global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
-
- $blogname = addslashes( $blogname );
- $weblog_title = addslashes( $weblog_title );
- $admin_email = addslashes( $admin_email );
- $username = addslashes( $username );
-
- // Check if the username has been used already. We should return an error message.
- if( $username == '' ) {
- $query = "SELECT ID
- FROM ".$wpdb->users."
- WHERE user_login = '".$blogname."'";
- $ID = $wpdb->get_var( $query );
- if( $ID != false ) {
- return "error: blogname used by user";
- }
- } else {
- $query = "SELECT ID
- FROM ".$wpdb->users."
- WHERE user_login = '".$username."'";
- $ID = $wpdb->get_var( $query );
- if( $ID != false ) {
- return "error: username used";
- }
- }
-
- // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
- // Need to get blog_id from wp_blogs, and create new table names.
- // Must restore table names at the end of function.
-
- $wpdb->hide_errors();
- $query = "SELECT id
- FROM ".$wpdb->site."
- WHERE domain = '".$domain."'
- AND path = '".$path."'";
- $site_id = $wpdb->get_var( $query );
-
- if( $site_id == false ) {
- $query = "INSERT INTO `wp_site` ( `id` , `domain` , `path` )
- VALUES ( NULL, '".$domain."', '".$path."')";
- $wpdb->query( $query );
- $site_id = $wpdb->insert_id;
- }
-
- $query = "SELECT blog_id
- FROM ".$wpdb->blogs."
- WHERE site_id = '".$site_id."'
- AND blogname = '".$blogname."'";
- $blog_id = $wpdb->get_var( $query );
- if( $blog_id != false ) {
- return "error: blogname used";
- }
- $query = "INSERT INTO ".$wpdb->blogs." ( blog_id, site_id, blogname, registered )
- VALUES ( NULL, '".$site_id."', '".$blogname."', NOW( ))";
- if( $wpdb->query( $query ) == false ) {
- return "error: problem creating blog entry";
- }
- $blog_id = $wpdb->insert_id;
-
- // backup
- $tmp[ 'siteid' ] = $wpdb->siteid;
- $tmp[ 'blogid' ] = $wpdb->blogid;
- $tmp[ 'posts' ] = $wpdb->posts;
- $tmp[ 'categories' ] = $wpdb->categories;
- $tmp[ 'post2cat' ] = $wpdb->post2cat;
- $tmp[ 'comments' ] = $wpdb->comments;
- $tmp[ 'links' ] = $wpdb->links;
- $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
- $tmp[ 'option' ] = $wpdb->option;
- $tmp[ 'postmeta' ] = $wpdb->postmeta;
- $tmptable_prefix = $table_prefix;
-
- // fix the new prefix.
- $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
- $wpdb->siteid = $site_id;
- $wpdb->blogid = $blog_id;
- $wpdb->posts = $table_prefix . 'posts';
- $wpdb->categories = $table_prefix . 'categories';
- $wpdb->post2cat = $table_prefix . 'post2cat';
- $wpdb->comments = $table_prefix . 'comments';
- $wpdb->links = $table_prefix . 'links';
- $wpdb->linkcategories = $table_prefix . 'linkcategories';
- $wpdb->options = $table_prefix . 'options';
- $wpdb->postmeta = $table_prefix . 'postmeta';
-
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
-
- require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
- $wpdb->hide_errors();
- $installed = $wpdb->get_results("SELECT * FROM $wpdb->posts");
- if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
- flush();
-
- if( $path == '/' ) {
- $slash = '';
- } else {
- $slash = $path;
- }
- if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- if( $blogname == 'main' ) {
- $url = "http://".$hostname.$path.$slash;
- } else {
- $url = "http://".$blogname.".".$domain.$path.$slash;
- }
- } else {
- if( $blogname == 'main' ) {
- $url = "http://".$hostname.$path.$slash;
- } else {
- $url = "http://".$hostname.$path.$blogname.$slash;
- }
- }
-
- // Set everything up
- make_db_current_silent();
- populate_options();
-
- // fix url.
- update_option('siteurl', $url);
-
- $wpdb->query("UPDATE $wpdb->options SET option_value = '".$weblog_title."' WHERE option_name = 'blogname'");
- $wpdb->query("UPDATE $wpdb->options SET option_value = '".$admin_email."' WHERE option_name = 'admin_email'");
-
- // Now drop in some default links
- $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
-
- // Default category
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
-
- // Set up admin user
- $random_password = substr(md5(uniqid(microtime())), 0, 6);
- if( $username != '' ) {
- $adminname = $username;
- } else {
- $adminname = $blogname;
- }
- $wpdb->query("INSERT INTO $wpdb->users (user_login, user_pass, user_email, user_registered) VALUES ( '$adminname', MD5('$random_password'), '$admin_email', NOW() )");
- $userID = $wpdb->insert_id;
- $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
- reset( $metavalues );
- while( list( $key, $val ) = each ( $metavalues ) )
- {
- $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
- VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
- $wpdb->query( $query );
- }
-
- // First post
- $now = date('Y-m-d H:i:s');
- $now_gmt = gmdate('Y-m-d H:i:s');
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
-
- $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
- $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
-
- // Default comment
- $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
-
- $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
- $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$username."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
- @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
-
- upgrade_all();
- // remove all perms except for the login user.
- $query = "DELETE FROM ".$wpdb->usermeta."
- WHERE user_id != '".$userID."'
- AND meta_key = '".$table_prefix."user_level'";
- $wpdb->query( $query );
-
- // insert admin user into user table.
- $adminusers = get_admin_users_for_domain();
- if( is_array( $adminusers ) ) {
- reset( $adminusers );
- while( list( $key, $val ) = each( $adminusers ) ) {
- $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
- VALUES ( NULL, '".$val[ 'ID' ]."', '".$table_prefix."user_level' , '10')";
- $wpdb->query( $query );
- }
- } else {
- die( "Problem getting admin users!" );
- }
-
- // restore wpdb variables
- reset( $tmp );
- while( list( $key, $val ) = each( $tmp ) )
- {
- $wpdb->$key = $val;
- }
- $table_prefix = $tmptable_prefix;
-
- $wpdb->show_errors();
-
- return "ok";
-}
-
-// New create blog
-
-function create_blog( $domain, $path, $username, $weblog_title, $admin_email, $site_id = 1 ) {
- global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
-
- $domain = addslashes( $domain );
- $weblog_title = addslashes( $weblog_title );
- $admin_email = addslashes( $admin_email );
- $username = addslashes( $username );
-
- if( empty($path) )
- $path = '/';
-
- // Check if the username has been used already. We should return an error message.
- if( $wpdb->get_var("SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path'" ) )
- return 'Blog URL already taken.';
-
- // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
- // Need to get blog_id from wp_blogs, and create new table names.
- // Must restore table names at the end of function.
-
- $wpdb->hide_errors();
-
- $query = "INSERT INTO $wpdb->blogs ( site_id, domain, path, registered ) VALUES ( '$site_id', '$domain', '$path', NOW() )";
- if( $wpdb->query( $query ) == false ) {
- return "error: problem creating blog entry";
- }
- $blog_id = $wpdb->insert_id;
-
- // backup
- $tmp[ 'siteid' ] = $wpdb->siteid;
- $tmp[ 'blogid' ] = $wpdb->blogid;
- $tmp[ 'posts' ] = $wpdb->posts;
- $tmp[ 'categories' ] = $wpdb->categories;
- $tmp[ 'post2cat' ] = $wpdb->post2cat;
- $tmp[ 'comments' ] = $wpdb->comments;
- $tmp[ 'links' ] = $wpdb->links;
- $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
- $tmp[ 'option' ] = $wpdb->option;
- $tmp[ 'postmeta' ] = $wpdb->postmeta;
- $tmptable_prefix = $table_prefix;
-
- // fix the new prefix.
- $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
- $wpdb->siteid = $site_id;
- $wpdb->blogid = $blog_id;
- $wpdb->posts = $table_prefix . 'posts';
- $wpdb->categories = $table_prefix . 'categories';
- $wpdb->post2cat = $table_prefix . 'post2cat';
- $wpdb->comments = $table_prefix . 'comments';
- $wpdb->links = $table_prefix . 'links';
- $wpdb->linkcategories = $table_prefix . 'linkcategories';
- $wpdb->options = $table_prefix . 'options';
- $wpdb->postmeta = $table_prefix . 'postmeta';
-
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
-
- require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
- $wpdb->hide_errors();
-
- flush();
-
- $url = 'http://' . $domain . $path;
-
- // Set everything up
- make_db_current_silent();
- populate_options();
-
- // fix url.
- update_option('siteurl', $url);
-
- $wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
- $wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
-
- // Now drop in some default links
- $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
-
- // Default category
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
-
- // Set up admin user
- $random_password = substr(md5(uniqid(microtime())), 0, 6);
-
- $wpdb->query("INSERT INTO $wpdb->users (user_login, user_pass, user_email, user_registered) VALUES ( '$username', MD5('$random_password'), '$admin_email', NOW() )");
- $userID = $wpdb->insert_id;
- $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
- reset( $metavalues );
- while( list( $key, $val ) = each ( $metavalues ) )
- {
- $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
- VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
- $wpdb->query( $query );
- }
-
- // First post
- $now = date('Y-m-d H:i:s');
- $now_gmt = gmdate('Y-m-d H:i:s');
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
-
- $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
- $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
-
- // Default comment
- $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
-
- $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
- $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$adminname."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
- @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
-
- upgrade_all();
- // remove all perms except for the login user.
- $query = "DELETE FROM $wpdb->usermeta WHERE user_id != '$userID' AND meta_key = '".$table_prefix."user_level'";
- $wpdb->query( $query );
-
- // restore wpdb variables
- reset( $tmp );
- while( list( $key, $val ) = each( $tmp ) )
- {
- $wpdb->$key = $val;
- }
- $table_prefix = $tmptable_prefix;
-
- $wpdb->show_errors();
-
- return "ok";
-}
-
-function get_blogaddress_by_id( $blog_id ) {
- global $hostname, $domain, $base, $wpdb;
-
- // not current blog
- $query = "SELECT *
- FROM ".$wpdb->blogs."
- WHERE blog_id = '".$blog_id."'";
- $bloginfo = $wpdb->get_results( $query, ARRAY_A );
- if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- return "http://".$bloginfo[ 'blogname' ].".".$domain.$base;
- } else {
- return "http://".$hostname.$base.$bloginfo[ 'blogname' ];
- }
-}
-
-function get_blogaddress_by_name( $blogname ) {
- global $domain, $base, $wpdb;
-
- if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- if( $blogname == 'main' )
- $blogname = 'www';
- return "http://".$blogname.".".$domain.$base;
- } else {
- return "http://".$hostname.$base.$blogname;
- }
-}
-
-function get_sitestats() {
- global $wpdb, $basedomain, $base;
-
- $query = "SELECT count(*) as c
- FROM ".$wpdb->blogs."
- WHERE site_id = '".$wpdb->siteid."'";
- $blogs = $wpdb->get_var( $query );
- $stats[ 'blogs' ] = $blogs;
-
- $query = "SELECT count(*) as c
- FROM ".$wpdb->users;
- $users = $wpdb->get_var( $query );
- $stats[ 'users' ] = $users;
-
- return $stats;
-
-}
-function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
- global $domain, $base, $basedomain, $wpdb, $wpmuBaseTablePrefix;
- if( $sitedomain == '' ) {
- $sitedomain = $basedomain;
- $site_id = $wpdb->siteid;
- } else {
- $query = "SELECT id
- FROM ".$wpdb->site."
- WHERE domain = '".$domain."'
- AND path = '".$base."'";
- $site_id = $wpdb->get_var( $query );
- }
- if( $site_id != false ) {
- $query = "SELECT ID, user_login, user_pass
- FROM ".$wpdb->users.", ".$wpdb->sitemeta."
- WHERE meta_key = 'admin_user_id'
- AND ".$wpdb->users.".ID = ".$wpdb->sitemeta.".meta_value
- AND site_id = '".$site_id."'";
- $details = $wpdb->get_results( $query, ARRAY_A );
- } else {
- $details = false;
- }
-
- return $details;
-}
-
-function get_site_settings( $option ) {
- global $wpdb;
-
- $query = "SELECT meta_value
- FROM $wpdb->sitemeta
- WHERE meta_key = '$option'
- AND site_id = '".$wpdb->siteid."'";
- $option = $wpdb->get_var( $query );
- @ $kellogs = unserialize($option);
- if ($kellogs !== FALSE)
- $option = $kellogs;
-
- return $option;
-}
-
-function add_site_settings( $key, $value ) {
- global $wpdb;
- if( $value != get_site_settings( $key ) ) {
- if ( is_array($value) || is_object($value) )
- $value = serialize($value);
- $query = "SELECT meta_value
- FROM ".$wpdb->sitemeta."
- WHERE meta_key = '$key'
- AND site_id = '".$wpdb->siteid."'";
- if( $wpdb->get_var( $query ) == false ) {
- $query = "INSERT INTO wp_sitemeta ( meta_id , site_id , meta_key , meta_value )
- VALUES ( NULL, '".$wpdb->siteid."', '".$key."', '".$wpdb->escape( $value )."')";
- $wpdb->query( $query );
- }
- }
-}
-
-function update_site_settings( $key, $value ) {
- global $wpdb;
- if( $value != get_site_settings( $key ) ) {
- if ( is_array($value) || is_object($value) )
- $value = serialize($value);
-
- $value = trim($value); // I can't think of any situation we wouldn't want to trim
- $query = "SELECT meta_value
- FROM ".$wpdb->sitemeta."
- WHERE meta_key = '$key'
- AND site_id = '".$wpdb->siteid."'";
- if( $wpdb->get_var( $query ) == false ) {
- add_site_settings( $key, $value );
- } else {
- $query = "UPDATE ".$wpdb->sitemeta."
- SET meta_value = '".$wpdb->escape( $value )."'
- WHERE meta_key = '".$key."'";
- $wpdb->query( $query );
- }
- }
-}
-
-function switch_to_blogid( $blog_id ) {
- global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings;
-
- // FIXME
-
- // backup
- $tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
- $tmpoldblogdetails[ 'posts' ] = $wpdb->posts;
- $tmpoldblogdetails[ 'categories' ] = $wpdb->categories;
- $tmpoldblogdetails[ 'post2cat' ] = $wpdb->post2cat;
- $tmpoldblogdetails[ 'comments' ] = $wpdb->comments;
- $tmpoldblogdetails[ 'links' ] = $wpdb->links;
- $tmpoldblogdetails[ 'linkcategories' ] = $wpdb->linkcategories;
- $tmpoldblogdetails[ 'option' ] = $wpdb->option;
- $tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
- $tmpoldblogdetails[ 'prefix' ] = $wpdb->prefix;
-
- // fix the new prefix.
- $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
- $wpdb->blogid = $blog_id;
- $wpdb->posts = $table_prefix . 'posts';
- $wpdb->categories = $table_prefix . 'categories';
- $wpdb->post2cat = $table_prefix . 'post2cat';
- $wpdb->comments = $table_prefix . 'comments';
- $wpdb->links = $table_prefix . 'links';
- $wpdb->linkcategories = $table_prefix . 'linkcategories';
- $wpdb->options = $table_prefix . 'options';
- $wpdb->postmeta = $table_prefix . 'postmeta';
-
- unset( $cache_settings );
-}
-
-function restore_current_blogid() {
- global $tmpoldblogdetails, $wpdb;
- // backup
- $wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
- $wpdb->posts = $tmpoldblogdetails[ 'posts' ];
- $wpdb->categories = $tmpoldblogdetails[ 'categories' ];
- $wpdb->post2cat = $tmpoldblogdetails[ 'post2cat' ];
- $wpdb->comments = $tmpoldblogdetails[ 'comments' ];
- $wpdb->links = $tmpoldblogdetails[ 'links' ];
- $wpdb->linkcategories = $tmpoldblogdetails[ 'linkcategories' ];
- $wpdb->option = $tmpoldblogdetails[ 'option' ];
- $wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
- $wpdb->prefix = $tmpoldblogdetails[ 'prefix' ];
-}
-?>
+<?PHP
+/*
+ Helper functions for WPMU
+ 4th March 2005
+
+ There are 2 types of helper functions; those that use hooks (do_action, apply_filters hooks) and those that support WPMU the Administration plugin.
+
+ Where possible - existing hooks have been used, but occasionally - extra hooks have been implemented in the WP Core.
+*/
+
+/**
+ * Retrieves a list of client blogs
+ *
+ * @return array
+ */
+function wpmu_getBlogs(){
+ $blogs = array();
+
+ $link = opendir(ABSPATH . 'wp-content/blogs.dir/');
+ while(false !== ($dir = readdir($link))){
+ if(is_dir(ABSPATH . 'wp-content/blogs.dir/' . $dir)) {
+ switch($dir){
+ case '.':
+ case '..':
+ case 'DEFAULT':
+ break;
+ case 'main':
+ array_unshift($blogs, $dir);
+ break;
+
+ default:
+ $blogs[] = $dir;
+ break;
+ }
+ }
+ }
+
+ closedir($link);
+
+ return $blogs;
+}
+
+
+// Cache clearing
+/**
+ * Clears the smarty cache when post/comments occur
+ *
+ */
+function wpmu_clear_cache() {
+ // for future use.
+}
+add_action('comment_post', 'wpmu_clear_cache');
+add_action('delete_post', 'wpmu_clear_cache');
+add_action('delete_comment', 'wpmu_clear_cache');
+add_action('private_to_published', 'wpmu_clear_cache');
+add_action('publish_phone', 'wpmu_clear_cache');
+add_action('publish_post', 'wpmu_clear_cache');
+add_action('trackback_post', 'wpmu_clear_cache');
+add_action('wp_set_comment_status', 'wpmu_clear_cache');
+
+function wpmu_update_blogs_date() {
+ global $wpdb;
+
+ $query = "UPDATE ".$wpdb->blogs."
+ SET last_updated = NOW()
+ WHERE blog_id = '".$wpdb->blogid."'";
+ $wpdb->query( $query );
+}
+add_action('comment_post', 'wpmu_update_blogs_date');
+add_action('delete_post', 'wpmu_update_blogs_date');
+add_action('delete_comment', 'wpmu_update_blogs_date');
+add_action('private_to_published', 'wpmu_update_blogs_date');
+add_action('publish_phone', 'wpmu_update_blogs_date');
+add_action('publish_post', 'wpmu_update_blogs_date');
+add_action('trackback_post', 'wpmu_update_blogs_date');
+add_action('wp_set_comment_status', 'wpmu_update_blogs_date');
+
+
+/**
+ * Cleans the passed path.
+ * Removes the wpmu & the blog name from the path
+ * This should only be used for display filters
+ *
+ * @param unknown $path
+ * @return unknown
+ */
+function wpmu_tidypath($path) {
+ global $wpblog;
+
+ $path = str_replace('/wpmu/','/',$path);
+ $path = str_replace("/{$wpblog}/",'/',$path);
+
+ return $path;
+}
+add_filter('wpmu_display_get_page_string','wpmu_tidypath',10);
+add_filter('wpmu_display_get_permalink','wpmu_tidypath',10);
+
+/**
+ * Wrapper for querying the databse
+ *
+ * @param string $query
+ * @return object
+ */
+function wpmu_adminDatabaseQuery($query) {
+ /* @var $wpdb wpdb */
+ global $wpdb;
+
+ $result = $wpdb->get_row($query);
+
+ return $result;
+}
+
+/**
+ * Set an option in the Master Blog 'main' options table
+ *
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_adminOptionSet($optionName, $optionValue) {
+ wpmu_blogOption_set('main',$optionName, $optionValue);
+}
+
+/**
+ * Retrieve a setting from the Master Blog Tables
+ *
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_adminOption_get($optionName, $default=null) {
+ return wpmu_blogOption_get('main',$optionName, $default);
+}
+
+/**
+ * Retrives a setting from a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_blogOption_get($blogName, $optionName, $default=null) {
+ global $wpdb;
+
+ // check if options table exists
+ if( defined('WP_INSTALLING') )
+ return null;
+
+ $query = wpmu_adminDatabaseQuery("SELECT * FROM ".$wpdb->options." WHERE option_name = '{$optionName}'");
+ if (!isset($query) || is_null($query)) {
+ $result = $default;
+ } else {
+ $result = $query->option_value;
+ if (!(unserialize($result)===false)) {
+ $result = unserialize($result);
+ }
+ }
+
+ return $result;
+}
+
+
+/**
+ * Sets an option for a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_blogOption_set($blogName, $optionName, $optionValue) {
+
+ global $wpdb;
+
+ $isExisting = wpmu_blogOption_get($blogName,$optionName,null);
+
+ if (is_array($optionValue) || is_object($optionValue)) {
+ $optionValue = serialize($optionValue);
+ }
+
+ if (is_null($isExisting)) {
+ wpmu_adminDatabaseQuery("INSERT INTO ".$wpdb->options." (option_name, option_value) values ('{$optionName}', '{$optionValue}')");
+ } else {
+ wpmu_adminDatabaseQuery("UPDATE ".$wpdb->options." set option_value = '{$optionValue}' where option_name = '{$optionName}'");
+ }
+}
+
+/*
+ Determines if the available space defined by the admin has been exceeded by the user
+*/
+/**
+ * Returns how much space is available (also shows a picture) for the current client blog, retrieving the value from the master blog 'main' option table
+ *
+ * @param string $action
+ * @return string
+ */
+function wpmu_checkAvailableSpace($action) {
+ // Using the action.
+ // Set the action to 'not-writable' to block the upload
+ global $wpblog, $blog_id;
+
+ // Default space allowed is 10 MB
+ $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", 10485760 );
+
+ $dirName = ABSPATH."wp-content/blogs.dir/".$blog_id."/files/";
+
+ $dir = dir($dirName);
+ $size = 0;
+
+ while($file = $dir->read()) {
+ if ($file != '.' && $file != '..') {
+ if (is_dir($file)) {
+ $size += dirsize($dirName . '/' . $file);
+ } else {
+ $size += filesize($dirName . '/' . $file);
+ }
+ }
+ }
+ $dir->close();
+
+ ?>
+ <table align="center" width="20%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>Space Available (<?php print $spaceAllowed-$size ?><i>bytes)</i></td>
+ </tr>
+ <tr>
+ <td bgcolor="<?php echo ((($size/$spaceAllowed)*100)<70)?"Green":"Red"; ?>">&nbsp;</td><td bgcolor="Black" width="<?php echo (($size/$spaceAllowed)*100); ?>%"></td>
+ </tr>
+ </table>
+ <?
+
+ if (($spaceAllowed-$size)>0) {
+ return $action;
+ } else {
+ // No space left
+ return 'not-writable';
+ }
+}
+add_filter('fileupload_init','wpmu_checkAvailableSpace');
+
+
+/**
+ * Retrieves a list of all plugins - and flags those that have been enabled
+ *
+ * @param array $args ByRef Array of plugins
+ */
+function wpmu_allBlogPlugins_get($args) {
+
+ $allPlugins = get_plugins();
+
+ $enabledPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',array());
+ $enabledPlugins = unserialize($enabledPlugins);
+ if (!is_array($enabledPlugins)) {
+ $enabledPlugins = array();
+ }
+
+ foreach ($enabledPlugins as $thisPlugin) {
+ if (isset($allPlugins[$thisPlugin])) {
+ $allPlugins[$thisPlugin]['enabled']='1';
+ }
+ }
+
+ $args[] = array(
+ 'caption'=>'Plugins Enabled',
+ 'name'=>'wpmu_global_blog_plugins',
+ 'value'=>$allPlugins,
+ 'type'=>'checkbox'
+ );
+}
+add_action('wpmu_options_admin_get','wpmu_allBlogPlugins_get');
+
+/**
+ * Sets global plugins for all blogs
+ *
+ * @param array $args The plugins to configure
+ */
+function wpmu_allBlogPlugins_set($args) {
+
+ // obtain the list of Admin Plugins to work with
+ $activePlugins = $args['wpmu_global_blog_plugins'];
+
+ // Process the array - turn it into something that is similar to the active_plugins array
+ // and work out if the plugin has an installation phase
+ $adminPlugins = array();
+ $pluginsThatNeedInstalling = array();
+ foreach ($activePlugins as $filename => $value) {
+ $adminPlugins[] = $filename;
+ // Check if the plugin has an install stage - by looking for AutoInstall in the plugin header
+ if (wpmu_checkPluginForInstallStages($filename)) {
+ $pluginsThatNeedInstalling[$filename]=true;
+ } else {
+ //
+ }
+ }
+
+ // Store the setting first in the main blog settings for wpmu
+ wpmu_adminOptionSet('wpmu_global_blog_plugins',serialize($adminPlugins));
+
+ // Now rotate through the client blogs and apply the setting
+ $allBlogs = wpmu_getBlogs();
+ foreach ($allBlogs as $thisBlog) {
+ // Exclude the 'main' blog
+ if ($allBlogs!='main') {
+ $currentClientPlugings = wpmu_blogOption_get($thisBlog,'active_plugins',array());
+
+ if (!(unserialize($currentClientPlugings)===false)) {
+ $currentClientPlugings = unserialize($currentClientPlugings);
+ }
+
+ // Deal with the case when we don't get back a serialized array
+ if (!is_array($currentClientPlugings)) {
+ $currentClientPlugings = array();
+ }
+
+ // Work through the currently setup plugins for this blog
+ foreach ($adminPlugins as $thisAdminPlugin) {
+ // If the client blog doesn't already has the plugin
+ if (!in_array($thisAdminPlugin, $currentClientPlugings)) {
+ $currentClientPlugings[] = $thisAdminPlugin;
+ if (isset($pluginsThatNeedInstalling[$thisAdminPlugin])) {
+ $clientPluginsThatNeedInstalling[] = $thisAdminPlugin;
+ } else {
+ //
+ }
+ } else {
+ //
+ }
+ }
+
+ // Store the new plugins for this blog
+ wpmu_blogOption_set($thisBlog,'active_plugins',serialize($currentClientPlugings));
+ if (count($clientPluginsThatNeedInstalling)>0) {
+ wpmu_blogOption_set($thisBlog,'wpmu_plugins_pending',serialize($clientPluginsThatNeedInstalling));
+ }
+ }
+ }
+}
+add_action('wpmu_options_admin_set','wpmu_allBlogPlugins_set');
+
+/**
+ * Determines if a plugin contains auto-install instructions
+ *
+ * @param string $plugin_file
+ * @return string|false Returns the install instructions or false
+ */
+function wpmu_checkPluginForInstallStages($plugin_file) {
+
+ if (file_exists(ABSPATH.'wp-content/plugins/'.$plugin_file)) {
+ $plugin_file = ABSPATH.'wp-content/plugins/'.$plugin_file;
+ } else {
+ die("{$plugin_file}");
+ }
+
+ $plugin_data = implode('', file($plugin_file));
+ preg_match("|AutoInstall:(.*)|i", $plugin_data, $pluginAutoInstall);
+
+ if (is_array($pluginAutoInstall)) {
+ $pluginAutoInstall = $pluginAutoInstall[0];
+ } else {
+ $pluginAutoInstall = "";
+ }
+
+ if (isset($pluginAutoInstall) && !is_null($pluginAutoInstall)) {
+ $pluginAutoInstall = str_replace('AutoInstall:','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('<code>','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('</code>','',$pluginAutoInstall);
+ return $pluginAutoInstall;
+ }
+ return false;
+}
+
+/**
+ * Evaluates an expression
+ *
+ * @param unknown $string
+ * @return unknown
+ */
+function wpmu_eval($string) {
+
+ $result = eval($string);
+
+ if ($result===false || is_null($result)) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Auto installs plugins
+ *
+ */
+function wpmu_autoInstallPlugins($pendingPlugins) {
+ global $wpblog;
+
+ foreach ($pendingPlugins as $key => $filename) {
+ $installOptions = wpmu_checkPluginForInstallStages($filename);
+ if ($installOptions) {
+ // Include the file
+ require_once(ABSPATH.'wp-content/plugins/'.$filename);
+ $result = wpmu_eval($installOptions);
+ } else {
+ $result = true;
+ }
+ if ($result==true) {
+ // Everything worked ok
+ unset($pendingPlugins[$key]);
+ } else {
+ // There was a problem - should be logged
+ }
+ }
+ wpmu_blogOption_set($wpblog,'wpmu_plugins_pending',serialize($pendingPlugins));
+}
+
+/*
+ Determine if there are any plugins that need installing or configuring
+ This will enable not just the auto install/configure of plugins - but updates (to plugins or plugin data) as well
+*/
+$pendingPlugins = wpmu_blogOption_get($wpblog,'wpmu_plugins_pending', null);
+
+if (is_null($pendingPlugins)) {
+ // If null is returned - then this is a brand new blog
+ $adminPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',null);
+ if (!is_null($adminPlugins)) {
+ // We've something to do
+ wpmu_autoInstallPlugins($adminPlugins);
+ }
+} else {
+ if (count($pendingPlugins)>0) {
+ wpmu_autoInstallPlugins($pendingPlugins);
+ }
+}
+
+function createBlog( $hostname, $domain, $path, $blogname, $weblog_title, $admin_email, $username='' ) {
+ global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
+
+ $blogname = addslashes( $blogname );
+ $weblog_title = addslashes( $weblog_title );
+ $admin_email = addslashes( $admin_email );
+ $username = addslashes( $username );
+
+ // Check if the username has been used already. We should return an error message.
+ if( $username == '' ) {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$blogname."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: blogname used by user";
+ }
+ } else {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$username."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: username used";
+ }
+ }
+
+ // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
+ // Need to get blog_id from wp_blogs, and create new table names.
+ // Must restore table names at the end of function.
+
+ $wpdb->hide_errors();
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$path."'";
+ $site_id = $wpdb->get_var( $query );
+
+ if( $site_id == false ) {
+ $query = "INSERT INTO `wp_site` ( `id` , `domain` , `path` )
+ VALUES ( NULL, '".$domain."', '".$path."')";
+ $wpdb->query( $query );
+ $site_id = $wpdb->insert_id;
+ }
+
+ $query = "SELECT blog_id
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$site_id."'
+ AND blogname = '".$blogname."'";
+ $blog_id = $wpdb->get_var( $query );
+ if( $blog_id != false ) {
+ return "error: blogname used";
+ }
+ $query = "INSERT INTO ".$wpdb->blogs." ( blog_id, site_id, blogname, registered )
+ VALUES ( NULL, '".$site_id."', '".$blogname."', NOW( ))";
+ if( $wpdb->query( $query ) == false ) {
+ return "error: problem creating blog entry";
+ }
+ $blog_id = $wpdb->insert_id;
+
+ // backup
+ $tmp[ 'siteid' ] = $wpdb->siteid;
+ $tmp[ 'blogid' ] = $wpdb->blogid;
+ $tmp[ 'posts' ] = $wpdb->posts;
+ $tmp[ 'categories' ] = $wpdb->categories;
+ $tmp[ 'post2cat' ] = $wpdb->post2cat;
+ $tmp[ 'comments' ] = $wpdb->comments;
+ $tmp[ 'links' ] = $wpdb->links;
+ $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmp[ 'option' ] = $wpdb->option;
+ $tmp[ 'postmeta' ] = $wpdb->postmeta;
+ $tmptable_prefix = $table_prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->siteid = $site_id;
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
+
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
+ $wpdb->hide_errors();
+ $installed = $wpdb->get_results("SELECT * FROM $wpdb->posts");
+ if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+ flush();
+
+ if( $path == '/' ) {
+ $slash = '';
+ } else {
+ $slash = $path;
+ }
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$blogname.".".$domain.$path.$slash;
+ }
+ } else {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$hostname.$path.$blogname.$slash;
+ }
+ }
+
+ // Set everything up
+ make_db_current_silent();
+ populate_options();
+
+ // fix url.
+ update_option('siteurl', $url);
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$weblog_title."' WHERE option_name = 'blogname'");
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$admin_email."' WHERE option_name = 'admin_email'");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+ // Set up admin user
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ if( $username != '' ) {
+ $adminname = $username;
+ } else {
+ $adminname = $blogname;
+ }
+ $wpdb->query("INSERT INTO $wpdb->users (user_login, user_pass, user_email, user_registered) VALUES ( '$adminname', MD5('$random_password'), '$admin_email', NOW() )");
+ $userID = $wpdb->insert_id;
+ $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
+ reset( $metavalues );
+ while( list( $key, $val ) = each ( $metavalues ) )
+ {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
+ $wpdb->query( $query );
+ }
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$username."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
+ @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
+
+ upgrade_all();
+ // remove all perms except for the login user.
+ $query = "DELETE FROM ".$wpdb->usermeta."
+ WHERE user_id != '".$userID."'
+ AND meta_key = '".$table_prefix."user_level'";
+ $wpdb->query( $query );
+
+ // insert admin user into user table.
+ $adminusers = get_admin_users_for_domain();
+ if( is_array( $adminusers ) ) {
+ reset( $adminusers );
+ while( list( $key, $val ) = each( $adminusers ) ) {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$val[ 'ID' ]."', '".$table_prefix."user_level' , '10')";
+ $wpdb->query( $query );
+ }
+ } else {
+ die( "Problem getting admin users!" );
+ }
+
+ // restore wpdb variables
+ reset( $tmp );
+ while( list( $key, $val ) = each( $tmp ) )
+ {
+ $wpdb->$key = $val;
+ }
+ $table_prefix = $tmptable_prefix;
+
+ $wpdb->show_errors();
+
+ return "ok";
+}
+
+// New create blog
+
+function create_blog( $domain, $path, $username, $weblog_title, $admin_email, $site_id = 1 ) {
+ global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
+
+ $domain = addslashes( $domain );
+ $weblog_title = addslashes( $weblog_title );
+ $admin_email = addslashes( $admin_email );
+ $username = addslashes( $username );
+
+ if( empty($path) )
+ $path = '/';
+
+ // Check if the username has been used already. We should return an error message.
+ if( $wpdb->get_var("SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path'" ) )
+ return 'Blog URL already taken.';
+
+ // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
+ // Need to get blog_id from wp_blogs, and create new table names.
+ // Must restore table names at the end of function.
+
+ $wpdb->hide_errors();
+
+ $query = "INSERT INTO $wpdb->blogs ( site_id, domain, path, registered ) VALUES ( '$site_id', '$domain', '$path', NOW() )";
+ if( $wpdb->query( $query ) == false ) {
+ return "error: problem creating blog entry";
+ }
+ $blog_id = $wpdb->insert_id;
+
+ // backup
+ $tmp[ 'siteid' ] = $wpdb->siteid;
+ $tmp[ 'blogid' ] = $wpdb->blogid;
+ $tmp[ 'posts' ] = $wpdb->posts;
+ $tmp[ 'categories' ] = $wpdb->categories;
+ $tmp[ 'post2cat' ] = $wpdb->post2cat;
+ $tmp[ 'comments' ] = $wpdb->comments;
+ $tmp[ 'links' ] = $wpdb->links;
+ $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmp[ 'option' ] = $wpdb->option;
+ $tmp[ 'postmeta' ] = $wpdb->postmeta;
+ $tmptable_prefix = $table_prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->siteid = $site_id;
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
+
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
+ $wpdb->hide_errors();
+
+ flush();
+
+ $url = 'http://' . $domain . $path;
+
+ // Set everything up
+ make_db_current_silent();
+ populate_options();
+
+ // fix url.
+ update_option('siteurl', $url);
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+ // Set up admin user
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+
+ $wpdb->query("INSERT INTO $wpdb->users (user_login, user_pass, user_email, user_registered) VALUES ( '$username', MD5('$random_password'), '$admin_email', NOW() )");
+ $userID = $wpdb->insert_id;
+ $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
+ reset( $metavalues );
+ while( list( $key, $val ) = each ( $metavalues ) )
+ {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
+ $wpdb->query( $query );
+ }
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$adminname."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
+ @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
+
+ upgrade_all();
+ // remove all perms except for the login user.
+ $query = "DELETE FROM $wpdb->usermeta WHERE user_id != '$userID' AND meta_key = '".$table_prefix."user_level'";
+ $wpdb->query( $query );
+
+ // restore wpdb variables
+ reset( $tmp );
+ while( list( $key, $val ) = each( $tmp ) )
+ {
+ $wpdb->$key = $val;
+ }
+ $table_prefix = $tmptable_prefix;
+
+ $wpdb->show_errors();
+
+ return "ok";
+}
+
+function get_blogaddress_by_id( $blog_id ) {
+ global $hostname, $domain, $base, $wpdb;
+
+ // not current blog
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE blog_id = '".$blog_id."'";
+ $bloginfo = $wpdb->get_results( $query, ARRAY_A );
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ return "http://".$bloginfo[ 'blogname' ].".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$bloginfo[ 'blogname' ];
+ }
+}
+
+function get_blogaddress_by_name( $blogname ) {
+ global $domain, $base, $wpdb;
+
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' )
+ $blogname = 'www';
+ return "http://".$blogname.".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$blogname;
+ }
+}
+
+function get_sitestats() {
+ global $wpdb, $basedomain, $base;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$wpdb->siteid."'";
+ $blogs = $wpdb->get_var( $query );
+ $stats[ 'blogs' ] = $blogs;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->users;
+ $users = $wpdb->get_var( $query );
+ $stats[ 'users' ] = $users;
+
+ return $stats;
+
+}
+function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
+ global $domain, $base, $basedomain, $wpdb, $wpmuBaseTablePrefix;
+ if( $sitedomain == '' ) {
+ $sitedomain = $basedomain;
+ $site_id = $wpdb->siteid;
+ } else {
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$base."'";
+ $site_id = $wpdb->get_var( $query );
+ }
+ if( $site_id != false ) {
+ $query = "SELECT ID, user_login, user_pass
+ FROM ".$wpdb->users.", ".$wpdb->sitemeta."
+ WHERE meta_key = 'admin_user_id'
+ AND ".$wpdb->users.".ID = ".$wpdb->sitemeta.".meta_value
+ AND site_id = '".$site_id."'";
+ $details = $wpdb->get_results( $query, ARRAY_A );
+ } else {
+ $details = false;
+ }
+
+ return $details;
+}
+
+function get_site_settings( $option ) {
+ global $wpdb;
+
+ $query = "SELECT meta_value
+ FROM $wpdb->sitemeta
+ WHERE meta_key = '$option'
+ AND site_id = '".$wpdb->siteid."'";
+ $option = $wpdb->get_var( $query );
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ $option = $kellogs;
+
+ return $option;
+}
+
+function add_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ $query = "INSERT INTO wp_sitemeta ( meta_id , site_id , meta_key , meta_value )
+ VALUES ( NULL, '".$wpdb->siteid."', '".$key."', '".$wpdb->escape( $value )."')";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function update_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+
+ $value = trim($value); // I can't think of any situation we wouldn't want to trim
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ add_site_settings( $key, $value );
+ } else {
+ $query = "UPDATE ".$wpdb->sitemeta."
+ SET meta_value = '".$wpdb->escape( $value )."'
+ WHERE meta_key = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function switch_to_blogid( $blog_id ) {
+ global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings;
+
+ // FIXME
+
+ // backup
+ $tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
+ $tmpoldblogdetails[ 'posts' ] = $wpdb->posts;
+ $tmpoldblogdetails[ 'categories' ] = $wpdb->categories;
+ $tmpoldblogdetails[ 'post2cat' ] = $wpdb->post2cat;
+ $tmpoldblogdetails[ 'comments' ] = $wpdb->comments;
+ $tmpoldblogdetails[ 'links' ] = $wpdb->links;
+ $tmpoldblogdetails[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmpoldblogdetails[ 'option' ] = $wpdb->option;
+ $tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
+ $tmpoldblogdetails[ 'prefix' ] = $wpdb->prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ unset( $cache_settings );
+}
+
+function restore_current_blogid() {
+ global $tmpoldblogdetails, $wpdb;
+ // backup
+ $wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
+ $wpdb->posts = $tmpoldblogdetails[ 'posts' ];
+ $wpdb->categories = $tmpoldblogdetails[ 'categories' ];
+ $wpdb->post2cat = $tmpoldblogdetails[ 'post2cat' ];
+ $wpdb->comments = $tmpoldblogdetails[ 'comments' ];
+ $wpdb->links = $tmpoldblogdetails[ 'links' ];
+ $wpdb->linkcategories = $tmpoldblogdetails[ 'linkcategories' ];
+ $wpdb->option = $tmpoldblogdetails[ 'option' ];
+ $wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
+ $wpdb->prefix = $tmpoldblogdetails[ 'prefix' ];
+}
+?>
diff --git a/wp-inst/wp-settings.php b/wp-inst/wp-settings.php
index dc2a11a..1c96dfd 100644
--- a/wp-inst/wp-settings.php
+++ b/wp-inst/wp-settings.php
@@ -1,216 +1,216 @@
-<?php
-$HTTP_HOST = getenv('HTTP_HOST'); /* domain name */
-$REMOTE_ADDR = getenv('REMOTE_ADDR'); /* visitor's IP */
-$HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); /* visitor's browser */
-
-// Fix for IIS, which doesn't set REQUEST_URI
-if (! isset($_SERVER['REQUEST_URI'])) {
- $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
-
- // Append the query string if it exists and isn't null
- if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
- $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
- }
-}
-
-if ( !(phpversion() >= '4.1') )
- die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
-
-if ( !extension_loaded('mysql') )
- die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
-
-function timer_start() {
- global $timestart;
- $mtime = explode(' ', microtime() );
- $mtime = $mtime[1] + $mtime[0];
- $timestart = $mtime;
- return true;
-}
-timer_start();
-
-// Change to E_ALL for development/debugging
-error_reporting(E_ALL ^ E_NOTICE);
-
-// For an advanced caching plugin to use, static because you would only want one
-if ( defined('WP_CACHE') )
- require (ABSPATH . 'wp-content/advanced-cache.php');
-
-define('WPINC', 'wp-includes');
-require_once (ABSPATH . WPINC . '/wp-db.php');
-
-$wpdb->blogs = $table_prefix . 'blogs';
-$wpdb->users = $table_prefix . 'users';
-$wpdb->usermeta = $table_prefix . 'usermeta';
-$wpdb->site = $table_prefix . 'site';
-$wpdb->sitemeta = $table_prefix . 'sitemeta';
-
-// find out what tables to use from $wpblog
-$wpdb->hide_errors();
-
-$domain = $_SERVER['HTTP_HOST'];
-
-$current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '/'");
-
-$blog_id = $current_blog->blog_id;
-$is_public = $current_blog->is_public;
-if( $blog_id == false ) {
- // no blog found, are we installing? Check if the table exists.
- if ( defined('WP_INSTALLING') ) {
- $query = "SELECT blog_id FROM ".$wpdb->blogs." limit 0,1";
- $blog_id = $wpdb->get_var( $query );
- if( $blog_id == false ) {
- // table doesn't exist. This is the first blog
- $blog_id = 1;
- } else {
- // table exists
- // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like.
- // default to using the "main" blog.
- $blog_id = 1;
- }
- } else {
- die( "No Blog by that name on this system." );
- }
-}
-
-if( $is_public == 'no' ) {
- // need to put checks in here?
- // A hook?
- die( "This blog is private." );
-}
-
-$wpdb->show_errors();
-
-$table_prefix = $table_prefix.$blog_id."_";
-
-// Table names
-$wpdb->siteid = $site_id;
-$wpdb->blogid = $blog_id;
-$wpdb->posts = $table_prefix . 'posts';
-$wpdb->categories = $table_prefix . 'categories';
-$wpdb->post2cat = $table_prefix . 'post2cat';
-$wpdb->comments = $table_prefix . 'comments';
-$wpdb->links = $table_prefix . 'links';
-$wpdb->linkcategories = $table_prefix . 'linkcategories';
-$wpdb->options = $table_prefix . 'options';
-$wpdb->postmeta = $table_prefix . 'postmeta';
-$wpdb->prefix = $table_prefix;
-
-if ( defined('CUSTOM_USER_TABLE') )
- $wpdb->users = CUSTOM_USER_TABLE;
-if ( defined('CUSTOM_USER_META_TABLE') )
- $wpdb->usermeta = CUSTOM_USER_META_TABLE;
-
-// We're going to need to keep this around for a few months even though we're not using it internally
-
-$tableposts = $wpdb->posts;
-$tableusers = $wpdb->users;
-$tablecategories = $wpdb->categories;
-$tablepost2cat = $wpdb->post2cat;
-$tablecomments = $wpdb->comments;
-$tablelinks = $wpdb->links;
-$tablelinkcategories = $wpdb->linkcategories;
-$tableoptions = $wpdb->options;
-$tablepostmeta = $wpdb->postmeta;
-
-require (ABSPATH . WPINC . '/functions.php');
-require (ABSPATH . WPINC . '/default-filters.php');
-require_once (ABSPATH . WPINC . '/wp-l10n.php');
-
-$wpdb->hide_errors();
-if ( !update_category_cache() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
- if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
- $link = 'install.php';
- else
- $link = 'wp-admin/install.php';
- die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
-}
-$wpdb->show_errors();
-
-require (ABSPATH . WPINC . '/functions-formatting.php');
-require (ABSPATH . WPINC . '/functions-post.php');
-require (ABSPATH . WPINC . '/capabilities.php');
-require (ABSPATH . WPINC . '/classes.php');
-require (ABSPATH . WPINC . '/template-functions-general.php');
-require (ABSPATH . WPINC . '/template-functions-links.php');
-require (ABSPATH . WPINC . '/template-functions-author.php');
-require (ABSPATH . WPINC . '/template-functions-post.php');
-require (ABSPATH . WPINC . '/template-functions-category.php');
-require (ABSPATH . WPINC . '/comment-functions.php');
-require (ABSPATH . WPINC . '/feed-functions.php');
-require (ABSPATH . WPINC . '/links.php');
-require (ABSPATH . WPINC . '/kses.php');
-require (ABSPATH . WPINC . '/version.php');
-
-$is_archived = get_settings( "is_archived" );
-if( $is_archived == 'yes' ) {
- die( "This blog has been archived or suspended temporarily. Please check back later." );
-}
-
-if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
- // Used to guarantee unique hash cookies
- $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
- define('COOKIEHASH', $cookiehash);
-endif;
-
-require (ABSPATH . WPINC . '/vars.php');
-
-do_action('core_files_loaded');
-
-// Check for hacks file if the option is enabled
-if (get_settings('hack_file')) {
- if (file_exists(ABSPATH . '/my-hacks.php'))
- require(ABSPATH . '/my-hacks.php');
-}
-
-if ( get_settings('active_plugins') ) {
- $current_plugins = get_settings('active_plugins');
- if ( is_array($current_plugins) ) {
- foreach ($current_plugins as $plugin) {
- if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
- include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
- }
- }
-}
-
-require (ABSPATH . WPINC . '/pluggable-functions.php');
-
-if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
- wp_cache_postload();
-
-do_action('plugins_loaded');
-
-define('TEMPLATEPATH', get_template_directory());
-
-// Load the default text localization domain.
-load_default_textdomain();
-
-// Pull in locale data after loading text domain.
-require_once(ABSPATH . WPINC . '/locale.php');
-
-// If already slashed, strip.
-if ( get_magic_quotes_gpc() ) {
- $_GET = stripslashes_deep($_GET );
- $_POST = stripslashes_deep($_POST );
- $_COOKIE = stripslashes_deep($_COOKIE);
- $_SERVER = stripslashes_deep($_SERVER);
-}
-
-// Escape with wpdb.
-$_GET = add_magic_quotes($_GET );
-$_POST = add_magic_quotes($_POST );
-$_COOKIE = add_magic_quotes($_COOKIE);
-$_SERVER = add_magic_quotes($_SERVER);
-
-function shutdown_action_hook() {
- do_action('shutdown');
-}
-register_shutdown_function('shutdown_action_hook');
-
-$wp_query = new WP_Query();
-$wp_rewrite = new WP_Rewrite();
-$wp = new WP();
-$wp_roles = new WP_Roles();
-
-// Everything is loaded and initialized.
-do_action('init');
-?>
+<?php
+$HTTP_HOST = getenv('HTTP_HOST'); /* domain name */
+$REMOTE_ADDR = getenv('REMOTE_ADDR'); /* visitor's IP */
+$HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); /* visitor's browser */
+
+// Fix for IIS, which doesn't set REQUEST_URI
+if (! isset($_SERVER['REQUEST_URI'])) {
+ $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
+
+ // Append the query string if it exists and isn't null
+ if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
+ $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
+ }
+}
+
+if ( !(phpversion() >= '4.1') )
+ die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
+
+if ( !extension_loaded('mysql') )
+ die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
+
+function timer_start() {
+ global $timestart;
+ $mtime = explode(' ', microtime() );
+ $mtime = $mtime[1] + $mtime[0];
+ $timestart = $mtime;
+ return true;
+}
+timer_start();
+
+// Change to E_ALL for development/debugging
+error_reporting(E_ALL ^ E_NOTICE);
+
+// For an advanced caching plugin to use, static because you would only want one
+if ( defined('WP_CACHE') )
+ require (ABSPATH . 'wp-content/advanced-cache.php');
+
+define('WPINC', 'wp-includes');
+require_once (ABSPATH . WPINC . '/wp-db.php');
+
+$wpdb->blogs = $table_prefix . 'blogs';
+$wpdb->users = $table_prefix . 'users';
+$wpdb->usermeta = $table_prefix . 'usermeta';
+$wpdb->site = $table_prefix . 'site';
+$wpdb->sitemeta = $table_prefix . 'sitemeta';
+
+// find out what tables to use from $wpblog
+$wpdb->hide_errors();
+
+$domain = $_SERVER['HTTP_HOST'];
+
+$current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '/'");
+
+$blog_id = $current_blog->blog_id;
+$is_public = $current_blog->is_public;
+if( $blog_id == false ) {
+ // no blog found, are we installing? Check if the table exists.
+ if ( defined('WP_INSTALLING') ) {
+ $query = "SELECT blog_id FROM ".$wpdb->blogs." limit 0,1";
+ $blog_id = $wpdb->get_var( $query );
+ if( $blog_id == false ) {
+ // table doesn't exist. This is the first blog
+ $blog_id = 1;
+ } else {
+ // table exists
+ // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like.
+ // default to using the "main" blog.
+ $blog_id = 1;
+ }
+ } else {
+ die( "No Blog by that name on this system." );
+ }
+}
+
+if( $is_public == 'no' ) {
+ // need to put checks in here?
+ // A hook?
+ die( "This blog is private." );
+}
+
+$wpdb->show_errors();
+
+$table_prefix = $table_prefix.$blog_id."_";
+
+// Table names
+$wpdb->siteid = $site_id;
+$wpdb->blogid = $blog_id;
+$wpdb->posts = $table_prefix . 'posts';
+$wpdb->categories = $table_prefix . 'categories';
+$wpdb->post2cat = $table_prefix . 'post2cat';
+$wpdb->comments = $table_prefix . 'comments';
+$wpdb->links = $table_prefix . 'links';
+$wpdb->linkcategories = $table_prefix . 'linkcategories';
+$wpdb->options = $table_prefix . 'options';
+$wpdb->postmeta = $table_prefix . 'postmeta';
+$wpdb->prefix = $table_prefix;
+
+if ( defined('CUSTOM_USER_TABLE') )
+ $wpdb->users = CUSTOM_USER_TABLE;
+if ( defined('CUSTOM_USER_META_TABLE') )
+ $wpdb->usermeta = CUSTOM_USER_META_TABLE;
+
+// We're going to need to keep this around for a few months even though we're not using it internally
+
+$tableposts = $wpdb->posts;
+$tableusers = $wpdb->users;
+$tablecategories = $wpdb->categories;
+$tablepost2cat = $wpdb->post2cat;
+$tablecomments = $wpdb->comments;
+$tablelinks = $wpdb->links;
+$tablelinkcategories = $wpdb->linkcategories;
+$tableoptions = $wpdb->options;
+$tablepostmeta = $wpdb->postmeta;
+
+require (ABSPATH . WPINC . '/functions.php');
+require (ABSPATH . WPINC . '/default-filters.php');
+require_once (ABSPATH . WPINC . '/wp-l10n.php');
+
+$wpdb->hide_errors();
+if ( !update_category_cache() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
+ if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
+ $link = 'install.php';
+ else
+ $link = 'wp-admin/install.php';
+ die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
+}
+$wpdb->show_errors();
+
+require (ABSPATH . WPINC . '/functions-formatting.php');
+require (ABSPATH . WPINC . '/functions-post.php');
+require (ABSPATH . WPINC . '/capabilities.php');
+require (ABSPATH . WPINC . '/classes.php');
+require (ABSPATH . WPINC . '/template-functions-general.php');
+require (ABSPATH . WPINC . '/template-functions-links.php');
+require (ABSPATH . WPINC . '/template-functions-author.php');
+require (ABSPATH . WPINC . '/template-functions-post.php');
+require (ABSPATH . WPINC . '/template-functions-category.php');
+require (ABSPATH . WPINC . '/comment-functions.php');
+require (ABSPATH . WPINC . '/feed-functions.php');
+require (ABSPATH . WPINC . '/links.php');
+require (ABSPATH . WPINC . '/kses.php');
+require (ABSPATH . WPINC . '/version.php');
+
+$is_archived = get_settings( "is_archived" );
+if( $is_archived == 'yes' ) {
+ die( "This blog has been archived or suspended temporarily. Please check back later." );
+}
+
+if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
+ // Used to guarantee unique hash cookies
+ $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
+ define('COOKIEHASH', $cookiehash);
+endif;
+
+require (ABSPATH . WPINC . '/vars.php');
+
+do_action('core_files_loaded');
+
+// Check for hacks file if the option is enabled
+if (get_settings('hack_file')) {
+ if (file_exists(ABSPATH . '/my-hacks.php'))
+ require(ABSPATH . '/my-hacks.php');
+}
+
+if ( get_settings('active_plugins') ) {
+ $current_plugins = get_settings('active_plugins');
+ if ( is_array($current_plugins) ) {
+ foreach ($current_plugins as $plugin) {
+ if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
+ include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
+ }
+ }
+}
+
+require (ABSPATH . WPINC . '/pluggable-functions.php');
+
+if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
+ wp_cache_postload();
+
+do_action('plugins_loaded');
+
+define('TEMPLATEPATH', get_template_directory());
+
+// Load the default text localization domain.
+load_default_textdomain();
+
+// Pull in locale data after loading text domain.
+require_once(ABSPATH . WPINC . '/locale.php');
+
+// If already slashed, strip.
+if ( get_magic_quotes_gpc() ) {
+ $_GET = stripslashes_deep($_GET );
+ $_POST = stripslashes_deep($_POST );
+ $_COOKIE = stripslashes_deep($_COOKIE);
+ $_SERVER = stripslashes_deep($_SERVER);
+}
+
+// Escape with wpdb.
+$_GET = add_magic_quotes($_GET );
+$_POST = add_magic_quotes($_POST );
+$_COOKIE = add_magic_quotes($_COOKIE);
+$_SERVER = add_magic_quotes($_SERVER);
+
+function shutdown_action_hook() {
+ do_action('shutdown');
+}
+register_shutdown_function('shutdown_action_hook');
+
+$wp_query = new WP_Query();
+$wp_rewrite = new WP_Rewrite();
+$wp = new WP();
+$wp_roles = new WP_Roles();
+
+// Everything is loaded and initialized.
+do_action('init');
+?>