includes/common.php
changeset 147 d8156d18ac58
parent 145 6f0bbf88c325
child 229 97ae8e9d5e29
equal deleted inserted replaced
146:fa3dab3cfb08 147:d8156d18ac58
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     5  * Version 1.0.2 (Coblynau)
     5  * Version 1.0 (Banshee)
     6  * Copyright (C) 2006-2007 Dan Fuhry
     6  * Copyright (C) 2006-2007 Dan Fuhry
     7  *
     7  *
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    10  *
    10  *
    21   </script><p><span style="color:black;">You been f***ed by Enano | valid XHTML 1.1</span></p></body></html>
    21   </script><p><span style="color:black;">You been f***ed by Enano | valid XHTML 1.1</span></p></body></html>
    22   <?php
    22   <?php
    23   exit;
    23   exit;
    24 }
    24 }
    25 
    25 
    26 $version = '1.0.2b1';
    26 $version = '1.0.1';
    27 
    27 
    28 function microtime_float()
    28 function microtime_float()
    29 {
    29 {
    30   list($usec, $sec) = explode(" ", microtime());
    30   list($usec, $sec) = explode(" ", microtime());
    31   return ((float)$usec + (float)$sec);
    31   return ((float)$usec + (float)$sec);
    54   die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.');
    54   die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.');
    55 }
    55 }
    56 
    56 
    57 if(defined('ENANO_DEBUG'))
    57 if(defined('ENANO_DEBUG'))
    58 {
    58 {
    59   require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php');
    59 //  require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php');
       
    60   function dc_here($m)     { return false; }
       
    61   function dc_dump($a, $g) { return false; }
       
    62   function dc_watch($n)    { return false; }
       
    63   function dc_start_timer($u) { return false; }
       
    64   function dc_stop_timer($m) { return false; }
    60 } else {
    65 } else {
    61   function dc_here($m)     { return false; }
    66   function dc_here($m)     { return false; }
    62   function dc_dump($a, $g) { return false; }
    67   function dc_dump($a, $g) { return false; }
    63   function dc_watch($n)    { return false; }
    68   function dc_watch($n)    { return false; }
    64   function dc_start_timer($u) { return false; }
    69   function dc_start_timer($u) { return false; }
   147 if(enano_version(false, true) != $version)
   152 if(enano_version(false, true) != $version)
   148 {
   153 {
   149   grinding_halt('Version mismatch', '<p>It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to <a href="'.scriptPath.'/upgrade.php">upgrade</a>?</p>');
   154   grinding_halt('Version mismatch', '<p>It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to <a href="'.scriptPath.'/upgrade.php">upgrade</a>?</p>');
   150 }
   155 }
   151 
   156 
   152 //
       
   153 // Low level maintenance
       
   154 //
       
   155 
       
   156 // If the search algorithm backend has been changed, empty out the search cache (the two cache formats are incompatible with each other)
       
   157 if ( getConfig('last_search_algo') != SEARCH_MODE )
       
   158 {
       
   159   if ( !$db->sql_query('DELETE FROM '.table_prefix.'search_cache;') )
       
   160     $db->_die();
       
   161   setConfig('last_search_algo', SEARCH_MODE);
       
   162 }
       
   163 
       
   164 // If the AES key size has been changed, bail out and fast
       
   165 if ( !getConfig('aes_key_size') )
       
   166 {
       
   167   setConfig('aes_key_size', AES_BITS);
       
   168 }
       
   169 else if ( $ks = getConfig('aes_key_size') )
       
   170 {
       
   171   if ( intval($ks) != AES_BITS )
       
   172   {
       
   173     grinding_halt('AES key size changed', '<p>Enano has detected that the AES key size in constants.php has been changed. This change cannot be performed after installation, otherwise the private key would have to be re-generated and all passwords would have to be re-encrypted.</p><p>Please change the key size back to ' . $ks . ' bits and reload this page.</p>');
       
   174   }
       
   175 }
       
   176 
       
   177 // Same for AES block size
       
   178 if ( !getConfig('aes_block_size') )
       
   179 {
       
   180   setConfig('aes_block_size', AES_BLOCKSIZE);
       
   181 }
       
   182 else if ( $ks = getConfig('aes_block_size') )
       
   183 {
       
   184   if ( intval($ks) != AES_BLOCKSIZE )
       
   185   {
       
   186     grinding_halt('AES block size changed', '<p>Enano has detected that the AES block size in constants.php has been changed. This change cannot be performed after installation, otherwise all passwords would have to be re-encrypted.</p><p>Please change the block size back to ' . $ks . ' bits and reload this page.</p>');
       
   187   }
       
   188 }
       
   189 
       
   190 // Our list of tables included in Enano
   157 // Our list of tables included in Enano
   191 $system_table_list = Array(
   158 $system_table_list = Array(
   192     table_prefix.'categories',
   159     table_prefix.'categories',
   193     table_prefix.'comments',
   160     table_prefix.'comments',
   194     table_prefix.'config',
   161     table_prefix.'config',
   207     table_prefix.'hits',
   174     table_prefix.'hits',
   208     table_prefix.'search_index',
   175     table_prefix.'search_index',
   209     table_prefix.'groups',
   176     table_prefix.'groups',
   210     table_prefix.'group_members',
   177     table_prefix.'group_members',
   211     table_prefix.'acl',
   178     table_prefix.'acl',
   212     table_prefix.'search_cache',
   179     table_prefix.'search_cache'
   213     table_prefix.'page_groups',
       
   214     table_prefix.'page_group_members',
       
   215     table_prefix.'tags'
       
   216   );
   180   );
   217 
   181 
   218 dc_here('common: initializing base classes');
   182 dc_here('common: initializing base classes');
   219 $plugins = new pluginLoader();
   183 $plugins = new pluginLoader();
   220 
   184 
   266         $n = 'The administrator has disabled the site. Please check back later.';
   230         $n = 'The administrator has disabled the site. Please check back later.';
   267       }
   231       }
   268       
   232       
   269       $text = RenderMan::render($n) . '
   233       $text = RenderMan::render($n) . '
   270       <div class="info-box">
   234       <div class="info-box">
   271         If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site.
   235         If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site or <a href="'.makeUrlNS('Special', 'Administration').'">use the administration panel</a>.
   272       </div>';
   236       </div>';
   273       $paths->wiki_mode = 0;
   237       $paths->wiki_mode = 0;
   274       die_semicritical('Site disabled', $text);
   238       die_semicritical('Site disabled', $text);
   275     }
   239     }
   276   }
   240   }