wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
3e083b 1 <?php
B 2 define('IN_ECS', true);
3 require(dirname(__FILE__) . '/includes/init.php');
4
5 $pagetype = !empty($_REQUEST['pagetype']) ? trim($_REQUEST['pagetype']) : 'goods';
6 $id =!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : '0';
7
8 switch($pagetype)
9 {
10     case 'goods':
11         $pathrow = $db->getRow("select c.path_name,c.cat_id from ". $ecs->table('goods')." AS g left join ". $ecs->table('category') ." AS c on g.cat_id=c.cat_id where g.goods_id='$id'" );
12         $pathrow['path_name'] = $pathrow['path_name'] ? $pathrow['path_name'] : ("cat".$pathrow['cat_id']);
13         $pathrow['path_name'] = PREFIX_CATEGORY ."-".$pathrow['path_name'];
14         $url = $pathrow['path_name'] ."/goods-$id.html";
15         header('HTTP/1.1 301 Moved Permanently');   
16         header('Location: '.$url);
17         break;
18     
19     case 'category':
20         $pathrow = $db->getRow("select path_name, cat_id from ".  $ecs->table('category') ."  where cat_id = '$id' " );
21         $pathrow['path_name'] = $pathrow['path_name'] ? $pathrow['path_name'] : ("cat".$pathrow['cat_id']);
22         $pathrow['path_name'] = PREFIX_CATEGORY ."-".$pathrow['path_name'];
23         $thisurl= $GLOBALS['ecs']->get_domain().$_SERVER['REQUEST_URI'];
24         $thisroot=$GLOBALS['ecs']->url();
25         $makeurl = str_replace($thisroot, '', $thisurl);
26         $makeurl = substr($makeurl, 0, strpos($makeurl, '.html')). ".html";
27         $url = $pathrow['path_name']. '/'.$makeurl;
28         //echo $url;
29         header('HTTP/1.1 301 Moved Permanently');   
30         header('Location: '.$url);
31         break;
32     
33     case 'article':
34         $pathrow = $db->getRow("select c.path_name,c.cat_id from ". $ecs->table('article')." AS a left join ". $ecs->table('article_cat') ." AS c on a.cat_id=c.cat_id where a.article_id='$id'" );
35         $pathrow['path_name'] = $pathrow['path_name'] ? $pathrow['path_name'] : ("cat".$pathrow['cat_id']);
36         $pathrow['path_name'] = PREFIX_ARTICLECAT ."-".$pathrow['path_name'];
37         $url = $pathrow['path_name'] ."/article-$id.html";
38         header('HTTP/1.1 301 Moved Permanently');   
39         header('Location: '.$url);
40         break;
41     
42     case 'article_cat':
43         $page = !empty($_REQUEST['page']) ? intval($_REQUEST['page']) : '0';
44         $sort = !empty($_REQUEST['sort']) ? trim($_REQUEST['sort']) : '';
45         $order = !empty($_REQUEST['order']) ? trim($_REQUEST['order']) : '';
46         $keywords = !empty($_REQUEST['keywords']) ? trim($_REQUEST['keywords']) : '';
47
48         $pathrow = $db->getRow("select path_name, cat_id from ".  $ecs->table('article_cat') ."  where cat_id='$id'" );
49         $pathrow['path_name'] = $pathrow['path_name'] ? $pathrow['path_name'] : ("cat".$pathrow['cat_id']);
50         $pathrow['path_name'] = PREFIX_ARTICLECAT ."-".$pathrow['path_name'];
51         $url = $pathrow['path_name'] ."/article_cat-".$id;
52         $url .= $page ? "-$page" : "";
53         if($keywords)
54         {
55             $url .= "-$keywords";
56         }
57         elseif($sort)
58         {
59             $url .= "-$sort";
60             $url .= $order ? "-$order" : "";
61         }
62         
63         $url .= ".html";
64         header('HTTP/1.1 301 Moved Permanently');   
65         header('Location: '.$url);
66         break;
67
68     default:
69     break;
70 }
71 ?>