Source of trunk/install.php at revision HEAD (05/07/2008 10:05:26, 27034 bytes, 868 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** Installer Script |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2005-2008 Codewise.org |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | ** This file is part of CodewiseBlog |
| 13 | ** |
| 14 | ** CodewiseBlog is free software; you can redistribute it and/or modify |
| 15 | ** it under the terms of the GNU General Public License as published by |
| 16 | ** the Free Software Foundation; either version 2 of the License, or |
| 17 | ** (at your option) any later version. |
| 18 | ** |
| 19 | ** CodewiseBlog is distributed in the hope that it will be useful, |
| 20 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | ** GNU General Public License for more details. |
| 23 | ** |
| 24 | ** You should have received a copy of the GNU General Public License |
| 25 | ** along with CodewiseBlog; if not, write to the Free Software |
| 26 | ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | */ |
| 28 | |
| 29 | switch($_GET['stage']) { |
| 30 | |
| 31 | default: |
| 32 | |
| 33 | ?> |
| 34 | <html> |
| 35 | <head> |
| 36 | <title>CodewiseBlog Installer</title> |
| 37 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 38 | </head> |
| 39 | <body> |
| 40 | <h1 class="main-title">CodewiseBlog</h1> |
| 41 | <table> |
| 42 | <tr> |
| 43 | <td> |
| 44 | <p><b>Welcome to the CodewiseBlog installer</b></p> |
| 45 | <p>This installer is divided up into multiple stages, described below. You will want to have the neccessary information on hand before you start.</p> |
| 46 | <ol> |
| 47 | <li><b>Stage 1:</b> |
| 48 | <blockquote> |
| 49 | Filesystem and permissions |
| 50 | </blockquote> |
| 51 | </li> |
| 52 | <li> |
| 53 | <b>Stage 2:</b> |
| 54 | <blockquote> |
| 55 | Database settings |
| 56 | </blockquote> |
| 57 | </li> |
| 58 | <li> |
| 59 | <b>Stage 3:</b> |
| 60 | <blockquote> |
| 61 | CodewiseBlog main settings |
| 62 | </blockquote> |
| 63 | </li> |
| 64 | <li> |
| 65 | <b>Stage 4:</b> |
| 66 | <blockquote> |
| 67 | Set Up A User |
| 68 | </blockquote> |
| 69 | </li> |
| 70 | <li> |
| 71 | <b>Stage 5:</b> |
| 72 | <blockquote> |
| 73 | Extra Webserver Configuration |
| 74 | </blockquote> |
| 75 | </li> |
| 76 | <ol> |
| 77 | </td> |
| 78 | </tr> |
| 79 | <tr> |
| 80 | <td align="center"> |
| 81 | <a href="install.php?stage=1"><span style="font-size:x-large">Start Stage 1</span></a> |
| 82 | </td> |
| 83 | </tr> |
| 84 | </table> |
| 85 | </body> |
| 86 | </html> |
| 87 | <?php |
| 88 | |
| 89 | break; |
| 90 | |
| 91 | case 1: |
| 92 | |
| 93 | require("file_put_contents.php"); |
| 94 | |
| 95 | if(isset($_POST['submit'])) { |
| 96 | $file = "<?php\n\ndefine('FSPATH', '".$_POST['fspath']."');\n\n?>\n"; |
| 97 | |
| 98 | file_put_contents("settings.php", $file); |
| 99 | |
| 100 | header("Location: install.php?stage=2"); |
| 101 | } else { |
| 102 | |
| 103 | if(isset($_POST['fspath'])) { |
| 104 | $fspath = preg_replace("%/+$%", "/", $_POST['fspath']); |
| 105 | } else { |
| 106 | $fspath = dirname($_SERVER['SCRIPT_FILENAME']) . "/"; |
| 107 | } |
| 108 | |
| 109 | if(!is_dir($fspath)) { |
| 110 | $perms = "<b>path does not exist</b>"; |
| 111 | } else { |
| 112 | $writable = is_writable("$fspath/settings.php"); |
| 113 | $writable_install = is_writable("$fspath/install.php"); |
| 114 | // $writable_htaccess = is_writable("$fspath/.htaccess"); |
| 115 | } |
| 116 | |
| 117 | ?> |
| 118 | <html> |
| 119 | <head> |
| 120 | <title>CodewiseBlog Installer</title> |
| 121 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 122 | </head> |
| 123 | <body> |
| 124 | <h1 class="main-title">CodewiseBlog</h1> |
| 125 | <form action="install.php?stage=1" method="post"> |
| 126 | <table style="border:none"> |
| 127 | <tr> |
| 128 | <td> |
| 129 | <table> |
| 130 | <tr> |
| 131 | <td>Path to CodewiseBlog:</td> |
| 132 | <td><input type="text" size="50" name="fspath" value="<?=$fspath?>" /></td> |
| 133 | <td>Autodetected; you probably don't need to change this.</td> |
| 134 | </tr> |
| 135 | <tr> |
| 136 | <td>settings.php is writable?</td> |
| 137 | <td><?=($writable ? "yes" : "no")?></td> |
| 138 | <td>settings.php needs to be writable before we continue |
| 139 | </tr> |
| 140 | <tr> |
| 141 | <td>install.php is writable?</td> |
| 142 | <td><?=($writable_install ? "yes" : "no")?></td> |
| 143 | <td>install.php needs to be writable or the installer won't be able to disable itself when the install is done and you'll have to do so manually.</td> |
| 144 | </tr> |
| 145 | <?php /* |
| 146 | <tr> |
| 147 | <td>.htaccess is writable?</td> |
| 148 | <td><?=($writable_htaccess ? "yes" : "no")?></td> |
| 149 | <td>If you're using Apache, .htaccess needs to be writable or the installer won't be able to finish the installation and you'll have to edit the file manually.</td> |
| 150 | </tr> */ ?> |
| 151 | </table> |
| 152 | </td> |
| 153 | </tr> |
| 154 | <tr> |
| 155 | <td align="center"> |
| 156 | <input type="submit" value="Refresh" /> |
| 157 | <input type="submit" name="submit" value="Continue to Stage 2" <?=($writable ? "" : "disabled=\"disabled\" ")?>/> |
| 158 | </td> |
| 159 | </tr> |
| 160 | </table> |
| 161 | </body> |
| 162 | </html> |
| 163 | |
| 164 | <?php |
| 165 | |
| 166 | } |
| 167 | |
| 168 | break; |
| 169 | |
| 170 | case 2: |
| 171 | |
| 172 | require("settings.php"); |
| 173 | require("file_put_contents.php"); |
| 174 | |
| 175 | chdir(FSPATH); |
| 176 | |
| 177 | if(isset($_POST['submit'])) { |
| 178 | |
| 179 | require("l1_mysql.php"); |
| 180 | |
| 181 | $db = new L1_MySQL($_POST['sql_host'], $_POST['sql_user'], $_POST['sql_pass'], $_POST['sql_db']); |
| 182 | |
| 183 | $q = $db->issue_query("SHOW TABLES"); |
| 184 | $tables = $db->fetch_column($q); |
| 185 | |
| 186 | if(!isset($_GET['force']) && count($tables = array_intersect(array("blogs","replies","shoutbox","skins","subscriptions","topics"), $tables)) > 0) |
| 187 | { |
| 188 | foreach($_POST as $name => $value) |
| 189 | { |
| 190 | $hiddens .= "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n"; |
| 191 | } |
| 192 | |
| 193 | $table_list = "<code>" . implode("</code>, <code>", $tables) . "</code>"; |
| 194 | ?> |
| 195 | <html> |
| 196 | <head> |
| 197 | <title>CodewiseBlog Installer</title> |
| 198 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 199 | </head> |
| 200 | <body> |
| 201 | <h1 class="main-title">CodewiseBlog</h1> |
| 202 | <form action="install.php?stage=2&force" method="post"> |
| 203 | <?=$hiddens?> |
| 204 | <div style="font-size:xx-large; color:red">WARNING:</div> |
| 205 | <br /> |
| 206 | <b>There appears to be a CodewiseBlog installation already present in the specified database.<br /> |
| 207 | Continuing farther will irrevocably destroy this data!</b><br /> |
| 208 | <br /> |
| 209 | The following tables will be erased: <?=$table_list?><br /> |
| 210 | <br /> |
| 211 | <input type="submit" value="Continue and Destroy Data?" /> |
| 212 | </body> |
| 213 | </html> |
| 214 | <?php |
| 215 | exit; |
| 216 | } |
| 217 | |
| 218 | $sql = file_get_contents(FSPATH . "structure.sql"); |
| 219 | foreach(explode(";", $sql) as $statement) |
| 220 | { |
| 221 | if(($statement = trim($statement)) != "") |
| 222 | $db->issue_query($statement); |
| 223 | } |
| 224 | |
| 225 | $desc = file_get_contents(FSPATH . "/skin_blueEye/DESCRIPTION"); |
| 226 | |
| 227 | $db->insert("skins", array("skinid" => "00000000000000000000000000000000", "blogid" => 1, "name" => "CodewiseBlog Default Skin", "description" => $desc)); |
| 228 | |
| 229 | $dir = opendir(FSPATH . "skin_blueEye"); |
| 230 | while($file = readdir($dir)) { |
| 231 | if(substr($file, 0, 1) == "." || substr($file, -1, 1) == "~" || is_dir(FSPATH."skin_blueEye/$file")) |
| 232 | continue; |
| 233 | $cont = file_get_contents(FSPATH."skin_blueEye/$file"); |
| 234 | if(preg_match("/\\.css$/", $file)) { |
| 235 | $section = "css"; |
| 236 | } elseif($file == "DESCRIPTION") { |
| 237 | continue; |
| 238 | } else { |
| 239 | $section = preg_replace("/\\.html$/", "", $file); |
| 240 | } |
| 241 | $db->issue_query("ALTER TABLE skins ADD ".$db->prepare_value($section,FALSE)." TEXT"); |
| 242 | $db->update("skins", array($section => $cont), array("skinid" => "00000000000000000000000000000000")); |
| 243 | } |
| 244 | |
| 245 | $file = file_get_contents("settings.php"); |
| 246 | $file = substr($file, 0, -4); |
| 247 | $file .= |
| 248 | "define('SQL_HOST', '{$_POST['sql_host']}'); |
| 249 | define('SQL_USER', '{$_POST['sql_user']}'); |
| 250 | define('SQL_PASS', '{$_POST['sql_pass']}'); |
| 251 | define('SQL_DB', '{$_POST['sql_db']}'); |
| 252 | define('SQL_ADMIN_EMAIL', '{$_POST['sql_admin_email']}'); |
| 253 | |
| 254 | ?> |
| 255 | "; |
| 256 | file_put_contents("settings.php", $file); |
| 257 | |
| 258 | header("Location: install.php?stage=3"); |
| 259 | } else { |
| 260 | |
| 261 | ?> |
| 262 | <html> |
| 263 | <head> |
| 264 | <title>CodewiseBlog Installer</title> |
| 265 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 266 | </head> |
| 267 | <body> |
| 268 | <h1 class="main-title">CodewiseBlog</h1> |
| 269 | <form action="install.php?stage=2" method="post"> |
| 270 | <table style="border:none"> |
| 271 | <tr> |
| 272 | <td> |
| 273 | <table> |
| 274 | <tr> |
| 275 | <td>MySQL hostname:</td> |
| 276 | <td><input type="text" size="50" name="sql_host" value="localhost" /></td> |
| 277 | <td>chances are this should be kept as localhost</td> |
| 278 | </tr> |
| 279 | <tr> |
| 280 | <td>MySQL username:</td> |
| 281 | <td><input type="text" size="50" name="sql_user" value="username" /></td> |
| 282 | <td>ask your host for the following settings</td> |
| 283 | </tr> |
| 284 | <tr> |
| 285 | <td>MySQL password:</td> |
| 286 | <td><input type="text" size="50" name="sql_pass" value="password" /></td> |
| 287 | <td></td> |
| 288 | </tr> |
| 289 | <tr> |
| 290 | <td>MySQL database:</td> |
| 291 | <td><input type="text" size="50" name="sql_db" value="codewiseblog" /></td> |
| 292 | <td><b>WARNING:</b> any existing CodewiseBlog database here will be destroyed</td> |
| 293 | </tr> |
| 294 | <tr> |
| 295 | <td>Admin Email:</td> |
| 296 | <td><input type="text" size="50" name="sql_admin_email" value="" /></td> |
| 297 | <td>MySQL errors will be emailed to this address</td> |
| 298 | </tr> |
| 299 | </table> |
| 300 | </td> |
| 301 | </tr> |
| 302 | <tr> |
| 303 | <td align="center"> |
| 304 | <input type="submit" name="submit" value="Install Database Tables and Continue to Stage 3" /> |
| 305 | </td> |
| 306 | </tr> |
| 307 | </table> |
| 308 | </form> |
| 309 | </body> |
| 310 | </html> |
| 311 | |
| 312 | <?php |
| 313 | |
| 314 | } |
| 315 | |
| 316 | break; |
| 317 | |
| 318 | case 3: |
| 319 | |
| 320 | require("settings.php"); |
| 321 | require("file_put_contents.php"); |
| 322 | |
| 323 | chdir(FSPATH); |
| 324 | |
| 325 | if(isset($_POST['submit'])) { |
| 326 | $allowed_tags = "\$ALLOWED_TAGS = array\n(\n"; |
| 327 | $lines = explode("\n", $_POST['allowed_tags']); |
| 328 | foreach($lines as $line) |
| 329 | { |
| 330 | $tagname = substr($line, 1, strpos($line, ":") - 2); |
| 331 | |
| 332 | $attribs = substr($line, strpos($line, ":") + 2); |
| 333 | $attribs_array = explode(", ", $attribs); |
| 334 | |
| 335 | foreach($attribs_array as $i => $text) |
| 336 | $attribs_array[$i] = trim($text); |
| 337 | |
| 338 | if($tagname == "") |
| 339 | continue; |
| 340 | elseif(count($attribs_array) == 0 || empty($attribs_array[0])) |
| 341 | $allowed_tags .= " '$tagname' => array(),\n"; |
| 342 | else |
| 343 | $allowed_tags .= " '$tagname' => array('" . implode("', '", $attribs_array) . "'),\n"; |
| 344 | } |
| 345 | $allowed_tags .= ");"; |
| 346 | |
| 347 | foreach($_POST as $name=>$value) |
| 348 | $_POST[$name] = str_replace("'", "\\'", $value); |
| 349 | |
| 350 | $file = file_get_contents("settings.php"); |
| 351 | $file = substr($file, 0, -4); |
| 352 | $file .= |
| 353 | "define('SUBDOMAIN_MODE', {$_POST['subdomain_mode']}); |
| 354 | define('BASE_DOMAIN', '{$_POST['base_domain']}'); |
| 355 | define('DEFAULT_SUBDOMAIN', '{$_POST['default_subdomain']}'); |
| 356 | define('INSTALLED_PATH', '{$_POST['installed_path']}'); |
| 357 | define('CUSTOM_URL_ENABLED', {$_POST['custom_url_enabled']}); |
| 358 | define('TOPICS_PER_PAGE', '{$_POST['topics_per_page']}'); |
| 359 | define('POSTS_PER_PAGE', '{$_POST['posts_per_page']}'); |
| 360 | define('SHOUTS_PER_PAGE', '{$_POST['shouts_per_page']}'); |
| 361 | define('DATE_FORMAT', '{$_POST['date_format']}'); |
| 362 | define('ANONYMOUS_NAME', '{$_POST['anonymous_name']}'); |
| 363 | define('SITE_TITLE', '{$_POST['site_title']}'); |
| 364 | define('SITE_MOTTO', '{$_POST['site_motto']}'); |
| 365 | define('IMAGEVERIFY', {$_POST['imageverify']}); |
| 366 | |
| 367 | $allowed_tags |
| 368 | |
| 369 | ?> |
| 370 | "; |
| 371 | file_put_contents("settings.php", $file); |
| 372 | |
| 373 | header("Location: install.php?stage=4"); |
| 374 | } else { |
| 375 | |
| 376 | preg_match("/^(([^.]+)\\.)?([^.]+\\.[^.]+)$/", $_SERVER['HTTP_HOST'], $match); |
| 377 | |
| 378 | $default_subdomain = $match[2]; |
| 379 | $base_domain = $match[3]; |
| 380 | $full_hostname = $match[0]; |
| 381 | |
| 382 | $installed_path = dirname($_SERVER['SCRIPT_NAME']) . "/"; |
| 383 | ?> |
| 384 | <html> |
| 385 | <head> |
| 386 | <title>CodewiseBlog Installer</title> |
| 387 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 388 | </head> |
| 389 | <body onload="loadElements()"> |
| 390 | <h1 class="main-title">CodewiseBlog</h1> |
| 391 | <form action="install.php?stage=3" method="post"> |
| 392 | <script type="text/javascript" language="JavaScript"> |
| 393 | var subdomainMode; |
| 394 | var baseDomain; |
| 395 | var defaultSubdomain; |
| 396 | var installedPath; |
| 397 | var exampleMainUrl; |
| 398 | var exampleUserUrl; |
| 399 | var username = "jrandomuser"; |
| 400 | |
| 401 | function loadElements() |
| 402 | { |
| 403 | subdomainMode = document.getElementById("subdomainMode"); |
| 404 | baseDomain = document.getElementById("baseDomain"); |
| 405 | defaultSubdomain = document.getElementById("defaultSubdomain"); |
| 406 | installedPath = document.getElementById("installedPath"); |
| 407 | exampleMainUrl = document.getElementById("exampleMainUrl"); |
| 408 | exampleUserUrl = document.getElementById("exampleUserUrl"); |
| 409 | |
| 410 | dataChanged(); |
| 411 | } |
| 412 | |
| 413 | function dataChanged() |
| 414 | { |
| 415 | if(defaultSubdomain.value == "") { |
| 416 | exampleMainUrl.value = "http://" + baseDomain.value + installedPath.value; |
| 417 | } else { |
| 418 | exampleMainUrl.value = "http://" + defaultSubdomain.value + "." + baseDomain.value + installedPath.value; |
| 419 | } |
| 420 | |
| 421 | if(subdomainMode.value == "TRUE") { |
| 422 | exampleUserUrl.value = "http://" + username + "." + baseDomain.value + installedPath.value; |
| 423 | } else { |
| 424 | exampleUserUrl.value = "http://" + baseDomain.value + installedPath.value + username; |
| 425 | } |
| 426 | } |
| 427 | </script> |
| 428 | <table style="border:none"> |
| 429 | <tr> |
| 430 | <td> |
| 431 | <table> |
| 432 | <tr> |
| 433 | <td>Subdomain Mode:</td> |
| 434 | <td><select name="subdomain_mode" onchange="dataChanged()" id="subdomainMode"><option value="TRUE">Enabled</option><option value="FALSE">Disabled</option></select></td> |
| 435 | </tr> |
| 436 | <tr> |
| 437 | <td>CodewiseBlog Domain:</td> |
| 438 | <td><input type="text" size="50" name="base_domain" value="<?=$base_domain?>" onchange="dataChanged()" id="baseDomain" /></td> |
| 439 | </tr> |
| 440 | <tr> |
| 441 | <td>Default Subdomain:</td> |
| 442 | <td><input type="text" size="50" name="default_subdomain" value="<?=$default_subdomain?>" onchange="dataChanged()" id="defaultSubdomain" /></td> |
| 443 | </tr> |
| 444 | <tr> |
| 445 | <td>CodewiseBlog Path:</td> |
| 446 | <td><input type="text" size="50" name="installed_path" value="<?=$installed_path?>" onchange="dataChanged()" id="installedPath" /></td> |
| 447 | </tr> |
| 448 | <tr> |
| 449 | <td>Main CodewiseBlog URL:</td> |
| 450 | <td><input type="text" size="50" readonly="readonly" value="" id="exampleMainUrl" /></td> |
| 451 | <td>This is the URL the CodewiseBlog front page will be located at under the above configuration settings.</td> |
| 452 | </tr> |
| 453 | <tr> |
| 454 | <td>CodewiseBlog User URL:</td> |
| 455 | <td><input type="text" size="50" readonly="readonly" value="" id="exampleUserUrl" /></td> |
| 456 | <td>If you have a user named 'jrandomuser', their blog will be located at this URL under the above configuration settings.</td> |
| 457 | </tr> |
| 458 | <tr> |
| 459 | <td>Custom URLs Enabled:</td> |
| 460 | <td><select name="custom_url_enabled"><option value="TRUE">Enabled</option><option value="FALSE">Disabled</option></select></td> |
| 461 | <td>If enabled, users can set up redirects to their blog from other websites and have the canonical URL reflect that.</td> |
| 462 | </tr> |
| 463 | <tr> |
| 464 | <td><hr /></td> |
| 465 | <td><hr /></td> |
| 466 | <td><hr /></td> |
| 467 | </tr> |
| 468 | <tr> |
| 469 | <td>Site Title:</td> |
| 470 | <td><input type="text" size="25" name="site_title" value="CodewiseBlog" /></td> |
| 471 | <td>The name of your site.</td> |
| 472 | </tr> |
| 473 | <tr> |
| 474 | <td>Site Motto:</td> |
| 475 | <td><input type="text" size="25" name="site_motto" value="A Better Place to Write" /></td> |
| 476 | <td>Some tagline text to display along with the title.</td> |
| 477 | </tr> |
| 478 | <tr> |
| 479 | <td>Image Verification on Comments:</td> |
| 480 | <td><select name="imageverify"> |
| 481 | <option value="TRUE" selected="selected">Enabled</option> |
| 482 | <option value="FALSE">Disabled</option> |
| 483 | </select> |
| 484 | </td> |
| 485 | <td>It is reccomended this is set to Enabled to prevent spam, but disabl e it if your server does not have GD installed or it doesn't work properly.</td> |
| 486 | </tr> |
| 487 | <tr> |
| 488 | <td>Blog Posts Per Page:</td> |
| 489 | <td><input type="text" size="3" name="topics_per_page" value="5" /></td> |
| 490 | <td>How many posts will be diplayed on one page. It's best to keep this value small</td> |
| 491 | </tr> |
| 492 | <tr> |
| 493 | <td>Comments Per Page:</td> |
| 494 | <td><input type="text" size="3" name="posts_per_page" value="10" /></td> |
| 495 | <td>How many comments will be displayed on one page.</td> |
| 496 | </tr> |
| 497 | <tr> |
| 498 | <td>Shoutbox Entries Per Page:</td> |
| 499 | <td><input type="text" size="3" name="shouts_per_page" value="10" /></td> |
| 500 | <td>The shoutbox will only show this many shouts at a time.</td> |
| 501 | </tr> |
| 502 | <tr> |
| 503 | <td>Date Format:</td> |
| 504 | <td><input type="text" size="50" name="date_format" value="F jS, Y \a\t g:i A" /></td> |
| 505 | <td>See <a href="http://www.php.net/date#AEN25031">this table</a> for help.</td> |
| 506 | </tr> |
| 507 | <tr> |
| 508 | <td>Anonymous Name:</td> |
| 509 | <td><input type="text" size="50" name="anonymous_name" value="Anonymous" /></td> |
| 510 | <td>Anonymous comments will be made under this name.</td> |
| 511 | </tr> |
| 512 | <tr> |
| 513 | <td>HTML Tags Allowed In Comments:</td> |
| 514 | <td><textarea name="allowed_tags" rows="25" cols="50"><b>: |
| 515 | <i>: |
| 516 | <u>: |
| 517 | <p>: |
| 518 | <br>: |
| 519 | <a>: href, name |
| 520 | <ol>: |
| 521 | <ul>: |
| 522 | <li>: |
| 523 | <em>: |
| 524 | <strong>: |
| 525 | <strike>: |
| 526 | <font>: color, size |
| 527 | <tt>: |
| 528 | <blockquote>: |
| 529 | <sub>: |
| 530 | <sup>: |
| 531 | </textarea></td> |
| 532 | <td> |
| 533 | Each line is a HTML tag and a colon, followed by HTML attributes allowed.<br /> |
| 534 | <br /> |
| 535 | For example, the line |
| 536 | <blockquote><code><a>: href. name</code></blockquote> |
| 537 | allows the text |
| 538 | <blockquote><code><a href="http://foo.com/bar" name="blah">text</a></code></blockquote> |
| 539 | to appear in a comment, but the text |
| 540 | <blockquote><code><a style="font-size:xx-large" href="http://somesite.com/">OMG WTF BBQ</a></code></blockquote> |
| 541 | would have the <code>style="font-size:xx-large"</code> part removed because it's not in the list of allowed attributes.<br /> |
| 542 | <br /> |
| 543 | If no attributes are specified, none are allowed. |
| 544 | </td> |
| 545 | </table> |
| 546 | </td> |
| 547 | </tr> |
| 548 | <tr> |
| 549 | <td align="center"> |
| 550 | <input type="submit" name="submit" value="Continue to Stage 4" /> |
| 551 | </td> |
| 552 | </tr> |
| 553 | </table> |
| 554 | </form> |
| 555 | </body> |
| 556 | </html> |
| 557 | <?php |
| 558 | |
| 559 | } |
| 560 | |
| 561 | break; |
| 562 | |
| 563 | case 4: |
| 564 | |
| 565 | require("settings.php"); |
| 566 | |
| 567 | chdir(FSPATH); |
| 568 | |
| 569 | if(isset($_POST['submit'])) { |
| 570 | |
| 571 | $empty = array(); |
| 572 | |
| 573 | if($_POST['username'] == "") |
| 574 | $empty[] = "Username"; |
| 575 | if($_POST['title'] == "") |
| 576 | $empty[] = "Blog Name"; |
| 577 | if($_POST['realname'] == "") |
| 578 | $empty[] = "Your Name"; |
| 579 | if($_POST['email'] == "") |
| 580 | $empty[] = "Your Email Address"; |
| 581 | if($_POST['password'] == "") |
| 582 | $empty[] = "Password"; |
| 583 | |
| 584 | if(count($empty) > 0) |
| 585 | { |
| 586 | die("<html> |
| 587 | <head> |
| 588 | <title>CodewiseBlog Installer</title> |
| 589 | <link rel=\"stylesheet\" href=\"skin_blueEye/blueEye.css\" /> |
| 590 | </head> |
| 591 | <body> |
| 592 | The following required fields were left empty. |
| 593 | You must go back and fill them in before installation can continue. |
| 594 | </body> |
| 595 | </html>"); |
| 596 | } |
| 597 | |
| 598 | if(!preg_match("/^[a-z0-9-]+$/", $_POST['username'])) |
| 599 | { |
| 600 | die("<html> |
| 601 | <head> |
| 602 | <title>CodewiseBlog Installer</title> |
| 603 | <link rel=\"stylesheet\" href=\"skin_blueEye/blueEye.css\" /> |
| 604 | </head> |
| 605 | <body> |
| 606 | Your username may only contain lower-case letters, numbers, and dashes. |
| 607 | </body> |
| 608 | </html>"); |
| 609 | } |
| 610 | |
| 611 | if($_POST['username'] == "root") |
| 612 | { |
| 613 | die("<html> |
| 614 | <head> |
| 615 | <title>CodewiseBlog Installer</title> |
| 616 | <link rel=\"stylesheet\" href=\"skin_blueEye/blueEye.css\" /> |
| 617 | </head> |
| 618 | <body> |
| 619 | Sorry, the username 'root' is reserved for the CodewiseBlog system. |
| 620 | Go back and change your username to something else. |
| 621 | </body> |
| 622 | </html>"); |
| 623 | } |
| 624 | |
| 625 | require("l1_mysql.php"); |
| 626 | |
| 627 | $db = new L1_MySQL(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB); |
| 628 | |
| 629 | $root_blog = array( |
| 630 | "blogid" => 1, |
| 631 | "name" => "root", |
| 632 | "email" => $_POST['email'], |
| 633 | "realname" => NULL, |
| 634 | "birthday" => NULL, |
| 635 | "location" => NULL, |
| 636 | "interests" => NULL, |
| 637 | "links" => NULL, |
| 638 | "photo" => NULL, |
| 639 | "homepage" => NULL, |
| 640 | "title" => "CodewiseBlog", |
| 641 | "password" => md5($_POST['password']), |
| 642 | "joindate" => 0, |
| 643 | "custom_url" => NULL, |
| 644 | "skinid" => "00000000000000000000000000000000", |
| 645 | "status" => "closed", |
| 646 | ); |
| 647 | |
| 648 | $user_blog = array( |
| 649 | "blogid" => 2, |
| 650 | "name" => $_POST['username'], |
| 651 | "email" => $_POST['email'], |
| 652 | "realname" => $_POST['realname'], |
| 653 | "birthday" => ($_POST['birthday'] == "" ? NULL : $_POST['birthday']), |
| 654 | "location" => ($_POST['location'] == "" ? NULL : $_POST['location']), |
| 655 | "interests" => ($_POST['interests'] == "" ? NULL : $_POST['interests']), |
| 656 | "links" => ($_POST['links'] == "" ? NULL : $_POST['links']), |
| 657 | "photo" => ($_POST['photo'] == "" ? NULL : $_POST['photo']), |
| 658 | "homepage" => ($_POST['homepage'] == "" ? NULL : $_POST['homepage']), |
| 659 | "title" => $_POST['title'], |
| 660 | "password" => md5($_POST['password']), |
| 661 | "joindate" => time(), |
| 662 | "custom_url" => NULL, |
| 663 | "skinid" => "00000000000000000000000000000000", |
| 664 | "status" => "active", |
| 665 | ); |
| 666 | |
| 667 | $db->insert("blogs", $root_blog); |
| 668 | $db->insert("blogs", $user_blog); |
| 669 | |
| 670 | header("Location: install.php?stage=5"); |
| 671 | |
| 672 | } else { |
| 673 | |
| 674 | ?> |
| 675 | <html> |
| 676 | <head> |
| 677 | <title>CodewiseBlog Installer</title> |
| 678 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 679 | </head> |
| 680 | <body> |
| 681 | <h1 class="main-title">CodewiseBlog</h1> |
| 682 | <form action="install.php?stage=4" method="post"> |
| 683 | <table style="border:none"> |
| 684 | <tr> |
| 685 | <td> |
| 686 | <table> |
| 687 | <tr> |
| 688 | <td>Username:</td> |
| 689 | <td><input type="text" size="50" name="username" value="" /></td> |
| 690 | <td>Your username may only contain lower-case letters, numbers, and dashes.</td> |
| 691 | </tr> |
| 692 | <tr> |
| 693 | <td>Blog Name:</td> |
| 694 | <td><input type="text" size="50" name="title" value="" /></td> |
| 695 | <td>This will be shown at the top of your blog and will identify it in other various places.</td> |
| 696 | </tr> |
| 697 | <tr> |
| 698 | <td>Your Name:</td> |
| 699 | <td><input type="text" size="50" name="realname" value="" /></td> |
| 700 | <td>Your real name.</td> |
| 701 | </tr> |
| 702 | <tr> |
| 703 | <td>Your Email Address:</td> |
| 704 | <td><input type="text" size="50" name="email" value="" /></td> |
| 705 | <td>Notification of new comments and other things will be sent to this address.</td> |
| 706 | </tr> |
| 707 | <tr> |
| 708 | <td>Password:</td> |
| 709 | <td><input type="text" size="50" name="password" value="" /></td> |
| 710 | <td>This will be your password for the User Control Panel and Admin Control Panel</td> |
| 711 | </tr> |
| 712 | <tr> |
| 713 | <td><hr /></td> |
| 714 | <td><hr /></td> |
| 715 | <td><hr /></td> |
| 716 | </tr> |
| 717 | <tr> |
| 718 | <td>The following fields are optional.</td> |
| 719 | <td></td> |
| 720 | <td></td> |
| 721 | </tr> |
| 722 | <tr> |
| 723 | <td>Homepage:</td> |
| 724 | <td><input type="text" size="50" name="homepage" value="" /></td> |
| 725 | <td>A link to your homepage or some other website of yours.</td> |
| 726 | </tr> |
| 727 | <tr> |
| 728 | <td>Location:</td> |
| 729 | <td><input type="text" size="50" name="location" value="" /></td> |
| 730 | <td>Some short text describing where you reside.</td> |
| 731 | </tr> |
| 732 | <tr> |
| 733 | <td>Birthday:</td> |
| 734 | <td><input type="text" size="10" name="birthday" value="" /></td> |
| 735 | <td>mm/dd/yyyy</td> |
| 736 | </tr> |
| 737 | <tr> |
| 738 | <td>Photo:</td> |
| 739 | <td><input type="text" size="50" name="photo" value="" /></td> |
| 740 | <td>URL of a photo of you or some other avatar. The image should be fairly small, not more than 200x200 for best results.</td> |
| 741 | </tr> |
| 742 | <tr> |
| 743 | <td>Links:</td> |
| 744 | <td><textarea name="links" rows="7" cols="80"></textarea></td> |
| 745 | <td>Some links to other websites. All HTML permitted.</td> |
| 746 | </tr> |
| 747 | <tr> |
| 748 | <td>Bio / Interests:</td> |
| 749 | <td><textarea name="interests" rows="7" cols="80"></textarea></td> |
| 750 | <td>A short biography or description of your interests.</td> |
| 751 | </tr> |
| 752 | </table> |
| 753 | </td> |
| 754 | </tr> |
| 755 | <tr> |
| 756 | <td align="center"> |
| 757 | <input type="submit" name="submit" value="Create User and Continue to Stage 5" /> |
| 758 | </td> |
| 759 | </tr> |
| 760 | </table> |
| 761 | </form> |
| 762 | </body> |
| 763 | </html> |
| 764 | <?php |
| 765 | |
| 766 | } |
| 767 | |
| 768 | break; |
| 769 | |
| 770 | case 5: |
| 771 | |
| 772 | require("settings.php"); |
| 773 | require("file_put_contents.php"); |
| 774 | |
| 775 | chdir(FSPATH); |
| 776 | |
| 777 | if(isset($_POST['submit'])) { |
| 778 | |
| 779 | $file = "<?php die(\"<html><body>The installer has been disabled.</body></html>\"); ?>\n" . file_get_contents("install.php"); |
| 780 | file_put_contents("install.php", $file); |
| 781 | |
| 782 | /* |
| 783 | $htaccess = |
| 784 | "Options +Indexes +FollowSymLinks |
| 785 | RewriteEngine on |
| 786 | RewriteRule !(CHANGELOG|COPYING|favicon\.ico|rdf\.php(/.*)?|stylesheet\.php|skin_importer\.php|install\.php)$ cwbmulti.php |
| 787 | php_flag magic_quotes_gpc off"; |
| 788 | file_put_contents(".htaccess", $htaccess); |
| 789 | */ |
| 790 | |
| 791 | ?> |
| 792 | <html> |
| 793 | <head> |
| 794 | <title>CodewiseBlog Installer</title> |
| 795 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 796 | </head> |
| 797 | <body> |
| 798 | <h1 class="main-title">CodewiseBlog</h1> |
| 799 | <b>The installation is now complete.</b> |
| 800 | <br /><br /> |
| 801 | <a href="<?php echo INSTALLED_PATH; ?>">Welcome to your new CodewiseBlog</a> |
| 802 | </body> |
| 803 | </html> |
| 804 | <?php |
| 805 | |
| 806 | } else { |
| 807 | |
| 808 | ?> |
| 809 | <html> |
| 810 | <head> |
| 811 | <title>CodewiseBlog Installer</title> |
| 812 | <link rel="stylesheet" href="skin_blueEye/blueEye.css" /> |
| 813 | </head> |
| 814 | <body> |
| 815 | <h1 class="main-title">CodewiseBlog</h1> |
| 816 | <table> |
| 817 | <tr> |
| 818 | <td> |
| 819 | <p><b>The installation is now nearly complete.</b></p> |
| 820 | <p>All that is left is to configure your server properly so that it works with CodewiseBlog. |
| 821 | Unfortunately, this installer script cannot perform these steps - you or your host need to do them by hand. |
| 822 | </p> |
| 823 | <p>The steps neccessary to complete installation are as follows: |
| 824 | <ol> |
| 825 | <li><b>Disable installer</b> |
| 826 | <blockquote> |
| 827 | The installer will disable itself upon submitting this page. |
| 828 | It can be re-enabled by editing the install.php file and deleting the first line. |
| 829 | </blockquote> |
| 830 | </li> |
| 831 | <li><b>Webserver Configuration</b> |
| 832 | <blockquote> |
| 833 | Apache: mod_rewrite must be installed and enabled. |
| 834 | You must be allowed by your host to use .htaccess files. |
| 835 | (by setting the directive '<code>AllowOverride All</code>' in Apache's configuration files) |
| 836 | </blockquote> |
| 837 | </li> |
| 838 | <li><b>Domain Name Configuration</b> |
| 839 | <blockquote> |
| 840 | If you enabled Subdomain Mode in Stage 3, your domain must be set up with a wildcard CNAME to your server. |
| 841 | For example, if your domain name is 'example.com', and CodewiseBlog is installed at 'blogs.example.com', |
| 842 | the line '<code>*.blogs.example.com. IN CNAME www.example.com.</code>' must be in your zone file. |
| 843 | </blockquote> |
| 844 | </li> |
| 845 | </ol> |
| 846 | </p> |
| 847 | </td> |
| 848 | </tr> |
| 849 | <tr> |
| 850 | <td align="center"> |
| 851 | <form action="install.php?stage=5" method="post"> |
| 852 | <input type="submit" name="submit" value="Disable Installer and Finish Installation" /> |
| 853 | </form> |
| 854 | </td> |
| 855 | </tr> |
| 856 | </table> |
| 857 | </body> |
| 858 | </html> |
| 859 | <?php |
| 860 | |
| 861 | } |
| 862 | |
| 863 | break; |
| 864 | |
| 865 | } |
| 866 | |
| 867 | ?> |
| 868 |