Example #1
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;
 }
Example #2
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->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");
 }
Example #3
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();
     }
 }
Example #4
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();
     }
 }
Example #5
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');
     }
 }