public function GenerateScript(&$error, &$optionsaved) { if ($this->progress_file == NULL) { if (!$this->init($error, $optionsaved)) { return FALSE; } } $params = array(); $params['__php_version__'] = $this->options->GetValue('PHPVersion'); $params['__progress_f__'] = $this->progress_file; $params['__log_file__'] = $this->log_file; $processUser = posix_getpwuid(posix_geteuid()); $gidinfo = posix_getgrgid($processUser['gid']); $params['__php_usr__'] = $processUser['name']; $params['__php_usrgroup__'] = $gidinfo['name']; $params['__extra_path_env__'] = $this->options->GetValue('ExtraPathEnv'); $params['__php_build_dir__'] = BuildConfig::Get(BuildConfig::BUILD_DIR); $params['__dl_method__'] = $this->dlmethod; $params['__install_dir__'] = $this->options->GetValue('InstallPath'); $params['__compiler_flags__'] = $this->options->GetValue('CompilerFlags'); $params['__enable_mailheader__'] = $this->options->GetValue('AddOnMailHeader') ? 1 : 0; $params['__lsapi_version__'] = BuildConfig::GetVersion(BuildConfig::LSAPI_VERSION); $params['__php_conf_options__'] = $this->options->GetValue('ConfigParam'); $params['__lsws_home__'] = SERVER_ROOT; $params['__install_script__'] = $this->build_install_script; $search = array_keys($params); $replace = array_values($params); //common header $template_file = 'build_common.template'; $template = file_get_contents($template_file, true); if ($template === false) { $error = DMsg::Err('err_failreadfile') . $template_file; return false; } $template_script = str_replace($search, $replace, $template); $prepare_script = $template_script; $install_script = $template_script; // prepare php $template_file = 'build_prepare.template'; $template = file_get_contents($template_file, true); if ($template === false) { $error = DMsg::Err('err_failreadfile') . $template_file; return false; } $template_script = str_replace($search, $replace, $template); $prepare_script .= $template_script; // install php $template_file2 = 'build_install.template'; $template2 = file_get_contents($template_file2, true); if ($template2 === false) { $error = DMsg::Err('err_failreadfile') . $template_file2; return false; } $template_script2 = str_replace($search, $replace, $template2); $install_script .= $template_script2; //prepare extension $template_file = 'build_prepare_ext.template'; $template = file_get_contents($template_file, true); if ($template === false) { $error = DMsg::Err('err_failreadfile') . $template_file; return false; } //install extension $template_file2 = 'build_install_ext.template'; $template2 = file_get_contents($template_file2, true); if ($template2 === false) { $error = DMsg::Err('err_failreadfile') . $template_file2; return false; } $extList = array(); if ($this->options->GetValue('AddOnSuhosin')) { $extList[] = 'Suhosin'; } if ($this->options->GetValue('AddOnAPC')) { $extList[] = 'APC'; } if ($this->options->GetValue('AddOnXCache')) { $extList[] = 'XCache'; } if ($this->options->GetValue('AddOnMemCache')) { $extList[] = 'MemCache'; } // if ($this->options->GetValue('AddOnMemCached')) { // $extList[] = 'MemCached'; // } if ($this->options->GetValue('AddOnOPcache')) { $extList[] = 'OPcache'; } foreach ($extList as $extName) { $newparams = array_merge($params, $this->ext_options[$extName]); $search = array_keys($newparams); $replace = array_values($newparams); $template_script = str_replace($search, $replace, $template); $prepare_script .= $template_script; $template_script2 = str_replace($search, $replace, $template2); $install_script .= $template_script2; } $this->extension_used = implode('.', $extList); $prepare_script .= 'main_msg "**DONE**"' . "\n"; $install_script .= 'main_msg "**DONE**"' . "\n"; if (file_put_contents($this->build_prepare_script, $prepare_script) === FALSE) { $error = DMsg::Err('buildphp_errcreatescript') . $this->build_prepare_script; return false; } if (chmod($this->build_prepare_script, 0700) == FALSE) { $error = DMsg::Err('buildphp_errchmod') . $this->build_prepare_script; return false; } if (file_put_contents($this->build_install_script, $install_script) === FALSE) { $error = DMsg::Err('buildphp_errcreatescript') . $this->build_install_script; return false; } if (chmod($this->build_install_script, 0700) == FALSE) { $error = DMsg::Err('buildphp_errchmod') . $this->build_install_script; return false; } // final manual run script $template_file = 'build_manual_run.template'; $template = file_get_contents($template_file, true); if ($template === false) { $error = DMsg::Err('err_failreadfile') . $template_file; return false; } $template_script = str_replace($search, $replace, $template); if (file_put_contents($this->build_manual_run_script, $template_script) === FALSE) { $error = DMsg::Err('buildphp_errcreatescript') . $this->build_manual_run_script; return false; } if (chmod($this->build_manual_run_script, 0700) == FALSE) { $error = DMsg::Err('buildphp_errchmod') . $this->build_manual_run_script; return false; } return true; }
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 = '<input type="button" class="btn btn-default btn-sm" value="' . DMsg::ALbl('buildphp_useprevconf') . '" ' . ($saved_options ? $saved_options->gen_loadconf_onclick('IMPORT') : 'disabled') . '> <input type="button" class="btn btn-default btn-sm" value="' . DMsg::ALbl('buildphp_restoredefault') . '" ' . $default_options->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'), '<a href="http://choon.net/php-mail-header.php" target="_blank">' . DMsg::ALbl('buildphp_mailheader1') . '</a> (' . DMsg::ALbl('buildphp_mailheader2') . ')'); } if ($supported['suhosin']) { $input .= $this->input_checkbox('addonSuhosin', $options->GetValue('AddOnSuhosin'), '<a href="http://suhosin.org" target="_blank">Suhosin</a> ' . DMsg::ALbl('buildphp_suhosin')); } $label_opcode = DMsg::ALbl('buildphp_opcodecache'); if ($supported['apc']) { $input .= $this->input_checkbox('addonAPC', $options->GetValue('AddOnAPC'), '<a href="http://pecl.php.net/package/APC" target="_blank">APC</a> (' . $label_opcode . ') V' . BuildConfig::GetVersion(BuildConfig::APC_VERSION)); } $input .= $this->input_checkbox('addonXCache', $options->GetValue('AddOnXCache'), '<a href="http://xcache.lighttpd.net/" target="_blank">XCache</a> (' . $label_opcode . ') V' . BuildConfig::GetVersion(BuildConfig::XCACHE_VERSION)); $input .= $this->input_checkbox('addonMemCache', $options->GetValue('AddOnMemCache'), '<a href="http://pecl.php.net/package/memcache" target="_blank">memcache</a> (memcached extension) V' . BuildConfig::GetVersion(BuildConfig::MEMCACHE_VERSION)); if ($supported['opcache']) { $input .= $this->input_checkbox('addonOPcache', $options->GetValue('AddOnOPcache'), '<a href="http://pecl.php.net/package/ZendOpcache" target="_blank">Zend OPcache</a> (' . $label_opcode . ') V' . BuildConfig::GetVersion(BuildConfig::OPCACHE_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; }