Example #1
0
 function index()
 {
     if (empty($this->project)) {
         return Swoole\JS::js_goto("您访问的项目不存在", "/");
     }
     if (!empty($_GET['p'])) {
         $this->swoole->tpl->assign('p', trim($_GET['p']));
     }
     $this->getTopData();
     $this->getTreeData();
     $this->getMainData();
     $this->swoole->tpl->display("wiki/index.html");
 }
Example #2
0
 /**
  * 添加好友
  */
 function friend()
 {
     if (!empty($_GET['add'])) {
         $fm = model('UserFriend');
         $get['frid'] = (int) $_GET['add'];
         $get['uid'] = $this->uid;
         $c = $fm->count($get);
         if ($c > 0) {
             return Swoole\JS::js_goto('你们已经是好友了!', '/person/myfriends/');
         } else {
             $fm->put($get);
             return Swoole\JS::js_goto('添加好友成功!', '/person/myfriends/');
         }
     }
 }
Example #3
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');
     }
 }
Example #4
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));
             }
         }
     }
 }
Example #5
0
 function delete_category()
 {
     if (isset($_GET['id'])) {
         $id = (int) $_GET['id'];
         $res = table('tiny_url_category')->set($id, array('status' => 2));
         $msg = $res ? '操作成功' : '操作失败';
         \Swoole\JS::js_goto($msg, '/url_shortener/category_list');
     } else {
         $this->http->status(302);
         $this->http->header('Location', '/url_shortener/category_list');
     }
 }
Example #6
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/');
         }
     }
 }