includes/common.php
changeset 228 b0a4d179be85
parent 227 0eca1498a77b
child 229 97ae8e9d5e29
equal deleted inserted replaced
197:90b7a52bea45 228:b0a4d179be85
     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.1.1
     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.2';
    26 $version = '1.1.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);
    79 require_once(ENANO_ROOT.'/includes/dbal.php');
    79 require_once(ENANO_ROOT.'/includes/dbal.php');
    80 require_once(ENANO_ROOT.'/includes/paths.php');
    80 require_once(ENANO_ROOT.'/includes/paths.php');
    81 require_once(ENANO_ROOT.'/includes/sessions.php');
    81 require_once(ENANO_ROOT.'/includes/sessions.php');
    82 require_once(ENANO_ROOT.'/includes/template.php');
    82 require_once(ENANO_ROOT.'/includes/template.php');
    83 require_once(ENANO_ROOT.'/includes/plugins.php');
    83 require_once(ENANO_ROOT.'/includes/plugins.php');
       
    84 require_once(ENANO_ROOT.'/includes/lang.php');
    84 require_once(ENANO_ROOT.'/includes/comment.php');
    85 require_once(ENANO_ROOT.'/includes/comment.php');
    85 require_once(ENANO_ROOT.'/includes/wikiformat.php');
    86 require_once(ENANO_ROOT.'/includes/wikiformat.php');
    86 require_once(ENANO_ROOT.'/includes/diff.php');
    87 require_once(ENANO_ROOT.'/includes/diff.php');
    87 require_once(ENANO_ROOT.'/includes/render.php');
    88 require_once(ENANO_ROOT.'/includes/render.php');
    88 require_once(ENANO_ROOT.'/includes/stats.php');
    89 require_once(ENANO_ROOT.'/includes/stats.php');
   104 global $db, $session, $paths, $template, $plugins; // Common objects
   105 global $db, $session, $paths, $template, $plugins; // Common objects
   105 global $enano_config; // A global used to cache config information without making loads of queries ;-)
   106 global $enano_config; // A global used to cache config information without making loads of queries ;-)
   106                       // In addition, $enano_config is used to fetch config information if die_semicritical() is called.
   107                       // In addition, $enano_config is used to fetch config information if die_semicritical() is called.
   107                       
   108                       
   108 global $email;
   109 global $email;
       
   110 global $lang;
   109 
   111 
   110 if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', '<p>Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.</p>');
   112 if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', '<p>Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.</p>');
   111                      
   113                      
   112 $db = new mysql();
   114 $db = new mysql();
   113 dc_here('common: calling $db->connect();');
   115 dc_here('common: calling $db->connect();');
   186 {
   188 {
   187   if ( intval($ks) != AES_BLOCKSIZE )
   189   if ( intval($ks) != AES_BLOCKSIZE )
   188   {
   190   {
   189     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>');
   191     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>');
   190   }
   192   }
       
   193 }
       
   194 
       
   195 // Is there no default language?
       
   196 if ( getConfig('lang_default') === false )
       
   197 {
       
   198   $q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;');
       
   199   if ( !$q )
       
   200     $db->_die('common.php - setting default language');
       
   201   if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') )
       
   202   {
       
   203     grinding_halt('No languages', '<p>There are no languages installed on this site.</p>
       
   204         <p>If you are the website administrator, you may install a language by writing and executing a simple PHP script to install it:</p>
       
   205         <pre>
       
   206 &lt;?php
       
   207 define("ENANO_ALLOW_LOAD_NOLANG", 1);
       
   208 $_GET["title"] = "langinstall";
       
   209 require("includes/common.php");
       
   210 install_language("eng", "English", "English", ENANO_ROOT . "/language/english/enano.json");</pre>');
       
   211   }
       
   212   $row = $db->fetchrow();
       
   213   setConfig('default_language', $row['lang_id']);
   191 }
   214 }
   192 
   215 
   193 // Our list of tables included in Enano
   216 // Our list of tables included in Enano
   194 $system_table_list = Array(
   217 $system_table_list = Array(
   195     table_prefix.'categories',
   218     table_prefix.'categories',