Attached Files |
CheckSystem_Requirements.png [^] (58,029 bytes) 2011-12-06 13:09

system_requirements_413.patch [^] (20,058 bytes) 2011-12-09 10:18
[Show Content]
Index: install.php
===================================================================
--- install.php (revision 14858)
+++ install.php (working copy)
@@ -68,14 +68,15 @@
* @var Array
*/
var $steps = Array (
- 'fresh_install' => Array ('check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
- 'clean_reinstall' => Array ('check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'fresh_install' => Array ('sys_requirements', 'check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'clean_reinstall' => Array ('initial', 'sys_requirements', 'check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
'already_installed' => Array ('check_paths', 'install_setup'),
'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'skin_upgrade', 'security', 'finish'),
'update_license' => Array ('check_paths', 'install_setup', 'select_license', /*'download_license',*/ 'select_domain', 'security', 'finish'),
'update_config' => Array ('check_paths', 'install_setup', 'sys_config', 'security', 'finish'),
'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'security', 'finish'),
+ 'sys_requirements' => Array ('check_paths', 'install_setup', 'sys_requirements', 'security', 'finish')
);
/**
@@ -83,14 +84,14 @@
*
* @var Array
*/
- var $skipLoginSteps = Array ('check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
+ var $skipLoginSteps = Array ('sys_requirements', 'check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
/**
* Steps, on which kApplication should not be initialized, because of missing correct db table structure
*
* @var Array
*/
- var $skipApplicationSteps = Array ('check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
+ var $skipApplicationSteps = Array ('sys_requirements', 'check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
/**
* Folders that should be writeable to continue installation. $1 - main writeable folder from config.php ("/system" by default)
@@ -198,6 +199,7 @@
}
$this->InitStep();
+
}
function SetFirstStep()
@@ -277,6 +279,14 @@
}
switch ($this->currentStep) {
+ case 'sys_requirements':
+ if (!isset($_POST['errors']) || $_POST['refresh_form'] == 'Refresh') {
+ $this->errorMessage = ' ';
+ }
+ if (isset($_POST['errors']) && $_POST['errors']) {
+ $this->errorMessage = '<br/>Installation can not continue until all required environment parameters are set correctly';
+ }
+ break;
case 'check_paths':
$writeable_base = $this->toolkit->getSystemConfig('Misc', 'WriteablePath');
foreach ($this->writeableFolders as $folder_path) {
@@ -324,6 +334,14 @@
$this->toolkit->setSystemConfig('Database', $field_name, '');
}*/
}
+
+// if (!isset($_POST['errors']) || $_POST['refresh_form'] == 'Refresh') {
+// $this->errorMessage = ' ';
+// }
+// if (isset($_POST['errors']) && $_POST['errors']) {
+// $this->errorMessage = '<br/>Installation can not continue until all required environment parameters are set correctly';
+// }
+//
break;
case 'download_license':
@@ -509,6 +527,14 @@
break;
}
}
+
+ // 2. Check DB requirements
+ $db_check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckDBRequirements');
+ if (!$db_check_results['version'] || !$db_check_results['packet_size']) {
+ $status = false;
+ $this->errorMessage = '<br/>Installation can not continue until all required environment parameters are set correctly';
+ }
+
if (!$status) break;
// 2. check permissions, that use have in this database
@@ -1019,11 +1045,11 @@
return ;
}
+ $this->InitApplication();
+
$this->currentStep = $this->GetNextStep();
$this->InitStep(); // init next step (that will be shown now)
- $this->InitApplication();
-
if ($this->currentStep == -1) {
// step after last step -> redirect to admin
$this->Application->Redirect('index', Array (), '', 'index.php');
@@ -1267,6 +1293,17 @@
$this->errorMessage = $error_message;
}
+ if ($this->currentStep == 'sys_requirements') {
+ if (isset($_REQUEST['cookies']) && $_REQUEST['cookies']) {
+ setcookie('test', $_REQUEST['cookies'], time()+3600);
+ } else {
+ $random_number = rand(1000000, 9999999);
+ setcookie('test', $random_number, time()+3600);
+ header('Location:'.$_SERVER['PHP_SELF'].'?cookies='.$random_number.'&preset='.$this->stepsPreset.'&step='.$this->currentStep);
+ exit;
+ }
+ }
+
include_once (FULL_PATH . '/' . REL_PATH . '/install/incs/install.tpl');
if ( isset($this->Application) ) {
@@ -1496,6 +1533,7 @@
*/
function GetStepBody()
{
+
$step_template = FULL_PATH.'/core/install/step_templates/'.$this->currentStep.'.tpl';
if (file_exists($step_template)) {
ob_start();
@@ -1642,6 +1680,9 @@
$step_titles = $this->_getStepTitles($this->steps[$this->stepsPreset]);
foreach ($this->steps[$this->stepsPreset] as $step_name) {
+ if ($step_name == 'initial') {
+ continue;
+ }
$template = $step_name == $this->currentStep ? $active_tpl : $passive_tpl;
$ret .= sprintf($template, $step_titles[$step_name]);
}
@@ -1691,7 +1732,7 @@
{
$button_visibility = Array (
'continue' => $this->GetNextStep() != -1 || ($this->stepsPreset == 'already_installed'),
- 'refresh' => in_array($this->currentStep, Array ('check_paths', 'security')),
+ 'refresh' => in_array($this->currentStep, Array ('check_paths', 'security', 'sys_requirements')),
'back' => in_array($this->currentStep, Array (/*'select_license',*/ 'download_license', 'select_domain')),
);
@@ -1707,4 +1748,39 @@
return array_key_exists($name, $button_visibility) ? $button_visibility[$name] : true;
}
+
+ function PrintDBRequirements()
+ {
+ $heading_tpl = '
+ <tr class="subsectiontitle">
+ <td class="text" colspan="2" style="border-top: 1px solid #000000; border-bottom: 1px solid #000000;">%s</td>
+ </tr>';
+
+ $error_tpl = '
+ <tr class="table-color2">
+ <td class="text">%s</td>
+ <td align="center" width="30">%s</td>
+ </tr>';
+
+ $check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckDBRequirements');
+
+ $output = sprintf($heading_tpl, '<strong>Server-side requirements</strong>');
+
+ $checks = Array (
+ 'version' => 'MySQL version: 5.0+ (required)',
+ 'packet_size' => 'MySQL Packet Size: 1MB min (required)',
+ );
+
+ foreach ($checks AS $key => $label) {
+ $error = '';
+ if (isset($check_results[$key])) {
+ $error = $check_results[$key] ? '[<span style="color:green;">PASSED</span>]' : '[<span class="error">FAILED</span>]';
+ }
+ $output .= sprintf($error_tpl, $label, $error);
+ }
+
+ $output .= sprintf($heading_tpl, '<strong>Database configuration</strong>', 'text');
+
+ echo $output;
+ }
}
Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 14858)
+++ install/install_toolkit.php (working copy)
@@ -159,6 +159,40 @@
}
/**
+ * Call prerequisites method
+ *
+ * @param string $module_path
+ * @param string $method
+ * @return array
+ */
+ function CallPrerequisitesMethod($module_path, $method)
+ {
+ static $prerequisit_classes = Array ();
+
+ $prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
+ if ( !file_exists($prerequisites_file)) {
+ return Array ();
+ }
+
+ if ( !isset($prerequisit_classes[$module_path]) ) {
+ // save class name, because 2nd time
+ // (in after call $prerequisite_class variable will not be present)
+ include_once $prerequisites_file;
+ $prerequisit_classes[$module_path] = $prerequisite_class;
+ }
+
+ $prerequisite_object = new $prerequisit_classes[$module_path]();
+ /* @var $prerequisite_object InPortalPrerequisites */
+
+ if ( method_exists($prerequisite_object, 'setToolkit') ) {
+ $prerequisite_object->setToolkit($this);
+ }
+
+ // some errors possible
+ return $prerequisite_object->$method();
+ }
+
+ /**
* Processes one license, received from server
*
* @param string $file_data
Index: install/prerequisites.php
===================================================================
--- install/prerequisites.php (revision 14858)
+++ install/prerequisites.php (working copy)
@@ -20,7 +20,7 @@
* Class, that holds all prerequisite scripts for "In-Portal" module
*
*/
- class InPortalPrerequisites extends kHelper {
+ class InPortalPrerequisites {
/**
* Install toolkit instance
@@ -30,6 +30,14 @@
var $_toolkit = null;
/**
+ * Connection to database
+ *
+ * @var kDBConnection
+ * @access protected
+ */
+ protected $Conn = null;
+
+ /**
* Sets common instance of installator toolkit
*
* @param kInstallToolkit $instance
@@ -42,6 +50,16 @@
/**
* Checks minimal version, that could be upgradeable
*
+ * @return kDBConnection
+ */
+ function &getConnection()
+ {
+ return $this->_toolkit->Conn;
+ }
+
+ /**
+ * Checks minimal version, that could be upgradeable
+ *
* @param Array $versions
* @param string $mode when called mode {install, upgrade, standalone)
* @return Array
@@ -54,8 +72,10 @@
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
- $inportal_version = $this->Conn->GetOne($sql);
+ $conn =& $this->getConnection();
+ $inportal_version = $conn->GetOne($sql);
+
if ($inportal_version === false) {
// only, when In-Portal was installed
return $errors;
@@ -72,4 +92,79 @@
return $errors;
}
+
+ /**
+ * Returns information about system requirements
+ *
+ * @return array
+ */
+ function CheckSystemRequirements()
+ {
+ // check PHP version 5.2+
+ $ret = Array();
+
+ $version_parts = explode('.', PHP_VERSION);
+ $ret['php_version'] = $version_parts[0] > 5 || ($version_parts[0] == 5 && $version_parts[1] > 1);
+
+ $ret['url_rewriting'] = function_exists('apache_get_modules') && in_array('mod_rewrite',apache_get_modules());
+ $ret['memcache'] = class_exists('Memcache');
+ $ret['curl'] = function_exists('curl_init');
+ $ret['freetype'] = function_exists('imagettfbbox');
+
+ $ret['gd_version'] = 0;
+ $ret['jpeg'] = 0;
+ if (function_exists('gd_info')) {
+ $gd_info = gd_info();
+ preg_match_all('/\d+/', $gd_info['GD Version'], $version_parts);
+ $ret['gd_version'] = $version_parts[0][0] > 1 || ($version_parts[0][0] == 1 && $version_parts[0][1] > 7);
+ $ret['jpeg'] = isset($gd_info['JPEG Support']) && $gd_info['JPEG Support'];
+ }
+ $ret['mysql'] = function_exists('mysql_connect');
+ $ret['json'] = function_exists('json_encode');
+
+ $original_memory_limit = ini_get('memory_limit');
+ ini_set('memory_limit', $original_memory_limit == '32M' ? '40M' : '32M');
+ $ret['memory_limit'] = 0;
+ if ($original_memory_limit != ini_get('memory_limit')) {
+ $ret['memory_limit'] = 1;
+ ini_set('memory_limit', $original_memory_limit);
+ }
+
+ $original_timezone = ini_get('date.timezone');
+ ini_set('date.timezone', $original_timezone == 'Asia/Delhi' ? 'Europe/London' : 'Asia/Delhi');
+ $ret['date.timezone'] = 0;
+ if ($original_timezone != ini_get('date.timezone')) {
+ $ret['date.timezone'] = 1;
+ ini_set('date.timezone', $original_timezone);
+ }
+ $ret['variables_order'] = (strpos(ini_get('variables_order'), 'GPC') !== false);
+ $ret['output_buffering'] = (ini_get('output_buffering') > 0);
+
+ return $ret;
+ }
+
+ /**
+ * Returns information about DB requirements
+ *
+ * @return array
+ */
+ function CheckDBRequirements()
+ {
+ // check PHP version 5.2+
+ $ret = Array();
+
+ $sql = 'SELECT version()';
+ $conn =& $this->getConnection();
+
+ $db_version = $conn->GetOne($sql);
+ $version_parts = explode('.', $db_version);
+ $ret['version'] = $version_parts[0] >= 5;
+
+ $sql = 'SHOW VARIABLES LIKE \'max_allowed_packet\'';
+ $a_db_variables = $conn->Query($sql, 'Variable_name');
+ $ret['packet_size'] = $a_db_variables['max_allowed_packet']['Value'] >= 1048576;
+
+ return $ret;
+ }
+
}
\ No newline at end of file
Index: install/step_templates/db_config.tpl
===================================================================
--- install/step_templates/db_config.tpl (revision 14858)
+++ install/step_templates/db_config.tpl (working copy)
@@ -1,3 +1,5 @@
+<?php $this->PrintDBRequirements(); ?>
+
<tr class="table-color2">
<td class="text"><b>Database Server Type<span class="error">*</span>:</b></td>
<td align="left">
@@ -67,7 +69,7 @@
</tr>
<?php if ($this->GetVar('preset') != 'already_installed') { ?>
-<!--show this option ONLY when config.php is empty or cant connect to In-Portal installation using current DB settings -->
+<!--show this option ONLY when config.php is empty or cant connect to In-Portal installation using current DB settings -->
<tr class="table-color2">
<td class="text" width="55%"><b>Use existing In-Portal installation in this Database:</b></td>
<td align="left">
Index: install/step_templates/db_reconfig.tpl
===================================================================
--- install/step_templates/db_reconfig.tpl (revision 14858)
+++ install/step_templates/db_reconfig.tpl (working copy)
@@ -1,3 +1,5 @@
+<?php $this->PrintDBRequirements(); ?>
+
<tr class="table-color2">
<td class="text"><b>Database Server Type<span class="error">*</span>:</b></td>
<td align="left">
Index: install/step_templates/install_setup.tpl
===================================================================
--- install/step_templates/install_setup.tpl (revision 14858)
+++ install/step_templates/install_setup.tpl (working copy)
@@ -32,6 +32,7 @@
$option_tpl = ob_get_clean();
$options = Array (
+ 'sys_requirements' => 'Check System Requirements',
'upgrade' => 'Upgrade In-Portal',
'clean_reinstall' => 'Reinstall In-Portal',
'fresh_install' => 'Install In-Portal to a New Database',
Index: install/step_templates/sys_requirements.tpl
===================================================================
--- install/step_templates/sys_requirements.tpl (revision 0)
+++ install/step_templates/sys_requirements.tpl (revision 0)
@@ -0,0 +1,107 @@
+<?php
+ $cookies_enabled = 0;
+ if(isset($_COOKIE['test']) && $_COOKIE['test'] == $_REQUEST['cookies']) {
+ $cookies_enabled = 1;
+ }
+
+ $heading_tpl = '
+ <tr class="subsectiontitle">
+ <td class="text" colspan="2" style="border-top: 1px solid #000000; border-bottom: 1px solid #000000;">%s</td>
+ </tr>';
+
+ $error_tpl = '
+ <tr class="table-color2">
+ <td class="text">%s</td>
+ <td align="center" width="30">%s</td>
+ </tr>';
+
+ $check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckSystemRequirements');
+
+ $output = sprintf($heading_tpl, '<strong>Server-side requirements</strong>');
+
+ $checks = Array (
+ 'php_version' => 'PHP version: 5.2+ (required)',
+ 'url_rewriting' => 'URL Rewriting Support (optional)',
+ '' => 'PHP extensions:',
+ 'memcache' => '- Memcache (optional)',
+ 'curl' => '- Curl (required)',
+ 'freetype' => '- Freetype (required)',
+ 'gd_version' => '- GD 1.8+ (required)',
+ 'jpeg' => '- jpeg (required)',
+ 'mysql' => '- MySQL (required)',
+ 'json' => '- JSON (optional)',
+ ' ' => 'PHP settings:',
+ 'memory_limit' => '- ini_set(\'memory_limit\', ...) works (optional)',
+ 'date.timezone' => '- ini_get(\'date.timezone\') - timezone set (required)',
+ 'variables_order' => '- ini_get(\'variables_order\') - contains "GPC" string',
+ 'output_buffering' => '- ini_get(\'output_buffering\') > 0 - buffering works (required)',
+ );
+
+ $required_checks = Array (
+ 'php_version',
+ 'curl',
+ 'freetype',
+ 'gd_version',
+ 'jpeg',
+ 'mysql',
+ 'date.timezone',
+ 'output_buffering',
+ );
+
+
+ $has_error = !$cookies_enabled;
+ foreach ($checks AS $key => $label) {
+ $error = '';
+ if (isset($check_results[$key])) {
+ if (!$check_results[$key] && in_array($key, $required_checks)) {
+ $has_error = 1;
+ }
+ $error = $check_results[$key] ? '[<span style="color:green;">PASSED</span>]' : '[<span class="error">FAILED</span>]';
+ }
+ $output .= sprintf($error_tpl, $label, $error);
+ }
+
+//PHP version: 5.2+ (required)
+//MySQL version: 5.1+ (required)
+//MySQL Packet Size: 2MB min (required for large website, optional for small website)
+//URL Rewriting Support: yes/no (optional)
+//PHP extensions:
+//- Memcache (optional); Memcache class
+//- Curl (required); curl_init function
+//- Freetype (required); imagettfbbox function
+//- GD 1.8+ (required)
+//- jpeg (required)
+//- MySQL; mysql_connect function (required)
+//- JSON (optional); json_encode function
+//- Java (optional); run "java args" (need to determine args that cause error on incorrectly installed java)
+//
+//PHP settings:
+//- ini_set('memory_limit', ...) - works/don't work (optional)
+//- ini_get('date.timezone') - timezone set/not set (required)
+//- ini_get('gpc_order') - contains "GPC" string
+//- ini_get('output_buffering') > 0 - buffering works (required)
+//
+
+ $output .= sprintf($heading_tpl, '<strong>Client-side requirements</strong>', 'text');
+
+ $error = $cookies_enabled ? '[<span style="color:green;">PASSED</span>]': '[<span class="error">FAILED</span>]';
+ $output .= sprintf($error_tpl, 'Cookies enabled', $error);
+
+ $output .= '<input type="hidden" id="cookies" name="cookies" value="'.$_REQUEST['cookies'].'"/>';
+ $output .= '<input type="hidden" id="errors" name="errors" value="1"/>';
+ $output .= '<input type="hidden" id="has_error_beyound_js" name="has_error_beyound_js" value="'.$has_error.'"/>';
+
+ $output .= '
+ <tr class="table-color2">
+ <td class="text">JavaScript enabled</td>
+ <td align="center" width="30">[<span id="check_javascript" class="error">FAILED</span>]</td>
+ </tr>
+ <script type="text/javascript">
+ $("#check_javascript").attr("class","").css("color","green").html("PASSED");
+ if (!$("#has_error_beyound_js").val()) {
+ $("#errors").val("");
+ }
+ </script>
+ ';
+ echo $output;
+?>
\ No newline at end of file
Index: install/steps_db.xml
===================================================================
--- install/steps_db.xml (revision 14858)
+++ install/steps_db.xml (working copy)
@@ -207,4 +207,7 @@
The characters entered in this field are placed <i>before</i> the names of the tables used by In-Portal.
For example, if you enter "inp_" into the prefix field, the table named Category will be named inp_Category.</p>]]>
</step>
+ <step name="sys_requirements" title="System Requirements Check">
+ <![CDATA[The <i>System Requirements Check</i> option should be used to ensure proper system behavior in the current environment.]]>
+ </step>
</steps>
\ No newline at end of file
system_requirements_v2.patch [^] (16,006 bytes) 2011-12-12 05:33
[Show Content]
Index: install.php
===================================================================
--- install.php (revision 14858)
+++ install.php (working copy)
@@ -68,14 +68,15 @@
* @var Array
*/
var $steps = Array (
- 'fresh_install' => Array ('check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
- 'clean_reinstall' => Array ('check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'fresh_install' => Array ('sys_requirements', 'check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'clean_reinstall' => Array ('install_setup', 'sys_requirements', 'check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
'already_installed' => Array ('check_paths', 'install_setup'),
'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'skin_upgrade', 'security', 'finish'),
'update_license' => Array ('check_paths', 'install_setup', 'select_license', /*'download_license',*/ 'select_domain', 'security', 'finish'),
'update_config' => Array ('check_paths', 'install_setup', 'sys_config', 'security', 'finish'),
'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'security', 'finish'),
+ 'sys_requirements' => Array ('check_paths', 'install_setup', 'sys_requirements', 'security', 'finish')
);
/**
@@ -83,14 +84,14 @@
*
* @var Array
*/
- var $skipLoginSteps = Array ('check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
+ var $skipLoginSteps = Array ('sys_requirements', 'check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
/**
* Steps, on which kApplication should not be initialized, because of missing correct db table structure
*
* @var Array
*/
- var $skipApplicationSteps = Array ('check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
+ var $skipApplicationSteps = Array ('sys_requirements', 'check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
/**
* Folders that should be writeable to continue installation. $1 - main writeable folder from config.php ("/system" by default)
@@ -277,6 +278,29 @@
}
switch ($this->currentStep) {
+ case 'sys_requirements':
+ $required_checks = Array (
+ 'php_version', 'curl', 'freetype', 'gd_version',
+ 'jpeg', 'mysql', 'date.timezone', 'output_buffering',
+ );
+
+ $check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckSystemRequirements');
+ $required_checks = array_diff($required_checks, array_keys( array_filter($check_results) ));
+
+ if ( $required_checks ) {
+ // php-based checks failed - show error
+ $this->errorMessage = '<br/>Installation can not continue until all required environment parameters are set correctly';
+ }
+ elseif ( $this->GetVar('js_enabled') === false ) {
+ // can't check JS without form submit - set some fake error, so user stays on this step
+ $this->errorMessage = ' ';
+ }
+ elseif ( !$this->GetVar('js_enabled') || !$this->GetVar('cookies_enabled') ) {
+ // js/cookies disabled
+ $this->errorMessage = '<br/>Installation can not continue until all required environment parameters are set correctly';
+ }
+ break;
+
case 'check_paths':
$writeable_base = $this->toolkit->getSystemConfig('Misc', 'WriteablePath');
foreach ($this->writeableFolders as $folder_path) {
@@ -509,8 +533,11 @@
break;
}
}
- if (!$status) break;
+ if ( !$status ) {
+ break;
+ }
+
// 2. check permissions, that use have in this database
$status = $this->CheckDatabase(($this->currentStep == 'db_config') && !$this->GetVar('UseExistingSetup'));
break;
@@ -1318,8 +1345,8 @@
// perform various check type to database specified
// 1. user is allowed to connect to database
// 2. user has all types of permissions in database
+ // 3. database environment settings met minimum requirements
-
if (mb_strlen($this->toolkit->getSystemConfig('Database', 'TablePrefix')) > 7) {
$this->errorMessage = 'Table prefix should not be longer than 7 characters';
return false;
@@ -1354,6 +1381,22 @@
$this->errorMessage = 'An In-Portal Database already exists at this location';
return false;
}
+
+ $requirements_error = Array ();
+ $db_check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckDBRequirements');
+
+ if ( !$db_check_results['version'] ) {
+ $requirements_error[] = '- MySQL Version is below 5.0';
+ }
+
+ if ( !$db_check_results['packet_size'] ) {
+ $requirements_error[] = '- MySQL Packet Size is below 1 MB';
+ }
+
+ if ( $requirements_error ) {
+ $this->errorMessage = 'Connection successful, but following system requirements were not met:<br/>' . implode('<br/>', $requirements_error);
+ return false;
+ }
}
else {
// user has insufficient permissions in database specified
@@ -1691,7 +1734,7 @@
{
$button_visibility = Array (
'continue' => $this->GetNextStep() != -1 || ($this->stepsPreset == 'already_installed'),
- 'refresh' => in_array($this->currentStep, Array ('check_paths', 'security')),
+ 'refresh' => in_array($this->currentStep, Array ('sys_requirements', 'check_paths', 'security')),
'back' => in_array($this->currentStep, Array (/*'select_license',*/ 'download_license', 'select_domain')),
);
Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 14858)
+++ install/install_toolkit.php (working copy)
@@ -159,6 +159,40 @@
}
/**
+ * Call prerequisites method
+ *
+ * @param string $module_path
+ * @param string $method
+ * @return array
+ */
+ function CallPrerequisitesMethod($module_path, $method)
+ {
+ static $prerequisit_classes = Array ();
+
+ $prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
+ if ( !file_exists($prerequisites_file)) {
+ return Array ();
+ }
+
+ if ( !isset($prerequisit_classes[$module_path]) ) {
+ // save class name, because 2nd time
+ // (in after call $prerequisite_class variable will not be present)
+ include_once $prerequisites_file;
+ $prerequisit_classes[$module_path] = $prerequisite_class;
+ }
+
+ $prerequisite_object = new $prerequisit_classes[$module_path]();
+ /* @var $prerequisite_object InPortalPrerequisites */
+
+ if ( method_exists($prerequisite_object, 'setToolkit') ) {
+ $prerequisite_object->setToolkit($this);
+ }
+
+ // some errors possible
+ return $prerequisite_object->$method();
+ }
+
+ /**
* Processes one license, received from server
*
* @param string $file_data
Index: install/prerequisites.php
===================================================================
--- install/prerequisites.php (revision 14858)
+++ install/prerequisites.php (working copy)
@@ -20,7 +20,7 @@
* Class, that holds all prerequisite scripts for "In-Portal" module
*
*/
- class InPortalPrerequisites extends kHelper {
+ class InPortalPrerequisites {
/**
* Install toolkit instance
@@ -30,6 +30,14 @@
var $_toolkit = null;
/**
+ * Connection to database
+ *
+ * @var kDBConnection
+ * @access protected
+ */
+ protected $Conn = null;
+
+ /**
* Sets common instance of installator toolkit
*
* @param kInstallToolkit $instance
@@ -42,6 +50,16 @@
/**
* Checks minimal version, that could be upgradeable
*
+ * @return kDBConnection
+ */
+ function &getConnection()
+ {
+ return $this->_toolkit->Conn;
+ }
+
+ /**
+ * Checks minimal version, that could be upgradeable
+ *
* @param Array $versions
* @param string $mode when called mode {install, upgrade, standalone)
* @return Array
@@ -54,8 +72,10 @@
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
- $inportal_version = $this->Conn->GetOne($sql);
+ $conn =& $this->getConnection();
+ $inportal_version = $conn->GetOne($sql);
+
if ($inportal_version === false) {
// only, when In-Portal was installed
return $errors;
@@ -72,4 +92,87 @@
return $errors;
}
+
+ /**
+ * Returns information about system requirements
+ *
+ * @return array
+ */
+ function CheckSystemRequirements()
+ {
+ $ret = Array ();
+ $ret['php_version'] = version_compare(PHP_VERSION, '5.2.0', '>=');
+
+ $ret['url_rewriting'] = function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules());
+ $ret['memcache'] = class_exists('Memcache');
+ $ret['curl'] = function_exists('curl_init');
+ $ret['freetype'] = function_exists('imagettfbbox');
+
+ $ret['gd_version'] = $ret['jpeg'] = false;
+
+ if ( function_exists('gd_info') ) {
+ $gd_info = gd_info();
+
+ $gd_version = preg_replace('/[^\d.]/', '', $gd_info['GD Version']);
+ $ret['gd_version'] = version_compare($gd_version, '1.8', '>=');
+
+ $ret['jpeg'] = isset($gd_info['JPEG Support']) && $gd_info['JPEG Support'];
+ }
+
+ $ret['mysql'] = function_exists('mysql_connect');
+ $ret['json'] = function_exists('json_encode');
+
+ $ret['memory_limit'] = $this->isPhpSettingChangeable('memory_limit', '33M');
+ $ret['date.timezone'] = ini_get('date.timezone') != '';
+
+ $ret['variables_order'] = strpos(ini_get('variables_order'), 'GPC') !== false;
+ $ret['output_buffering'] = ini_get('output_buffering') > 0;
+
+ return $ret;
+ }
+
+ /**
+ * Detects if setting of php.ini can be changed
+ *
+ * @param string $setting_name
+ * @param string $new_value
+ * @return bool
+ */
+ protected function isPhpSettingChangeable($setting_name, $new_value)
+ {
+ $backup_value = ini_get($setting_name);
+ ini_set($setting_name, $new_value);
+
+ if ( ini_get($setting_name) != $backup_value ) {
+ ini_set($setting_name, $backup_value);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns information about DB requirements
+ *
+ * @return array
+ */
+ function CheckDBRequirements()
+ {
+ // check PHP version 5.2+
+ $ret = Array();
+
+ $sql = 'SELECT VERSION()';
+ $conn =& $this->getConnection();
+
+ $db_version = preg_replace('/[^\d.]/', '', $conn->GetOne($sql));
+ $ret['version'] = version_compare($db_version, '5.0', '>=');
+
+ $sql = 'SHOW VARIABLES LIKE "max_allowed_packet"';
+ $db_variables = $conn->Query($sql, 'Variable_name');
+
+ $ret['packet_size'] = $db_variables['max_allowed_packet']['Value'] >= 1048576;
+
+ return $ret;
+ }
}
\ No newline at end of file
Index: install/step_templates/install_setup.tpl
===================================================================
--- install/step_templates/install_setup.tpl (revision 14858)
+++ install/step_templates/install_setup.tpl (working copy)
@@ -32,6 +32,7 @@
$option_tpl = ob_get_clean();
$options = Array (
+ 'sys_requirements' => 'Check System Requirements',
'upgrade' => 'Upgrade In-Portal',
'clean_reinstall' => 'Reinstall In-Portal',
'fresh_install' => 'Install In-Portal to a New Database',
Index: install/step_templates/sys_requirements.tpl
===================================================================
--- install/step_templates/sys_requirements.tpl (revision 0)
+++ install/step_templates/sys_requirements.tpl (revision 0)
@@ -0,0 +1,73 @@
+<?php
+ $heading_tpl = '
+ <tr class="subsectiontitle">
+ <td class="text" colspan="2" style="border-top: 1px solid #000000; border-bottom: 1px solid #000000;">%s</td>
+ </tr>';
+
+ $error_tpl = '
+ <tr class="table-color2">
+ <td class="text">%s</td>
+ <td align="center" width="30">%s</td>
+ </tr>';
+
+ $check_titles = Array (
+ 'php_version' => 'PHP version: 5.2+ (required)',
+ 'url_rewriting' => 'URL Rewriting Support (optional)',
+ 'sep1' => '<strong>PHP extensions:</strong>',
+ 'memcache' => '- Memcache (optional)',
+ 'curl' => '- Curl (required)',
+ 'freetype' => '- Freetype (required)',
+ 'gd_version' => '- GD 1.8+ (required)',
+ 'jpeg' => '- jpeg (required)',
+ 'mysql' => '- MySQL (required)',
+ 'json' => '- JSON (optional)',
+ 'sep2' => '<strong>PHP settings:</strong>',
+ 'memory_limit' => "- ini_set('memory_limit', ...) works (optional)",
+ 'date.timezone' => "- ini_get('date.timezone') - timezone set (required)",
+ 'variables_order' => "- ini_get('variables_order') - contains \"GPC\" string",
+ 'output_buffering' => "- ini_get('output_buffering') > 0 - buffering works (required)",
+ );
+
+ $output = sprintf($heading_tpl, '<strong>Server-side requirements</strong>');
+ $check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckSystemRequirements');
+
+ /*$required_checks = Array (
+ 'php_version', 'curl', 'freetype', 'gd_version',
+ 'jpeg', 'mysql', 'date.timezone', 'output_buffering',
+ );
+
+ $required_checks = array_diff($required_checks, array_keys( array_filter($check_results) ));*/
+
+ foreach ($check_titles AS $key => $title) {
+ if ( substr($key, 0, 3) == 'sep' ) {
+ $check_result = '';
+ }
+ else {
+ $check_result = $check_results[$key] ? '[<span style="color:green;">PASSED</span>]' : '[<span class="error">FAILED</span>]';
+ }
+
+ $output .= sprintf($error_tpl, $title, $check_result);
+ }
+
+ $output .= sprintf($heading_tpl, '<strong>Client-side requirements</strong>', 'text');
+ $output .= sprintf($error_tpl, 'Cookies enabled', '[<span class="error" id="cookies_enabled_mark">FAILED</span>]');
+ $output .= sprintf($error_tpl, 'JavaScript enabled', '[<span class="error" id="js_enabled_mark">FAILED</span>]');
+
+ $output .= '<input type="hidden" name="js_enabled" id="js_enabled" value="0"/>';
+ $output .= '<input type="hidden" name="cookies_enabled" id="cookies_enabled" value="0"/>';
+
+ $output .= "<script type='text/javascript'>
+ \$('#js_enabled').val(1);
+ \$('#js_enabled_mark').removeClass('error').css('color', 'green').html('PASSED');
+
+ document.cookie = 'install_cookie_test=1';
+ var \$cookies_enabled = document.cookie.indexOf('install_cookie_test') != -1;
+
+ if ( \$cookies_enabled ) {
+ \$('#cookies_enabled').val(1);
+ \$('#cookies_enabled_mark').removeClass('error').css('color', 'green').html('PASSED');
+ }
+ </script>";
+
+ echo $output;
+?>
Index: install/steps_db.xml
===================================================================
--- install/steps_db.xml (revision 14858)
+++ install/steps_db.xml (working copy)
@@ -207,4 +207,7 @@
The characters entered in this field are placed <i>before</i> the names of the tables used by In-Portal.
For example, if you enter "inp_" into the prefix field, the table named Category will be named inp_Category.</p>]]>
</step>
+ <step name="sys_requirements" title="System Requirements Check">
+ <![CDATA[The <i>System Requirements Check</i> option should be used to ensure proper system behavior in the current environment.]]>
+ </step>
</steps>
\ No newline at end of file
system_requirements_java.patch [^] (1,189 bytes) 2011-12-12 09:20
[Show Content]
Index: install/prerequisites.php
===================================================================
--- install/prerequisites.php (revision 14860)
+++ install/prerequisites.php (working copy)
@@ -121,6 +121,8 @@
$ret['mysql'] = function_exists('mysql_connect');
$ret['json'] = function_exists('json_encode');
+ exec('java -version 2>&1', $output);
+ $ret['java'] = (stripos($output[0], 'java version') !== false);
$ret['memory_limit'] = $this->isPhpSettingChangeable('memory_limit', '33M');
$ret['date.timezone'] = ini_get('date.timezone') != '';
Index: install/step_templates/sys_requirements.tpl
===================================================================
--- install/step_templates/sys_requirements.tpl (revision 14860)
+++ install/step_templates/sys_requirements.tpl (working copy)
@@ -21,6 +21,7 @@
'jpeg' => '- jpeg (required)',
'mysql' => '- MySQL (required)',
'json' => '- JSON (optional)',
+ 'java' => '- Java (optional)',
'sep2' => '<strong>PHP settings:</strong>',
'memory_limit' => "- ini_set('memory_limit', ...) works (optional)",
'date.timezone' => "- ini_get('date.timezone') - timezone set (required)",
updated_java_check_during_installation_v2.patch [^] (1,854 bytes) 2011-12-13 03:58
[Show Content]
Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 14860)
+++ install/install_toolkit.php (working copy)
@@ -1158,10 +1158,10 @@
$current = $this->getSystemConfig('Misc', 'CompressionEngine');
}
- $output = shell_exec('java -version');
+ $output = shell_exec('java -version 2>&1');
$compression_engines = Array ('' => 'None', 'yui' => 'YUICompressor (Java)', 'php' => 'PHP-based');
- if ( strpos($output, 'Java Version') === false ) {
+ if ( stripos($output, 'java version') === false ) {
if ( $current == 'yui' ) {
$compression_engines['yui'] .= ' (offline)';
}
Index: install/prerequisites.php
===================================================================
--- install/prerequisites.php (revision 14860)
+++ install/prerequisites.php (working copy)
@@ -122,6 +122,9 @@
$ret['mysql'] = function_exists('mysql_connect');
$ret['json'] = function_exists('json_encode');
+ $output = shell_exec('java -version 2>&1');
+ $ret['java'] = stripos($output, 'java version') !== false;
+
$ret['memory_limit'] = $this->isPhpSettingChangeable('memory_limit', '33M');
$ret['date.timezone'] = ini_get('date.timezone') != '';
Index: install/step_templates/sys_requirements.tpl
===================================================================
--- install/step_templates/sys_requirements.tpl (revision 14860)
+++ install/step_templates/sys_requirements.tpl (working copy)
@@ -13,6 +13,7 @@
$check_titles = Array (
'php_version' => 'PHP version: 5.2+ (required)',
'url_rewriting' => 'URL Rewriting Support (optional)',
+ 'java' => 'Java (optional)',
'sep1' => '<strong>PHP extensions:</strong>',
'memcache' => '- Memcache (optional)',
'curl' => '- Curl (required)',
upgrade_to_520_fails_on_prerequisit_check.patch [^] (2,870 bytes) 2012-01-06 07:40
[Show Content]
Index: install_toolkit.php
===================================================================
--- install_toolkit.php (revision 14988)
+++ install_toolkit.php (working copy)
@@ -133,27 +133,13 @@
*/
function CheckPrerequisites($module_path, $versions, $mode)
{
- static $prerequisit_classes = Array ();
-
- $prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
- if ( !file_exists($prerequisites_file) || !$versions ) {
+ if ( !$versions ) {
return Array ();
}
- if ( !isset($prerequisit_classes[$module_path]) ) {
- // save class name, because 2nd time
- // (in after call $prerequisite_class variable will not be present)
- include_once $prerequisites_file;
- $prerequisit_classes[$module_path] = $prerequisite_class;
- }
-
- $prerequisite_object = new $prerequisit_classes[$module_path]();
+ $prerequisite_object =& $this->getPrerequisiteObject($module_path);
/* @var $prerequisite_object InPortalPrerequisites */
- if ( method_exists($prerequisite_object, 'setToolkit') ) {
- $prerequisite_object->setToolkit($this);
- }
-
// some errors possible
return $prerequisite_object->CheckPrerequisites($versions, $mode);
}
@@ -167,29 +153,44 @@
*/
function CallPrerequisitesMethod($module_path, $method)
{
- static $prerequisit_classes = Array ();
+ $prerequisite_object =& $this->getPrerequisiteObject($module_path);
+ /* @var $prerequisite_object InPortalPrerequisites */
+ return $prerequisite_object->$method();
+ }
+
+ /**
+ * Returns prerequisite object to be used for checks
+ *
+ * @param string $module_path
+ * @param string $versions
+ * @return bool
+ * @access protected
+ */
+ protected function &getPrerequisiteObject($module_path)
+ {
+ static $prerequisite_classes = Array ();
+
$prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
- if ( !file_exists($prerequisites_file)) {
- return Array ();
+ if ( !file_exists($prerequisites_file) ) {
+ return false;
}
- if ( !isset($prerequisit_classes[$module_path]) ) {
+ if ( !isset($prerequisite_classes[$module_path]) ) {
// save class name, because 2nd time
// (in after call $prerequisite_class variable will not be present)
include_once $prerequisites_file;
- $prerequisit_classes[$module_path] = $prerequisite_class;
+ $prerequisite_classes[$module_path] = $prerequisite_class;
}
- $prerequisite_object = new $prerequisit_classes[$module_path]();
+ $prerequisite_object = new $prerequisite_classes[$module_path]();
/* @var $prerequisite_object InPortalPrerequisites */
if ( method_exists($prerequisite_object, 'setToolkit') ) {
$prerequisite_object->setToolkit($this);
}
- // some errors possible
- return $prerequisite_object->$method();
+ return $prerequisite_object;
}
/**
|