install/includes/stages/website.php
changeset 348 87e08a6e4fec
child 391 85f91037cd4f
equal deleted inserted replaced
347:299a90e28abc 348:87e08a6e4fec
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
       
     5  * Version 1.1.1
       
     6  * Copyright (C) 2006-2007 Dan Fuhry
       
     7  * Installation package
       
     8  * website.php - Installer website-settings stage
       
     9  *
       
    10  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
       
    11  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
       
    14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
       
    15  */
       
    16 
       
    17 if ( !defined('IN_ENANO_INSTALL') )
       
    18   die();
       
    19 
       
    20 // Note: this is called from database_*.php, not directly from install.php
       
    21 
       
    22 $ui->add_header('<script type="text/javascript" src="includes/js/formutils.js"></script>');
       
    23 $ui->show_header();
       
    24 
       
    25 ?>
       
    26 
       
    27 <script type="text/javascript">
       
    28   // <![CDATA[
       
    29   function ajaxMrwTest()
       
    30   {
       
    31     install_set_ajax_loading();
       
    32     // Send a series of tests to the server, and if we get an "expected" response
       
    33     setTimeout("ajaxGet(scriptPath + '/install/rewrite', __ajaxMrwTest_chain_rewrite);", 750);
       
    34   }
       
    35   var __ajaxMrwTest_chain_rewrite = function()
       
    36   {
       
    37     if ( ajax.readyState == 4 )
       
    38     {
       
    39       if ( ajax.responseText == 'good_rewrite' )
       
    40       {
       
    41         ajaxMrwSet('rewrite');
       
    42       }
       
    43       else
       
    44       {
       
    45         ajaxGet(scriptPath + '/install/install.php/shortened?do=modrewrite_test', __ajaxMrwTest_chain_shortened);
       
    46       }
       
    47     }
       
    48   }
       
    49   var __ajaxMrwTest_chain_shortened = function()
       
    50   {
       
    51     if ( ajax.readyState == 4 )
       
    52     {
       
    53       if ( ajax.responseText == 'good_shortened' )
       
    54       {
       
    55         ajaxMrwSet('standard');
       
    56       }
       
    57       else
       
    58       {
       
    59         ajaxGet(scriptPath + '/install/install.php?do=modrewrite_test&str=standard', __ajaxMrwTest_chain_standard);
       
    60       }
       
    61     }
       
    62   }
       
    63   var __ajaxMrwTest_chain_standard = function()
       
    64   {
       
    65     if ( ajax.readyState == 4 )
       
    66     {
       
    67       if ( ajax.responseText == 'good_standard' )
       
    68       {
       
    69         ajaxMrwSet('standard');
       
    70       }
       
    71       else
       
    72       {
       
    73         // FIXME: l10n
       
    74         install_unset_ajax_loading();
       
    75         new messagebox(MB_OK | MB_ICONSTOP, 'All tests failed', 'None of the URL handling tests worked; you may have problems using Enano on your server.');
       
    76       }
       
    77     }
       
    78   }
       
    79   function ajaxMrwSet(level)
       
    80   {
       
    81     install_unset_ajax_loading();
       
    82     if ( !in_array(level, ['rewrite', 'shortened', 'standard']) )
       
    83       return false;
       
    84     
       
    85     document.getElementById('url_radio_rewrite').checked = false;
       
    86     document.getElementById('url_radio_shortened').checked = false;
       
    87     document.getElementById('url_radio_standard').checked = false;
       
    88     document.getElementById('url_radio_' + level).checked = true;
       
    89     document.getElementById('url_radio_' + level).focus();
       
    90     
       
    91     // FIXME: l10n
       
    92     switch ( level )
       
    93     {
       
    94       case 'rewrite':
       
    95         var str = 'The installer has detected that using rewritten URLs is the best level that will work.';
       
    96         break;
       
    97       case 'shortened':
       
    98         var str = 'The installer has detected that using shortened URLs is the best level that will work.';
       
    99         break;
       
   100       case 'standard':
       
   101         var str = 'The installer has detected that using standard URLs is the only level that will work.';
       
   102         break;
       
   103     }
       
   104     document.getElementById('mrw_report').className = 'info-box-mini';
       
   105     document.getElementById('mrw_report').innerHTML = str;
       
   106   }
       
   107   
       
   108   function verify()
       
   109   {
       
   110     var frm = document.forms['install_website'];
       
   111     var fail = false;
       
   112     if ( frm.site_name.value == '' )
       
   113     {
       
   114       fail = true;
       
   115       new Spry.Effect.Shake($(frm.site_name).object, {duration: 750}).start();
       
   116       frm.site_name.focus();
       
   117     }
       
   118     if ( frm.site_desc.value == '' )
       
   119     {
       
   120       new Spry.Effect.Shake($(frm.site_desc).object, {duration: 750}).start();
       
   121       if ( !fail )
       
   122         frm.site_desc.focus();
       
   123       fail = true;
       
   124     }
       
   125     if ( frm.copyright.value == '' )
       
   126     {
       
   127       new Spry.Effect.Shake($(frm.copyright).object, {duration: 750}).start();
       
   128       if ( !fail )
       
   129         frm.copyright.focus();
       
   130       fail = true;
       
   131     }
       
   132     return ( !fail );
       
   133   }
       
   134   // ]]>
       
   135 </script>
       
   136 
       
   137 <form action="install.php?stage=login" method="post" name="install_website" onsubmit="return verify();"><?php
       
   138   foreach ( $_POST as $key => &$value )
       
   139   {
       
   140     if ( !preg_match('/^[a-z0-9_]+$/', $key) )
       
   141       die('You idiot hacker...');
       
   142     if ( $key == '_cont' )
       
   143       continue;
       
   144     $value_clean = str_replace(array('\\', '"', '<', '>'), array('\\\\', '\\"', '&lt;', '&gt;'), $value);
       
   145     echo "\n  <input type=\"hidden\" name=\"$key\" value=\"$value_clean\" />";
       
   146   }
       
   147   
       
   148   $https = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' );
       
   149   $scriptpath_full = 'http' . ( $https ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'] . scriptPath . '/';
       
   150   ?>
       
   151   
       
   152   <table border="0" cellspacing="0" cellpadding="10">
       
   153   
       
   154     <tr>
       
   155       <td>
       
   156         <b>Pick a name</b><br />
       
   157         <span id="hint_site_name" class="fieldtip">Now for the fun part - it's time to name your website. Try to pick something that doesn't include any special characters, since this can make project-page URLs look botched.</span>
       
   158       </td>
       
   159       <td style="width: 50%;">
       
   160         <input type="text" name="site_name" size="50" tabindex="1" />
       
   161       </td>
       
   162     </tr>
       
   163     
       
   164     <tr>
       
   165       <td>
       
   166         <b>Enter a short description</b><br />
       
   167         <span id="hint_site_desc" class="fieldtip">Here you should enter a very short description of your site. Sometimes this is a slogan or, depending on the theme you've chosen, a set of keywords that can go into a META description tag.</span>
       
   168       </td>
       
   169       <td>
       
   170         <input type="text" name="site_desc" size="50" tabindex="2" />
       
   171       </td>
       
   172     </tr>
       
   173     
       
   174     <tr>
       
   175       <td>
       
   176         <b>Copyright info</b><br />
       
   177         <span id="hint_copyright" class="fieldtip">The text you enter here will be shown at the bottom of most pages. Typically this is where a copyright notice would go. Keep it short and sweet; you can use <a href="http://docs.enanocms.org/Help:3.1">internal links</a> to link to project pages you'll create later.</span>
       
   178       </td>
       
   179       <td>
       
   180         <input type="text" name="copyright" size="50" tabindex="3" />
       
   181       </td>
       
   182     </tr>
       
   183     
       
   184     <tr>
       
   185       <td valign="top">
       
   186         <b>URL formatting</b><br />
       
   187         This lets you choose how URLs within your site will be formatted. If the setting you pick doesn't work, you can change it by editing config.php after installation.
       
   188       </td>
       
   189       <td>
       
   190       
       
   191         <table border="0" cellpadding="10" cellspacing="0">
       
   192           <tr>
       
   193             <td valign="top">
       
   194               <input type="radio" name="url_scheme" value="standard" id="url_radio_standard" tabindex="5" />
       
   195             </td>
       
   196             <td>
       
   197               <label for="url_radio_standard">
       
   198                 <b>Standard URLs</b>
       
   199               </label>
       
   200               <span class="fieldtip" id="hint_url_scheme_standard">
       
   201                 <p>Compatible with all servers. This is the default option and should be used unless you're sure that one of the other options below.</p>
       
   202                 <p><small><b>Example:</b> <tt><?php echo $scriptpath_full . 'index.php?title=Page'; ?></tt></small></p>
       
   203               </span>
       
   204             </td>
       
   205           </tr>
       
   206         </table>
       
   207         
       
   208         <table border="0" cellpadding="10" cellspacing="0">
       
   209           <tr>
       
   210             <td valign="top">
       
   211               <input type="radio" checked="checked" name="url_scheme" value="shortened" id="url_radio_shortened" tabindex="5" />
       
   212             </td>
       
   213             <td>
       
   214               <label for="url_radio_shortened">
       
   215                 <b>Shortened URLs</b>
       
   216               </label>
       
   217               <span class="fieldtip" id="hint_url_scheme_shortened">
       
   218                 <p>This eliminates the "?title=" portion of your URL, and instead uses a slash. This is occasionally more friendly to search engines.</p>
       
   219                 <p><small><b>Example:</b> <tt><?php echo $scriptpath_full . 'index.php/Page'; ?></tt></small></p>
       
   220               </span>
       
   221             </td>
       
   222           </tr>
       
   223         </table>
       
   224         
       
   225         <table border="0" cellpadding="10" cellspacing="0">
       
   226           <tr>
       
   227             <td valign="top">
       
   228               <input type="radio" name="url_scheme" value="rewrite" id="url_radio_rewrite" tabindex="5" />
       
   229             </td>
       
   230             <td>
       
   231               <label for="url_radio_rewrite">
       
   232                 <b>Rewritten URLs</b>
       
   233               </label>
       
   234               <span id="hint_url_scheme_rewrite" class="fieldtip">
       
   235                 <p>Using this option, you can completely eliminate the "index.php" from URLs. This is the most friendly option to search engines and looks very professional, but requires support for URL rewriting on your server. If you're running Apache and have the right permissions, Enano can configure this automatically. Otherwise, you'll need to configure your server manually and have a knowledge of regular expressions for this option to work.</p>
       
   236                 <p><small><b>Example:</b> <tt><?php echo $scriptpath_full . 'Page'; ?></tt></small></p>
       
   237               </span>
       
   238             </td>
       
   239           </tr>
       
   240         </table>
       
   241         
       
   242         <p>
       
   243           <a href="#mrw_scan" onclick="ajaxMrwTest(); return false;" tabindex="4">Auto-detect the best formatting scheme</a>
       
   244         </p>
       
   245         
       
   246         <div id="mrw_report"></div>
       
   247         
       
   248       </td>
       
   249     </tr>
       
   250     
       
   251   </table>
       
   252   
       
   253   <div style="text-align: center;">
       
   254     <input type="submit" name="_cont" value="<?php echo $lang->get('meta_btn_continue'); ?>" tabindex="6" />
       
   255   </div>
       
   256   
       
   257 </form>
       
   258