function callstep($step, $data = array()) { switch ($step) { case 5: return step5($data); case 4: return step4($data); case 3: return step3($data); case 2: return step2($data); default: return step1($data); } }
} switch ($_GET['step']) { case 1: require './include/var.php'; env_check($env_items); dirfile_check($dirfile_items); function_check($func_items); break; case 3: $install_error = ''; $install_recover = ''; $demo_data = file_exists('./data/utf8_add.sql') ? true : false; step3($install_error, $install_recover); break; case 4: step4(); break; case 5: $sitepath = strtolower(substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))); $sitepath = str_replace('/shop/install', "", $sitepath); $auto_site_url = strtolower('http://' . $_SERVER['HTTP_HOST'] . $sitepath); break; default: break; } function step3(&$install_error, &$install_recover) { global $html_title, $html_header, $html_footer; if ($_POST['submitform'] != 'submit') { return; }
// mysql settings ok, go test mysql settings and select database. checkConfigFile(); header_html(sprintf(__('Step %d'), 2)); step3($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["update"]); break; case "Etape_3": // Create and fill database checkConfigFile(); header_html(sprintf(__('Step %d'), 3)); if (empty($_POST["databasename"])) { $_POST["databasename"] = ""; } if (empty($_POST["newdatabasename"])) { $_POST["newdatabasename"] = ""; } step4($_POST["databasename"], $_POST["newdatabasename"]); break; case "Etape_4": // finish installation header_html(sprintf(__('Step %d'), 4)); step7(); break; case "update_1": checkConfigFile(); if (empty($_POST["databasename"])) { $_POST["databasename"] = ""; } update1($_POST["databasename"]); break; } }
/** * Stems a word. Simple huh? * * @param string $word Word to stem * @return string Stemmed word */ function stem($word) { if (strlen($word) <= 2) { return $word; } $word = step1ab($word); $word = step1c($word); $word = step2($word); $word = step3($word); $word = step4($word); $word = step5($word); return $word; }
break; case "Etape_2": // mysql settings ok, go test mysql settings and select database. header_html($LANG['install'][77] . " 2"); step3($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["update"]); break; case "Etape_3": // Create and fill database header_html($LANG['install'][77] . " 3"); if (empty($_POST["databasename"])) { $_POST["databasename"] = ""; } if (empty($_POST["newdatabasename"])) { $_POST["newdatabasename"] = ""; } step4($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["databasename"], $_POST["newdatabasename"]); break; case "Etape_4": // finish installation header_html($LANG['install'][77] . " 4"); step7(); break; case "update_1": if (empty($_POST["databasename"])) { $_POST["databasename"] = ""; } update1($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["databasename"]); break; } } footer_html();
$template->set_template_file(VIVVO_FS_ROOT . 'installer/templates/frame.xml'); $installer_lang = $sm->get_lang(); if (isset($_POST['installer_lang'])) { setcookie('installer_lang', $_POST['installer_lang']); $_COOKIE['installer_lang'] = $_POST['installer_lang']; } if (isset($_COOKIE['installer_lang'])) { $installer_lang->load_lang($_COOKIE['installer_lang'], 'installer/lang/', 'installer'); } else { $installer_lang->load_lang($_COOKIE['installer_lang'] = 'vietnamese', 'installer/lang/', 'installer'); } define('VIVVO_INSTALLER_LANG', $_COOKIE['installer_lang']); $um = $sm->get_url_manager(); $lang = $sm->get_lang(); if ($um->get_param('step') == 2) { step2($template, $dm, $lang); } elseif ($um->get_param('step') == 3) { step3($template, $dm, $lang); } elseif ($um->get_param('step') == 4) { step4($template, $dm, $lang); } elseif ($um->get_param('step') == 5) { step5($template, $dm, $lang); } elseif ($um->get_param('step') == 6) { step6($template, $dm, $lang); vivvo_cache::get_instance()->delete_all(); } else { step1($template, $dm, $lang); } $template->assign('DUMP_MESSAGES', $dm->_dump_pool); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n"; echo $sm->get_output();
function step5() { $db = $_REQUEST['db']; if (!$db['host'] || !$db['user'] || !$db['database']) { step4('请设置数据库服务器地址,用户和数据库名'); } $link = @mysql_connect($db['host'], $db['user'], $db['pass']); if (!$link) { step4($db['host'] . '连接失败,请确认输入正确的服务器地址,账号和密码'); } mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary", $link); if (!$db['cover']) { $sql = "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='{$db['database']}'"; $q = mysql_query($sql, $link); $r = mysql_fetch_array($q); if ($r) { step4($db['database'] . '数据库已存在,您可以勾选覆盖数据库'); } } $app = file_get_contents(CACHE_DIR . 'app.tmp'); $app = json_decode($app, 1); $socket = new hgSocket(); $con = $socket->connect($app['ip'], $app['port']); if (!intval($con)) { step4('安装无法完成,服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $app['ip'] . ':' . $app['port'] . '上'); } $socket->close(); $auth = @file_get_contents(CACHE_DIR . 'auth.tmp'); $auth = json_decode($auth, 1); $db['pass'] = hg_encript_str($db['pass'], true, $auth['appkey']); file_put_contents(CACHE_DIR . 'db.tmp', json_encode($db)); global $Cfg; $curl = new curl($Cfg['upgradeServer']['host'] . ':' . $Cfg['upgradeServer']['port'], '', $Cfg['upgradeServer']['token']); $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY); $curl->setSubmitType('get'); $curl->setReturnFormat('json'); $curl->initPostData(); $curl->addRequestData('install', 1); $curl->addRequestData('app', 'livworkbench'); $ret = $curl->request('db.php'); if (!is_array($ret)) { hg_errorReport('获取数据库结构失败,无法完成安装,请联系软件提供商'); } $curl->initPostData(); $curl->addRequestData('a', 'checklastversion'); $curl->addRequestData('app', 'livworkbench'); $lastversion = $curl->request('check_version.php'); ob_start(); if (!$db['cover']) { hg_flushMsg('开始创建数据库 ' . $db['database']); $sql = 'CREATE DATABASE ' . $db['database'] . ' DEFAULT CHARACTER SET UTF8'; $q = mysql_query($sql, $link); if (!$q) { step4($db['database'] . '创建失败, 请确认此账号有权限创建数据库'); continue; } hg_flushMsg('数据库 ' . $db['database'] . ' 已创建'); } mysql_select_db($db['database'], $link); foreach ($ret as $table => $sql) { if (substr($table, 0, 4) == 'liv_') { $table = $db['dbprefix'] . substr($table, 4); $sql = preg_replace('/CREATE\\s+TABLE\\s+([`]{0,1})liv_/is', 'CREATE TABLE \\1' . $db['dbprefix'], $sql); } if (substr($table, 0, 4) == 'm2o_') { $table = $db['dbprefix'] . substr($table, 4); $sql = preg_replace('/CREATE\\s+TABLE\\s+([`]{0,1})m2o_/is', 'CREATE TABLE \\1' . $db['dbprefix'], $sql); } hg_flushMsg('开始创建数据表 ' . $table); if ($db['cover']) { $dropsql = 'DROP table ' . $table; mysql_query($dropsql, $link); } mysql_query($sql, $link); } hg_flushMsg('数据库创建完成 '); $content = get_serv_file($app, $app['dir'] . 'conf/config.php'); $content = preg_replace("/\\\$gGlobalConfig\\s*\\['App_.*'\\]\\s*=\\s*array\\s*(.*?);/is", $appstring, $content); if ($db) { $db['pass'] = hg_encript_str($db['pass'], false, $auth['appkey']); $string = "\$gDBconfig = array(\n'host' => '{$db['host']}',\n'user' => '{$db['user']}',\n'pass' => '{$db['pass']}',\n'database' => '{$db['database']}',\n'charset' => 'utf8',\n'pconncet' => 0,\n);"; $content = preg_replace("/\\\$gDBconfig\\s*=\\s*array\\s*(.*?);/is", $string, $content); $content = preg_replace("/define\\('DB_PREFIX',\\s*'.*?'\\);/is", "define('DB_PREFIX','{$db['dbprefix']}');", $content); } $match = preg_match("/define\\('INITED_APP',\\s*.*?\\s*\\);/is", $content); if ($match) { $content = preg_replace("/define\\('INITED_APP',\\s*.*?\\s*\\);/is", "define('INITED_APP', false);", $content); } else { $content = preg_replace("/\\?>/is", "\ndefine('INITED_APP', false);\n?>", $content); } $content = preg_replace("/define\\('APPID',\\s*'*\\d+'*\\);/is", "", $content); $content = preg_replace("/define\\('APPKEY',\\s*'.*?'\\);/is", "", $content); $content = preg_replace("/define\\('CUSTOM_APPID',\\s*\\d+\\);/is", "define('CUSTOM_APPID','{$auth['appid']}');", $content); $content = preg_replace("/define\\('CUSTOM_APPKEY',\\s*'.*?'\\);/is", "define('CUSTOM_APPKEY','{$auth['appkey']}');", $content); $content = preg_replace("/define\\('CUSTOM_NAME',\\s*'.*?'\\);/is", "define('CUSTOM_NAME','{$auth['display_name']}');", $content); $content = preg_replace("/define\\('DEBUG_MODE',\\s*.*?\\);/is", "define('DEBUG_MODE',false);", $content); $content = preg_replace("/define\\('DEVELOP_MODE',\\s*.*?\\);/is", "define('DEVELOP_MODE',0);", $content); $match = preg_match("/\\\$gGlobalConfig\\['license'\\]\\s*=\\s*\\'.*\\';/is", $content); if ($match) { $content = preg_replace("/\\\$gGlobalConfig\\['license'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['license'] = '{$auth['domain']}';", $content); } else { $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['license'] = '{$auth['domain']}';\n?>", $content); } $match = preg_match("/\\\$gGlobalConfig\\['version'\\]\\s*=\\s*\\'.*\\';/is", $content); if ($match) { $content = preg_replace("/\\\$gGlobalConfig\\['version'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['version'] = '{$lastversion}';", $content); } else { $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['version'] = '{$lastversion}';\n?>", $content); } $match = preg_match("/\\\$gGlobalConfig\\['mcphost'\\]\\s*=\\s*\\'.*\\';/is", $content); if ($match) { $content = preg_replace("/\\\$gGlobalConfig\\['mcphost'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['mcphost'] = '{$app['ip']}';", $content); } else { $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['mcphost'] = '{$app['ip']}';\n?>", $content); } $match = preg_match("/\\\$gGlobalConfig\\['php_run_type'\\]\\s*=\\s*\\'.*\\';/is", $content); if ($match) { $content = preg_replace("/\\\$gGlobalConfig\\['php_run_type'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['php_run_type'] = '{$app['php_run_type']}';", $content); } else { $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['php_run_type'] = '{$app['php_run_type']}';\n?>", $content); } $match = preg_match("/\\\$gGlobalConfig\\['php_socket_path'\\]\\s*=\\s*\\'.*\\';/is", $content); if ($match) { $content = preg_replace("/\\\$gGlobalConfig\\['php_socket_path'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['php_socket_path'] = '{$app['php_socket_path']}';", $content); } else { $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['php_socket_path'] = '{$app['php_socket_path']}';\n?>", $content); } write_serv_file($app, $app['dir'] . 'conf/config.php', $content, 'utf8'); $template_conf = $app['dir'] . 'conf/template.conf.php'; $content = get_serv_file($app, $template_conf); if ($content) { global $Cfg; $curl = new curl($Cfg['upgradeServer']['host'] . ':' . $Cfg['upgradeServer']['port'], '', $Cfg['upgradeServer']['token']); $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY); $curl->setSubmitType('get'); $curl->setReturnFormat('json'); $curl->initPostData(); $curl->addRequestData('install', 1); $curl->addRequestData('app', 'livtemplates'); $templates_url = $curl->request('check_version.php'); $content = preg_replace("/define\\('CACHE_TEMPLATE',\\s*.*?\\);/is", "define('CACHE_TEMPLATE',true);", $content); $content = preg_replace("/define\\('RESOURCE_URL',\\s*.*?\\);/is", "define('RESOURCE_URL','./res/images/');", $content); $content = preg_replace("/define\\('SCRIPT_URL',\\s*.*?\\);/is", "define('SCRIPT_URL','./res/scripts/');", $content); $content = preg_replace("/define\\('COMBO_URL',\\s*.*?\\);/is", "define('COMBO_URL','');", $content); $content = preg_replace("/define\\('TEMPLATE_API',\\s*.*?\\);/is", "define('TEMPLATE_API','{$templates_url}');", $content); write_serv_file($app, $template_conf, $content, 'utf8'); } $cron_conf = $app['dir'] . 'cron/config.py'; $content = get_serv_file($app, $cron_conf); if ($content) { $content = preg_replace("/CRON_TAB\\s*=\\s*\\(.*?\\)/is", "CRON_TAB = ('{$app['domain']}', 80, 'token', 'crontab.php')", $content); write_serv_file($app, $cron_conf, $content, 'utf8'); } hg_flushMsg('配置系统完成'); hg_redirect('?action=step6'); }
include_once('ressources/class.users.menus.inc'); include_once('ressources/class.squid.inc'); $usersmenus=new usersMenus(); if(!$usersmenus->AsSquidAdministrator){ $tpl=new templates(); $alert=$tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}'); echo "alert('$alert');"; die(); } if(isset($_GET["step0"])){step0();exit;} if(isset($_GET["step1"])){step1();exit;} if(isset($_GET["step2"])){step2();exit;} if(isset($_GET["step3"])){step3();exit;} if(isset($_GET["step4"])){step4();exit;} if(isset($_POST["DOMAIN"])){Save();exit;} if(isset($_POST["LOCALNET"])){Save();exit;} if(isset($_POST["PROXY"])){Save();exit;} if(isset($_POST["agree"])){agree();exit;} start_js(); function start_js(){ header("content-type: application/x-javascript"); $tpl=new templates(); $page=CurrentPageName();