Beispiel #1
0
 function edit()
 {
     if (!empty($_POST['name'])) {
         $inserts['name'] = $_POST['name'];
         $inserts['intro'] = $_POST['intro'];
         $msg['code'] = 0;
         if (empty($_POST['id'])) {
             $res = table("project")->put($inserts);
             $msg['message'] = $res ? "添加成功,ID: " . $res : "添加失败";
         } else {
             $res = table("project")->set(intval($_POST['id']), $inserts);
             $msg['message'] = $res ? "修改成功" : "修改失败";
         }
         $this->assign('msg', $msg);
     }
     if (empty($_GET)) {
         $form['name'] = \Swoole\Form::input('name');
         $form['intro'] = \Swoole\Form::input('intro');
         $this->assign('form', $form);
     } else {
         $id = (int) $_GET['id'];
         $res = table("project")->get($id)->get();
         $form['name'] = \Swoole\Form::input('name', $res['name']);
         $form['intro'] = \Swoole\Form::input('intro', $res['intro']);
         $form['id'] = \Swoole\Form::hidden('id', $res['id']);
     }
     $this->assign('form', $form);
     $this->display();
 }
Beispiel #2
0
 function getForms()
 {
     $forms['gold'] = Swoole\Form::select('gold', range(0, 200, 5), 0, true);
     $gets['order'] = '';
     $category = Model('AskCategory')->getMap($gets, 'name');
     $forms['category'] = Swoole\Form::select('category', $category);
     return $forms;
 }
Beispiel #3
0
 function data()
 {
     //\Swoole\Error::dbd();
     $interface_id = intval($_GET['interface_id']);
     $module_id = intval($_GET['module_id']);
     if (!empty($interface_id) and !empty($module_id)) {
         $log_table = 'logs';
         $gets['interface_id'] = $interface_id;
         $gets['module_id'] = $module_id;
         if (empty($_GET['date_key'])) {
             $_GET['date_key'] = date('Y-m-d');
             $log_table = 'logs_' . date('Y-m-d');
         } else {
             $log_table = 'logs_' . $_GET['date_key'];
         }
         $start_hour = !empty($_GET['hour_start']) ? $_GET['hour_start'] : '00';
         $end_hour = !empty($_GET['hour_end']) ? $_GET['hour_end'] : 23;
         $start_time = $_GET['date_key'] . ' ' . $start_hour . ':00:' . '00';
         $end_time = $_GET['date_key'] . ' ' . $end_hour . ':00:' . '00';
         //echo $start_time.'---'.$end_time."<br>";
         $gets['where'][] = 'time > ' . strtotime($start_time);
         $gets['where'][] = 'time < ' . strtotime($end_time);
         if (!empty($_GET['special_id'])) {
             $gets['special_id'] = $_GET['special_id'];
         }
         if (!empty($_GET['client_ip'])) {
             $gets['client_ip'] = $_GET['client_ip'];
         }
         if (!empty($_GET['level'])) {
             $gets['level'] = $_GET['level'];
         }
         $gets['page'] = !empty($_GET['page']) ? $_GET['page'] : 1;
         $gets['pagesize'] = 50;
         $gets['order'] = 'id asc';
         $logs = table($log_table)->gets($gets, $pager);
         $this->assign('pager', array('total' => $pager->total, 'render' => $pager->render()));
         if (!empty($logs)) {
             foreach ($logs as $k => $l) {
                 if (!empty($l['txt'])) {
                     $logs[$k]['txt'] = htmlentities($l['txt']);
                 }
             }
             $return['status'] = 200;
             $return['msg'] = '获取日志成功';
             $return['content'] = $logs;
         } else {
             $return['status'] = 400;
             $return['msg'] = '没有匹配的日志';
         }
         $client_ids = $this->redis->sMembers($module_id . "_" . $interface_id);
         foreach ($client_ids as $k => $v) {
             $_client_ids[$v] = $v;
         }
     }
     $form['client'] = \Swoole\Form::select('client_ip', $_client_ids, $_GET['client_ip'], '', array('class' => 'select2'));
     $this->assign('form', $form);
     $this->assign('logs', $return);
 }
Beispiel #4
0
 function modify()
 {
     if (empty($_GET['id'])) {
         return "error: requirer miki_page id";
     }
     $id = (int) $_GET['id'];
     $_cont = model('WikiContent');
     $_tree = model('WikiTree');
     $cont = $_cont->get($id);
     $node = $_tree->get($id);
     $form['comment'] = Swoole\Form::radio('close_comment', array('0' => '开启', '1' => '关闭'), $cont['close_comment'], false, null, 'radio-inline');
     $form['order_by_time'] = Swoole\Form::radio('order_by_time', array('0' => '手工排序', '1' => '按添加时间自动排序'), $node['order_by_time'], false, null, 'radio-inline');
     $this->assign("form", $form);
     if (!empty($_POST)) {
         $cont->title = trim($_POST['title']);
         if (!empty($_POST['content']) and $_POST['content'][0] == '`') {
             $_POST['content'] = ' ' . $_POST['content'];
         }
         $cont->content = $_POST['content'];
         $cont->close_comment = $_POST['close_comment'];
         $cont->uptime = time();
         $node->text = $cont->title;
         $node->link = trim($_POST['link']);
         $node->order_by_time = $_POST['order_by_time'];
         $node->save();
         $cont->save();
         $this->assign("info", "修改成功");
     }
     $this->isUseEditor();
     $this->assign("node", $node->get());
     $this->assign("page", $cont->get());
     $this->display("wiki/create.php");
 }
Beispiel #5
0
 /**
  *
  * @param  string $error 出错时设置
  *
  * @return true or false
  */
 function checkForm($input, $method, &$error)
 {
     if ($this->_form_secret) {
         $k = 'form_' . get_class($this) . '_' . $method;
         if (!isset($_SESSION)) {
             session();
         }
         if ($_COOKIE[$k] != $_SESSION[$k]) {
             $error = '错误的请求';
             return false;
         }
     }
     $this->_form_();
     return Form::checkInput($input, $this->_form, $error);
 }
Beispiel #6
0
 function profile()
 {
     if ($_POST) {
         if (empty($_POST['nickname'])) {
             return Swoole\JS::js_back('昵称不能为空!');
         }
         if (!empty($_FILES['avatar']['name'])) {
             global $php;
             $php->upload->thumb_width = 90;
             $php->upload->thumb_height = 120;
             $php->upload->thumb_qulitity = 90;
             $php->upload->base_dir = "/static/uploads/avatar";
             $upfile = $php->upload->save('avatar');
             if ($upfile === false) {
                 return Swoole\JS::js_back('上传失败!');
             }
             $set['avatar'] = $_SESSION['user']['avatar'] = $upfile['thumb'];
         }
         $set['nickname'] = trim($_POST['nickname']);
         $set['intro'] = trim($_POST['intro']);
         $set['company'] = $_POST['company'];
         $set['blog'] = $_POST['blog'];
         $set['mobile'] = $_POST['mobile'];
         $set['sex'] = (int) $_POST['sex'];
         $set['education'] = (int) $_POST['education'];
         $set['skill'] = implode(',', $_POST['skill']);
         $set['php_level'] = (int) $_POST['php_level'];
         $u = model('UserInfo');
         $u->set($this->uid, $set);
         $_SESSION['user']['realname'] = $set['realname'];
         $_SESSION['user']['mobile'] = $set['mobile'];
         return Swoole\JS::js_back('修改成功!');
     } else {
         require WEBPATH . '/dict/forms.php';
         $_u = model('UserInfo');
         $u = $_u->get($this->uid)->get();
         $_skill = model('UserSkill')->getMap(array());
         $_forms['sex'] = Swoole\Form::radio('sex', $forms['sex'], $u['sex']);
         $_forms['education'] = Swoole\Form::select('education', $forms['education'], $u['education']);
         $_forms['skill'] = Swoole\Form::checkbox('skill', $_skill, $u['skill']);
         $_forms['level'] = Swoole\Form::radio('php_level', $forms['level'], $u['php_level']);
         $this->swoole->tpl->assign('user', $u);
         $this->swoole->tpl->assign('forms', $_forms);
         $this->swoole->tpl->display();
         //$this->view->showTrace();
     }
 }
Beispiel #7
0
 function write()
 {
     $_m = model('UserLogs');
     $_l = model('UserLogCat');
     if ($_POST) {
         //如果没得到id,说明提交的是添加操作
         if (empty($_POST['title'])) {
             return Swoole\JS::js_back('标题不能为空!');
         }
         Swoole\Filter::safe($_POST['content']);
         $_POST['content'] = Swoole\Filter::remove_xss($_POST['content']);
         Swoole\Filter::addslash($_POST['content']);
         $blog['title'] = $_POST['title'];
         $blog['content'] = $_POST['content'];
         $blog['c_id'] = (int) $_POST['c_id'];
         if (isset($_POST['act']) and $_POST['act'] == 'draft') {
             $blog['dir'] = 1;
         } else {
             $blog['dir'] = 0;
         }
         if (!empty($_POST['id'])) {
             //如果得到id,说明提交的是修改的操作
             $id = (int) $_POST['id'];
             $det = $_m->get($id)->get();
             if ($det['uid'] != $this->uid) {
                 exit('access deny!not your blog!');
             }
             $_m->set($id, $blog);
             if (isset($_POST['autosave'])) {
                 return 1;
             } else {
                 return Swoole\JS::js_back('修改成功', -2);
             }
         } else {
             $blog['uid'] = $this->uid;
             $bid = $_m->put($blog);
             $_l->set($blog['c_id'], array('num' => '`num`+1'));
             if (isset($_POST['autosave'])) {
                 return $bid;
             } else {
                 return Swoole\JS::js_back('添加成功');
             }
         }
     } else {
         require_once WEBPATH . '/swoole_plugin/fckeditor/Swoole.plugin.php';
         $cat = $_l->getMap(array('uid' => $this->uid), 'name');
         if (empty($cat)) {
             $cat = array();
         }
         if (!empty($_GET['id'])) {
             $id = $_GET['id'];
             $det = $_m->get($id)->get();
             Swoole\Filter::deslash($det['content']);
             $form = Swoole\Form::select('c_id', $cat, $det['c_id']);
             $this->swoole->tpl->assign('det', $det);
             $editor = editor("content", $det['content'], 480, false, false, array('empty' => '请选择日志分类'));
         } else {
             $form = Swoole\Form::select('c_id', $cat, '', false, array('empty' => '请选择日志分类'));
             $editor = editor("content", '', 480, false);
         }
         $this->swoole->tpl->assign('form', $form);
         $this->swoole->tpl->assign('editor', $editor);
         $this->swoole->tpl->display();
     }
 }
Beispiel #8
0
 function guestbook()
 {
     if ($_POST) {
         if (empty($_POST['realname'])) {
             Swoole\JS::js_back('姓名不能为空!');
             exit;
         }
         if (empty($_POST['mobile'])) {
             Swoole\JS::js_back('电话不能为空!');
             exit;
         }
         unset($_POST['x'], $_POST['y']);
         $_POST['product'] = implode(',', $_POST['product']);
         $_POST['source'] = implode(',', $_POST['source']);
         $php->model->Guestbook->put($_POST);
         Swoole\JS::js_goto('注册成功!', 'guestbook.php');
     }
     if (!empty($_GET['id'])) {
         $gb = $php->model->Guestbook->get($_GET['id'])->get();
         $php->tpl->assign('gb', $gb);
         $php->tpl->display('guestbook_detail.html');
     } else {
         require 'dict/forms.php';
         $pager = null;
         $gets['page'] = empty($_GET['page']) ? 1 : $_GET['page'];
         $gets['pagesize'] = 12;
         $gets['select'] = "id,username,title,addtime";
         $gets['where'][] = "reply!=''";
         $list = $php->model->Guestbook->gets($gets, $pager);
         $_forms['title'] = Swoole\Form::radio('title', $forms['title'], null, true, array('empty' => '请选择称谓'));
         $_forms['age'] = Swoole\Form::select('age', $forms['age'], null, true, array('empty' => '请选择年龄阶段'));
         $_forms['ctime'] = Swoole\Form::select('ctime', $forms['ctime'], null, true, array('empty' => '请选择方便沟通的时间'));
         $_forms['product'] = Swoole\Form::checkbox('product', $forms['product'], null, true);
         $_forms['source'] = Swoole\Form::checkbox('source', $forms['source'], null, true);
         $pager = array('total' => $pager->total, 'render' => $pager->render());
         $php->tpl->assign('pager', $pager);
         $php->tpl->assign('forms', $_forms);
         $php->tpl->assign("list", $list);
         $php->tpl->display('guestbook.html');
     }
 }
Beispiel #9
0
 function add_module()
 {
     //\Swoole\Error::dbd();
     if (empty($_GET['id']) and empty($_POST)) {
         $gets['select'] = 'id,username,realname';
         $tmp = table('user')->gets($gets);
         $user = array();
         foreach ($tmp as $t) {
             $name = !empty($t['realname']) ? $t['realname'] : '';
             $user[$t['id']] = "{$name} [{$t['username']}]";
         }
         $form['name'] = \Swoole\Form::input('name');
         $form['intro'] = \Swoole\Form::text('intro');
         $form['owner_uid'] = \Swoole\Form::select('owner_uid', $user, '', null, array('class' => 'select2 select2-offscreen', 'style' => "width:100%"));
         $form['backup_uids'] = \Swoole\Form::muti_select('backup_uids[]', $user, array(), null, array('class' => 'select2 select2-offscreen', 'multiple' => "1", 'style' => "width:100%"), false);
         $tmp = table('project')->gets(array("order" => "id desc"));
         $project = array();
         foreach ($tmp as $t) {
             $project[$t['id']] = $t['name'];
         }
         $form['project_id'] = \Swoole\Form::select('project_id', $project, '', null, array('class' => 'select2 select2-offscreen', 'style' => "width:100%"));
         $this->assign('form', $form);
         $this->display();
     } elseif (!empty($_GET['id']) and empty($_POST)) {
         $id = (int) $_GET['id'];
         $module = table("module")->get($id)->get();
         $gets['select'] = '*';
         $tmp = table('user')->gets($gets);
         $user = array();
         foreach ($tmp as $t) {
             $name = !empty($t['realname']) ? $t['realname'] : '';
             $user[$t['id']] = "{$name} [{$t['username']}]";
         }
         $form['id'] = \Swoole\Form::hidden('id', $module['id']);
         $form['name'] = \Swoole\Form::input('name', $module['name']);
         $form['intro'] = \Swoole\Form::text('intro', $module['intro']);
         $form['owner_uid'] = \Swoole\Form::select('owner_uid', $user, $module['owner_uid'], null, array('class' => 'select2 select2-offscreen', 'style' => "width:100%"));
         $form['backup_uids'] = \Swoole\Form::muti_select('backup_uids[]', $user, explode(',', $module['backup_uids']), null, array('class' => 'select2 select2-offscreen', 'multiple' => "1", 'style' => "width:100%"), false);
         $tmp = table('project')->gets(array("order" => "id desc"));
         $project = array();
         foreach ($tmp as $t) {
             $project[$t['id']] = $t['name'];
         }
         $form['project_id'] = \Swoole\Form::select('project_id', $project, $module['project_id'], null, array('class' => 'select2 select2-offscreen', 'style' => "width:100%"));
         $this->assign('form', $form);
         $this->display();
     } elseif (!empty($_POST) and empty($_POST['id'])) {
         $in['name'] = trim($_POST['name']);
         $in['owner_uid'] = trim($_POST['owner_uid']);
         if (empty($in['owner_uid'])) {
             $in['owner_uid'] = $this->uid;
         }
         $in['project_id'] = trim($_POST['project_id']);
         $backup_uids = '';
         if (!empty($_POST['backup_uids'])) {
             $backup_uids = implode(',', $_POST['backup_uids']);
         }
         $in['backup_uids'] = $backup_uids;
         //            $in['backup_name'] = trim($_POST['backup_name']);
         $in['intro'] = trim($_POST['intro']);
         $c = table('module')->count(array('name' => $in['name']));
         if ($c > 0) {
             \Swoole\JS::js_goto("操作失败,已存在同名模块", "/setting/add_module/");
         } else {
             $id = table('module')->put($in);
             if ($id) {
                 \Swoole\JS::js_goto("操作成功", "/setting/add_module/");
                 \Swoole::$php->log->put("{$_SESSION['userinfo']['username']} add module success {$id} : " . print_r($in, 1));
             } else {
                 \Swoole\JS::js_goto("操作失败", "/setting/add_module/");
                 \Swoole::$php->log->put("{$_SESSION['userinfo']['username']} add module failed:  " . print_r($in, 1));
             }
         }
     } else {
         $id = (int) $_POST['id'];
         $in['name'] = trim($_POST['name']);
         $in['owner_uid'] = trim($_POST['owner_uid']);
         $in['project_id'] = trim($_POST['project_id']);
         $backup_uids = '';
         if (!empty($_POST['backup_uids'])) {
             $backup_uids = implode(',', $_POST['backup_uids']);
         }
         $in['backup_uids'] = $backup_uids;
         $in['intro'] = trim($_POST['intro']);
         $where['name'] = $in['name'];
         $where['where'][] = "id !={$id}";
         $c = table('module')->count($where);
         if ($c > 0) {
             \Swoole\JS::js_goto("操作失败,已存在同名模块", "/setting/module_list/");
         } else {
             $res = table('module')->set($id, $in);
             if ($res) {
                 \Swoole\JS::js_goto("操作成功", "/setting/module_list/");
                 \Swoole::$php->log->put("{$_SESSION['userinfo']['username']} modify module success {$id} : " . print_r($in, 1));
             } else {
                 \Swoole\JS::js_goto("操作失败", "/setting/module_list/");
                 \Swoole::$php->log->put("{$_SESSION['userinfo']['username']} modify module failed:  " . print_r($in, 1));
             }
         }
     }
 }
 function category_list()
 {
     $gets = array();
     $id = trim(get_post('id'));
     if ($id !== '') {
         $id = (int) $id;
         $gets['where'][] = "id={$id}";
         $_GET['id'] = $id;
     } else {
         $id = null;
     }
     $name = trim(get_post('name'));
     if ($name !== '') {
         $name = trim($name);
         $gets['where'][] = "name like '%{$name}%'";
         $_GET['name'] = $name;
     } else {
         $name = null;
     }
     $project_id = trim(get_post('project_id'));
     if ($project_id !== '') {
         $project_id = (int) $project_id;
         $gets['where'][] = "project_id = {$project_id}";
         $_GET['project_id'] = $project_id;
     } else {
         $project_id = null;
     }
     $projects = table('project')->gets(array('select' => 'id, name', 'order' => 'id desc'));
     $projects = array_rebuild($projects, 'id', 'name');
     // 搜索表单
     $form['id'] = \Swoole\Form::input('id', htmlspecialchars($id), array('id' => 'id', 'placeholder' => 'ID'));
     $form['name'] = \Swoole\Form::input('name', htmlspecialchars($name), array('id' => 'name', 'placeholder' => '分类名称'));
     $form['project_id'] = \Swoole\Form::select('project_id', $projects, htmlspecialchars($project_id), null, array('class' => 'select2', 'style' => 'width:100%'));
     $gets['order'] = 'id desc';
     $gets['page'] = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
     $gets['pagesize'] = 20;
     $gets['where'][] = 'status = 1';
     $data = table('tiny_url_category')->gets($gets, $pager);
     foreach ($data as $k => $v) {
         $data[$k]['project_name'] = !empty($projects[$v['project_id']]) ? $projects[$v['project_id']] : null;
     }
     $this->assign('form', $form);
     $this->assign('data', $data);
     $this->assign('pager', array('render' => $pager->render()));
     $this->display();
 }
Beispiel #11
0
 function data($module_id)
 {
     //\Swoole\Error::dbd();
     $log_table = 'logs2_';
     $gets['module'] = $module_id;
     if (empty($_GET['date_key'])) {
         $_GET['date_key'] = date('Ymd');
         $log_table = $log_table . date('Ymd');
     } else {
         $log_table = $log_table . $_GET['date_key'];
     }
     if (!empty($_GET['type'])) {
         $gets['type'] = $_GET['type'];
     }
     if (!empty($_GET['subtype'])) {
         $gets['subtype'] = $_GET['subtype'];
     }
     if (!empty($_GET['client'])) {
         $gets['ip'] = $_GET['client'];
     }
     if (!empty($_GET['level'])) {
         $gets['level'] = $_GET['level'] - 1;
     }
     if (!empty($_GET['uid'])) {
         if (is_numeric($_GET['uid'])) {
             $gets['uid'] = $_GET['uid'];
         } else {
             $gets['ukey'] = $_GET['uid'];
         }
     }
     if (isset($_GET['hour_start'])) {
         $gets['where'][] = 'hour >= ' . $_GET['hour_start'];
     }
     if (isset($_GET['hour_end'])) {
         $gets['where'][] = 'hour <= ' . $_GET['hour_end'];
     }
     //排序
     if (!empty($_GET['order'])) {
         $gets['order'] = str_replace('_', ' ', $_GET['order']);
     } else {
         $gets['order'] = 'id desc';
     }
     //页数
     if (!empty($_GET['pagesize'])) {
         $gets['pagesize'] = intval($_GET['pagesize']);
     } else {
         $gets['pagesize'] = 50;
     }
     $gets['page'] = !empty($_GET['page']) ? $_GET['page'] : 1;
     $logs = table($log_table)->gets($gets, $pager);
     $this->assign('pager', array('total' => $pager->total, 'pagesize' => $gets['pagesize'], 'render' => $pager->render()));
     $clients = $this->redis->sMembers('logs2:client:' . $module_id);
     $types = $this->redis->sMembers('logs2:type:' . $module_id);
     $subtypes = $this->redis->sMembers('logs2:subtype:' . $module_id);
     $_clients = $_types = $_subtypes = array();
     foreach ($clients as $k => $v) {
         $_clients[$v] = $v;
     }
     foreach ($types as $k => $v) {
         $_types[$v] = $v;
     }
     foreach ($subtypes as $k => $v) {
         $_subtypes[$v] = $v;
     }
     $client = empty($_GET['client']) ? 0 : $_GET['client'];
     $type = empty($_GET['type']) ? '' : $_GET['type'];
     $subtype = empty($_GET['subtype']) ? '' : $_GET['subtype'];
     $form['clients'] = \Swoole\Form::select('client', $_clients, $client, '', array('class' => 'select2'));
     $form['types'] = \Swoole\Form::select('type', $_types, $type, '', array('class' => 'select2'));
     $form['subtypes'] = \Swoole\Form::select('subtype', $_subtypes, $subtype, '', array('class' => 'select2'));
     $this->assign('form', $form);
     $this->assign('logs', $logs);
 }
Beispiel #12
0
 function add()
 {
     //不是超级用户不能查看修改用户
     if ($this->userinfo['usertype'] != 0) {
         return "access deny";
     }
     //\Swoole::$php->db->debug = true;
     if (empty($_GET) and empty($_POST)) {
         $tmp = table('project')->gets(array("order" => "id desc"));
         $project = array();
         foreach ($tmp as $t) {
             $project[$t['id']] = $t['name'];
         }
         $form['project_id'] = \Swoole\Form::muti_select('project_id[]', $project, array(), null, array('class' => 'select2 select2-offscreen', 'multiple' => "1", 'style' => "width:100%"), false);
         $form['uid'] = \Swoole\Form::input('uid');
         $form['mobile'] = \Swoole\Form::input('mobile');
         $form['realname'] = \Swoole\Form::input('realname');
         $form['username'] = \Swoole\Form::input('username');
         $form['usertype'] = \Swoole\Form::select('usertype', $this->config['usertype'], null, null, array('class' => 'select2'));
         $this->assign('form', $form);
         $this->display();
     } elseif (!empty($_GET['id']) and empty($_POST)) {
         $id = (int) $_GET['id'];
         $user = table('user')->get($id)->get();
         $tmp = table('project')->gets(array("order" => "id desc"));
         $project = array();
         foreach ($tmp as $t) {
             $project[$t['id']] = $t['name'];
         }
         $form['project_id'] = \Swoole\Form::muti_select('project_id[]', $project, explode(',', $user['project_id']), null, array('class' => 'select2 select2-offscreen', 'multiple' => "1", 'style' => "width:100%"), false);
         $form['uid'] = \Swoole\Form::input('uid', $user['uid']);
         $form['mobile'] = \Swoole\Form::input('mobile', $user['mobile']);
         $form['realname'] = \Swoole\Form::input('realname', $user['realname']);
         $form['username'] = \Swoole\Form::input('username', $user['username']);
         $form['usertype'] = \Swoole\Form::select('usertype', $this->config['usertype'], null, null, array('class' => 'select2'));
         $form['id'] = \Swoole\Form::hidden('id', $user['id']);
         $this->assign('form', $form);
         $this->display();
     } elseif (!empty($_POST['id'])) {
         $id = (int) $_POST['id'];
         $inserts['realname'] = $_POST['realname'];
         $inserts['username'] = $_POST['username'];
         $inserts['uid'] = (int) $_POST['uid'];
         $inserts['project_id'] = implode(',', $_POST['project_id']);
         $inserts['mobile'] = $_POST['mobile'];
         $res = table("user")->set($id, $inserts);
         if ($res) {
             \Swoole\JS::js_goto("修改成功", '/user/ulist/');
         } else {
             \Swoole\JS::js_goto("修改失败", '/user/ulist/');
         }
     } else {
         $inserts['realname'] = $_POST['realname'];
         $inserts['username'] = trim($_POST['username']);
         $inserts['uid'] = isset($_POST['uid']) ? (int) $_POST['uid'] : 0;
         $inserts['project_id'] = isset($_POST['project_id']) ? implode(',', $_POST['project_id']) : '';
         $inserts['mobile'] = $_POST['mobile'];
         //默认密码
         $inserts['password'] = Swoole\Auth::mkpasswd($inserts['username'], '123456');
         $res = table("user")->put($inserts);
         if ($res) {
             \Swoole\JS::js_goto("添加成功", '/user/ulist//');
         } else {
             \Swoole\JS::js_goto("添加失败", '/user/ulist/');
         }
     }
 }