Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cCLISetup
  • cSetupLanguageChooser
  • cSetupNotInstallable
  • cSetupTypeChooser

Functions

  • checkAndInclude
  • checkExistingPlugin
  • checkInstallationSettings
  • findSimilarText
  • getArgs
  • getContenidoVersion
  • getSystemDirectories
  • initializeVariables
  • listClients
  • passwordPrompt
  • printHelpText
  • prnt
  • prntln
  • prntst
  • progressBar
  • stripLastSlash
  • updateClientPath
  • updateContenidoVersion
  • updateSysadminPassword
  • updateSystemProperties
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * Main CONTENIDO setup bootstrap file.
  5:  *
  6:  * @package    Setup
  7:  * @subpackage Setup
  8:  * @author     Murat Purc <murat@purc.de>
  9:  * @copyright  four for business AG <www.4fb.de>
 10:  * @license    http://www.contenido.org/license/LIZENZ.txt
 11:  * @link       http://www.4fb.de
 12:  * @link       http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: // Report all errors except warnings
 18: error_reporting(E_ALL ^E_NOTICE);
 19: 
 20: header('Content-Type: text/html; charset=ISO-8859-1');
 21: 
 22: /**
 23:  * Setup file inclusion
 24:  *
 25:  * @param  string  $filename
 26:  */
 27: function checkAndInclude($filename) {
 28:     if (file_exists($filename) && is_readable($filename)) {
 29:         include_once($filename);
 30:     } else {
 31:         echo "<pre>";
 32:         echo "Setup was unable to include necessary files. The file $filename was not found. Solutions:\n\n";
 33:         echo "- Make sure that all files are correctly uploaded to the server.\n";
 34:         echo "- Make sure that include_path is set to '.' (of course, it can contain also other directories). Your include path is: " . ini_get("include_path") . "\n";
 35:         echo "</pre>";
 36:     }
 37: }
 38: 
 39: checkAndInclude(CON_SETUP_PATH . '/lib/defines.php');
 40: 
 41: // Check version in the 'first' line, as class.security.php uses
 42: // PHP5 object syntax not compatible with PHP < 5
 43: if (version_compare(PHP_VERSION, CON_SETUP_MIN_PHP_VERSION, '<')) {
 44:     die(sprintf("You need PHP >= %s for CONTENIDO. Sorry, even the setup doesn't work otherwise. Your version: %s\n", CON_SETUP_MIN_PHP_VERSION, PHP_VERSION));
 45: }
 46: 
 47: // Include the environment definer file
 48: include_once(CON_FRONTEND_PATH . '/contenido/environment.php');
 49: 
 50: // Include cStringMultiByteWrapper and cString
 51: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.string.multi.byte.wrapper.php');
 52: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.string.php');
 53: 
 54: // Include security class and check request variables
 55: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.filehandler.php');
 56: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.requestvalidator.php');
 57: 
 58: /**
 59:  * Check configuration path for the environment
 60:  * If no configuration for environment found, copy from production
 61:  */
 62: $installationPath = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../..'));
 63: $configPath = $installationPath . '/data/config/' . CON_ENVIRONMENT;
 64: if (!cFileHandler::exists($configPath)) {
 65:     // create environment config
 66:     mkdir($configPath);
 67:     // if not successful throw exception
 68:     if (!cFileHandler::exists($configPath)) {
 69:         throw new cException('Can not create environment directory: data folder is not writable');
 70:     }
 71:     // get config source path
 72:     $configPathProduction = $installationPath . '/data/config/production/';
 73:     // load config source directory
 74:     $directoryIterator = new DirectoryIterator($configPathProduction);
 75:     // iterate through files
 76:     foreach ($directoryIterator as $dirContent) {
 77:         // check file is not dot and file
 78:         if ($dirContent->isFile() && !$dirContent->isDot()) {
 79:             // get filename
 80:             $configFileName = $dirContent->getFilename();
 81:             // build source string
 82:             $source = $configPathProduction . $configFileName;
 83:             // build target string
 84:             $target = $configPath . '/' . $configFileName;
 85:             // try to copy from source to target, if not successful throw exception
 86:             if(!copy($source, $target)) {
 87:                 throw new cException('Can not copy configuration files for the environment: environment folder is not writable');
 88:             }
 89:         }
 90:     }
 91: }
 92: 
 93: try {
 94:     $requestValidator = cRequestValidator::getInstance();
 95:     $requestValidator->checkParams();
 96: } catch (cFileNotFoundException $e) {
 97:     die($e->getMessage());
 98: }
 99: 
100: session_start();
101: 
102: if (is_array($_REQUEST)) {
103:     foreach ($_REQUEST as $key => $value) {
104:         if ($key == 'c') {
105:             // c = setup controller to process
106:             continue;
107:         }
108:         if (($value != '' && $key != 'dbpass' && $key != 'adminpass' && $key != 'adminpassrepeat') || ($key == 'dbpass' && $_REQUEST['dbpass_changed'] == 'true') || ($key == 'adminpass' && $_REQUEST['adminpass_changed'] == 'true') || ($key == 'adminpassrepeat' && $_REQUEST['adminpassrepeat_changed'] == 'true')) {
109:             $_SESSION[$key] = $value;
110:         }
111:     }
112: }
113: 
114: // set max_execution_time
115: $maxExecutionTime = (int) ini_get('max_execution_time');
116: if ($maxExecutionTime < 60 && $maxExecutionTime !== 0) {
117:     ini_set('max_execution_time', 60);
118: }
119: 
120: // Some basic configuration
121: global $cfg;
122: 
123: $cfg['path']['frontend'] = CON_FRONTEND_PATH;
124: $cfg['path']['contenido'] = $cfg['path']['frontend'] . '/contenido/';
125: $cfg['path']['contenido_config'] = CON_FRONTEND_PATH . '/data/config/' . CON_ENVIRONMENT . '/';
126: 
127: // DB related settings
128: $cfg['sql']['sqlprefix'] = (isset($_SESSION['dbprefix'])) ? $_SESSION['dbprefix'] : 'con';
129: $cfg['db'] = array(
130:     'connection' => array(
131:         'host' => (isset($_SESSION['dbhost'])) ? $_SESSION['dbhost'] : '',
132:         'database' => (isset($_SESSION['dbname'])) ? $_SESSION['dbname'] : '',
133:         'user' => (isset($_SESSION['dbuser'])) ? $_SESSION['dbuser'] : '',
134:         'password' => (isset($_SESSION['dbpass'])) ? $_SESSION['dbpass'] : '',
135:         'charset' => (isset($_SESSION['dbcharset'])) ? $_SESSION['dbcharset'] : ''
136:     ),
137:     'haltBehavior' => 'report',
138:     'haltMsgPrefix' => (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] . ' ' : '',
139:     'enableProfiling' => false,
140: );
141: 
142: checkAndInclude($cfg['path']['contenido_config'] . 'config.path.php');
143: checkAndInclude($cfg['path']['contenido_config'] . 'config.misc.php');
144: checkAndInclude($cfg['path']['contenido_config'] . 'cfg_sql.inc.php');
145: 
146: // Takeover configured PHP settings
147: if ($cfg['php_settings'] && is_array($cfg['php_settings'])) {
148:     foreach ($cfg['php_settings'] as $settingName => $value) {
149:         // date.timezone is handled separately
150:         if ($settingName !== 'date.timezone') {
151:             @ini_set($settingName, $value);
152:         }
153:     }
154: }
155: error_reporting($cfg['php_error_reporting']);
156: 
157: // force date.timezone setting
158: $timezoneCfg = $cfg['php_settings']['date.timezone'];
159: if (!empty($timezoneCfg) && ini_get('date.timezone') !== $timezoneCfg) {
160:     // if the timezone setting from the cfg differs from the php.ini setting, set timezone from CFG
161:     date_default_timezone_set($timezoneCfg);
162: } else if (empty($timezoneCfg) && (ini_get('date.timezone') === '' || ini_get('date.timezone') === false)) {
163:     // if there are no timezone settings, set UTC timezone
164:     date_default_timezone_set('UTC');
165: }
166: 
167: // Initialization of autoloader
168: checkAndInclude($cfg['path']['contenido'] . $cfg['path']['classes'] . 'class.autoload.php');
169: cAutoload::initialize($cfg);
170: 
171: // Set generateXHTML property of cHTML class to prevent db query, especially at
172: // the beginning of an new installation where we have no db
173: cHTML::setGenerateXHTML(false);
174: 
175: // Common includes
176: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.php54.php');
177: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.i18n.php');
178: checkAndInclude($cfg['path']['contenido'] . 'includes/api/functions.api.general.php');
179: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
180: checkAndInclude($cfg['path']['contenido'] . 'classes/class.template.php');
181: checkAndInclude(CON_SETUP_PATH . '/lib/class.setupcontrols.php');
182: checkAndInclude(CON_SETUP_PATH . '/lib/functions.filesystem.php');
183: checkAndInclude(CON_SETUP_PATH . '/lib/functions.environment.php');
184: checkAndInclude(CON_SETUP_PATH . '/lib/functions.safe_mode.php');
185: checkAndInclude(CON_SETUP_PATH . '/lib/functions.mysql.php');
186: checkAndInclude(CON_SETUP_PATH . '/lib/functions.phpinfo.php');
187: checkAndInclude(CON_SETUP_PATH . '/lib/functions.libraries.php');
188: checkAndInclude(CON_SETUP_PATH . '/lib/functions.system.php');
189: checkAndInclude(CON_SETUP_PATH . '/lib/functions.sql.php');
190: checkAndInclude(CON_SETUP_PATH . '/lib/functions.setup.php');
191: checkAndInclude(CON_SETUP_PATH . '/lib/class.setupmask.php');
192: 
193: // PHP version check
194: if (false === isPHPCompatible()) {
195:     $sNotInstallableReason = 'php_version';
196:     checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
197: }
198: 
199: // PHP ini session check
200: if (getPHPIniSetting('session.use_cookies') == 0) {
201:     $sNotInstallableReason = 'session_use_cookies';
202:     checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
203: }
204: 
205: // PHP database extension check
206: $extension = getMySQLDatabaseExtension();
207: if (!is_null($extension)) {
208:     $cfg['database_extension'] = $extension;
209: } else {
210:     $sNotInstallableReason = 'database_extension';
211:     checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
212: }
213: 
214: if (isset($_SESSION['language'])) {
215:     i18nInit('locale/', $_SESSION['language'], 'setup');
216: }
217: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0