install.php
changeset 249 f4323fa79313
parent 248 ed13b72b13cc
child 251 275c70f80137
equal deleted inserted replaced
248:ed13b72b13cc 249:f4323fa79313
   770   case 'pophelp':
   770   case 'pophelp':
   771     $topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
   771     $topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
   772     switch($topic)
   772     switch($topic)
   773     {
   773     {
   774       case 'admin_embed_php':
   774       case 'admin_embed_php':
   775         $title = 'Allow administrators to embed PHP';
   775         $title = $lang->get('pophelp_admin_embed_php_title');
   776         $content = '<p>This option allows you to control whether anything between the standard &lt;?php and ?&gt; tags will be treated as
   776         $content = $lang->get('pophelp_admin_embed_php_body');
   777                         PHP code by Enano. If this option is enabled, and members of the Administrators group use these tags, Enano will
       
   778                         execute that code when the page is loaded. There are obvious potential security implications here, which should
       
   779                         be carefully considered before enabling this option.</p>
       
   780                     <p>If you are the only administrator of this site, or if you have a high level of trust for those will be administering
       
   781                        the site with you, you should enable this to allow extreme customization of pages.</p>
       
   782                     <p>Leave this option off if you are at all concerned about security – if your account is compromised and PHP embedding
       
   783                        is enabled, an attacker can run arbitrary code on your server! Enabling this will also allow administrators to
       
   784                        embed Javascript and arbitrary HTML and CSS.</p>
       
   785                     <p>If you don\'t have experience coding in PHP, you can safely disable this option. You may change this at any time
       
   786                        using the ACL editor by selecting the Administrators group and This Entire Website under the scope selection. <!-- , or by
       
   787                        using the "embedded PHP kill switch" in the administration panel. --></p>';
       
   788         break;
   777         break;
   789       default:
   778       default:
   790         $title = 'Invalid topic';
   779         $title = 'Invalid topic';
   791         $content = 'Invalid help topic.';
   780         $content = 'Invalid help topic.';
   792         break;
   781         break;
   793     }
   782     }
       
   783     $close_window = $lang->get('pophelp_btn_close_window');
   794     echo <<<EOF
   784     echo <<<EOF
   795 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   785 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   796 <html>
   786 <html>
   797   <head>
   787   <head>
   798     <title>Enano installation quick help &bull; {$title}</title>
   788     <title>Enano installation quick help &bull; {$title}</title>
   813   </head>
   803   </head>
   814   <body>
   804   <body>
   815     <h2>{$title}</h2>
   805     <h2>{$title}</h2>
   816     {$content}
   806     {$content}
   817     <p style="text-align: right;">
   807     <p style="text-align: right;">
   818       <a href="#" onclick="window.close(); return false;">Close window</a>
   808       <a href="#" onclick="window.close(); return false;">{$close_window}</a>
   819     </p>
   809     </p>
   820   </body>
   810   </body>
   821 </html>
   811 </html>
   822 EOF;
   812 EOF;
   823     exit;
   813     exit;
  1437         $k = array_keys($_POST);
  1427         $k = array_keys($_POST);
  1438         for($i=0;$i<sizeof($_POST);$i++) {
  1428         for($i=0;$i<sizeof($_POST);$i++) {
  1439           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1429           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1440         }
  1430         }
  1441       ?>
  1431       ?>
  1442       <p>The next step is to enter some information about your website. You can always change this information later, using the administration panel.</p>
  1432       <p><?php echo $lang->get('website_header_blurb'); ?></p>
  1443       <table border="0">
  1433       <table border="0">
  1444         <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>
  1434         <tr>
  1445         <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>
  1435           <td>
  1446         <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>
  1436             <b><?php echo $lang->get('website_field_name_title'); ?></b><br />
  1447         <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>
  1437             <?php echo $lang->get('website_field_name_body'); ?>
  1448         <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>
  1438           </td>
       
  1439           <td>
       
  1440             <input onkeyup="verify();" name="sitename" type="text" size="30" />
       
  1441           </td>
       
  1442           <td>
       
  1443             <img id="s_name" alt="Good/bad icon" src="images/bad.gif" />
       
  1444           </td>
       
  1445         </tr>
       
  1446         <tr>
       
  1447           <td>
       
  1448             <b><?php echo $lang->get('website_field_desc_title'); ?></b><br />
       
  1449             <?php echo $lang->get('website_field_desc_body'); ?>
       
  1450           </td>
       
  1451           <td>
       
  1452             <input onkeyup="verify();" name="sitedesc" type="text" size="30" />
       
  1453           </td>
       
  1454           <td>
       
  1455             <img id="s_desc" alt="Good/bad icon" src="images/bad.gif" />
       
  1456           </td>
       
  1457         </tr>
       
  1458         <tr>
       
  1459           <td>
       
  1460             <b><?php echo $lang->get('website_field_copyright_title'); ?></b><br />
       
  1461             <?php echo $lang->get('website_field_copyright_body'); ?>
       
  1462           </td>
       
  1463           <td>
       
  1464             <input onkeyup="verify();" name="copyright" type="text" size="30" />
       
  1465           </td>
       
  1466           <td>
       
  1467             <img id="s_copyright" alt="Good/bad icon" src="images/bad.gif" />
       
  1468           </td>
       
  1469         </tr>
       
  1470         <tr>
       
  1471           <td>
       
  1472             <b><?php echo $lang->get('website_field_wikimode_title'); ?></b><br />
       
  1473             <?php echo $lang->get('website_field_wikimode_body'); ?>
       
  1474           </td>
       
  1475           <td>
       
  1476             <input name="wiki_mode" type="checkbox" id="wmcheck" />  <label for="wmcheck"><?php echo $lang->get('website_field_wikimode_checkbox'); ?></label>
       
  1477           </td>
       
  1478           <td>
       
  1479             &nbsp;
       
  1480           </td>
       
  1481         </tr>
       
  1482         <tr>
       
  1483           <td>
       
  1484             <b><?php echo $lang->get('website_field_urlscheme_title'); ?></b><br />
       
  1485             <?php echo $lang->get('website_field_urlscheme_body'); ?>
       
  1486           </td>
       
  1487           <td colspan="2">
       
  1488             <input type="radio" <?php if(!is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="ugly" id="ugly"  />  <label for="ugly"><?php echo $lang->get('website_field_urlscheme_ugly'); ?></label><br />
       
  1489             <input type="radio" <?php if(is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="short" id="short" />  <label for="short"><?php echo $lang->get('website_field_urlscheme_short'); ?></label><br />
       
  1490             <input type="radio" name="urlscheme" value="tiny" id="petite">  <label for="petite"><?php echo $lang->get('website_field_urlscheme_tiny'); ?></label>
       
  1491           </td>
       
  1492         </tr>
  1449       </table>
  1493       </table>
  1450       <div class="pagenav">
  1494       <div class="pagenav">
  1451        <table border="0">
  1495        <table border="0">
  1452        <tr>
  1496          <tr>
  1453        <td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />&bull; Verify that your site information is correct. Again, all of the above settings can be changed from the administration panel.</p></td>
  1497            <td>
  1454        </tr>
  1498              <input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" onclick="return verify();" name="_cont" />
       
  1499            </td>
       
  1500            <td>
       
  1501              <p>
       
  1502                <span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
       
  1503                &bull; <?php echo $lang->get('website_objective_verify'); ?>
       
  1504              </p>
       
  1505            </td>
       
  1506          </tr>
  1455        </table>
  1507        </table>
  1456      </div>
  1508      </div>
  1457     </form>
  1509     </form>
  1458     <?php
  1510     <?php
  1459     break;
  1511     break;
  1474     {
  1526     {
  1475       $cryptkey = $aes->gen_readymade_key();
  1527       $cryptkey = $aes->gen_readymade_key();
  1476       $handle = @fopen(ENANO_ROOT.'/config.new.php', 'w');
  1528       $handle = @fopen(ENANO_ROOT.'/config.new.php', 'w');
  1477       if(!$handle)
  1529       if(!$handle)
  1478       {
  1530       {
  1479         echo '<p>ERROR: Cannot open config.php for writing - exiting!</p>';
  1531         echo '<p>ERROR: Despite my repeated attempts to verify that the configuration file can be written, I was indeed prevented from opening it for writing. Maybe you\'re still on <del>crack</del> Windows?</p>';
  1480         $template->footer();
  1532         $template->footer();
  1481         exit;
  1533         exit;
  1482       }
  1534       }
  1483       fwrite($handle, '<?php $cryptkey = \''.$cryptkey.'\'; ?>');
  1535       fwrite($handle, '<?php $cryptkey = \''.$cryptkey.'\'; ?>');
  1484       fclose($handle);
  1536       fclose($handle);
  1535         $k = array_keys($_POST);
  1587         $k = array_keys($_POST);
  1536         for($i=0;$i<sizeof($_POST);$i++) {
  1588         for($i=0;$i<sizeof($_POST);$i++) {
  1537           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1589           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1538         }
  1590         }
  1539       ?>
  1591       ?>
  1540       <p>Next, enter your desired username and password. The account you create here will be used to administer your site.</p>
  1592       <p><?php echo $lang->get('login_header_blurb'); ?></p>
  1541       <table border="0">
  1593       <table border="0">
  1542         <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>
  1594         <tr>
  1543         <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>
  1595           <td><b><?php echo $lang->get('login_field_username_title'); ?></b><br /><small><?php echo $lang->get('login_field_username_body'); ?></small></td>
  1544         <tr><td>Enter it again to confirm:</td><td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td></tr>
  1596           <td><input onkeyup="verify();" name="admin_user" type="text" size="30" /></td>
  1545         <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>
  1597           <td><img id="s_user" alt="Good/bad icon" src="images/bad.gif" /></td>
  1546         <tr>
  1598         </tr>
  1547           <td>
  1599         <tr>
  1548             Allow administrators to embed PHP code into pages:<br />
  1600           <td><?php echo $lang->get('login_field_password_title'); ?></td>
  1549             <small><span style="color: #D84308">Do not under any circumstances enable this option without reading these
  1601           <td><input onkeyup="verify();" name="admin_pass" type="password" size="30" /></td>
  1550                    <a href="install.php?mode=pophelp&amp;topic=admin_embed_php"
  1602           <td rowspan="2"><img id="s_password" alt="Good/bad icon" src="images/bad.gif" /></td>
  1551                       onclick="window.open(this.href, 'pophelpwin', 'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes'); return false;"
  1603         </tr>
  1552                       style="color: #D84308; text-decoration: underline;">important security implications</a>.
  1604         <tr>
  1553             </span></small>
  1605           <td><?php echo $lang->get('login_field_password_confirm'); ?></td>
  1554           </td>
  1606           <td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td>
  1555           <td>
  1607         </tr>
  1556             <label><input type="radio" name="admin_embed_php" value="2" checked="checked" /> Disabled</label>&nbsp;&nbsp;
  1608         <tr>
  1557             <label><input type="radio" name="admin_embed_php" value="4" /> Enabled</label>
  1609           <td><?php echo $lang->get('login_field_email_title'); ?></td>
       
  1610           <td><input onkeyup="verify();" name="admin_email" type="text" size="30" /></td>
       
  1611           <td><img id="s_email" alt="Good/bad icon" src="images/bad.gif" /></td>
       
  1612         </tr>
       
  1613         <tr>
       
  1614           <td>
       
  1615             <?php echo $lang->get('login_field_allowphp_title'); ?><br />
       
  1616             <small>
       
  1617               <span style="color: #D84308">
       
  1618                 <?php
       
  1619                   echo $lang->get('login_field_allowphp_body',
       
  1620                     array(
       
  1621                       'important_notes' => '<a href="install.php?mode=pophelp&amp;topic=admin_embed_php" onclick="window.open(this.href, \'pophelpwin\', \'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes\'); return false;" style="color: #D84308; text-decoration: underline;">' . $lang->get('login_field_allowphp_isi') . '</a>'
       
  1622                       )
       
  1623                     );
       
  1624                 ?>
       
  1625               </span>
       
  1626             </small>
       
  1627           </td>
       
  1628           <td>
       
  1629             <label><input type="radio" name="admin_embed_php" value="2" checked="checked" /> <?php echo $lang->get('login_field_allowphp_disabled'); ?></label>&nbsp;&nbsp;
       
  1630             <label><input type="radio" name="admin_embed_php" value="4" /> <?php echo $lang->get('login_field_allowphp_enabled'); ?></label>
  1558           </td>
  1631           </td>
  1559           <td></td>
  1632           <td></td>
  1560         </tr>
  1633         </tr>
  1561         <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>
  1634         <tr><td colspan="3"><?php echo $lang->get('login_aes_blurb'); ?></td></tr>
  1562       </table>
  1635       </table>
  1563       <div class="pagenav">
  1636       <div class="pagenav">
  1564        <table border="0">
  1637        <table border="0">
  1565        <tr>
  1638          <tr>
  1566        <td><input type="submit" value="Continue" onclick="return cryptdata();" name="_cont" /></td><td><p><span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />&bull; 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>
  1639            <td>
  1567        </tr>
  1640              <input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" onclick="return cryptdata();" name="_cont" />
       
  1641            </td>
       
  1642            <td>
       
  1643              <p>
       
  1644                <span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
       
  1645                &bull; <?php echo $lang->get('login_objective_remember'); ?>
       
  1646              </p>
       
  1647            </td>
       
  1648          </tr>
  1568        </table>
  1649        </table>
  1569       </div>
  1650       </div>
  1570       <div id="cryptdebug"></div>
  1651       <div id="cryptdebug"></div>
  1571      <input type="hidden" name="use_crypt" value="no" />
  1652       <input type="hidden" name="use_crypt" value="no" />
  1572      <input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" />
  1653       <input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" />
  1573      <input type="hidden" name="crypt_data" value="" />
  1654       <input type="hidden" name="crypt_data" value="" />
  1574     </form>
  1655     </form>
  1575     <script type="text/javascript">
  1656     <script type="text/javascript">
  1576     // <![CDATA[
  1657     // <![CDATA[
  1577       var frm = document.forms.login;
  1658       var frm = document.forms.login;
  1578       frm.admin_user.focus();
  1659       frm.admin_user.focus();
  1658         $k = array_keys($_POST);
  1739         $k = array_keys($_POST);
  1659         for($i=0;$i<sizeof($_POST);$i++) {
  1740         for($i=0;$i<sizeof($_POST);$i++) {
  1660           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1741           echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
  1661         }
  1742         }
  1662       ?>
  1743       ?>
  1663       <h3>Enano is ready to install.</h3>
  1744       <h3><?php echo $lang->get('confirm_header_blurb_title'); ?></h3>
  1664        <p>The wizard has finished collecting information and is ready to install the database schema. Please review the information below,
  1745        <p><?php echo $lang->get('confirm_header_blurb_body'); ?></p>
  1665           and then click the button below to install the database.</p>
       
  1666       <ul>
  1746       <ul>
  1667         <li>Database hostname: <?php echo $_POST['db_host']; ?></li>
  1747         <li><?php echo $lang->get('confirm_lbl_db_host'); ?> <?php echo $_POST['db_host']; ?></li>
  1668         <li>Database name: <?php echo $_POST['db_name']; ?></li>
  1748         <li><?php echo $lang->get('confirm_lbl_db_name'); ?> <?php echo $_POST['db_name']; ?></li>
  1669         <li>Database user: <?php echo $_POST['db_user']; ?></li>
  1749         <li><?php echo $lang->get('confirm_lbl_db_user'); ?> <?php echo $_POST['db_user']; ?></li>
  1670         <li>Database password: &lt;hidden&gt;</li>
  1750         <li><?php echo $lang->get('confirm_lbl_db_pass'); ?></li>
  1671         <li>Site name: <?php echo $_POST['sitename']; ?></li>
  1751         <li><?php echo $lang->get('confirm_lbl_sitename'); ?> <?php echo $_POST['sitename']; ?></li>
  1672         <li>Site description: <?php echo $_POST['sitedesc']; ?></li>
  1752         <li><?php echo $lang->get('confirm_lbl_sitedesc'); ?> <?php echo $_POST['sitedesc']; ?></li>
  1673         <li>Administration username: <?php echo $_POST['admin_user']; ?></li>
  1753         <li><?php echo $lang->get('confirm_lbl_adminuser'); ?> <?php echo $_POST['admin_user']; ?></li>
  1674         <li>Cipher strength: <?php echo (string)AES_BITS; ?>-bit AES<br /><small>Cipher strength is defined in the file constants.php; if you desire to change the cipher strength, you may do so and then restart installation. Unless your site is mission-critical, changing the cipher strength is not necessary.</small></li>
  1754         <li><?php echo $lang->get('confirm_lbl_aesbits'); ?> <?php echo $lang->get('confirm_lbl_aes_strength', array( 'aes_bits' => AES_BITS )); ?><br /><small><?php echo $lang->get('confirm_lbl_aes_change'); ?></small></li>
  1675       </ul>
  1755       </ul>
  1676       <div class="pagenav">
  1756       <div class="pagenav">
  1677         <table border="0">
  1757         <table border="0">
  1678           <tr>
  1758           <tr>
  1679             <td><input type="submit" value="Install Enano!" name="_cont" /></td><td><p><span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />&bull; Pray.</p></td>
  1759             <td>
       
  1760               <input type="submit" value="<?php echo $lang->get('confirm_btn_install_enano'); ?>" name="_cont" />
       
  1761             </td>
       
  1762             <td>
       
  1763               <p>
       
  1764                 <span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
       
  1765                 <!-- Like this even needs to be localized. :-P -->
       
  1766                 &bull; <?php echo $lang->get('confirm_objective_pray'); ?>
       
  1767               </p>
       
  1768             </td>
  1680           </tr>
  1769           </tr>
  1681         </table>
  1770         </table>
  1682       </div>
  1771       </div>
  1683     </form>
  1772     </form>
  1684     <?php
  1773     <?php