增加老旧页面查询功能

hotfix/远程访问多媒体中心
lmr@hainatravel.com 8 years ago
parent b7f27083af
commit 1ffb6cb2a4

@ -4,21 +4,6 @@ if (!defined('BASEPATH'))
class Tools extends CI_Controller
{
//缓存文件绝对路径
private $dir = '';
//存放缓存文件的数组
private $file = array();
//存放缓存文件夹的数组
private $path = array();
//缓存更新接口
private $cache_api = '';
//缓存更新参数
private $post_para = '';
//当前站点域名
private $current_domain = '';
//文件更新日期
private $file_time = array();
function __construct()
{
parent::__construct();
@ -37,157 +22,17 @@ class Tools extends CI_Controller
* @param String $site_code
*
*/
public function update()
public function old()
{
//设置缓存文件文件夹
$cache_config = $this->config->item('cache');
$current_cache_config = $cache_config[$this->site_code];
$this->dir = $current_cache_config['cache_path'];
//设置当前站点
$this->current_domain = $this->config->item('site_url');
//echo $this->config->item('site_url');
//设置缓存更新接口及POST参数
$this->cache_api = $current_cache_config['cache_api'];
$this->post_para = $current_cache_config['cache_api_para'];
//遍历缓存文件夹
$this->tree($this->dir, $this->file, $this->path, $this->file_time);
//按目录筛选结果
$this->filter($this->file, $this->path);
//整理需要传递到视图的数据
$data['file'] = $this->file;
$data['path'] = $this->path;
$data['file_time'] = $this->file_time;
$data['cache_api'] = $this->cache_api;
$data['post_para'] = $this->post_para;
$data['yeardiff'] = $this->input->get_post('yeardiff');
$data['nopub'] = $this->input->get_post('nopub');
//参数
if (!$data['yeardiff']) $data['yeardiff'] = 3;
//老旧信息
$data['info'] = $this->Information_model->get_oldest_info($data['yeardiff'], $data['nopub']);
//视图
$this->load->view('cache/update', $data);
}
/**
*
* 公有函数:扫描已有缓存文件并更新。
*
* 必要参数:
* @param String $site_code
*
*/
public function sitemap()
{
header("Content-type:text/xml");
//设置缓存文件文件夹
$cache_config = $this->config->item('cache');
$current_cache_config = $cache_config[$this->site_code];
$this->dir = $current_cache_config['cache_path'];
//设置当前站点
$this->current_domain = $this->config->item('site_url');
//设置缓存更新接口及POST参数
$this->cache_api = $current_cache_config['cache_api'];
$this->post_para = $current_cache_config['cache_api_para'];
//遍历缓存文件夹
$this->tree($this->dir, $this->file, $this->path, $this->file_time);
//按目录筛选结果
$this->filter($this->file, $this->path);
//整理需要传递到视图的数据
$data['file'] = $this->file;
$data['path'] = $this->path;
$data['file_time'] = $this->file_time;
$data['cache_api'] = $this->cache_api;
$data['post_para'] = $this->post_para;
//排序file数组
sort ($data['file']);
//生成sitemap
$dom = new DomDocument('1.0', 'utf-8');
$urlset = $dom->createElement('urlset');
$urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$dom->appendchild($urlset);
foreach ($data['file'] as $f)
{
$url = $dom->createElement('url');
$loc = $dom->createElement('loc');
$text = $dom->createTextNode($f);
$loc->appendchild($text);
$url->appendchild($loc);
$urlset->appendchild($url);
}
echo($dom->saveXML());
}
/**
*
* 私有函数:递归遍历缓存文件夹,将目录存放到$path文件存放到$file。
*
* 必要参数:
* @param String $dir - 需要遍历的目录
* @param Array $file - 存放文件结果的数组引用
* @param Array $path - 存放路径结果的数组引用
* @param Array $file_time - 存放文件更新日期的数组引用
*
*/
private function tree($dir, &$file, &$path, &$file_time)
{
$mydir = dir($dir);
while($f = $mydir->read())
{
if(is_dir("$dir/$f") && $f!="." && $f!=".." && (strpos($dir, '/cn/')==false))
{
$path[] = "$dir/$f";
$this->tree("$dir/$f", $file, $path, $file_time);
}
else
{
if ($f!='.' && $f!='..' && (strpos($dir, '/cn/')==false) && (strpos($f, '.pdf')===false))
{
$file_temp = str_ireplace('index.htm###', '', $f.'###');
$file_temp = str_ireplace('###', '', $file_temp);
$path_temp = str_ireplace($this->dir, '', $dir);
$url_temp = $this->current_domain.$path_temp.'/'.$file_temp;
$file_time[$url_temp] = date("F d Y H:i:s", filemtime("$dir/$f"));
$file[] = $url_temp;
}
}
}
$mydir->close();
}
/**
*
* 私有函数:筛选目录和文件。
*
* 必要参数:
* @param Array $file - 存放文件结果的数组引用
* @param Array $path - 存放路径结果的数组引用
*
* 可选参数POST参数 - $_POST['p']
*
*/
private function filter(&$file, &$path)
{
if (isset($_POST['p']) && !empty($_POST['p']))
{
//删选文件
foreach ($file as &$f)
{
(stripos($f, $_POST['p'])!==false) or $f = false;
}
$file = array_filter($file);
//删选目录
foreach ($path as &$p)
{
(stripos($p, $_POST['p'])!==false) or $p = false;
}
$path = array_filter($path);
}
$this->load->view('tools/old', $data);
}
}

@ -329,10 +329,8 @@ class Information_model extends CI_Model {
}
//获取3年未更新的信息
function get_oldest_info() {
//年份条件
$yeardiff = $this->input->get_post('yeardiff');
if (!$yeardiff) $yeardiff = 3;
function get_oldest_info($yeardiff = 3, $has_no_pub = true) {
$has_no_pub ? $sql_no_pub = '' : $sql_no_pub = "AND ic_status = 1";
//sql
$sql = "SELECT
ic_id,
@ -343,11 +341,14 @@ class Information_model extends CI_Model {
ic_datetime,
ic_type,
ic_author,
ic_status=1,
ic_status,
ic_view
FROM infoContents
WHERE datediff(YEAR,DATEPART(yyyy, ic_datetime),DATEPART(YYYY, getdate())) > ?
AND ic_sitecode = ? ";
WHERE YEAR(GETDATE()) - YEAR(ic_datetime) >= ?
AND ic_sitecode = ?
".$sql_no_pub."
AND ic_url <> ''
ORDER BY ic_datetime";
$query = $this->HT->query($sql, array($yeardiff, $this->config->item('site_code')));
return $query->result();
}

@ -908,9 +908,11 @@
'info' => '信息',
'deal' => '促销',
'2015' => '2015',
'tour2017' => '2017',
'op' => 'OP',
'best' => '实用信息',
'culture' => '文化'
'culture' => '文化',
'top10' => 'TOP10'
);
?>
<label>匹配到一级导航
@ -934,10 +936,12 @@
<option value="flight"><?php echo($meta_subnavi_arr['flight']); ?></option>
<option value="info"><?php echo($meta_subnavi_arr['info']); ?></option>
<option value="deal"><?php echo($meta_subnavi_arr['deal']); ?></option>
<option value="tour2017"><?php echo($meta_subnavi_arr['tour2017']); ?></option>
<option value="2015"><?php echo($meta_subnavi_arr['2015']); ?></option>
<option value="op"><?php echo($meta_subnavi_arr['op']); ?></option>
<option value="best"><?php echo($meta_subnavi_arr['best']); ?></option>
<option value="culture"><?php echo($meta_subnavi_arr['culture']); ?></option>
<option value="top10"><?php echo($meta_subnavi_arr['top10']); ?></option>
</select>
</div>
<div class="col-sm-8">

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>更新静态页-v1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="http://europe.chtcdn.com/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<script type="text/javascript" src="http://europe.chtcdn.com/js/jquery.js"></script>
<script type="text/javascript" src="http://europe.chtcdn.com/bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
.show-grid {padding: 15px; background: #efefef; border-radius: 5px;}
.mr10 {margin-right: 10px;}
.nav {margin-bottom: 5px;}
.pic {display: none;}
.msg {color: #07c;}
.mt12 {margin-top: 12px;}
.msg_wait {color: #999;}
.none {display: none;}
.form-search {display: inline-block;margin:0 0 0 5px !important;}
.input-medium.search-query {width: 250px;}
#search,#insert,#update {margin-top: 2px;float: right;}
@media (min-width: 1200px) {
.container.wd {
padding: 0 15px;
width: 1170px;
}
}
</style>
<script type="text/javascript">
$(function() {
//下拉选站点
$('a.sss').on('click', function() {
var site = $(this).html();
location.href = '/info.php/login/change_site/'+site+'/?url=/tools/old#';
});
});
</script>
</head>
<body>
<div class="container wd">
<div class="row show-grid">
<ul class="nav nav-pills">
<li class="active dropdown mr10">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
站点:<?php echo($this->config->item('site_code'));?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>
<a class="sss">cht</a>
</li>
<li>
<a class="sss">jp</a>
</li>
<li>
<a class="sss">gm</a>
</li>
<li>
<a class="sss">vc</a>
</li>
<li>
<a class="sss">vac</a>
</li>
<li>
<a class="sss">ru</a>
</li>
<li>
<a class="sss">it</a>
</li>
</ul>
</li>
<span class="label label-info">信息:<?php echo(count($info));?>个 (只显示前800个)</span>
<form class="form-search" id="path_search" action="#" method="post">
<select name="yeardiff">
<option value="1" <?php if($yeardiff==1) echo('selected'); ?>>1年前</option>
<option value="2" <?php if($yeardiff==2) echo('selected'); ?>>2年前</option>
<option value="3" <?php if($yeardiff==3) echo('selected'); ?>>3年前</option>
<option value="4" <?php if($yeardiff==4) echo('selected'); ?>>4年前</option>
<option value="5" <?php if($yeardiff==5) echo('selected'); ?>>5年前</option>
<option value="6" <?php if($yeardiff==6) echo('selected'); ?>>6年前</option>
</select>
<span class="checkbox">
<label>
<input type="checkbox" name="nopub" value="1" <?php if($nopub==1) echo('checked'); ?>> 显示未发布的信息
</label>
</span>
&nbsp;&nbsp;&nbsp;&nbsp;
<button type="submit" class="btn">筛选</button>
</form>
</ul>
</div>
<div class="row">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>文件名</th>
<th width="10%">更新日期</th>
<th width="8%">是否发布</th>
</tr>
</thead>
<tbody class="data_group">
<?php foreach($info as $key=>$it) {
if ($key == 800) break;
?>
<tr class="data">
<td><?php echo($key+1);?></td>
<td title="<?php echo($it->ic_url);?>"><?php echo($it->ic_url);?></td>
<td title="<?php echo($it->ic_datetime);?>"><?php echo(date('Y-m-d', strtotime($it->ic_datetime)));?></td>
<td title="<?php echo($it->ic_datetime);?>">
<?php
if ($it->ic_status == 1)
echo('<span style="color:#07c"></span>');
else
echo('<span style="color:#a12023"></span>');
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save