-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathem-optimize-master_setting.php
More file actions
148 lines (146 loc) · 3.95 KB
/
em-optimize-master_setting.php
File metadata and controls
148 lines (146 loc) · 3.95 KB
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
<?php
/**
* 数据库优化
* @copyright (c) crazyus.us All Rights Reserved
*/
!defined('EMLOG_ROOT') && exit('access deined!');
function plugin_setting_view() {
/*Load the language*/
include(EMLOG_ROOT."/content/plugins/em-optimize-master/lang/".Option::get('language').".php");
/*end*/
$DB = Database::getInstance();
function format_size($size) {
$measure = "Byte";
if ($size >= 1024) {
$size = $size / 1024;
$measure = "KiB";
}
if ($size >= 1024) {
$size = $size / 1024;
$measure = "MB";
}
$return = sprintf('%0.4s',$size);
if (substr($return, -1) == "." ) $return = substr($return, 0, -1);
return $return . " ". $measure;
}
?>
<script type="text/javascript">
$("#menu_mg").addClass('active');
$("#optimizedb").addClass('active-page');
setTimeout(hideActived,2600);
</script>
<div class="heading-bg card-views">
<ul class="breadcrumbs">
<li><a href="./"><i class="fa fa-home"></i> <?php echo $_lang['home'] ?></a></li>
<li class="active"> <?php echo $_lang['optimize'] ?> </li>
</ul>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default card-view">
<div class="panel-body">
<?php echo $_lang['tips'] ?>
</div>
<div id="cache">
<div class="form-group text-center">
<a id="opt" class="btn btn-info button"/><?php echo $_lang['button'] ?></a>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default card-view">
<div class="table-wrap ">
<div class="table-responsive">
<table class="table table-striped table-bordered mb-0" id="optimized">
<thead>
<tr>
<th><b> <?php echo $_lang['name'] ?> </b></th>
<th class="tdcenter"><b> <?php echo $_lang['size'] ?> </b></th>
<th class="tdcenter"><b> <?php echo $_lang['record'] ?> </b></th>
<th class="tdcenter"><b> <?php echo $_lang['overhead'] ?> </b></th>
</tr>
</thead>
<tbody>
<?php
$tables = array();
$result = $DB->query("SHOW TABLE STATUS");
$tot =0;
$rs =0;
$nrs=0;
while($row = $DB->fetch_array($result)) {
$total_size = $row[ "Data_length" ] + $row[ "Index_length" ];$gain= $row['Data_free'];
$total_gain += $gain;
$gain = round ($gain,2);$tbl = $row['Name'];
$rs++;
$tot = $tot + $total_size;?><tr>
<td> <?php echo $tbl?></td>
<td class="tdcenter"> <?php echo format_size($total_size);?></td>
<td class="tdcenter">
<?php
$q=("select * from $tbl");
$rez= $DB-> query($q);
echo $rowss= $DB-> num_rows($rez);
$nrs =$nrs +$rowss;?> <?php echo $_lang['format'] ?>
</td>
<?php
if ($gain == 0){
?>
<td class="tdcenter">
0 KiB
</td>
<?php }else{ ?>
<td class="tdcenter" style=\"color: #ff0000;\">
<?php echo format_size($gain) ?>
</td>
<?php } ?>
</tr>
<?php }?>
<tr>
<td><?php echo $_lang['total'] ?><sup><?php echo $rs ?> <?php echo $_lang['formats'] ?> </sup></td>
<td> <?php echo format_size($tot);?> </td>
<td> <?php echo $nrs ?> <?php echo $_lang['format'] ?></td>
<td> <?php echo format_size($total_gain);?> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).on("click","#opt",function(){
$("#optimized").html('<img src="<?php echo BLOG_URL ?>content/plugins/em-optimize-master/loading.gif" style="width:12px;height:12px"/> <a style="color:#666;" rel="external nofollow" title="<?php echo $_lang['doing'] ?>" id="opt" > <?php echo $_lang['doing'] ?>....</a>');
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("optimized").innerHTML=xmlhttp.responseText;
}
}
var url="";
url="<?php echo BLOG_URL ?>content/plugins/em-optimize-master/em-optimize-master_do.php?opt=suc&token=<?php echo LoginAuth::genToken(); ?>";
xmlhttp.open("GET",url,true);
xmlhttp.send();
})
</script>
<?php
}
?>