177 { |
177 { |
178 static $conn = false; |
178 static $conn = false; |
179 if ( $act_get ) |
179 if ( $act_get ) |
180 return $conn; |
180 return $conn; |
181 |
181 |
182 $db_user = mysql_real_escape_string($_POST['db_user']); |
182 $db_user =& $_POST['db_user']; |
183 $db_pass = mysql_real_escape_string($_POST['db_pass']); |
183 $db_pass =& $_POST['db_pass']; |
184 $db_name = mysql_real_escape_string($_POST['db_name']); |
184 $db_name =& $_POST['db_name']; |
185 |
185 |
186 if ( !preg_match('/^[a-z0-9_]+$/', $db_name) ) |
186 if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) ) |
187 die("<p>SECURITY: malformed database name</p>"); |
187 { |
|
188 $db_name = htmlspecialchars($db_name); |
|
189 die("<p>SECURITY: malformed database name \"$db_name\"</p>"); |
|
190 } |
188 |
191 |
189 // First, try to connect using the normal credentials |
192 // First, try to connect using the normal credentials |
190 $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); |
193 $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); |
191 if ( !$conn ) |
194 if ( !$conn ) |
192 { |
195 { |
240 { |
253 { |
241 // Couldn't connect as root; bail out |
254 // Couldn't connect as root; bail out |
242 return false; |
255 return false; |
243 } |
256 } |
244 // create the database, if it doesn't exist |
257 // create the database, if it doesn't exist |
245 $q = @mysql_query("CREATE DATABASE IF NOT EXISTS $db_name;", $conn_root); |
258 $q = @mysql_query("CREATE DATABASE IF NOT EXISTS `$db_name`;", $conn_root); |
246 if ( !$q ) |
259 if ( !$q ) |
247 { |
260 { |
248 // this really should never fail, so don't give any tolerance to it |
261 // this really should never fail, so don't give any tolerance to it |
249 return false; |
262 return false; |
250 } |
263 } |
|
264 unset($db_user, $db_pass); |
|
265 $db_user = mysql_real_escape_string($_POST['db_user']); |
|
266 $db_pass = mysql_real_escape_string($_POST['db_pass']); |
251 // we're in with root rights; grant access to the database |
267 // we're in with root rights; grant access to the database |
252 $q = @mysql_query("GRANT ALL PRIVILEGES ON $db_name.* TO '{$db_user}'@'localhost';", $conn_root); |
268 $q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'localhost';", $conn_root); |
253 if ( !$q ) |
269 if ( !$q ) |
254 { |
270 { |
255 return false; |
271 return false; |
256 } |
272 } |
257 if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' ) |
273 if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' ) |
258 { |
274 { |
259 $q = @mysql_query("GRANT ALL PRIVILEGES ON $db_name.* TO '{$db_user}'@'%';", $conn_root); |
275 $q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'%';", $conn_root); |
260 if ( !$q ) |
276 if ( !$q ) |
261 { |
277 { |
262 return false; |
278 return false; |
263 } |
279 } |
264 } |
280 } |
|
281 mysql_close($conn_root); |
|
282 // grant tables have hopefully been flushed, kill and reconnect our regular user connection |
|
283 mysql_close($conn); |
|
284 $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); |
|
285 if ( !$conn ) |
|
286 { |
|
287 return false; |
|
288 } |
265 } |
289 } |
266 else |
290 else |
267 { |
291 { |
268 return false; |
292 return false; |
269 } |
293 } |
270 // try again |
294 // try again |
271 $q = @mysql_query("USE $db_name;", $conn); |
295 $q = @mysql_query("USE `$db_name`;", $conn); |
272 if ( !$q ) |
296 if ( !$q ) |
273 { |
297 { |
274 // really failed this time; bail out |
298 // really failed this time; bail out |
275 return false; |
299 return false; |
276 } |
300 } |
1348 echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n"; |
1372 echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n"; |
1349 } |
1373 } |
1350 ?> |
1374 ?> |
1351 <p>The next step is to enter some information about your website. You can always change this information later, using the administration panel.</p> |
1375 <p>The next step is to enter some information about your website. You can always change this information later, using the administration panel.</p> |
1352 <table border="0"> |
1376 <table border="0"> |
1353 <tr><td><b>Website name</b><br />The display name of your website. Allowed characters are uppercase and lowercase letters, numerals, and spaces. This must not be blank or "Enano".</td><td><input onkeyup="verify();" name="sitename" type="text" size="30" /></td><td><img id="s_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1377 <tr> |
1354 <tr><td><b>Website description</b><br />This text will be shown below the name of your website.</td><td><input onkeyup="verify();" name="sitedesc" type="text" size="30" /></td><td><img id="s_desc" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1378 <td> |
1355 <tr><td><b>Copyright info</b><br />This should be a one-line legal notice that will appear at the bottom of all your pages.</td><td><input onkeyup="verify();" name="copyright" type="text" size="30" /></td><td><img id="s_copyright" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1379 <b>Website name</b><br /> |
1356 <tr><td><b>Wiki mode</b><br />This feature allows people to create and edit pages on your site. Enano keeps a history of all page modifications, and you can protect pages to prevent editing.</td><td><input name="wiki_mode" type="checkbox" id="wmcheck" /> <label for="wmcheck">Yes, make my website a wiki.</label></td><td></td></tr> |
1380 The display name of your website. Allowed characters are uppercase and lowercase letters, numerals, and spaces. This must not |
1357 <tr><td><b>URL scheme</b><br />Choose how the page URLs will look. Depending on your server configuration, you may need to select the first option. If you don't know, select the first option, and you can always change it later.</td><td colspan="2"><input type="radio" <?php if(!is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="ugly" id="ugly"> <label for="ugly">Standard URLs - compatible with any web server (www.example.com/index.php?title=Page_name)</label><br /><input type="radio" <?php if(is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="short" id="short"> <label for="short">Short URLs - requires Apache with a PHP module (www.example.com/index.php/Page_name)</label><br /><input type="radio" name="urlscheme" value="tiny" id="petite"> <label for="petite">Tiny URLs - requires Apache on Linux/Unix/BSD with PHP module and mod_rewrite enabled (www.example.com/Page_name)</label></td></tr> |
1381 be blank or "Enano". |
|
1382 </td> |
|
1383 <td> |
|
1384 <input onkeyup="verify();" name="sitename" type="text" size="30" /> |
|
1385 </td> |
|
1386 <td> |
|
1387 <img id="s_name" alt="Good/bad icon" src="images/bad.gif" /> |
|
1388 </td> |
|
1389 </tr> |
|
1390 <tr> |
|
1391 <td> |
|
1392 <b>Website description</b><br /> |
|
1393 This text will be shown below the name of your website. |
|
1394 </td> |
|
1395 <td> |
|
1396 <input onkeyup="verify();" name="sitedesc" type="text" size="30" /> |
|
1397 </td> |
|
1398 <td> |
|
1399 <img id="s_desc" alt="Good/bad icon" src="images/bad.gif" /> |
|
1400 </td> |
|
1401 </tr> |
|
1402 <tr> |
|
1403 <td> |
|
1404 <b>Copyright info</b><br /> |
|
1405 This should be a one-line legal notice that will appear at the bottom of all your pages. |
|
1406 </td> |
|
1407 <td> |
|
1408 <input onkeyup="verify();" name="copyright" type="text" size="30" /> |
|
1409 </td> |
|
1410 <td> |
|
1411 <img id="s_copyright" alt="Good/bad icon" src="images/bad.gif" /> |
|
1412 </td> |
|
1413 </tr> |
|
1414 <tr> |
|
1415 <td> |
|
1416 <b>Wiki mode</b><br /> |
|
1417 This feature allows people to create and edit pages on your site. Enano keeps a history of all page modifications, and you can |
|
1418 protect pages to prevent editing. |
|
1419 </td> |
|
1420 <td> |
|
1421 <input name="wiki_mode" type="checkbox" id="wmcheck" /> <label for="wmcheck">Yes, make my website a wiki.</label> |
|
1422 </td> |
|
1423 <td> |
|
1424 |
|
1425 </td> |
|
1426 </tr> |
|
1427 <tr> |
|
1428 <td> |
|
1429 <b>URL scheme</b><br /> |
|
1430 Choose how the page URLs will look. Depending on your server configuration, you may need to select the first option. If you |
|
1431 don't know, select the first option, and you can always change it later. |
|
1432 </td> |
|
1433 <td colspan="2"> |
|
1434 <input type="radio" <?php if(!is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="ugly" id="ugly" /> <label for="ugly">Standard URLs - compatible with any web server (www.example.com/index.php?title=Page_name)</label><br /> |
|
1435 <input type="radio" <?php if(is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="short" id="short" /> <label for="short">Short URLs - requires Apache with a PHP module (www.example.com/index.php/Page_name)</label><br /> |
|
1436 <input type="radio" name="urlscheme" value="tiny" id="petite"> <label for="petite">Tiny URLs - requires Apache on Linux/Unix/BSD with PHP module and mod_rewrite enabled (www.example.com/Page_name)</label> |
|
1437 </td> |
|
1438 </tr> |
1358 </table> |
1439 </table> |
1359 <div class="pagenav"> |
1440 <div class="pagenav"> |
1360 <table border="0"> |
1441 <table border="0"> |
1361 <tr> |
1442 <tr> |
1362 <td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Verify that your site information is correct. Again, all of the above settings can be changed from the administration panel.</p></td> |
1443 <td> |
1363 </tr> |
1444 <input type="submit" value="Continue" onclick="return verify();" name="_cont" /> |
|
1445 </td> |
|
1446 <td> |
|
1447 <p> |
|
1448 <span style="font-weight: bold;">Before clicking continue:</span><br /> |
|
1449 • Verify that your site information is correct. Again, all of the above settings can be changed from the administration |
|
1450 panel. |
|
1451 </p> |
|
1452 </td> |
|
1453 </tr> |
1364 </table> |
1454 </table> |
1365 </div> |
1455 </div> |
1366 </form> |
1456 </form> |
1367 <?php |
1457 <?php |
1368 break; |
1458 break; |
1446 echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n"; |
1536 echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n"; |
1447 } |
1537 } |
1448 ?> |
1538 ?> |
1449 <p>Next, enter your desired username and password. The account you create here will be used to administer your site.</p> |
1539 <p>Next, enter your desired username and password. The account you create here will be used to administer your site.</p> |
1450 <table border="0"> |
1540 <table border="0"> |
1451 <tr><td><b>Administration username</b><br /><small>The administration username you will use to log into your site.<br />This cannot be "anonymous" or in the form of an IP address.</small></td><td><input onkeyup="verify();" name="admin_user" type="text" size="30" /></td><td><img id="s_user" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1541 <tr> |
1452 <tr><td>Administration password:</td><td><input onkeyup="verify();" name="admin_pass" type="password" size="30" /></td><td rowspan="2"><img id="s_password" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1542 <td><b>Administration username</b><br /><small>The administration username you will use to log into your site.<br />This cannot be "anonymous" or in the form of an IP address.</small></td><td><input onkeyup="verify();" name="admin_user" type="text" size="30" /></td><td><img id="s_user" alt="Good/bad icon" src="images/bad.gif" /></td> |
1453 <tr><td>Enter it again to confirm:</td><td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td></tr> |
1543 </tr> |
1454 <tr><td>Your e-mail address:</td><td><input onkeyup="verify();" name="admin_email" type="text" size="30" /></td><td><img id="s_email" alt="Good/bad icon" src="images/bad.gif" /></td></tr> |
1544 <tr> |
|
1545 <td>Administration password:</td> |
|
1546 <td><input onkeyup="verify();" name="admin_pass" type="password" size="30" /></td> |
|
1547 <td rowspan="2"><img id="s_password" alt="Good/bad icon" src="images/bad.gif" /></td> |
|
1548 </tr> |
|
1549 <tr> |
|
1550 <td>Enter it again to confirm:</td> |
|
1551 <td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td> |
|
1552 </tr> |
|
1553 <tr> |
|
1554 <td>Your e-mail address:</td> |
|
1555 <td><input onkeyup="verify();" name="admin_email" type="text" size="30" /></td> |
|
1556 <td><img id="s_email" alt="Good/bad icon" src="images/bad.gif" /></td> |
|
1557 </tr> |
1455 <tr> |
1558 <tr> |
1456 <td> |
1559 <td> |
1457 Allow administrators to embed PHP code into pages:<br /> |
1560 Allow administrators to embed PHP code into pages:<br /> |
1458 <small><span style="color: #D84308">Do not under any circumstances enable this option without reading these |
1561 <small><span style="color: #D84308">Do not under any circumstances enable this option without reading these |
1459 <a href="install.php?mode=pophelp&topic=admin_embed_php" |
1562 <a href="install.php?mode=pophelp&topic=admin_embed_php" |
1469 </tr> |
1572 </tr> |
1470 <tr><td colspan="3">If your browser supports Javascript, the password you enter here will be encrypted with AES before it is sent to the server.</td></tr> |
1573 <tr><td colspan="3">If your browser supports Javascript, the password you enter here will be encrypted with AES before it is sent to the server.</td></tr> |
1471 </table> |
1574 </table> |
1472 <div class="pagenav"> |
1575 <div class="pagenav"> |
1473 <table border="0"> |
1576 <table border="0"> |
1474 <tr> |
1577 <tr> |
1475 <td><input type="submit" value="Continue" onclick="return cryptdata();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Remember the username and password you enter here! You will not be able to administer your site without the information you enter on this page.</p></td> |
1578 <td> |
1476 </tr> |
1579 <input type="submit" value="Continue" onclick="return cryptdata();" name="_cont" /> |
|
1580 </td> |
|
1581 <td> |
|
1582 <p> |
|
1583 <span style="font-weight: bold;">Before clicking continue:</span><br /> |
|
1584 • Remember the username and password you enter here! You will not be able to administer your site without the |
|
1585 information you enter on this page. |
|
1586 </p> |
|
1587 </td> |
|
1588 </tr> |
1477 </table> |
1589 </table> |
1478 </div> |
1590 </div> |
1479 <div id="cryptdebug"></div> |
1591 <div id="cryptdebug"></div> |
1480 <input type="hidden" name="use_crypt" value="no" /> |
1592 <input type="hidden" name="use_crypt" value="no" /> |
1481 <input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" /> |
1593 <input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" /> |
1482 <input type="hidden" name="crypt_data" value="" /> |
1594 <input type="hidden" name="crypt_data" value="" /> |
1483 </form> |
1595 </form> |
1484 <script type="text/javascript"> |
1596 <script type="text/javascript"> |
1485 // <![CDATA[ |
1597 // <![CDATA[ |
1486 var frm = document.forms.login; |
1598 var frm = document.forms.login; |
1487 frm.admin_user.focus(); |
1599 frm.admin_user.focus(); |