<?php namespace Phpcmf\Controllers\Admin;

class Log extends \Phpcmf\Common {

	public function index() {

        $file = WRITEPATH.'app/weixin.log';
        if (!$file) {
            $this->_admin_msg(0, '文件不存在：'.$file);
        }
        if (filesize($file) > 1024*1024*2) {
            $this->_admin_msg(0, '此日志文件大于2MB，请使用Ftp等工具查看此文件：'.$file);
        }

		\Phpcmf\Service::V()->assign([
		    'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
                [
                    '请求日志' => ['weixin/log/index', 'fa fa-shield'],
                ]
            ),
            'code' => file_get_contents($file),
            'islog' => isset($this->weixin['account']['log']) && $this->weixin['account']['log'],
        ]);
		\Phpcmf\Service::V()->display('log.html');
	}


    public function del() {

        $file = WRITEPATH.'app/weixin.log';
        unlink($file);

        $this->_json(1, dr_lang('操作成功'));
    }

}
