install.php
changeset 279 8acd77a6c19d
parent 278 53ba55d33abb
parent 276 acfdccf7a2bf
child 280 dc08c70ca550
equal deleted inserted replaced
278:53ba55d33abb 279:8acd77a6c19d
    12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    13  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    13  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    14  */
    14  */
    15  
    15  
    16 @include('config.php');
    16 @include('config.php');
    17 if( ( defined('ENANO_INSTALLED') || defined('MIDGET_INSTALLED') ) && ((isset($_GET['mode']) && ($_GET['mode']!='finish' && $_GET['mode']!='css')) || !isset($_GET['mode'])))
    17 if( ( defined('ENANO_INSTALLED') || defined('MIDGET_INSTALLED') ) && ((isset($_GET['mode']) && ($_GET['mode']!='finish' && $_GET['mode']!='css') && $_GET['mode']!='showlicense') || !isset($_GET['mode'])))
    18 {
    18 {
    19   $_GET['title'] = 'Enano:Installation_locked';
    19   $_GET['title'] = 'Enano:Installation_locked';
    20   require('includes/common.php');
    20   require('includes/common.php');
    21   die_friendly('Installation locked', '<p>The Enano installer has found a Enano installation in this directory. You MUST delete config.php if you want to re-install Enano.</p><p>If you wish to upgrade an older Enano installation to this version, please use the <a href="upgrade.php">upgrade script</a>.</p>');
    21   die_friendly('Installation locked', '<p>The Enano installer has found a Enano installation in this directory. You MUST delete config.php if you want to re-install Enano.</p><p>If you wish to upgrade an older Enano installation to this version, please use the <a href="upgrade.php">upgrade script</a>.</p>');
    22   exit;
    22   exit;
   317 {
   317 {
   318   $conn = stg_mysql_connect(true);
   318   $conn = stg_mysql_connect(true);
   319   if ( !$conn )
   319   if ( !$conn )
   320     return false;
   320     return false;
   321   // Our list of tables included in Enano
   321   // Our list of tables included in Enano
   322   $tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'search_cache', 'tags', 'page_groups', 'page_group_members' );
   322   $tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'tags', 'page_groups', 'page_group_members' );
   323   
   323   
   324   // Drop each table individually; if it fails, it probably means we're trying to drop a
   324   // Drop each table individually; if it fails, it probably means we're trying to drop a
   325   // table that didn't exist in the Enano version we're deleting the database for.
   325   // table that didn't exist in the Enano version we're deleting the database for.
   326   foreach ( $tables as $table )
   326   foreach ( $tables as $table )
   327   {
   327   {
   570   fwrite($handle, $contents);
   570   fwrite($handle, $contents);
   571   fclose($handle);
   571   fclose($handle);
   572   return true;
   572   return true;
   573 }
   573 }
   574 
   574 
       
   575 function stg_build_index()
       
   576 {
       
   577   global $db, $session, $paths, $template, $plugins; // Common objects;
       
   578   if ( $paths->rebuild_search_index() )
       
   579     return true;
       
   580   return false;
       
   581 }
       
   582 
   575 function stg_rename_config()
   583 function stg_rename_config()
   576 {
   584 {
   577   if ( !@rename('./config.new.php', './config.php') )
   585   if ( !@rename('./config.new.php', './config.php') )
   578   {
   586   {
   579     echo '<p>Can\'t rename config.php</p>';
   587     echo '<p>Can\'t rename config.php</p>';
   690     if($cv) $color='FFCCCC'; else $color='FFAAAA';
   698     if($cv) $color='FFCCCC'; else $color='FFAAAA';
   691     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
   699     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
   692     $failed = true;
   700     $failed = true;
   693   }
   701   }
   694 }
   702 }
   695 function is_apache()
   703 function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
   696 {
   704 
   697   return strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false;
   705 function show_license($fb = false)
       
   706 {
       
   707   ?>
       
   708   <div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
       
   709   <?php
       
   710     if ( !file_exists('./GPL') || !file_exists('./language/english/install/license-deed.html') )
       
   711     {
       
   712       echo 'Cannot find the license files.';
       
   713     }
       
   714     echo file_get_contents('./language/english/install/license-deed.html');
       
   715     if ( defined('ENANO_BETA_VERSION') || $branch == 'unstable' )
       
   716     {
       
   717       ?>
       
   718       <h3><?php echo $lang->get('license_info_unstable_title'); ?></h3>
       
   719       <p><?php echo $lang->get('license_info_unstable_body'); ?></p>
       
   720       <?php
       
   721     }
       
   722     ?>
       
   723     <h3><?php echo $lang->get('license_section_gpl_heading'); ?></h3>
       
   724     <?php if ( $lang->lang_code != 'eng' ): ?>
       
   725     <p><i><?php echo $lang->get('license_gpl_blurb_inenglish'); ?></i></p>
       
   726     <?php endif; ?>
       
   727     <?php echo wikiFormat(file_get_contents(ENANO_ROOT . '/GPL')); ?>
       
   728    <?php
       
   729    global $template;
       
   730    if ( $fb )
       
   731    {
       
   732      echo '<p style="text-align: center;">Because I could never find the Create a Page button in PHP-Nuke.</p>';
       
   733      echo '<p>' . str_replace('http://enanocms.org/', 'http://www.2robots.com/2003/10/15/web-portals-suck/', $template->fading_button) . '</p>';
       
   734      echo '<p style="text-align: center;">It\'s not a portal, my friends.</p>';
       
   735    }
       
   736    ?>
       
   737  </div>
       
   738  <?php
   698 }
   739 }
   699 
   740 
   700 require_once('includes/template.php');
   741 require_once('includes/template.php');
   701 
   742 
   702 //
   743 if(!isset($_GET['mode']))
   703 // Startup localization
   744 {
   704 //
       
   705 
       
   706 // We need $db just for the _die function
       
   707 $db = new mysql();
       
   708 
       
   709 $lang = new Language('eng');
       
   710 $lang->load_file('./language/english/install.json');
       
   711 
       
   712 if ( !isset($_GET['mode']) )
       
   713   $_GET['mode'] = 'welcome';
   745   $_GET['mode'] = 'welcome';
   714 
   746 }
   715 switch($_GET['mode'])
   747 switch($_GET['mode'])
   716 {
   748 {
   717   case 'mysql_test':
   749   case 'mysql_test':
   718     error_reporting(0);
   750     error_reporting(0);
   719     $dbhost     = rawurldecode($_POST['host']);
   751     $dbhost     = rawurldecode($_POST['host']);
   860               'website' => $lang->get('website_modetitle'),
   892               'website' => $lang->get('website_modetitle'),
   861               'login'   => $lang->get('login_modetitle'),
   893               'login'   => $lang->get('login_modetitle'),
   862               'confirm' => $lang->get('confirm_modetitle'),
   894               'confirm' => $lang->get('confirm_modetitle'),
   863               'install' => $lang->get('install_modetitle'),
   895               'install' => $lang->get('install_modetitle'),
   864               'finish'  => $lang->get('finish_modetitle')
   896               'finish'  => $lang->get('finish_modetitle')
       
   897               '_hiddenstages' => '...', // all stages below this line are hidden
       
   898               'showlicense' => $lang->get('license_modetitle')
   865             );
   899             );
   866 
   900 
   867 $sideinfo = '';
   901 $sideinfo = '';
   868 $vars = $template->extract_vars('elements.tpl');
   902 $vars = $template->extract_vars('elements.tpl');
   869 $p = $template->makeParserText($vars['sidebar_button']);
   903 $p = $template->makeParserText($vars['sidebar_button']);
       
   904 $hidden = false;
   870 foreach ( $modestrings as $id => $str )
   905 foreach ( $modestrings as $id => $str )
   871 {
   906 {
   872   if ( $_GET['mode'] == $id )
   907   if ( $_GET['mode'] == $id )
   873   {
   908   {
   874     $flags = 'style="font-weight: bold; text-decoration: underline;"';
   909     $flags = 'style="font-weight: bold; text-decoration: underline;"';
   876   }
   911   }
   877   else
   912   else
   878   {
   913   {
   879     $flags = '';
   914     $flags = '';
   880   }
   915   }
   881   $p->assign_vars(Array(
   916   if ( $id == '_hiddenstages' )
   882       'HREF' => '#',
   917     $hidden = true;
   883       'FLAGS' => $flags . ' onclick="return false;"',
   918   if ( !$hidden )
   884       'TEXT' => $str
   919   {
   885     ));
   920     $p->assign_vars(Array(
   886   $sideinfo .= $p->run();
   921         'HREF' => '#',
       
   922         'FLAGS' => $flags . ' onclick="return false;"',
       
   923         'TEXT' => $str
       
   924       ));
       
   925     $sideinfo .= $p->run();
       
   926   }
   887 }
   927 }
   888 
   928 
   889 $template->init_vars();
   929 $template->init_vars();
   890 
   930 
   891 if(isset($_GET['mode']) && $_GET['mode'] == 'css')
   931 if(isset($_GET['mode']) && $_GET['mode'] == 'css')
   913     else
   953     else
   914       $branch = 'stable';
   954       $branch = 'stable';
   915   }
   955   }
   916 }
   956 }
   917 
   957 
   918 $template->header();
       
   919 if(!isset($_GET['mode'])) $_GET['mode'] = 'license';
       
   920 switch($_GET['mode'])
   958 switch($_GET['mode'])
   921 { 
   959 { 
   922   default:
   960   default:
   923   case 'welcome':
   961   case 'welcome':
   924     ?>
   962     ?>
   952   case "license":
   990   case "license":
   953     ?>
   991     ?>
   954     <h3><?php echo $lang->get('license_heading'); ?></h3>
   992     <h3><?php echo $lang->get('license_heading'); ?></h3>
   955      <p><?php echo $lang->get('license_blurb_thankyou'); ?></p>
   993      <p><?php echo $lang->get('license_blurb_thankyou'); ?></p>
   956      <p><?php echo $lang->get('license_blurb_pleaseread'); ?></p>
   994      <p><?php echo $lang->get('license_blurb_pleaseread'); ?></p>
   957      <div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
   995      <?php show_license(); ?>
   958        <?php
       
   959        if ( !file_exists('./GPL') || !file_exists('./language/english/install/license-deed.html') )
       
   960        {
       
   961          echo 'Cannot find the license files.';
       
   962        }
       
   963        echo file_get_contents('./language/english/install/license-deed.html');
       
   964        if ( defined('ENANO_BETA_VERSION') || $branch == 'unstable' )
       
   965        {
       
   966          ?>
       
   967          <h3><?php echo $lang->get('license_info_unstable_title'); ?></h3>
       
   968          <p><?php echo $lang->get('license_info_unstable_body'); ?></p>
       
   969          <?php
       
   970        }
       
   971        ?>
       
   972        <h3><?php echo $lang->get('license_section_gpl_heading'); ?></h3>
       
   973        <?php if ( $lang->lang_code != 'eng' ): ?>
       
   974        <p><i><?php echo $lang->get('license_gpl_blurb_inenglish'); ?></i></p>
       
   975        <?php endif; ?>
       
   976        <?php echo wikiFormat(file_get_contents(ENANO_ROOT . '/GPL')); ?>
       
   977      </div>
       
   978      <div class="pagenav">
   996      <div class="pagenav">
   979        <form action="install.php?mode=sysreqs" method="post">
   997        <form action="install.php?mode=sysreqs" method="post">
   980          <table border="0">
   998          <table border="0">
   981          <tr>
   999          <tr>
   982            <td>
  1000            <td>
  1878         $paths->init();
  1896         $paths->init();
  1879         
  1897         
  1880         run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_import_language', $lang->get('install_stg_importlang_body'));
  1898         run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_import_language', $lang->get('install_stg_importlang_body'));
  1881         run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body'));
  1899         run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body'));
  1882         
  1900         
       
  1901         run_installer_stage('buildindex', 'Initialize search index', 'stg_build_index', 'Something went wrong while the page manager was attempting to build a search index.');
       
  1902         
  1883         /*
  1903         /*
  1884          * HACKERS:
  1904          * HACKERS:
  1885          * If you're making a custom distribution of Enano, put all your custom plugin-related code here.
  1905          * If you're making a custom distribution of Enano, put all your custom plugin-related code here.
  1886          * You have access to the full Enano API as well as being logged in with complete admin rights.
  1906          * You have access to the full Enano API as well as being logged in with complete admin rights.
  1887          * Don't do anything horrendously fancy here, unless you add a new stage (or more than one) and
  1907          * Don't do anything horrendously fancy here, unless you add a new stage (or more than one) and
  1915   case "finish":
  1935   case "finish":
  1916     echo '<h3>' . $lang->get('finish_msg_congratulations') . '</h3>
  1936     echo '<h3>' . $lang->get('finish_msg_congratulations') . '</h3>
  1917            ' . $lang->get('finish_body') . '
  1937            ' . $lang->get('finish_body') . '
  1918            <p>' . $lang->get('finish_link_mainpage', array('mainpage_link' => 'index.php')) . '</p>';
  1938            <p>' . $lang->get('finish_link_mainpage', array('mainpage_link' => 'index.php')) . '</p>';
  1919     break;
  1939     break;
       
  1940   // this stage is never shown during the installation, but is provided for legal purposes
       
  1941   case "showlicense":
       
  1942     show_license(true);
       
  1943     break;
  1920 }
  1944 }
  1921 $template->footer();
  1945 $template->footer();
  1922  
  1946  
  1923 ?>
  1947 ?>