/** * Builds the upgrader page. * * @access public * @return string A block of valid XHTML to display an introduction and form. */ function Display() { // Get values $values = $this->_Defaults; foreach ($this->_Defaults as $name => $value) { if (isset($_SESSION['upgrade']['Database'][$name])) { $values[$name] = $_SESSION['upgrade']['Database'][$name]; } } $data = array(); if (isset($_SESSION['upgrade']['data']['Database'])) { $data = $_SESSION['upgrade']['data']['Database']; } $tpl = new Jaws_Template(false, false); $tpl->Load('display.html', 'stages/Database/templates'); $tpl->SetBlock('Database'); $tpl->setVariable('db_info', _t('UPGRADE_DB_INFO')); $tpl->SetVariable('next', _t('GLOBAL_NEXT')); if ($_SESSION['secure']) { $JCrypt = Jaws_Crypt::getInstance(array('pvt_key' => $_SESSION['pvt_key'], 'pub_key' => $_SESSION['pub_key'])); if (!Jaws_Error::IsError($JCrypt)) { $tpl->SetVariable('length', $JCrypt->length()); $tpl->SetVariable('modulus', $JCrypt->modulus()); $tpl->SetVariable('exponent', $JCrypt->exponent()); $tpl->SetVariable('func_onsubmit', 'EncryptPassword(this)'); } else { $_SESSION['secure'] = false; $tpl->SetVariable('func_onsubmit', 'true'); } } else { $_SESSION['pub_key'] = ''; $_SESSION['pvt_key'] = ''; $tpl->SetVariable('func_onsubmit', 'true'); } $fields = 0; if (!isset($data['host'])) { $fields++; $tpl->SetBlock('Database/host'); $tpl->setVariable('lbl_host', _t('UPGRADE_DB_HOST')); $tpl->setVariable('host_info', _t('UPGRADE_DB_HOST_INFO', 'localhost')); $tpl->SetVariable('host', $values['host']); $tpl->ParseBlock('Database/host'); } if (!isset($data['user'])) { $fields++; $tpl->SetBlock('Database/user'); $tpl->setVariable('lbl_user', _t('UPGRADE_DB_USER')); $tpl->setVariable('is_db_admin', _t('UPGRADE_DB_IS_ADMIN')); $tpl->SetVariable('user', $values['user']); $tpl->SetVariable('isdba_checked', empty($values['isdba']) || $values['isdba'] == 'false' ? '' : 'checked="checked"'); $tpl->ParseBlock('Database/user'); } if (!isset($data['password'])) { $fields++; $tpl->SetBlock('Database/password'); $tpl->setVariable('lbl_pass', _t('UPGRADE_DB_PASS')); $tpl->SetVariable('dbpass', ''); $tpl->ParseBlock('Database/password'); } if (!isset($data['name'])) { $fields++; $tpl->SetBlock('Database/name'); $tpl->setVariable('lbl_db_name', _t('UPGRADE_DB_NAME')); $tpl->SetVariable('name', $values['name']); $tpl->ParseBlock('Database/name'); } if (!isset($data['path'])) { $fields++; $tpl->SetBlock('Database/path'); $tpl->setVariable('lbl_db_path', _t('UPGRADE_DB_PATH')); $tpl->setVariable('path_info', _t('UPGRADE_DB_PATH_INFO')); $tpl->SetVariable('path', $values['path']); $tpl->ParseBlock('Database/path'); } if (!isset($data['port'])) { $fields++; $tpl->SetBlock('Database/port'); $tpl->setVariable('lbl_port', _t('UPGRADE_DB_PORT')); $tpl->setVariable('port_info', _t('UPGRADE_DB_PORT_INFO')); $tpl->SetVariable('port', $values['port']); $tpl->ParseBlock('Database/port'); } if (!isset($data['prefix'])) { $fields++; $tpl->SetBlock('Database/prefix'); $tpl->setVariable('lbl_prefix', _t('UPGRADE_DB_PREFIX')); $tpl->setVariable('prefix_info', _t('UPGRADE_DB_PREFIX_INFO')); $tpl->SetVariable('prefix', $values['prefix']); $tpl->ParseBlock('Database/prefix'); } // drivers if (!isset($data['driver'])) { $fields++; $tpl->SetBlock('Database/drivers'); $tpl->setVariable('lbl_driver', _t('UPGRADE_DB_DRIVER')); $drivers = array('mysqli' => array('ext' => 'mysqli', 'title' => 'MySQLi (4.1.3 and above)'), 'mysql' => array('ext' => 'mysql', 'title' => 'MySQL'), 'pgsql' => array('ext' => 'pgsql', 'title' => 'PostgreSQL'), 'oci8' => array('ext' => 'oci8', 'title' => 'Oracle'), 'mssql' => array('ext' => 'mssql', 'title' => 'MSSQL Server'), 'sqlsrv' => array('ext' => 'sqlsrv', 'title' => 'MSSQL Server(Microsoft Driver)'), 'ibase' => array('ext' => 'interbase', 'title' => 'Interbase/Firebird')); $modules = get_loaded_extensions(); $modules = array_map('strtolower', $modules); foreach ($drivers as $driver => $driver_info) { _log(JAWS_LOG_DEBUG, "Checking if " . $driver_info['title'] . "(" . $driver_info['ext'] . ") driver is available"); if (!in_array($driver_info['ext'], $modules)) { $available = false; //However... mssql support exists in some Linux distros with the sybase package if ($driver_info['ext'] == 'mssql' && function_exists('mssql_connect')) { $available = true; } if ($available === false) { _log(JAWS_LOG_DEBUG, "Driver " . $driver_info['title'] . "(" . $driver_info['ext'] . ") is NOT available"); continue; } } _log(JAWS_LOG_DEBUG, "Driver " . $driver_info['title'] . "(" . $driver_info['ext'] . ") is available"); $tpl->setBlock('Database/drivers/driver'); $tpl->setVariable('d_name', $driver); $tpl->setVariable('d_realname', $driver_info['title']); if (!empty($values['driver']) && $values['driver'] == $driver) { $selected = ' selected="selected"'; } else { $selected = ''; } $tpl->setVariable('d_selected', $selected); $tpl->ParseBlock('Database/drivers/driver'); } $tpl->ParseBlock('Database/drivers'); } if ($fields === 0 && !isset($GLOBALS['message'])) { $_SESSION['upgrade']['Database']['skip'] = '1'; header('Location: index.php'); } $tpl->ParseBlock('Database'); return $tpl->Get(); }
/** * Builds the upgrader page stage * * @access public * @return string A block of valid XHTML to display the requirements */ function Display() { $tpl = new Jaws_Template(false, false); $tpl->load('display.html', 'stages/Requirements/templates'); $tpl->setBlock('Requirements'); $tpl->setVariable('requirements', _t('UPGRADE_REQUIREMENTS')); $tpl->setVariable('requirement', _t('UPGRADE_REQ_REQUIREMENT')); $tpl->setVariable('optional', _t('UPGRADE_REQ_OPTIONAL')); $tpl->setVariable('recommended', _t('UPGRADE_REQ_RECOMMENDED')); $tpl->setVariable('directive', _t('UPGRADE_REQ_DIRECTIVE')); $tpl->setVariable('actual', _t('UPGRADE_REQ_ACTUAL')); $tpl->setVariable('result', _t('UPGRADE_REQ_RESULT')); $tpl->SetVariable('next', _t('GLOBAL_NEXT')); $modules = get_loaded_extensions(); $modules = array_map('strtolower', $modules); _log(JAWS_LOG_DEBUG, "Checking requirements..."); // PHP version $tpl->setBlock('Requirements/req_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_PHP_VERSION')); $tpl->setVariable('item_requirement', _t('UPGRADE_REQ_GREATER_THAN', MIN_PHP_VERSION)); $tpl->setVariable('item_actual', phpversion()); if (version_compare(phpversion(), MIN_PHP_VERSION, ">=") == 1) { _log(JAWS_LOG_DEBUG, "PHP installed version looks ok (>= " . MIN_PHP_VERSION . ")"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "PHP installed version (" . phpversion() . ") is not supported"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/req_item'); // config directory $tpl->setBlock('Requirements/req_item'); $result = $this->_check_path('config', 'r'); $tpl->setVariable('item', _t('UPGRADE_REQ_DIRECTORY', 'config')); $tpl->setVariable('item_requirement', _t('UPGRADE_REQ_READABLE')); $tpl->setVariable('item_actual', $this->_get_perms('config')); if ($result) { _log(JAWS_LOG_DEBUG, "config directory has read-permission privileges"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "config directory doesn't have read-permission privileges"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/req_item'); // data directory $tpl->setBlock('Requirements/req_item'); $result = $this->_check_path('data', 'rw'); $tpl->setVariable('item', _t('UPGRADE_REQ_DIRECTORY', 'data')); $tpl->setVariable('item_requirement', _t('UPGRADE_REQ_WRITABLE')); $tpl->setVariable('item_actual', $this->_get_perms('data')); if ($result) { _log(JAWS_LOG_DEBUG, "data directory has read and write permission privileges"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "data directory doesn't have read and write permission privileges"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/req_item'); // Database drivers $tpl->setBlock('Requirements/req_item'); $tpl->setVariable('item', implode('<br/>', $this->_db_drivers)); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $actual = ''; $db_state = false; foreach (array_keys($this->_db_drivers) as $ext) { $db_state = $db_state || in_array($ext, $modules); $actual .= (!empty($actual) ? '<br />' : '') . (in_array($ext, $modules) ? $ext : '-----'); } $tpl->setVariable('item_actual', $actual); if ($db_state) { _log(JAWS_LOG_DEBUG, "Available database drivers: {$actual}"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "No database driver found"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/req_item'); // XML extension $tpl->setBlock('Requirements/req_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_EXTENSION', 'XML')); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $tpl->setVariable('item_actual', in_array('xml', $modules) ? _t('GLOBAL_YES') : _t('GLOBAL_NO')); if (in_array('xml', $modules)) { _log(JAWS_LOG_DEBUG, "xml support is enabled"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "xml support is not enabled"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/req_item'); // File Upload $tpl->setBlock('Requirements/rec_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_FILE_UPLOAD')); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $check = (bool) ini_get('file_uploads'); $tpl->setVariable('item_actual', $check ? _t('GLOBAL_YES') : _t('GLOBAL_NO')); if ($check) { _log(JAWS_LOG_DEBUG, "PHP accepts file uploads"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "PHP doesn't accept file uploads"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/rec_item'); // Safe mode $tpl->setBlock('Requirements/rec_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_SAFE_MODE')); $tpl->setVariable('item_requirement', _t('UPGRADE_REQ_OFF')); $safe_mode = (bool) ini_get('safe_mode'); $tpl->setVariable('item_actual', $safe_mode ? _t('UPGRADE_REQ_ON') : _t('UPGRADE_REQ_OFF')); if ($safe_mode) { _log(JAWS_LOG_DEBUG, "PHP has safe-mode turned on"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "PHP has safe-mode turned off"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/rec_item'); // GD/ImageMagick $tpl->setBlock('Requirements/rec_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_EXTENSION', 'GD/ImageMagick')); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $actual = in_array('gd', $modules) ? 'GD' : ''; $actual .= in_array('magickwand', $modules) ? (empty($actual) ? '' : ' + ') . 'ImageMagick' : ''; $actual = empty($actual) ? 'No' : $actual; $tpl->setVariable('item_actual', $actual); if (in_array('gd', $modules) || in_array('magickwand', $modules)) { _log(JAWS_LOG_DEBUG, "PHP has GD or ImageMagick turned on"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "PHP has GD or ImageMagick turned off"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/rec_item'); // Exif extension $tpl->setBlock('Requirements/rec_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_EXTENSION', 'Exif')); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $tpl->setVariable('item_actual', in_array('exif', $modules) ? _t('GLOBAL_YES') : _t('GLOBAL_NO')); if (in_array('exif', $modules)) { _log(JAWS_LOG_DEBUG, "exif support is enabled"); $result_txt = '<span style="color: #0b0;">' . _t('UPGRADE_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "exif support is not enabled"); $result_txt = '<span style="color: #b00;">' . _t('UPGRADE_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/rec_item'); // OpenSSL extension $tpl->setBlock('Requirements/rec_item'); $tpl->setVariable('item', _t('UPGRADE_REQ_EXTENSION', 'OpenSSL')); $tpl->setVariable('item_requirement', _t('GLOBAL_YES')); $tpl->setVariable('item_actual', in_array('openssl', $modules) ? _t('GLOBAL_YES') : _t('GLOBAL_NO')); if (in_array('openssl', $modules)) { _log(JAWS_LOG_DEBUG, "openssl extension is loaded"); $result_txt = '<span style="color: #0b0;">' . _t('INSTALL_REQ_OK') . '</span>'; } else { _log(JAWS_LOG_DEBUG, "openssl extension is not loaded"); $result_txt = '<span style="color: #b00;">' . _t('INSTALL_REQ_BAD') . '</span>'; } $tpl->setVariable('result', $result_txt); $tpl->parseBlock('Requirements/rec_item'); $tpl->parseBlock('Requirements'); return $tpl->get(); }
$tpl->ParseBlock('page/stage'); } } if (isset($GLOBALS['message'])) { switch ($GLOBALS['message']->getLevel()) { case JAWS_ERROR_INFO: $type = 'info'; break; case JAWS_ERROR_WARNING: $type = 'warning'; break; case JAWS_ERROR_ERROR: $type = 'error'; break; } $tpl->setBlock('page/message'); $tpl->setVariable('text', $GLOBALS['message']->getMessage()); $tpl->setVariable('type', $type); $tpl->parseBlock('page/message'); } $tpl->ParseBlock('page'); // Defines where the layout template should be loaded from. $direction = _t('GLOBAL_LANG_DIRECTION'); $dir = $direction == 'rtl' ? '.' . $direction : ''; // Display the layout $layout = new Jaws_Template(false, false); $layout->Load('layout.html', 'templates'); $layout->SetBlock('layout'); // Basic setup $layout->SetVariable('BASE_URL', Jaws_Utils::getBaseURL('/install/')); $layout->SetVariable('.dir', $dir);