chengkun
2025-04-30 6ab292fb7415be124651e312ec4f21c594568f17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
 
class admin_xml_controller extends adminCommon{
    function index_action(){ 
        $this->yuntpl(array('admin/admin_xml'));
    }
    function archive_action(){
 
        if($_POST['limit']){
            
            $type=trim($_POST['type']);
            
            if($type=='ask'||$type=='sitemap'){
                
                $askM            =    $this -> MODEL('ask');
                
                if($_POST['order']=='uptime'){
                    
                    $order                =    'lastupdate';
                    
                    $where['orderby']    =    array('lastupdate,desc');
                }else{
                    
                    $order                =    'add_time';
                    
                    $where['orderby']    =    array('add_time,desc');
                }
                $where['limit']            =    intval($_POST['limit']);
                
                $qlist            =    $askM -> getList($where,array('field'=>"`id` as `id`,`".$order."` as `time`"));
                
                $rows['ask']    =    $qlist;
            }
            if($type=='news'||$type=='sitemap'){
                
                $articleM        =    $this -> MODEL('article');
                
                if($_POST['order']=='uptime'){
                    
                    $order='lastupdate';
                    
                    $where['orderby']    =    array('lastupdate,desc');
                }else{
                    
                    $order='datetime';
                    
                    $where['orderby']    =    array('datetime,desc');
                }
                $where['limit']            =    intval($_POST['limit']);
                
                $nlist            =    $articleM -> getList($where,array('field'=>"`id`,`".$order."` as `time`,`datetime`"));
                
                $rows['news']    =    $nlist['list'];
            }
            if($type=='company'||$type=='sitemap'){
                
                $companyM        =    $this -> MODEL('company');
                
                if($_POST['order']=='uptime'){
                    
                    $order                =    'lastupdate';
                    
                    $where['orderby']    =    array('lastupdate,desc');
                }else{
                    
                    $order                =    'jobtime';
                    
                    $where['orderby']    =    array('jobtime,desc');
                }
                $where['limit']            =    intval($_POST['limit']);
                
                $comlist        =    $companyM -> getList($where,array('field'=>"`uid` as `id`,`".$order."` as `time`"));
                
                $rows['company']=    $comlist['list'];
            }
            if($type=='job'||$type=='sitemap'){
                
                $jobM            =    $this -> MODEL('job');
                
                $where['sdate']            =    array('<',time());
                
                $where['state']            =    1;
                
                if($_POST['order']=='uptime'){
                    
                    $order                =    'lastupdate';
                    
                    $where['orderby']    =    array('lastupdate,desc');
                }else{
                    
                    $order                =    'sdate';
                    
                    $where['orderby']    =    array('sdate,desc');
                }
                $where['limit']            =    intval($_POST['limit']);
                
                $joblist        =    $jobM -> getList($where,array('field'=>"`id`,`".$order."` as `time`"));
                
                $rows['job']    =    $joblist['list'];
            }
            if($type=='resume'||$type=='sitemap'){
                
                $resumeM        =    $this -> MODEL('resume');
                
                $where['status']        =    1;
                
                $where['r_status']        =    1;
                
                $where['job_classid']    =    array('<>','');
            
                if($_POST['order']=='uptime'){
                    
                    $order                =    'lastupdate';
                    
                    $where['orderby']    =    array('lastupdate,desc');
                }else{
                    
                    $order                =    'addtime';
                    
                    $where['orderby']    =    array('addtime,desc');
                }
                $where['limit']            =    intval($_POST['limit']);
                
                $rlist            =    $resumeM -> getSimpleList($where,array('field'=>"`id`,`".$order."` as `time`"));
                
                $rows['resume']    =    $rlist;
            }
            if(strpos(trim($_POST['name']),'.xml')==true){
                
                $_POST['name']=substr(trim($_POST['name']),0,strpos(trim($_POST['name']),'.xml'));
            }
 
            if(is_array($rows)){
                
                $show    =    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<urlset>\r\n";
                
                foreach($rows as $key=>$v){
                    
                    if($key=='ask'){
                        
                        foreach($v as $val){
                            
                            $url    =    Url('ask',array('c'=>'content','id'=>$val['id']));
                            
                            $url    =    str_replace("&","&amp;",$url);
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                    if($key=='news'&&$this->config["sy_news_rewrite"]=='2'){
                        
                        foreach($v as $val){
                            
                            $url    =    $this->config['sy_weburl']."/news/".date("Ymd",$val["datetime"])."/".$val[id].".html";
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                    if($key=='news'&&$this->config["sy_news_rewrite"]!='2'){
                        
                        foreach($v as $val){
                            
                            $url    =    Url("article",array("c"=>"show","id"=>$val[id]));
                            
                            $url    =    str_replace("&","&amp;",$url);
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                    if($key=='company'){
                        
                        foreach($v as $val){
                            
                            $url    =    Url('company',array('c'=>'show',"id"=>$val['id']));
                            
                            $url    =    str_replace("&","&amp;",$url);
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                    if($key=='job'){
                        
                        foreach($v as $val){
                            
                            $url    =    Url("job",array("c"=>"comapply","id"=>$val['id']));
                            
                            $url    =    str_replace("&","&amp;",$url);
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                    if($key=='resume'){
                        
                        foreach($v as $val){
                            
                            $url    =    Url("resume",array("c"=>'show',"id"=>$val['id']));
                            
                            $url    =    str_replace("&","&amp;",$url);
                            
                            $show  .=    "<url><loc>".$url."</loc><lastmod>".date("Y-m-d",$val['time'])."</lastmod><changefreq>".$_POST['frequency']."</changefreq></url>\r\n";
                        }
                    }
                }
                
                $show.="</urlset>";
                
                if(CheckRegUser($_POST['name'])==false){
                    
                    $this -> layer_msg("XML名称包含特殊字符!",8,0,'index.php?m=admin_xml');
                }
                $path    =    APP_PATH."/".$_POST['name'].".xml";
                
                $fp        =    @fopen($path,"w");
                
                @fwrite($fp,$show);
                
                @fclose($fp);
                
                @chmod($path,0777);
                
                $this -> layer_msg("生成成功!",9,0,'index.php?m=admin_xml');
            }else{
                
                $this -> layer_msg("没有数据可以生成!",9,0,'index.php?m=admin_xml');
            }
        }
    }
 
}
?>