init(); } private function init() { $this->steps = array(1 => DMsg::ALbl('buildphp_step1'), 2 => DMsg::ALbl('buildphp_step2'), 3 => DMsg::ALbl('buildphp_step3'), 4 => DMsg::ALbl('buildphp_step4')); $this->check = new BuildCheck(); } private function step_indicator() { $cur_step = $this->check->GetNextStep(); $buf = '
'; return $buf; } private function toolbar_btn($label, $hrefjs, $id='', $disabled='') { $buf = '\n"; return $buf; } private function form_start() { $cur_step = $this->check->GetNextStep(); $buf .= '
'; $hasNext = ($cur_step < 4); $hasPrev = ($cur_step == 2 || $cur_step == 3); $disabled = ($cur_step == 3); if ($hasNext) $buf .= $this->toolbar_btn(DMsg::UIStr('btn_next'), 'step(1)', 'nextbtn', $disabled); if ($hasPrev) $buf .= $this->toolbar_btn(DMsg::UIStr('btn_prev'), 'step(0)', 'prevbtn', $disabled); $buf .= '

' . $cur_step . ' - ' . $this->steps[$cur_step]; if ($cur_step > 1) { $buf .= ' for PHP ' . $this->check->pass_val['php_version']; } $buf .= '

'; return $buf; } private function form_end() { $cur_step = $this->check->GetNextStep(); $version = $this->check->pass_val['php_version']; return '
'; } private function form_group($label, $required, $input, $tip='', $note='', $err='') { $buf = '
'; if ($tip) $buf .= '' . $tip . ''; $buf .= $input . '
'; if ($err) $buf .= ' ' . htmlspecialchars($err,ENT_QUOTES) . ''; if ( $note ) $buf .= '

'. htmlspecialchars($note,ENT_QUOTES) .'

'; $buf .= '
'; return $buf; } private function input_select($name, $options, $val='') { $buf = ''; return $buf; } private function input_text($name, $val) { $buf = ''; return $buf; } private function input_textarea($name, $value, $rows, $wrap='off') { $buf = '\n"; return $buf; } private function input_checkbox($name, $value, $label) { $buf = '
\n"; return $buf; } public function PrintPage() { echo $this->step_indicator(); switch ($this->check->GetNextStep()) { case 1: return $this->print_step_1(); case 2: return $this->print_step_2(); case 3: return $this->print_step_3(); case 4: return $this->print_step_4(); default: echo UIBase::error_divmesg("Invalid entrance"); } } function print_step_1() { $buf = $this->form_start(); if ( isset($this->check->pass_val['err'])) { $buf .= UIBase::error_divmesg($this->check->pass_val['err']); } $phpversion = BuildConfig::GetVersion(BuildConfig::PHP_VERSION); $select = $this->input_select('phpversel', $phpversion); $note = DMsg::ALbl('buildphp_updatever') . '/usr/local/lsws/admin/html/lib/util/build_php/BuildConfig.php'; $buf .= $this->form_group(DMsg::ALbl('buildphp_phpver'), true, $select, '', $note); $buf .= $this->form_end(); echo $buf; } function print_step_2() { $options = NULL; $saved_options = NULL; $default_options = NULL; $cur_step = $this->check->GetCurrentStep(); $pass_val = $this->check->pass_val; if ($cur_step == 1) { $php_version = $pass_val['php_version']; $options = new BuildOptions($php_version); $options->setDefaultOptions(); $default_options = $options; $supported = $this->check->GetModuleSupport($php_version); } elseif ($cur_step == 2) { $options = $pass_val['input_options']; $php_version = $options->GetValue('PHPVersion'); $default_options = new BuildOptions($php_version); $default_options->setDefaultOptions(); } elseif ($cur_step == 3) { $php_version = $pass_val['php_version']; $options = new BuildOptions($php_version); $default_options = new BuildOptions($php_version); $default_options->setDefaultOptions(); } if ($options == NULL) return "NULL options\n"; $saved_options = $options->getSavedOptions(); if ($saved_options != NULL && $cur_step == 3) { $options = $saved_options; } $buf = $this->form_start(); if ( isset($pass_val['err'])) { $buf .= UIBase::error_divmesg(DMsg::ALbl('note_inputerr')); } $input = 'gen_loadconf_onclick('IMPORT') : 'disabled') . '>   gen_loadconf_onclick('DEFAULT') . '>'; $buf .= $this->form_group(DMsg::ALbl('buildphp_loadconf'), false, $input); $input = $this->input_text('path_env', $options->GetValue('ExtraPathEnv')); $err = isset($pass_val['err']['path_env'])? $pass_val['err']['path_env']:''; $tip = DMsg::GetAttrTip('extrapathenv')->Render(); $buf .= $this->form_group(DMsg::ALbl('buildphp_extrapathenv'), false, $input, $tip, '', $err); $input = $this->input_text('installPath', $options->GetValue('InstallPath')); $err = isset($pass_val['err']['installPath'])? $pass_val['err']['installPath']:''; $tip = DMsg::GetAttrTip('installpathprefix')->Render(); $buf .= $this->form_group(DMsg::ALbl('buildphp_installpathprefix'), true, $input, $tip, '', $err); $input = $this->input_text('compilerFlags', $options->GetValue('CompilerFlags')); $err = isset($pass_val['err']['compilerFlags'])? $pass_val['err']['compilerFlags']:''; $tip = DMsg::GetAttrTip('compilerflags')->Render(); $buf .= $this->form_group(DMsg::ALbl('buildphp_compilerflags'), false, $input, $tip, '', $err); $input = $this->input_textarea('configureParams', $options->GetValue('ConfigParam'), 6, 'soft'); $err = isset($pass_val['err']['configureParams'])? $pass_val['err']['configureParams']:''; $tip = DMsg::GetAttrTip('configureparams')->Render(); $buf .= $this->form_group(DMsg::ALbl('buildphp_confparam'), true, $input, $tip, '', $err); $input = ''; if ($supported['mailheader']) { $input = $this->input_checkbox('addonMailHeader', $options->GetValue('AddOnMailHeader'), '
' . DMsg::ALbl('buildphp_mailheader1') . ' (' . DMsg::ALbl('buildphp_mailheader2') .')'); } if ($supported['suhosin']) { $input .= $this->input_checkbox('addonSuhosin', $options->GetValue('AddOnSuhosin'), 'Suhosin ' . DMsg::ALbl('buildphp_suhosin')); } $label_opcode = DMsg::ALbl('buildphp_opcodecache'); if ($supported['apc']) { $input .= $this->input_checkbox('addonAPC', $options->GetValue('AddOnAPC'), 'APC (' . $label_opcode .') V' . BuildConfig::GetVersion(BuildConfig::APC_VERSION)); } if ($supported['xcache']) { $input .= $this->input_checkbox('addonXCache', $options->GetValue('AddOnXCache'), 'XCache (' . $label_opcode .') V' . BuildConfig::GetVersion(BuildConfig::XCACHE_VERSION)); } if ($supported['opcache']) { $input .= $this->input_checkbox('addonOPcache', $options->GetValue('AddOnOPcache'), 'Zend OPcache (' . $label_opcode .') V' . BuildConfig::GetVersion(BuildConfig::OPCACHE_VERSION)); } if ($supported['memcache']) { $input .= $this->input_checkbox('addonMemCache', $options->GetValue('AddOnMemCache'), 'memcache (memcached extension) V' . BuildConfig::GetVersion(BuildConfig::MEMCACHE_VERSION)); } if ($supported['memcachd']) { $input .= $this->input_checkbox('addonMemCachd', $options->GetValue('AddOnMemCachd'), 'memcached (PHP extension for interfacing with memcached via libmemcached library) V' . BuildConfig::GetVersion(BuildConfig::MEMCACHED_VERSION)); } if ($supported['memcachd7']) { $input .= $this->input_checkbox('addonMemCachd7', $options->GetValue('AddOnMemCachd7'), 'memcached (PHP extension for interfacing with memcached via libmemcached library) V' . BuildConfig::GetVersion(BuildConfig::MEMCACHED7_VERSION)); } $note = DMsg::ALbl('buildphp_updatever') . ' /usr/local/lsws/admin/html/lib/util/build_php/BuildConfig.php'; $buf .= $this->form_group(DMsg::ALbl('buildphp_addonmodules'), false, $input, '', $note); $buf .= $this->form_end(); echo $buf; } function print_step_3() { $options = $this->check->pass_val['build_options']; if ($options == NULL) // illegal entry return; $buf = $this->form_start(); $err = ''; $optionsaved = ''; $tool = new BuildTool($options); if (!$tool || !$tool->GenerateScript($err, $optionsaved)) { $buf .= UIBase::error_divmesg(DMsg::UIStr('buildphp_failgenscript') . " $err"); } else { if ($optionsaved) $buf .= UIBase::info_divmesg(DMsg::UIStr('buildphp_confsaved')); else $buf .= UIBase::error_divmesg(DMsg::UIStr('buildphp_failsaveconf')); $_SESSION['progress_file'] = $tool->progress_file; $_SESSION['log_file'] = $tool->log_file; $cmd = 'bash -c "exec ' . $tool->build_prepare_script . ' 1> ' . $tool->log_file . ' 2>&1" &'; exec($cmd); $buf .= UIBase::warn_divmesg(DMsg::UIStr('buildphp_nobrowserrefresh')); $buf .= ''; $buf .= ''; $buf .= '
' . DMsg::ALbl('buildphp_mainstatus') . ':

					
' . DMsg::ALbl('buildphp_detaillog') . ':
' . $cmd . '
'; } $buf .= $this->form_end(); echo $buf; } function print_step_4() { $manual_script = $this->check->pass_val['manual_script']; if ($manual_script == NULL) // illegal entry return; $buf = $this->form_start(); $ver = $this->check->pass_val['php_version']; $binname = 'lsphp-' . $ver; $repl = array('%%server_root%%' => SERVER_ROOT, '%%binname%%' => $binname, '%%phpver%%' => $ver[0]); $notes = ''; } $buf .= UIBase::info_divmesg($notes); $echo_cmd = 'echo "For security reason, please log in and manually run the pre-generated script to continue."'; exec($echo_cmd . ' > ' . $this->check->pass_val['log_file']); exec($echo_cmd . ' > ' . $this->check->pass_val['progress_file']); $repl = array('%%manual_script%%' => $manual_script); $buf .= UIBase::warn_divmesg(DMsg::UIStr('buildphp_manualrunnotice', $repl)); $buf .= '
' . DMsg::ALbl('buildphp_mainstatus') . ':

				
' . DMsg::ALbl('buildphp_detaillog') . ':
' . $cmd . '
'; $buf .= $this->form_end(); echo $buf; } } echo UI::content_header('fa-list', DMsg::ALbl('menu_tools'), DMsg::ALbl('menu_compilephp')); $ui = new CompilePHPUI(); $ui->PrintPage(); ?>