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