-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread_cache_list.php
105 lines (81 loc) · 2.27 KB
/
read_cache_list.php
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
<?php
/*
* e107 Static Cache
* Read cache list from ajax calls
*
*/
require_once('../../class2.php');
if (!defined('e107_INIT')) { exit; }
if(!e107::isInstalled('static_cache'))
{
return '';
}
if (!getperms('P'))
{
e107::redirect('home');
exit;
}
$qry_params = $_POST['params'];
$oSql = e107::getDb();
//count results
$qry = "SELECT
COUNT(l.scache_id) AS tot_results
FROM
#static_cache_cpages l
";
//if search something...
if( $qry_params['search_str'] ){
$qry .= "WHERE
l.scache_key LIKE '%".$qry_params['search_str']."%'
OR
l.scache_url LIKE '%".$qry_params['search_str']."%'
OR
l.scache_path LIKE '%".$qry_params['search_str']."%'
OR
l.scache_lastmod LIKE '%".$qry_params['search_str']."%'
";
}
$oSql->gen($qry);
$row = $oSql->fetch();
$total_rows = $row['tot_results'];
//continue with real query
$qry = "SELECT
l.*
FROM
#static_cache_cpages l
";
//if search something...
if( $qry_params['search_str'] ){
$qry .= "WHERE
l.scache_key LIKE '%".$qry_params['search_str']."%'
OR
l.scache_url LIKE '%".$qry_params['search_str']."%'
OR
l.scache_path LIKE '%".$qry_params['search_str']."%'
OR
l.scache_lastmod LIKE '%".$qry_params['search_str']."%'
";
}
$qry .= "
ORDER BY
";
//if sort orders...
if( $qry_params['sort_field'] ){
$qry .= "`".$qry_params['sort_field']."` ".( ($qry_params['sort_order'])? $qry_params['sort_order']:'DESC' )." ";
}else{
$qry .= "l.scache_id DESC ";
}
$qry .= " LIMIT ".$qry_params['page_offset'].", ".$qry_params['page_size'] ;
$qry .= " ;";
//echo $qry;
$oSql->gen($qry);
$res_lines = Array();
while($row = $oSql->fetch()){
//push to rows array...
$row['scache_lastmod'] = gmdate("Y-m-d\TH:i:s\Z",$row['scache_lastmod']);
$row['btn_delete'] = '<button title="'.LAN_STATIC_CACHE_ADMIN_20.'" class="btn btn-xs btn-danger fa fa-eraser " onclick="cnt_delete(\''.$row['scache_id'].'\');" ></span>' ;
array_push($res_lines, $row);
}
$arr_results = array( "d" => array( "total" => $total_rows, "rows" => $res_lines ) );
echo json_encode( $arr_results );
?>