/**
  * 微站管理员清单
  * 和修改删除方法
  */
 function user()
 {
     $params = '';
     $user = $this->getModel('User');
     $count = $user->where(array('role_id' => 4, 'agent_id' => array('gt', 0)))->count();
     $page = new Page($count, C('APPLICATION_LIST_PAGE_SIZE'), $params);
     $rs = $user->where(array('role_id' => 4, 'agent_id' => array('gt', 0)))->order('id DESC')->limit($page->firstRow, $page->listRows)->select();
     foreach ($rs as $key => $value) {
         $rs[$key]['role'] = $this->USER_ROLE[$rs[$key]['role_id']];
         $rs[$key]['status'] = $this->USER_STATUS[$rs[$key]['status']];
         unset($rs[$key]['password']);
     }
     $this->assign('count', $count);
     $this->assign('list', $rs);
     $this->assign('page', $page->show());
     $this->assign('salt', md5(time()));
     $id = I('get.id');
     if (preg_match("/^[0-9]+\$/", $id)) {
         // 提取信息准备修改
         $rs = $user->find($id);
         if ($rs == null) {
         } else {
             $this->assign('info', $rs);
         }
     }
     $this->assign('roles', $this->USER_ROLE);
     $this->display();
 }
 function index()
 {
     $params = '';
     $user = $this->getModel('User');
     $count = $user->count();
     $page = new Page($count, C('APPLICATION_LIST_PAGE_SIZE'), $params);
     $rs = $user->order('id DESC')->limit($page->firstRow, $page->listRows)->select();
     foreach ($rs as $key => $value) {
         $rs[$key]['role'] = $this->USER_ROLE[$rs[$key]['role_id']];
         $rs[$key]['status'] = $this->USER_STATUS[$rs[$key]['status']];
         unset($rs[$key]['password']);
     }
     $this->assign('count', $count);
     $this->assign('list', $rs);
     $this->assign('page', $page->show());
     $this->assign('salt', md5(time()));
     // agent
     $agent = $this->getModel('Agent');
     $agents = $agent->field('id,enterprise')->order('enterprise ASC')->select();
     $this->assign('agents', $agents);
     $id = I('get.id', 0, 'int');
     if ($id > 0) {
         // 提取信息准备修改
         $rs = $user->find($id);
         if ($rs == null) {
         } else {
             $this->assign('info', $rs);
         }
     }
     $this->assign('roles', $this->USER_ROLE);
     $this->display();
 }
 function index()
 {
     $model = $this->getModel('Member');
     $count = $model->where(array('state' => 1))->count();
     $page = new Page($count, 10);
     $list = $model->field('id,create_time,title')->where(array('state' => 1))->limit($page->firstRow, $page->listRows)->order('id DESC')->select();
     $this->assign('page', $page->show());
     $this->assign('list', $list);
     $this->display();
 }
 function index()
 {
     $ch = I('get.ch', 0, 'int');
     if ($ch == 0) {
         return;
     }
     switch ($ch) {
         case 101:
             $chName = '生命安全';
             break;
         case 102:
             $chName = '环境监测';
             break;
         case 103:
             $chName = '备品备件';
             break;
         case 104:
             $chName = '维护维修';
             break;
         case 201:
             $chName = 'PDF资料';
             break;
         case 202:
             $chName = '服务网点';
             break;
         case 203:
             $chName = '指导培训';
             break;
         case 301:
             $chName = '最新动态';
             break;
         case 401:
             $chName = '招聘信息';
             break;
         default:
             return;
     }
     $params = '&ch=' . $ch;
     $model = $this->getModel('Article');
     $count = $model->where(array('ch' => $ch, 'state' => 1))->count();
     $page = new Page($count, 10, $params);
     $list = $model->field('id,create_time,title')->where(array('ch' => $ch, 'state' => 1))->limit($page->firstRow, $page->listRows)->order('id DESC')->select();
     $this->assign('ch', $ch);
     $this->assign('ch_name', $chName);
     $this->assign('page', $page->show());
     $this->assign('list', $list);
     $this->display();
 }
示例#5
0
 function project()
 {
     $project = $this->getModel('Project');
     if (IS_POST && isset($_GET['save'])) {
         $id = I('post.id', 0, 'int');
         $name = I('post.name');
         $subname = I('post.subname');
         if (get_magic_quotes_gpc()) {
             $content = stripslashes($_POST['content']);
             // 处理在线编辑器的转义
         } else {
             $content = $_POST['content'];
         }
         $imagePath = '/public/kindeditor4110/attached/';
         $imageDir = realpath(dirname('.')) . $imagePath;
         if (!file_exists($imageDir)) {
             mkdir($imageDir, 0777, true);
         }
         if ($id == 0) {
             // add
             if (isset($_FILES['main']) && $_FILES['main']['error'] == 0) {
                 $file = $_FILES['main'];
                 $fileName = $file['name'];
                 $fileTmpName = $file['tmp_name'];
                 $fileExt = substr($fileName, strrpos($fileName, '.') + 1);
                 $imageName1 = md5(time()) . '.' . $fileExt;
                 $imageFile1 = $imageDir . $imageName1;
                 if (file_exists($imageFile1)) {
                     unlink($imageFile1);
                 }
                 move_uploaded_file($fileTmpName, $imageFile1);
             } else {
                 $this->error('请上传首页用题图');
                 return;
             }
             if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0) {
                 $file = $_FILES['logo'];
                 $fileName = $file['name'];
                 $fileTmpName = $file['tmp_name'];
                 $fileExt = substr($fileName, strrpos($fileName, '.') + 1);
                 $imageName2 = md5(time() + 1) . '.' . $fileExt;
                 $imageFile2 = $imageDir . $imageName2;
                 if (file_exists($imageFile2)) {
                     unlink($imageFile2);
                 }
                 move_uploaded_file($fileTmpName, $imageFile2);
             } else {
                 $this->error('请上传详情页Logo');
                 return;
             }
             $create = $project->add(array('name' => $name, 'subname' => $subname, 'content' => $content, 'main' => $imagePath . $imageName1, 'logo' => $imagePath . $imageName2, 'main_path' => $imageFile1, 'logo_path' => $imageFile2, 'create_time' => $this->date));
             if ($create) {
                 $this->success('案例保存成功', '/web/project');
                 return;
             }
             $this->error('案例保存失败' . $project->getDbError());
             return;
         } else {
             // edit
             $rs = $project->find($id);
             if ($rs == null) {
                 $this->error('要修改的案例不存在');
                 return;
             }
             $params = array('name' => $name, 'subname' => $subname, 'content' => $content);
             if (isset($_FILES['main']) && $_FILES['main']['error'] == 0) {
                 $file = $_FILES['main'];
                 $fileName = $file['name'];
                 $fileTmpName = $file['tmp_name'];
                 $fileExt = substr($fileName, strrpos($fileName, '.') + 1);
                 $imageName1 = md5(time()) . '.' . $fileExt;
                 $imageFile1 = $imageDir . $imageName1;
                 if (file_exists($imageFile1)) {
                     unlink($imageFile1);
                 }
                 $f = move_uploaded_file($fileTmpName, $imageFile1);
                 if ($f) {
                     unlink($rs['main_path']);
                     $params['main'] = $imagePath . $imageName1;
                     $params['main_path'] = $imageFile1;
                 }
             }
             if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0) {
                 $file = $_FILES['logo'];
                 $fileName = $file['name'];
                 $fileTmpName = $file['tmp_name'];
                 $fileExt = substr($fileName, strrpos($fileName, '.') + 1);
                 $imageName2 = md5(time() + 1) . '.' . $fileExt;
                 $imageFile2 = $imageDir . $imageName2;
                 if (file_exists($imageFile2)) {
                     unlink($imageFile2);
                 }
                 $f = move_uploaded_file($fileTmpName, $imageFile2);
                 if ($f) {
                     unlink($rs['logo_path']);
                     $params['logo'] = $imagePath . $imageName2;
                     $params['logo_path'] = $imageFile1;
                 }
             }
             $update = $project->save($params, array('where' => 'id=' . $id));
             if ($update) {
                 $this->success('案例更新成功', '/web/project');
                 return;
             }
             $this->error('案例更新失败' . $project->getDbError());
             return;
         }
     }
     $params = '';
     $count = $project->count();
     $page = new Page($count, C('APPLICATION_LIST_PAGE_SIZE'), $params);
     $rs = $project->order('id DESC')->limit($page->firstRow, $page->listRows)->select();
     $this->assign('count', $count);
     $this->assign('list', $rs);
     $this->assign('page', $page->show());
     $id = I('get.id', 0, 'int');
     if ($id > 0) {
         // 提取信息准备修改
         $rs = $project->find($id);
         if ($rs == null) {
         } else {
             $rs['content'] = htmlspecialchars($rs['content']);
             // 处理在线编辑器的转义
             $this->assign('info', $rs);
         }
     }
     $this->display();
 }