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(); } }
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->swoole->tpl->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->swoole->tpl->assign("info", "修改成功"); } $this->swoole->tpl->assign("node", $node->get()); $this->swoole->tpl->assign("page", $cont->get()); $this->swoole->tpl->display("wiki/create.html"); }
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'); } }