(PDO::FETCH_ASSOC); foreach ($rows as $row) { if (!empty($row['url_pattern']) && isset($page_type_map[$row['page_type']])) { $route = $page_type_map[$row['page_type']]; // 将url_pattern转换为正则表达式 $pattern = url_pattern_to_regex($row['url_pattern']); if ($pattern) { $url_patterns[$pattern] = array( 'control' => $route['control'], 'action' => $route['action'], 'url_pattern' => $row['url_pattern'] ); // 如果有参数映射,也添加进去 if (isset($route['params'])) { $url_patterns[$pattern]['params'] = $route['params']; } } } } } } } catch (Exception $e) { // 数据库连接失败,使用默认配置 } // 如果没有从数据库读取到配置,使用默认配置 if (empty($url_patterns)) { $url_patterns = array( // 首页 '/^converter\/?$/' => array('control' => 'exchange', 'action' => 'converter', 'url_pattern' => 'converter'), '/^rates\/?$/' => array('control' => 'exchange', 'action' => 'rates', 'url_pattern' => 'rates'), '/^rmb-rate\/?$/' => array('control' => 'exchange', 'action' => 'cnyrate', 'url_pattern' => 'rmb-rate'), '/^bank-rate\/?$/' => array('control' => 'exchange', 'action' => 'bank', 'url_pattern' => 'bank-rate'), '/^forex\/?$/' => array('control' => 'exchange', 'action' => 'forex', 'url_pattern' => 'forex'), '/^currency\/?$/' => array('control' => 'exchange', 'action' => 'currency', 'url_pattern' => 'currency'), '/^daxie\/?$/' => array('control' => 'exchange', 'action' => 'daxie', 'url_pattern' => 'daxie'), '/^article\/?$/' => array('control' => 'exchange', 'action' => 'article', 'url_pattern' => 'article'), // 详情页 - 使用 [a-zA-Z] 支持大小写混合 '/^converter\/([a-zA-Z]{3})-([a-zA-Z]{3})\/?$/' => array('control' => 'exchange', 'action' => 'converter_pair', 'url_pattern' => 'converter/{from}-{to}/', 'params' => array('from' => 1, 'to' => 2)), '/^converter2\/([a-zA-Z]{3})-([a-zA-Z]{3})\/([0-9.]+)\.html$/' => array('control' => 'exchange', 'action' => 'converter_detail', 'url_pattern' => 'converter2/{from}-{to}/{amount}.html', 'params' => array('from' => 1, 'to' => 2, 'amount' => 3)), '/^rmb-rate\/([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'cnyrate_detail', 'url_pattern' => 'rmb-rate/{code}.html', 'params' => array('code' => 1)), '/^bank-rate\/([a-zA-Z]+)\.html$/' => array('control' => 'exchange', 'action' => 'bank_detail', 'url_pattern' => 'bank-rate/{code}.html', 'params' => array('code' => 1)), '/^forex\/([a-zA-Z0-9_-]+)\.html$/' => array('control' => 'exchange', 'action' => 'forex_detail', 'url_pattern' => 'forex/{code}.html', 'params' => array('code' => 1)), '/^currency\/([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'currency_detail', 'url_pattern' => 'currency/{code}.html', 'params' => array('code' => 1)), '/^daxie\/([0-9.]+)\.html$/' => array('control' => 'exchange', 'action' => 'daxie_detail', 'url_pattern' => 'daxie/{amount}.html', 'params' => array('amount' => 1)), '/^history\/([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'history_currency', 'url_pattern' => 'history/{code}.html', 'params' => array('code' => 1)), '/^history\/([a-zA-Z]{3})-([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'history_pair', 'url_pattern' => 'history/{from}-{to}.html', 'params' => array('from' => 1, 'to' => 2)), '/^trend\/([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'trend_currency', 'url_pattern' => 'trend/{code}.html', 'params' => array('code' => 1)), '/^trend\/([a-zA-Z]{3})-([a-zA-Z]{3})\.html$/' => array('control' => 'exchange', 'action' => 'trend_pair', 'url_pattern' => 'trend/{from}-{to}.html', 'params' => array('from' => 1, 'to' => 2)), ); } foreach ($url_patterns as $pattern => $route) { if (preg_match($pattern, $rewrite, $matches)) { $_GET['control'] = $route['control']; $_GET['action'] = $route['action']; // 提取参数 if (isset($route['params'])) { foreach ($route['params'] as $param_name => $match_index) { if (isset($matches[$match_index])) { $value = $matches[$match_index]; // 货币代码参数转换为大写 if (in_array($param_name, array('from', 'to', 'code', 'base', 'target'))) { $value = strtoupper($value); } $_GET[$param_name] = $value; } } } // 重要:删除 rewrite 参数,防止后面的代码再次处理 unset($_GET['rewrite']); return; } } } if(empty($_GET)) return; if(!empty($_ENV['_config']['lecms_parseurl']) && isset($_GET['rewrite']) && !empty($_GET['rewrite'])) { if( isset($this->data['cfg']) ) { $cfg = $this->data['cfg']; }else{ $cfg = $this->runtime->xget(); $this->data['cfg'] = $cfg; } $uri = $_GET['rewrite']; unset($_GET['rewrite']); //访问 域名/index.php?rewrite=xx , 直接 301 重定向到 域名/xx $request_uri = isset($_SERVER['REQUEST_URI']) ? strtolower($_SERVER['REQUEST_URI']) : ''; if( $request_uri && strpos($request_uri, '?rewrite=') !== false ){ http_location($cfg['weburl'].$uri, '301'); } $url_suffix = $_ENV['_config']['url_suffix']; $url_suffix_len = strlen($url_suffix); /** * URL重写钩子 - 将首页路由到 exchange 控制器 * 在 parseurl_control 的 index 方法中执行 * 此时 $uri 已经包含了 rewrite 的值,且 $_GET['rewrite'] 已经被 unset */ if (strpos($uri, 'ex_pic/') === 0) { if (!function_exists('imagecreatetruecolor') || !function_exists('imagettftext')) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); exit; } if (preg_match('#^ex_pic/history/([a-zA-Z]{3})-([a-zA-Z]{3})/([0-9]+)\.jpg$#', $uri, $m)) { $from = strtoupper($m[1]); $to = strtoupper($m[2]); $days = intval($m[3]); if (!in_array($days, array(7, 30, 90))) $days = 7; $chart_data = array(); try { $model_file_history = PLUGIN_PATH . 'le_exchange/model/exchange_history_model.class.php'; if (file_exists($model_file_history)) { include_once $model_file_history; } $model_file_rate = PLUGIN_PATH . 'le_exchange/model/exchange_rate_model.class.php'; if (file_exists($model_file_rate)) { include_once $model_file_rate; } $exchange_history = new exchange_history(); $exchange_rate = new exchange_rate(); // 使用模型直接获取带交叉汇率计算的历史记录列表 // 由于 $exchange_history->get_history_list() 返回的是从近到远排序的数据 $history_list_raw = $exchange_history->get_history_list($to, $days, $from); $today_date = date('Y-m-d'); $has_today = false; if (!empty($history_list_raw)) { foreach ($history_list_raw as $item) { if ($item['date'] === $today_date) { $has_today = true; break; Lecms 3.0.3 lang[error]

lang[error_info]

lang[error_line]

lang[basic_trace]

lang[program_flow]

SQL

$_GET

$_POST

$_COOKIE

lang[include_file]

lang[other_trace]