summaryrefslogtreecommitdiffstats
path: root/wp-inst/mm-newblog.php
blob: f79a53e306e88790bfb578969122dbe370b217ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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 get_footer(); ?>