includes/common.php
changeset 348 87e08a6e4fec
parent 335 67bd3121a12e
child 350 dd7cbc97f681
child 351 8978cb3541ca
equal deleted inserted replaced
347:299a90e28abc 348:87e08a6e4fec
    82 }
    82 }
    83 
    83 
    84 // ENANO_ROOT is sometimes defined by plugins like AjIM that need the constant before the Enano API is initialized
    84 // ENANO_ROOT is sometimes defined by plugins like AjIM that need the constant before the Enano API is initialized
    85 if ( !defined('ENANO_ROOT') )
    85 if ( !defined('ENANO_ROOT') )
    86   define('ENANO_ROOT', dirname(dirname($filename)));
    86   define('ENANO_ROOT', dirname(dirname($filename)));
    87 
       
    88 // Debugging features are PHP5-specifid
       
    89 if ( defined('ENANO_DEBUG') && version_compare(PHP_VERSION, '5.0.0') < 0 )
       
    90 {
       
    91   die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.');
       
    92 }
       
    93 
    87 
    94 // We deprecated debugConsole in 1.0.2 because it was never used and there were a lot of unneeded debugging points in the code.
    88 // We deprecated debugConsole in 1.0.2 because it was never used and there were a lot of unneeded debugging points in the code.
    95 
    89 
    96 // _nightly.php is used to tag non-Mercurial-generated nightly builds
    90 // _nightly.php is used to tag non-Mercurial-generated nightly builds
    97 if ( file_exists( ENANO_ROOT . '/_nightly.php') )
    91 if ( file_exists( ENANO_ROOT . '/_nightly.php') )
   183   {
   177   {
   184     case 'cookie_destroy':
   178     case 'cookie_destroy':
   185       unset($_COOKIE['sid']);
   179       unset($_COOKIE['sid']);
   186       setcookie('sid', '', time()-3600*24, scriptPath);
   180       setcookie('sid', '', time()-3600*24, scriptPath);
   187       setcookie('sid', '', time()-3600*24, scriptPath.'/');
   181       setcookie('sid', '', time()-3600*24, scriptPath.'/');
   188       die('Session cookie cleared. <a href="'.$_SERVER['PHP_SELF'].'">Continue</a>');
   182       die('Session cookie cleared. <a href="'.htmlspecialchars($_SERVER['PHP_SELF']).'">Continue</a>');
   189       break;
   183       break;
   190   }
   184   }
   191 }
   185 }
   192 
   186 
   193 // Select and fetch the site configuration
   187 // Select and fetch the site configuration
   207 }
   201 }
   208 
   202 
   209 $db->free_result();
   203 $db->free_result();
   210 
   204 
   211 // Now that we have the config, check the Enano version.
   205 // Now that we have the config, check the Enano version.
   212 if ( enano_version(false, true) != $version )
   206 if ( enano_version(false, true) != $version && !defined('IN_ENANO_UPGRADE') )
   213 {
   207 {
   214   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>');
   208   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>');
   215 }
   209 }
   216 
   210 
   217 //
   211 //
   281     table_prefix.'banlist',
   275     table_prefix.'banlist',
   282     table_prefix.'files',
   276     table_prefix.'files',
   283     table_prefix.'privmsgs',
   277     table_prefix.'privmsgs',
   284     table_prefix.'sidebar',
   278     table_prefix.'sidebar',
   285     table_prefix.'hits',
   279     table_prefix.'hits',
   286     table_prefix.'search_index',
       
   287     table_prefix.'groups',
   280     table_prefix.'groups',
   288     table_prefix.'group_members',
   281     table_prefix.'group_members',
   289     table_prefix.'acl',
   282     table_prefix.'acl',
   290     table_prefix.'page_groups',
   283     table_prefix.'page_groups',
   291     table_prefix.'page_group_members',
   284     table_prefix.'page_group_members',
   348   }
   341   }
   349 
   342 
   350   // All checks passed! Start the main components up.  
   343   // All checks passed! Start the main components up.  
   351   $session->start();
   344   $session->start();
   352   
   345   
   353   // This is where plugins will want to add pages from 1.1.x on out. You can still add pages at base_classes_initted but the titles won't be localized.
   346   // This is where plugins will want to add pages from 1.1.x on out. You can still add
       
   347   // pages at base_classes_initted but the titles won't be localized. This is because
       
   348   // the session manager has to be started before localization will work in the user's
       
   349   // preferred language.
   354   $code = $plugins->setHook('session_started');
   350   $code = $plugins->setHook('session_started');
   355   foreach ( $code as $cmd )
   351   foreach ( $code as $cmd )
   356   {
   352   {
   357     eval($cmd);
   353     eval($cmd);
   358   }
   354   }