/** * @brief patch 路由组装 * * @param $routeName 路由名 * @param $params 路由规则参数 * * @return string */ public static function patch($routeName, $params) { if ($route = self::getRoute($routeName)) { $pattern = array(); foreach ($route['params'] as $row) { $pattern[$row] = isset($params[$row]) ? $params[$row] : '{' . $row . '}'; } if (OptionLibrary::get('rewrite') == 'open') { return Request::getDomain() . substr(LOGX_PATH, 0, strlen(LOGX_PATH) - 1) . vsprintf($route['format'], $pattern); } else { return Request::getDomain() . LOGX_PATH . 'index.php' . vsprintf($route['format'], $pattern); } } else { return ''; } }
/** * @brief setCookie 设置 Cookie * * @param $name Cookie 名 * @param $value Cookie 值 * @param $expire Cookie 过期时间 * * @return void */ public static function setCookie($name, $value, $expire = 0) { $path = str_replace(' ', '%20', LOGX_PATH); $domainFull = Request::getDomain(); $domain = str_replace('http://', '', $domainFull); if ($domain == $domainFull) { $domain = str_replace('https://', '', $domainFull); $secure = TRUE; } else { $secure = FALSE; } if (self::$_prefix == '') { self::$_prefix = substr(md5(DB_PREFIX), 0, 8); } setcookie(self::$_prefix . $name, $value, $expire, $path, $domain, $secure); }
<?php showFoot(); break; case 5: if (Request::P('submit', 'string')) { if (Request::P('password', 'string') != Request::P('repassword', 'string')) { showError('<strong>您两次输入的密码不一致</strong><br />请返回重新输入。', 'install.php?step=4'); } if (!Request::P('username', 'string') || !Request::P('password', 'string') || !Request::P('email', 'string')) { showError('<strong>用户名、邮箱、密码均为必填</strong><br />请返回重新输入。', 'install.php?step=4'); } $info = Cache::get('InstallInfomation'); $info['admin'] = Request::P('username', 'string'); $info['email'] = Request::P('email', 'string'); $info['adminpw'] = md5(Request::P('password', 'string')); $info['domain'] = Request::getDomain(); Cache::delete('InstallInfomation'); // 连接到数据库 Database::connect($info['host'], $info['user'], $info['pw'], $info['name']); // 构建数据库 $scripts = file_get_contents(LOGX_ROOT . 'install.php'); preg_match('/-- Database ' . 'Structure Begin --(.*)-- Database ' . 'Structure End --/s', $scripts, $match); $scripts = $match[1]; $scripts = str_replace('logx_', $info['prefix'], $scripts); $scripts = explode(';', $scripts); foreach ($scripts as $script) { $script = str_replace(array('{time}', '{blogname}', '{admin}', '{adminpw}', '{domain}', '{email}'), array(time(), $info['blog'], $info['admin'], $info['adminpw'], $info['domain'], $info['email']), trim($script)); if ($script) { Database::query($script); } }