|
<?php
namespace app\admin\controller;
use think\Request;
use app\admin\model\LoginNote as LoginNoteModel;
class Index extends Base
{
public function index()
{
$id = $this->uid;
$login_note_model = new LoginNoteModel();
$data_login = $login_note_model->where('userid', $id)->order('id desc')->limit(10)->select();
$data_login_counts = $login_note_model->where('userid', $id)->count();
$this->assign('data_login_counts', $data_login_counts);
$this->assign('data_login', $data_login);
return $this->fetch();
}
public function usedspace()
{
if (Request::instance()->isAjax()) {
$dirname = ROOT_PATH;
$dirsize = get_dir_size($dirname);
define('BKM', 1024);
if ($dirsize>BKM) {
$dirsize = round($dirsize/BKM, 2);
if ($dirsize>BKM) {
$dirsize = round($dirsize/BKM, 2);
$dirsize .="M";
} else {
$dirsize .="K";
}
} else {
$dirsize .="B";
}
return ['code'=>1, 'size'=>$dirsize];
}
}
public function clearcache()
{
if (Request::instance()->isAjax()) {
$temp_dir = RUNTIME_PATH . 'temp/';
$cache_dir = RUNTIME_PATH . 'cache/';
try {
deldir($temp_dir);
deldir($cache_dir);
} catch (\Exception $e) {
return ['code'=>0, 'msg'=>$e->getMessage()];
}
return ['code'=>1, 'msg'=>'清除成功'];
}
}
}
|