查是否是黄历插件的URL,直接在最开始处理,避免被分类处理拦截 $url_suffix = $_ENV['_config']['url_suffix']; $url_suffix_len = strlen($url_suffix); // 检查cfg是否存在 if (isset($cfg['le_hl'])) { // 动态获取插件后台设置的黄历前缀 $plugin_prefix = isset($cfg['le_hl']['day_prefix']) ? $cfg['le_hl']['day_prefix'] : 'huangli'; // 支持插件设置的前缀和默认的 hl 前缀 $possible_prefixes = array('hl', $plugin_prefix); // 检查是否匹配黄历插件的URL模式 foreach ($possible_prefixes as $prefix) { $prefix_len = strlen($prefix); // 处理首页 if($uri == $prefix || $uri == $prefix . '/' || ($url_suffix_len > 0 && ($uri == $prefix . $url_suffix || $uri == $prefix . '/' . $url_suffix))) { $_GET['control'] = 'hl'; $_GET['action'] = 'index'; return; }elseif(substr($uri,0,$prefix_len+1)=="{$prefix}/"){ // 处理带后缀的URL $newurl = $uri; if ($url_suffix_len > 0 && substr($uri, -$url_suffix_len) == $url_suffix) { $newurl = substr($uri, 0, -$url_suffix_len); } $_GET['control'] = 'hl'; if(substr($newurl, $prefix_len+1) == 'caishen'){ $_GET['action'] = 'caishen'; return; }elseif (substr($newurl, $prefix_len+1) == 'jishi'){ $_GET['action'] = 'jishi'; return; } //具体日期的黄历 $pattern = '/^'.$prefix.'\/(\d+)-(\d+)-(\d+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[3]) && $mat[3]){ $_GET['action'] = 'index'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['ri'] = $mat[3]; return; } //年月的吉日 $pattern = '/^'.$prefix.'\/(\d+)-(\d+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[2]) && $mat[2]){ $_GET['action'] = 'yue'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; return; } //某年日历 $pattern = '/^'.$prefix.'\/(\d+)-rili$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[1]) && $mat[1]){ $_GET['action'] = 'nian_rili'; $_GET['nian'] = $mat[1]; return; } //某年节气详情 $pattern = '/^'.$prefix.'\/(\d+)-(\w+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[2]) && $mat[2]){ $_GET['action'] = 'nian_jieqi'; $_GET['nian'] = $mat[1]; $_GET['jieqipy'] = $mat[2]; return; } //某年某月某吉日(结婚) $pattern = '/^'.$prefix.'\/(\d+)-(\d+)-(\w+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[3]) && $mat[3]){ $_GET['action'] = 'yuejiri'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['eventpy'] = $mat[3]; return; } //某年某月某吉日(结婚)带生肖 $pattern = '/^'.$prefix.'\/(\d+)-(\d+)-([a-zA-Z]+)-([a-zA-Z]+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[4]) && $mat[4]){ $_GET['action'] = 'yuejiri'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['eventpy'] = $mat[3]; $_GET['sx'] = $mat[4]; return; } //2025-3-21-jiehun.html 某日某黄历是否合适 $pattern = '/^'.$prefix.'\/(\d+)-(\d+)-(\d+)-(\w+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[4]) && $mat[4]){ $_GET['action'] = 'eventno'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['ri'] = $mat[3]; $_GET['eventpy'] = $mat[4]; return; } //具体日期的吉时 $pattern = '/^'.$prefix.'\/jishi\/(\d+)-(\d+)-(\d+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[3]) && $mat[3]){ $_GET['action'] = 'jishi'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['ri'] = $mat[3]; return; } //具体日期的财神位 $pattern = '/^'.$prefix.'\/caishen\/(\d+)-(\d+)-(\d+)$/'; preg_match($pattern, $newurl, $mat); if(isset($mat[3]) && $mat[3]){ $_GET['action'] = 'caishen'; $_GET['nian'] = $mat[1]; $_GET['yue'] = $mat[2]; $_GET['ri'] = $mat[3]; return; } } } } if($uri == 'yangtoyin' && IS_POST){ //阳历转阴历 $_GET['control'] = 'hl'; $_GET['action'] = 'yangtoyin'; return; }elseif($uri == 'yintoyang' && IS_POST){ //阴历转阳历 $_GET['control'] = 'hl'; $_GET['action'] = 'yintoyang'; return; } if(substr($uri , 0 , 4) == 'bjx/' && strlen($uri) > 4){ $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); if(!isset($u_arr[1])){ core::error404(); } $_GET['control'] = 'qm'; $_GET['action'] = 'bjx'; $_GET['xing'] = $u_arr[1]; return; }elseif(substr($uri , 0 , 5) == 'xing/' && strlen($uri) > 5){ $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); $_GET['control'] = 'qm'; $_GET['action'] = 'xing'; $_GET['xing'] = $u_arr[1]; if(is_numeric($u_arr[1])){ $_GET['action'] = 'xinglist'; $_GET['id'] = $u_arr[1]; //分页 if(isset($u_arr[2])){ if($page = $this->page_check($u_arr[2])){ $_GET['page'] = $page; }else{ core::error404(); } } return; } if(!isset($u_arr[2])){ core::error404(); } $sex_zi = explode('_', $u_arr[2]); if(!isset($sex_zi[1])){ core::error404(); } $_GET['sex'] = $sex_zi[0]; $_GET['zi'] = $sex_zi[1]; //分页 if(isset($u_arr[3])){ if($page = $this->page_check($u_arr[3])){ $_GET['page'] = $page; }else{ core::error404(); } } return; }elseif(substr($uri , 0 , 7) == 'mingzi/' && strlen($uri) > 7){ if(substr($uri, -4) == '.jpg'){ $newurl = substr($uri, 0, -4); $u_arr = explode('/', $newurl); if(isset($u_arr[2])){ $_GET['control'] = 'qm'; $_GET['action'] = 'mingzipic'; $_GET['xingming'] = $u_arr[2]; return; } } $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); if(!isset($u_arr[2])){ core::error404(); } $_GET['control'] = 'qm'; $_GET['action'] = 'mingzi'; $_GET['xing'] = $u_arr[1]; $_GET['ming'] = $u_arr[2]; return; }elseif(substr($uri , 0 , 7) == 'zidian/' && strlen($uri) > 7){ $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); if(!isset($u_arr[1])){ core::error404(); } $_GET['control'] = 'qm'; $_GET['action'] = 'kangxizidian'; $_GET['id'] = $u_arr[1]; return; }//标题缩略图伪静态 if( preg_match('/pic\/(.*)\.jpg/i', $uri, $match) ){ $title = base64_decode($match[1]); $title = decrypt($title); if(empty($title)){ exit(); } //如果浏览器对当前页面已经有缓存,那么就直接使用它 if (isset($_SERVER['http_IF_MODIFIED_SINCE'])) { header('Last-Modified: '.$_SERVER['HTTP_IF_MODIFIED_SINCE'],true,304); exit(); } //随机取一个背景图 $bgimgdir = PLUGIN_PATH.'le_title_pic/bg_img/'; if( !is_dir($bgimgdir) ){exit();} $all_image_files = _scandir($bgimgdir);//背景图存放文件夹的jpg图片 foreach ($all_image_files as $k=>$file){ if($file == '.' || $file == '..'){ unset($all_image_files[$k]); } } if( empty($all_image_files) ){ exit(); } shuffle($all_image_files); $backgroundFile = array_slice($all_image_files, 0, 1); $backgroundPath = $bgimgdir.$backgroundFile[0]; $font = PLUGIN_PATH."le_title_pic/static/font.otf"; //字体 $size = 14; //默认字体大小 $oneline = 10; preg_match_all("/./u", $title, $t_arr);//将所有字符转成单个数组 $tarr = $t_arr[0]; $t_total = count($tarr); //标题长度 if($t_total > 30){ $t_total = 30; } $cha = 30 - $t_total; $size = $size + $cha; if($size > 28 ){ $size = 28; }elseif($size < 18){ $size = 18; } $text = ''; if($t_total > $oneline){ $line = 2; $bnum = $t_total/2; $snum = 0; for ($x = 0; $x < $t_total; $x++) { $snum++; if($snum >= $bnum){ $snum = 0; $text .= $tarr[$x].PHP_EOL; }else{ if($x > 27){ $text .= "..."; break; }else{ $text .= $tarr[$x]; } } } }else{ $text = $title; $line = 1; } //创建图片 $img = imagecreatefromjpeg($backgroundPath); $width = imagesx($img); $height = imagesy($img); if($line > 1){ $a = imagettfbbox($size, 0, $font, $text); //得到字符串虚拟方框四个点的坐标 $len = $a[2] - $a[0]; $x = ($width-$len)/2; $h = $size/10; $y = ($height/2)-15+$h; }else{ $a = imagettfbbox($size, 0, $font, $text); //得到字符串虚拟方框四个点的坐标 $len = $a[2] - $a[0]; $x = ($width-$len)/2; $h = $size/10; $y = ($height/2)+10+$h; } $color = imagecolorallocate($img, 255, 255, 255); // 0 0 0 表示黑色 $setting = $this->kv->get('le_title_pic_setting'); $cache_day = $setting['cache_day'].' day'; //缓存天数 //将规定当前页面缓存的时间(两天),并在下一次访问中使用这个缓存时间节点。接下来判断是否已经有缓存,如果有,就使用缓存。 header("Cache-Control: private, max-age=10800, pre-check=10800"); header("Pragma: private"); header("Expires: " . date(DATE_RFC822, strtotime($cache_day))); header("Content-type:image/jpeg"); imagettftext($img, $size, 0, $x, $y, $color, $font, $text); imagejpeg($img); imagedestroy($img); exit(); } // mz/ 路径解析 - 宝宝起名方案页 if(substr($uri , 0 , 4) == 'mz/' && strlen($uri) > 4){ $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); if(!isset($u_arr[1])){ core::error404(); } $_GET['control'] = 'qm'; $_GET['action'] = 'mz'; $_GET['xing'] = $u_arr[1]; // 解析性别和类型 if(isset($u_arr[2])){ $sex_type = explode('_', $u_arr[2]); $_GET['sex'] = isset($sex_type[0]) ? $sex_type[0] : 0; $_GET['type'] = isset($sex_type[1]) ? $sex_type[1] : 1; } return; } // 笔画URL解析 - 移到最前面,确保最先被调用 $r = $this->bihua_url($cfg, $uri); if($r){return;} // 部首URL解析 $r = $this->bushou_url($cfg, $uri); if($r){return;} // 拼音URL解析 $r = $this->pinyin_url($cfg, $uri); if($r){return;} // 康熙字典URL解析 $r = $this->kangxi_url($cfg, $uri); if($r){return;} //站点地图 $sitemap_uri = array('sitemap.xml', 'sitemap.html', 'sitemap.txt'); if(in_array($uri, $sitemap_uri)){ $u_arr = explode('.', $uri); $_GET['control'] = 'sitemap'; $_GET['action'] = $u_arr[1]; return; } $r = $this->category_url($cfg, $uri); if($r){return;} $r = $this->content_url($cfg, $uri); if($r){return;} $r = $this->tag_url($cfg, $uri); if($r){return;} $r = $this->search_url($cfg, $uri); if($r){return;} $r = $this->comment_url($cfg, $uri); if($r){return;} $r = $this->index_page_url($cfg, $uri); if($r){return;} $r = $this->tag_like_url($cfg, $uri); if($r){return;} $r = $this->user_url($cfg, $uri); if($r){return;} $r = $this->model_url($cfg, $uri); if($r){return;} $r = $this->flags_url($cfg, $uri); if($r){return;} $r = $this->space_url($cfg, $uri); if($r){return;} } //伪静态结束------------------------------------------------------------------------------------------------------ // 伪静态时,如果 $uri 有值,但没有解析到相关 $_GET 时,就提示404 if(empty($_GET) && isset($uri) && !empty($uri)) { core::error404(); } if( !isset($_GET['control']) ) { $r = $this->other_url(); if($r){return;} } } //---------------------------------------------------------------------- 以下是各模块URL解析的具体函数实现 //模型页URL解析 protected function model_url($cfg = array(), $uri = ''){ // 如果是bihua开头的URL,直接返回false,不处理,让bihua_url方法处理 if(substr($uri, 0, 6) == 'bihua/') { return false; } //模型信息 table=>mid $model_arr = array_flip($cfg['table_arr']); // 模型URL未设置后缀/的情况,301重定向到已设置后缀的URL if( isset($model_arr[$uri]) ) { http_location($cfg['weburl'].$uri.'/', '301'); } $_GET['control'] = 'model'; $_GET['action'] = 'index'; if(substr($uri, -1) == '/'){ $newurl = substr($uri, 0, -1); }else{ $newurl = $uri; } //模型首页URL if( isset($model_arr[$newurl]) ) { $_GET['mid'] = (int)$model_arr[$newurl]; return true; } //模型分页URL $u_arr = explode('/', $newurl); if( isset($model_arr[$u_arr[0]]) ) { $_GET['mid'] = (int)$model_arr[$u_arr[0]]; //分页 if( isset($u_arr[1]) ){ if($page = $this->page_check($u_arr[1])){ $_GET['page'] = $page; }else{ core::error404(); } } return true; } unset($_GET['control']); unset($_GET['action']); return false; } //分类URL解析 protected function category_url($cfg = array(), $uri = ''){ //分类信息 alias=>cid $cate_arr = arr if(isset($mat[1])) { // 使用bihua控制器来处理 $_GET['control'] = 'bihua'; $_GET['action'] = 'index'; $_GET['bihua'] = $mat[1]; return true; } } } return false; } //动态URL解析 protected function other_url(){ if(isset($_GET['u'])) { $u = $_GET['u']; unset($_GET['u']); }elseif(!empty($_SERVER['PATH_INFO'])) { $u = R('PATH_INFO', 'S'); }else{ $_GET = array(); $u = R('QUERY_STRING', 'S'); } //清除URL后缀 $url_suffix = C('url_suffix'); if($url_suffix) { $suf_len = strlen($url_suffix); if(substr($u, -($suf_len)) == $url_suffix) $u = substr($u, 0, -($suf_len)); } $uarr = explode('&', $u); $u = $uarr[0]; if(count($uarr) > 1){ array_shift($uarr); foreach ($uarr as $v){ $varr = explode('=', $v); $_GET[$varr[0]] = isset($varr[1]) ? urldecode($varr[1]) : ''; } } unset($uarr); $uarr = explode('-', $u); if(count($uarr) < 2) {core::error404();} //控制器 if(isset($uarr[0])) { $_GET['control'] = empty($uarr[0]) ? 'index': strtolower($uarr[0]); array_shift($uarr); } //方法 if(isset($uarr[0])) { $_GET['action'] = empty($uarr[0]) ? 'index': strtolower($uarr[0]); array_shift($uarr); } //伪静态下 访问动态首页、内容页URL、分类URL、标签URL 则进入404页面 $dis_control = array('index', 'show', 'cate', 'tag'); if( in_array($_GET['control'], $dis_control) && $_GET['action'] == 'index'){ core::error404(); } //参数 $num = count($uarr); for($i=0; $i<$num; $i+=2){ isset($uarr[$i+1]) && $_GET[$uarr[$i]] = $uarr[$i+1]; } return false; } //分页参数验证 private function page_check($param){ if(empty($param)){ return false; }else{ preg_match('/^page_([1-9]\d*)$/', $param, $mat); if(isset($mat[1])){ return $mat[1]; }else{ return false; } } } //正整数参数验证 private function integer_check($param){ if(empty($param)){ return false; }elseif( preg_match($this->integer_pattern, $param) ){ return true; }else{ return false; } } //模型ID验证(不含单页) private function mid_check($mid, $cfg){ if($mid > 1 && isset($cfg['table_arr'][$mid])){ return true; }else{ return false; } } //部首URL解析 protected function bushou_url($cfg = array(), $uri = ''){ // 匹配bushou/格式的URL(部首列表页) if($uri == 'bushou/') { // 使用cate控制器来处理,对应分类ID为21 $_GET['control'] = 'cate'; $_GET['action'] = 'index'; $_GET['cid'] = 21; return true; } // 匹配bushou/部首.html格式的URL if(substr($uri, 0, 7) == 'bushou/') { $url_suffix = $_ENV['_config']['url_suffix']; $url_suffix_len = strlen($url_suffix); // 检查URL后缀 if(substr($uri, -$url_suffix_len) == $url_suffix) { $newurl = substr($uri, 7, -$url_suffix_len); // 提取部首,支持URL编码 $newurl = urldecode($newurl); if(!empty($newurl)) { // 使用bushou控制器来处理 $_GET['control'] = 'bushou'; $_GET['action'] = 'index'; $_GET['bushou'] = $newurl; return true; } } } return false; } //拼音URL解析 protected function pinyin_url($cfg = array(), $uri = ''){ // 匹配pinyin/拼音.html格式的URL if(substr($uri, 0, 7) == 'pinyin/') { $url_suffix = $_ENV['_config']['url_suffix']; $url_suffix_len = strlen($url_suffix); // 检查URL后缀 if(substr($uri, -$url_suffix_len) == $url_suffix) { $newurl = substr($uri, 7, -$url_suffix_len); // 提取拼音,支持URL编码 $newurl = urldecode($newurl); if(!empty($newurl)) { // 使用pinyin控制器来处理 $_GET['control'] = 'pinyin'; $_GET['action'] = 'index'; $_GET['pinyin'] = $newurl; return true; } } } return false; } //康熙字典URL解析 protected function kangxi_url($cfg = array(), $uri = ''){ if(substr($uri , 0 , 7) == 'kangxi/' && strlen($uri) > 7){ $url_suffix = $_ENV['_config']['url_suffix']; $url_suffix_len = strlen($url_suffix); if(substr($uri, -$url_suffix_len) == $url_suffix) { $newurl = substr($uri, 0, -$url_suffix_len); $u_arr = explode('/', $newurl); if(!isset($u_arr[1])){ core::error404(); } if(isset($u_arr[2])){ $nannv_pinyin_to_char = array('nan' => '男', 'nv' => '女'); $wuxing_pinyin_to_char = array('jin' => '金', 'mu' => '木', 'shui' => '水', 'huo' => '火', 'tu' => '土'); $nannv_value = $u_arr[1]; $wuxing_value = $u_arr[2]; $valid_nannv = false; $valid_wuxing = false; if(isset($nannv_pinyin_to_char[$nannv_value])) { $nannv_value = $nannv_pinyin_to_char[$nannv_value]; $valid_nannv = true; } if(isset($wuxing_pinyin_to_char[$wuxing_value])) { $wuxing_value = $wuxing_pinyin_to_char[$wuxing_value]; $valid_wuxing = true; } if(!$valid_nannv || !$valid_wuxing) { core::error404(); } $_GET['control'] = 'kangxi'; $_GET['action'] = 'index'; $_GET['nannv'] = $nannv_value; $_GET['wuxing'] = $wuxing_value; return true; } } } return false; } } Lecms 3.0.3 错误

错误信息

错误位置

基本信息

程序流程

SQL

$_GET

$_POST

$_COOKIE

包含文件

其他信息