123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- class Public_Controller extends CI_Controller
- {
- protected $page_size;
- protected $branch_array;
- protected $setting;
- //告警类型
- public $warning_type = array(
- "10" => "失陷事件",
- "20" => "脆弱性",
- "30" => "残余攻击"
- );
- //告警级别
- public $warning_level = array(
- "10" => "已失陷",
- "20" => "高可疑",
- "30" => "低可疑",
- "40" => "高危",
- "50" => "中危",
- "60" => "低危"
- );
- //告警状态
- public $warning_status = array(
- "10" => "待审核下发",
- "20" => "已忽略",
- "30" => "已生成工单",
- "40" => "已处置"
- );
- //工单状态
- public $workorder_status = array(
- "10" => "待签收",
- "20" => "已签收,正在处理",
- "30" => "处理完成,待复核",
- "40" => "驳回处理",
- "50" => "已结束",
- "60" => "已删除"
- );
- //发送类型
- public $send_type = array(
- "10" => "短信",
- "20" => "邮件"
- );
- //用户角色
- public $user_types = array(
- "1" => "管理员",
- "2" => "工程师"
- );
- //用户状态
- public $user_status = array(
- "10" => "正常",
- "40" => "已停用"
- );
- //应用授权状态
- public $appauth_status = array(
- "10" => "启用",
- "40" => "停用"
- );
- //平台对应关系
- public $from = array(
- "sip" => "安全感知平台"
- );
- public function __construct()
- {
- parent::__construct();
- $this->load->helper(array('url'));
- $this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
- $cahce_setting = $this->cache->get('setting');
- if(!$cahce_setting){
- $this->load->model("setting_model");
- $setting = $this->setting_model->get_setting();
- if($setting) {
- $cahce_setting = $setting;
- $this->cache->save('setting', $setting, 30000);
- }
- }
- $cahce_branch = $this->cache->get('branchs');
- if(!$cahce_branch){
- $this->load->model("branch_model");
- $branch_list = $this->branch_model->select_branch();
- if($branch_list){
- $branch = array();
- foreach($branch_list as $key=>$val){
- $branch[$val['branch_id']] = $val;
- }
- $this->cache->save('branchs', $branch, 30000);
- $cahce_branch= $branch;
- }else{
- $this->cache->save('branchs', array(), 30000);
- $cahce_branch = array();
- }
- }
- if(!array_key_exists('save_time',$cahce_setting) || $cahce_setting['save_time']==""){
- $cahce_setting['save_time'] = "180";
- }
- $this->setting = $cahce_setting;
- $this->branch_array = $cahce_branch;
- $this->assign("setting",$cahce_setting);
- $this->assign("branch",$cahce_branch);
- $this->page_size = $this->config->item('page_size');
- $this->assign("sys_name", $this->config->item('sys_name'));
- $this->assign("from",$this->from);
- }
- public function assign($key, $val)
- {
- $this->ci_smarty->assign($key, $val);
- }
- //Smaty模板输出
- public function display($html)
- {
- $this->output->set_header('X-Frame-Options: sameorigin');
- $this->output->set_header("X-XSS-Protection: 1");
- $this->output->set_header("X-Content-Type-Options:nosniff");
- $this->ci_smarty->display($html);
- }
- //输出Json
- public function response($data)
- {
- $this->output->set_header('X-Frame-Options: sameorigin');
- $this->output->set_header("X-XSS-Protection: 1");
- $this->output->set_header("X-Content-Type-Options:nosniff");
- $this->output->set_header('Content-Type: application/json; charset=utf-8');
- echo json_encode($data);
- }
- /*
- * 创建唯一ID
- */
- public function create_id()
- {
- return date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
- }
- /**
- * 分页配置
- * @param $count 内容总数
- * @param $page_size 每页数量
- * @param $url 分页URL
- * @return mixed 分页html
- */
- public function page_config($count, $page_size, $url)
- {
- $config ['base_url'] = $url; //设置基地址
- $config['num_links'] = 4;
- $config ['total_rows'] = $count;
- $config ['per_page'] = $page_size; //每页显示的数据数量
- $config['use_page_numbers'] = TRUE;
- $config['full_tag_open'] = '<ul class="pagination">';
- $config['full_tag_close'] = '</ul>';
- $config ['prev_link'] = '<';
- $config['prev_tag_open'] = '<li>';
- $config['prev_tag_close'] = '</li>';
- $config ['next_link'] = '>';
- $config['next_tag_open'] = '<li>';
- $config['next_tag_close'] = '</li>';
- $config['num_tag_open'] = '<li>';
- $config['num_tag_close'] = '</li>';
- $config['cur_tag_open'] = '<li class="active"><a href="#">';
- $config['cur_tag_close'] = '</a></li>';
- $config ['first_link'] = '«';
- $config['first_tag_open'] = '<li>';
- $config['first_tag_close'] = '</li>';
- $config ['last_link'] = '»';
- $config['last_tag_open'] = '<li>';
- $config['last_tag_close'] = '</li>';
- $config['page_query_string'] = TRUE;
- return $config;
- }
- }
- class MY_Controller extends Public_Controller
- {
- public function __construct()
- {
- parent::__construct();
- if (!$this->session->user_id || !$this->session->username) {
- redirect("login");
- } else {
- $this->assign("username", $this->session->username);
- $this->assign("user_type", $this->session->user_type);
- $this->assign("user_id", $this->session->user_id);
- }
- }
- }
|