Example #1
1
 public function lists($productId)
 {
     if (IS_AJAX) {
         $page_size = 10;
         $page = I('page', 1, 'intval');
         $start = ($page - 1) * $page_size;
         $map = array('product_id' => $productId, 'status' => 1);
         $ProductBid = M('ProductBid');
         $total_count = $ProductBid->where($map)->count();
         if ($total_count) {
             $total_page = ceil($total_count / $page_size);
             $bid_list = $ProductBid->where($map)->order('bid_id desc')->limit($start . ',' . $page_size)->select();
             $User = M('User');
             foreach ($bid_list as $key => $value) {
                 $bid_list[$key]['user_info'] = $User->find($value['user_id']);
             }
             $this->assign('bid_list', $bid_list);
             $product_info = M('Product')->where($map)->find();
             $this->assign('product_info', $product_info);
             $range_price = $product_info['range_price'];
             $content = $this->fetch('ajaxLists');
             if ($product_info['product_type'] == 3) {
                 $value = array('info' => array('currentPrice' => $product_info['range_price'], 'bidPrice' => $product_info['range_price'], 'lastId' => 1), 'htmlString' => $content, 'isNextPage' => $total_page == 1 || $total_page == $page ? false : true, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => $total_page);
             } else {
                 $max_bid_price = $ProductBid->where($map)->max('bid_price');
                 $value = array('info' => array('currentPrice' => $max_bid_price, 'bidPrice' => $max_bid_price + $range_price, 'lastId' => 1), 'htmlString' => $content, 'isNextPage' => $total_page == 1 || $total_page == $page ? false : true, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => $total_page);
             }
         } else {
             $value = array('htmlString' => '', 'isNextPage' => false, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => 1);
         }
         $this->resultSuccess('加载中...', $value);
     } else {
         //$this->display();
     }
 }
Example #2
0
 /**
  * 通过省份获取城市列表
  */
 public function getCityListByProvince()
 {
     $provinceId = (int) I('provinceId');
     $m = D('Home/Areas');
     $cityList = $m->getCityListByProvince($provinceId);
     $this->ajaxReturn($cityList);
 }
 /**
  * 文档保存成功后执行行为
  * @param  array  $data     文档数据
  * @param  array  $catecory 分类数据
  */
 public function documentSaveComplete($param)
 {
     if (MODULE_NAME == 'Home') {
         list($data, $category) = $param;
         /* 附件默认配置项 */
         $default = C('ATTACHMENT_DEFAULT');
         /* 合并当前配置 */
         $config = $category['extend']['attachment'];
         $config = empty($config) ? $default : array_merge($default, $config);
         $attach = I('post.attachment');
         /* 该分类不允许上传附件 */
         if (!$config['is_upload'] || !in_array($attach['type'], str2arr($config['allow_type']))) {
             return;
         }
         switch ($attach['type']) {
             case 1:
                 //外链
                 # code...
                 break;
             case 2:
                 //文件
                 $info = json_decode(think_decrypt($attach['info']), true);
                 if (!empty($info)) {
                     $Attachment = D('Addons://Attachment/Attachment');
                     $Attachment->saveFile($info['name'], $info, $data['id']);
                 } else {
                     return;
                     //TODO:非法附件上传,可记录日志
                 }
                 break;
         }
     }
 }
 function preview()
 {
     $vote_id = I('id', 0, 'intval');
     $url = addons_url('Invite://Wap/index', array('id' => $vote_id));
     $this->assign('url', $url);
     $this->display(SITE_PATH . '/Application/Home/View/default/Addons/preview.html');
 }
 public function index()
 {
     if (IS_POST) {
         $login = array();
         switch (I('user', null, false)) {
             case 'admin':
                 $login['uid'] = 1;
                 $login['user'] = '******';
                 break;
             case 'test':
                 $login['uid'] = 2;
                 $login['user'] = '******';
                 break;
             case 'guest':
                 $login['uid'] = 3;
                 $login['user'] = '******';
                 break;
             default:
                 $this->error('用户不存在');
         }
         if (count($login)) {
             session('auth', $login);
             $this->success('登陆成功', U('Index/index'));
         }
     } else {
         $this->display();
     }
 }
 public function login()
 {
     #是否显示验证码
     $msg = '';
     if (IS_POST) {
         $name = I('name');
         $password = I('password');
         if (!empty($name) && !empty($password)) {
             #验证用户信息
             $user_info = D('Common/Admin')->loginCheck($name, $password);
             #记录登录日志
             $log_data = array('admin_id' => isset($user_info['id']) ? $user_info['id'] : 0, 'login_time' => date('Y-m-d H:i:s'), 'login_ip' => get_client_ip());
             $log_result = D('Common/Adminlog')->log_add($log_data);
             #跳转
             if (isset($user_info['id'])) {
                 session('user', $user_info['id']);
                 redirect(U('admin/Index/index'));
             } else {
                 $this->error('登录失败,用户名或密码错误。');
             }
         } else {
             $this->error('登录失败,用户名或密码错误。');
         }
     }
     $this->display();
 }
 /**
  * 时刻记录
  * Enter description here ...
  */
 public function energy_time()
 {
     $uid = I('uid', '0', 'intval');
     $start_time = mktime(0, 0, 0, date("m"), 1, date("Y"));
     $end_time = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
     $res = $this->_mod->where('uid =' . $uid . ' and add_time >= ' . $start_time . ' and add_time <= ' . $end_time)->order('add_time')->select();
     $date_array = array();
     foreach ($res as $key => $val) {
         $res[$key]['add_time'] = date('m.d', $val['add_time']);
         $res[$key]['time'] = date('H:i', $val['add_time']);
         if (!in_array($res[$key]['add_time'], $date_array)) {
             array_push($date_array, $res[$key]['add_time']);
         }
     }
     foreach ($date_array as $value) {
         foreach ($res as $k => $v) {
             if ($value == $v['add_time']) {
                 $result[$v['add_time']][] = $v;
                 //按日期分组
             }
         }
     }
     $appjson = $result;
     if (C('APP_JSON_RETURN')) {
         $this->jsonReturn($appjson);
     }
 }
 function _after_update($data, $options)
 {
     $pid = $data['id'];
     $data_detail['pid'] = $pid;
     $subject = array_filter(I('subject'));
     $model_detail = M("DailyReportDetail");
     $model_detail->where($data_detail)->delete();
     foreach ($subject as $key => $val) {
         $data_detail['type'] = 1;
         $data_detail['subject'] = $val;
         $data_detail['item'] = implode("|||", I("item_{$key}"));
         $data_detail['start_time'] = implode("|||", I("start_time_{$key}"));
         $data_detail['end_time'] = implode("|||", I("end_time_{$key}"));
         $data_detail['status'] = implode("|||", I("status"));
         $model_detail->add($data_detail);
     }
     $plan_subject = array_filter(I('plan_subject'));
     $plan_item = I('plan_item');
     $plan_start_time = I('plan_start_time');
     $plan_end_time = I('plan_end_time');
     $plan_priority = I('plan_priority');
     $is_need_help = I('is_need_help');
     foreach ($plan_subject as $key => $val) {
         $data_detail['type'] = 2;
         $data_detail['subject'] = $val;
         $data_detail['item'] = $plan_item[$key];
         $data_detail['start_time'] = $plan_start_time[$key];
         $data_detail['end_time'] = $plan_end_time[$key];
         $data_detail['priority'] = $plan_priority[$key];
         $data_detail['is_need_help'] = $is_need_help[$key];
         $model_detail->add($data_detail);
     }
     $plan_subject = $data['plan_subject'];
 }
Example #9
0
 public function confirm_stock_in($id, $current_node)
 {
     if (!I('get.workflow_submit')) {
         return ['pause' => 'true', 'type' => 'redirect', 'url' => '/storage/stockIn/confirm/bill/' . $id . '/node/' . $current_node['id']];
     }
     $detail_service = D('Storage/StockInDetail');
     $stock_service = D('Storage/Stock');
     $log_service = D('Storage/StockLog');
     $this->startTrans();
     $rows = I('post.rows');
     foreach ($rows as $k => $row) {
         if (!$row['id'] || !$row['this_time_in_quantity'] || !$row['storage_id'] || !$row['product_id'] || !$row['product_unique_id']) {
             continue;
         }
         $detail_service->where(['id' => $row['id']])->setInc('already_in', $row['this_time_in_quantity']);
         $rows[$k]['quantity'] = $row['this_time_in_quantity'];
         // 写库存操作记录
         if (false === $log_service->record(['source_model' => 'storage.stockIn', 'source_id' => $id, 'direction' => 'in', 'product_id' => $row['product_id'], 'product_unique_id' => $row['product_unique_id'], 'quantity' => $row['this_time_in_quantity']])) {
             $this->error = 'storage.Trigger error when record stock log';
             $this->rollback();
             return false;
         }
     }
     // 更新库存清单
     if (false === $stock_service->change_quantity('+', $rows)) {
         $this->error = __('storage.Trigger error when update stock balance');
         $this->rollback();
         return false;
     }
     $this->commit();
     return ['type' => 'redirect', 'url' => '/storage/stockIn/view/bill/' . $id];
 }
 public function download()
 {
     $r_mac = I('param.mac', '');
     $Public = A('Public');
     $webid = I('get.id', '');
     $Web = M('website');
     $web = $Web->join('rou_ap_main on rou_ap_main.id=rou_website.rid')->where('rou_ap_main.mac=' . $r_mac)->find();
     foreach ($web as $k => $v) {
         if ($v === '') {
             $Public->error('请先配置站点');
         }
     }
     $WebNav = M('webnav');
     $nav = $WebNav->where(array('wid' => $webid, 'is_show' => 1))->select();
     $navStr = '';
     foreach ($nav as $item) {
         $navStr .= '<option>' . $item['navname'] . '</option>';
     }
     $path = '/Down/' . $web['filename'] . '/';
     //生成配置文件
     $config = '<title>' . $web['web_name'] . '</title>
     <address>' . $web['address'] . '</address>
     <phone>' . $web['phone'] . '</phone>
     <email>' . $web['email'] . '</email>
     <nav>' . $navStr . '</nav>';
     $suffix = date('YmdHis', time()) . '_' . rand(0, 999);
     $hd = fopen(WEB_ROOT . $path . 'config_' . $suffix . '.txt', 'w') or die('无法打开文件');
     fwrite($hd, $config);
     fclose($hd);
     $zip = new \Org\Util\PHPZip();
     $zip->ZipAndDownload(WEB_ROOT . $path);
 }
 public function submit()
 {
     $ip_false = M('option')->where("meta_key='ip_false' AND type='user'")->getField('meta_value', true);
     if ($ip_false && in_array(mc_user_ip(), $ip_false)) {
         $this->error('您的IP被永久禁止登陆!');
     } else {
         $page_id = M('meta')->where("meta_key='user_name' AND meta_value='" . mc_magic_in(I('param.user_name')) . "' AND type='user'")->getField('page_id');
         $user_pass_true = mc_get_meta($page_id, 'user_pass', true, 'user');
         if ($_POST['user_name'] && $_POST['user_pass'] && md5($_POST['user_pass'] . mc_option('site_key')) == $user_pass_true) {
             $user_pass = md5(I('param.user_pass') . mc_option('site_key'));
             cookie('user_name', I('param.user_name'), 36000000000);
             cookie('user_pass', $user_pass, 36000000000);
             $ip_array = M('action')->where("page_id='" . mc_user_id() . "' AND action_key='ip'")->getField('action_value', true);
             if ($ip_array && in_array(mc_user_ip(), $ip_array)) {
             } else {
                 if (!mc_is_admin()) {
                     mc_add_action(mc_user_id(), 'ip', mc_user_ip());
                 }
             }
             if ($_POST['comefrom']) {
                 $this->success('登陆成功', $_POST['comefrom']);
             } else {
                 if (mc_is_mobile()) {
                     $this->success('登陆成功', U('user/index/pro?id=' . mc_user_id()));
                 } else {
                     $this->success('登陆成功', U('user/index/index?id=' . mc_user_id()));
                 }
             }
         } else {
             $this->error('用户名与密码不符!');
         }
     }
 }
 /**
  * 微站管理员清单
  * 和修改删除方法
  */
 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();
 }
Example #13
0
 public function ng_index()
 {
     $page = I('get.index_page');
     //The request page number
     $page = $page ? $page : 1;
     /**
      * 1.我的动态
      * 2.我关注的人的动态
      * 3.公开的
      * 4.按时间排序
      * 关联的模型: hs_user,hs_piece,hs_piece_comment
      */
     /*$sql = "SELECT u.id,u.userName,u.avatar,p.piece_id,p.user_id,p.date,p.tag,p.content from hs_user as u,hs_piece as p 
       where p.visible=1 AND u.id=p.user_id AND p.user_id in (SELECT followed_id as id from hs_follow where follower_id=".$this->user_id." 
       union SElECT id from hs_user where id=".$this->user_id.") order by p.date desc limit ".$page*$this->piece_nums_per_page.
       ",".$this->piece_nums_per_page;*/
     $sql2 = "select count(c.comment_id) as comments_num,u.userName,u.avatar,p.piece_id,p.user_id,p.date,p.tag,p.content,p.visible,p.visible_tag \r\n        from hs_piece as p join hs_user as u on p.user_id=u.id left join hs_piece_comment as c on p.piece_id=c.piece_id where p.user_id=" . $this->user_id . " or p.user_id in (select f.followed_id from hs_follow as f where f.follower_id=" . $this->user_id . ") and p.visible=1 group by p.piece_id order by p.date desc ";
     $pieces = $this->piece_model->query($sql2);
     if ($pieces !== false) {
         if ($pieces == NULL) {
             $this->ajaxReturn(array('pieces' => $pieces, 'error' => 2, 'msg' => '暂无记录!'), 'json');
         }
         if (count($pieces)) {
             $pieces = A('Auth')->filter_invisible_piece($pieces);
             //过滤不可见的碎片
             $pieces = Util::pageOfArray($pieces, $page, $this->piece_nums_per_page);
             //分页
         }
         $this->ajaxReturn(array('pieces' => $pieces, 'error' => 0), 'json');
     } else {
         $this->ajaxReturn(array('pieces' => $pieces, 'error' => 1, 'msg' => '查询失败!'), 'json');
     }
 }
Example #14
0
 /**
  * 后台登陆控制器
  */
 public function login()
 {
     $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me'));
     //处理下次自动登录
     if ($arr['remember-me'] == 1) {
         $account = $arr['user_login'];
         $ip = get_client_ip(0, true);
         $value = $account . '|' . $ip;
         $value = encrypt($value, C('ENCRYPTION_KEY'));
         @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/");
     }
     $user = M('user')->where(array('user_login' => $arr['user_login']))->find();
     $userinfo = D('user')->getInfo($user['id']);
     if ($user['user_status'] == 0) {
         $this->error('账号被禁用,请联系管理员...');
     }
     if ($user['user_type'] != '管理员') {
         $this->error('无权限登录...');
     }
     if (!$user || $user['user_pass'] != $arr['user_pass']) {
         $this->error('账号密码错误,请重试...');
     }
     $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s"));
     $result = M('user')->save($data);
     if (!$result) {
         $this->error('登录失败,请重试...');
     }
     session('uid', $user['id']);
     session('username', $userinfo['username']);
     session('last_login_time', $data['last_login_time']);
     session('last_login_ip', $data['last_login_ip']);
     $this->success('登陆成功', U('Index/index'));
 }
Example #15
0
 /**
  * 读取数据 do_data
  */
 public function do_data()
 {
     $topic_id = I('get.id');
     /* 判断是否存在缓存 */
     $cache = S('HOME_TOPIC_ARTICLE_ID_' . $topic_id);
     if ($cache) {
         $data = $cache;
     } else {
         /* 查询条件 */
         $field = 'topic.id as topic_id,topic.upfile,topic.content,topic.province,topic.city,topic.create_time,
                   user.nick_name,user.sex,user.upfile_head as user_upfile_head';
         $where['topic.id'] = array('EQ', $topic_id);
         $where['topic.status'] = array('EQ', 1);
         $where['topic.display'] = array('EQ', 1);
         $where['user.status'] = array('EQ', 1);
         $where['user.display'] = array('EQ', 1);
         /* 查询数据 */
         $data = $this->alias('topic')->field($field)->where($where)->join('__USER__ user on topic.user_id = user.id')->find();
         /* 读取用户头像 */
         if ($data['user_upfile_head'] && !strstr($data['user_upfile_head'], 'http://')) {
             $data['user_upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $data['user_upfile_head'];
         }
         /* 转换数据 */
         if ($data['content']) {
             $data['content'] = urldecode($data['content']);
         }
         /* 设置缓存 */
         S('HOME_TOPIC_ARTICLE_ID_' . $topic_id, $data, C('CACHE_TIME'));
     }
     /* 下载链接 */
     $data['data_setting'] = S('data_setting');
     return $data;
 }
 public function index()
 {
     $sysinfo = M('sys')->order('id asc')->find();
     $this->assign('sys', $sysinfo);
     $appid = $sysinfo['web_appid'];
     $appsecret = $sysinfo['web_appsecret'];
     if (!defined('VIRIFY')) {
         virifylocal();
     }
     $_scene = M('scene');
     $where['scenecode_varchar'] = I('get.id', 0);
     $where['delete_int'] = 0;
     $_scene_list = $_scene->where($where)->select();
     // print_r($_scene_list); exit('dddd');
     $sysinfo = M('sys')->order('id asc')->find();
     if ($sysinfo['is_user_anli_shenghe'] && !isset($_GET['preview'])) {
         if ($_scene_list[0]["shenhe"] != 1) {
             $this->error('抱歉,您的场景还没通过管理员审核', '/#/main');
         }
     }
     $argu2 = array();
     $argu2['title'] = $_scene_list[0]["scenename_varchar"];
     $argu2['url'] = C('IS_OPEN_STATIC') ? 'v-' . $_scene_list[0]["scenecode_varchar"] : 'index.php?c=view&id=' . $_scene_list[0]["scenecode_varchar"];
     $argu2['desc'] = $_scene_list[0]["desc_varchar"];
     $argu2['imgsrc'] = $_scene_list[0]["thumbnail_varchar"];
     $this->assign("confinfo2", $argu2);
     $mydd = get_client_ip();
     if ($mydd !== '127.0.0.1') {
         $confinfo = $this->get_js_sdk($appid, $appsecret);
     }
     $this->assign("confinfo", $confinfo);
     $this->display(HTML_VESION);
 }
Example #17
0
 public function edit()
 {
     if (IS_POST) {
         //dump($_POST);die;
         unset($_POST['banner'][0]);
         $_POST['banner'] = json_encode($_POST['banner']);
         $res = D('Shop')->save_item($_POST);
         if (!$res['status']) {
             $this->error('对不起,编辑失败!');
         } else {
             $this->success('恭喜你,编辑成功!', 'shoplist');
         }
     } else {
         //载入分类
         $this->assign('catelist', D('GoodsCate')->get_cate_list(0));
         $res = D('Shop')->getRow($_GET['id']);
         $addr = M('Addr')->where(array('path' => "0"))->select();
         //dd($addr);
         //dump($_GET["cate_id"]);
         $this->assign('addr', $addr);
         $this->assign('aid', I('get.cate_id'));
         $res['banner'] = json_decode($res['banner'], true);
         $this->assign('page', $res);
         //图片库提取
         $where['status'] = 1;
         $piclist = M('Picture')->where($where)->field(true)->order('id desc')->limit('0,16')->select();
         $this->assign('piclist', $piclist);
         $this->display();
     }
 }
 public function _before_del()
 {
     $id = I('get.id');
     if ($id == 1) {
         $this->error('默认管理员不可被删除');
     }
 }
 /**
  * 编辑团购banner
  */
 public function edit()
 {
     $id = I('id');
     if (IS_POST) {
         $info = I('data');
         if ($_FILES['act_banner']['name']) {
             $result = $this->ectouchUpload('act_banner', 'banner_image');
             if ($result['error'] > 0) {
                 $this->message($result['message'], NULL, 'error');
             }
             /* 生成banner链接 */
             $data2['act_banner'] = substr($result['message']['act_banner']['savepath'], 2) . $result['message']['act_banner']['savename'];
             if ($this->model->table('touch_goods_activity')->where('act_id=' . $id)->count()) {
                 $this->model->table('touch_goods_activity')->data($data2)->where('act_id=' . $id)->update();
             } else {
                 $data2['act_id'] = $id;
                 $this->model->table('touch_goods_activity')->data($data2)->insert();
             }
         }
         $this->message(L('edit_success'), url('index'));
     }
     $info = $this->model->table('goods_activity')->field('act_id,act_name')->where(array('act_id' => $id))->find();
     $touch_info = $this->model->table('touch_goods_activity')->field('act_banner')->where(array('act_id' => $id))->find();
     $info['act_banner'] = $touch_info['act_banner'];
     /* 模板赋值 */
     $this->assign('info', $info);
     $this->assign('ur_here', L('articlecat_edit'));
     $this->display();
 }
 /**
  * 列表页面
  */
 public function index()
 {
     $uid = I('uid', '', 'intval');
     $map = $this->_search();
     if ($uid) {
         $map['id'] = $uid;
     }
     $mod = D($this->_name);
     $field_list = 'id,username,reg_time';
     !empty($mod) && ($list = $this->_list($mod, $map, '', '', $field_list));
     foreach ($list as $key => $value) {
         $log = $this->_user_log_mod->where("uid = {$value['id']}")->order('add_time DESC')->select();
         $list[$key]['visit_num'] = count($log);
         $list[$key]['last_time'] = $log[0]['add_time'];
     }
     $list = $this->array_sort($list, 'visit_num');
     if ($_GET['excel'] == 1) {
         foreach ($list as $k => $v) {
             $list[$k]['reg_time'] = date('Y/m/d H:i:s', $v['reg_time']);
             $list[$k]['last_time'] = date('Y/m/d H:i:s', $v['last_time']);
         }
         $title = array('ID', '用户名', '注册时间', '访问次数', '最后登录');
         $filename = '用户统计数据表';
         $this->ecport_excel($filename, $title, $list);
     }
     //echo '<pre>';
     //print_r($list);
     //exit();
     $this->assign('list', $list);
     $this->display();
 }
 public function handleInfo()
 {
     $post = I('post.');
     //dd($post);
     $info = '电话: ' . $post['phone'] . ' QQ: ' . $post['qq'];
     $user = $this->_getInfo();
     if ($post['phone'] != null) {
         $user['phone_num'] = $post['phone'];
     }
     if ($post['qq'] != null) {
         $user['tencent_num'] = $post['qq'];
     }
     // 发布招领的就加一分, 需要审核, 失物不需要审核
     if ($post['species'] == 1) {
         $user['score'] = $user['score'] + 1;
         $check = 0;
     } else {
         $check = 1;
     }
     M('user_info')->save($user);
     $kindname = M('product_kinds')->where(array('kind_id' => I('kind')))->find();
     $connectpeople = M('user_info')->where(array('user_id' => session('relace_user_id')))->find();
     // 保存添加
     $sta = $this->_saveData(array('pro_name' => $kindname['kind_name'], 'pro_description' => $post['content'], 'L_or_F_time' => $this->_timeStyle(I('date')), 'L_or_F_place' => $post['place'], 'connect_info' => $info, 'connect_people' => $connectpeople['stu_name'], 'pro_kind_id' => $post['kind'], 'pro_user_id' => session('relace_user_id'), 'create_time' => time(), 'lost_or_found' => $post['species'], 'check_state' => $check, 'status' => 0));
     $this->ajaxReturn(array('status' => $sta));
 }
Example #22
0
 /**
  * 编辑
  * @param $id 编辑id
  */
 public function edit($id)
 {
     if (IS_POST) {
         //收集验证数据
         if ($this->model->create() !== false) {
             //修改数据并保存到数据库
             if ($this->model->save($this->usePostParams ? I('post.') : '') !== false) {
                 $this->success('修改成功', U('index'));
                 return;
             }
         }
         $this->error('操作失败' . show_model_error($this->model));
     } else {
         //>>回显
         //通过find查询出要编辑的一行
         $rows = $this->model->find($id);
         //将数据分配到页面上
         $this->assign($rows);
         $this->assign('meta_title', $this->meta_title);
         //查询数据
         $this->_editGetTreeList(true, 'id,name,parent_id');
         //展示视图页面
         $this->display('edit');
     }
 }
 public function update($admin_id)
 {
     $admin_id = $admin_id + 0;
     $model = new \Model\AdminModel();
     if (IS_POST) {
         if ($data = $model->create()) {
             $password = I('post.password');
             //判断有没有输入新密码
             if (empty($password)) {
                 unset($data['password']);
             } else {
                 //重新生成密码和salt
                 $str = uniqid();
                 $salt = substr($str, -6);
                 $password = I('post.password');
                 //生成密码
                 $data['password'] = md5(md5($password) . $salt);
                 $data['salt'] = $salt;
             }
             if ($model->save($data) !== false) {
                 $this->success('修改管理员成功', U('showlist'), 1);
                 exit;
             }
             $this->error('修改管理员失败');
         }
         $this->error($model->getError());
     }
     //获取要修改管理员的属性并显示
     $info = $model->field('admin_id,admin_name,role_id')->join("left join it_admin_role using(admin_id)")->find($admin_id);
     $this->assign('info', $info);
     //获取角色并遍历显示
     $role_list = M('Role')->select();
     $this->assign('role_list', $role_list);
     $this->display();
 }
Example #24
0
 /**
  * 修改权限
  */
 public function rule_edit($id)
 {
     $model = D('Rule');
     if (IS_POST) {
         if ($data = $model->create()) {
             //判断提交的父id是否是自己和自己的子分类
             $id = I('post.id');
             $data['ru_id'] = $id;
             if ($model->save($data) !== false) {
                 $this->success('修改成功', U('rule_list'));
                 exit;
             } else {
                 $this->error($model->getError());
             }
         } else {
             $this->error($model->getError());
         }
     }
     $id = (int) $id;
     //取出要修改的分类的数据
     $info = $model->find($id);
     $this->assign('id', $id);
     $this->assign('info', $info);
     $data = $model->order('ru_order')->where(array('ru_pid' => '0', 'ru_status' => '1'))->select();
     $this->assign('data', $data);
     $this->display();
 }
 public function index()
 {
     $id = I('id', '', 'htmlspecialchars');
     $my_id = session('user_id');
     // 只能通过get id才能访问
     if (empty($id)) {
         $this->error('页面不存在!', '/index');
         die;
     }
     $atten = M()->query("select count(*) from dm_items_support where user_id = {$id} and attention=1");
     //关注的人数
     $frien = M()->query("select count(*) from dm_person_friends where user_id = {$id}  ");
     //好友数
     $topic = M()->query("select count(*) from dm_community_comments_first where user_id = {$id} ");
     //帖子数
     $userinfo = M()->query("select * from dm_user_info where id = {$id}");
     if (empty($userinfo[0])) {
         $this->error('不存在该用户', '/index');
         die;
     }
     $usernews = M()->query("select * from dm_community_comments_first where user_id = {$id}");
     foreach ($usernews as $key => $value) {
         $usernews[$key]['time'] = date('n\\月j\\日 G:i', $value['time']);
     }
     $this->assign('atten', $atten);
     $this->assign('frien', $frien);
     $this->assign('topic', $topic);
     $this->assign('add_id', $id);
     // $this->assign('my_id',$id);
     $this->assign('userinfo', $userinfo);
     $this->assign('usernews', $usernews);
     $this->display();
 }
Example #26
0
 public function bindUser()
 {
     $arr['token'] = I('token');
     $arr['type'] = I('type');
     if (!$arr['token']) {
         $this->apiError(0, '未知的设备标识');
     }
     if ($this->checkBind($arr['token'])) {
         $this->apiError(0, '已绑定');
     }
     $arr['type'] = $arr['type'] ? $arr['type'] : 1;
     $arr['uid'] = $this->uid;
     $arr['status'] = 1;
     $arr['create_time'] = time();
     $res = M('baidu_user')->add($arr);
     if ($res) {
         $list = $this->getMsg($this->uid);
         if ($list) {
             foreach ($list as $key => $v) {
                 $this->push2user1($this->uid, $v['msg'], $v['style'], $v['content_id'], $v['id'], $arr['type'], $arr['token']);
             }
         }
         $this->apiSuccess('success');
     } else {
         $this->apiError(0, '绑定失败');
     }
 }
 public function index()
 {
     $data = I('post.');
     if (!empty($data['username']) && !empty($data['password']) && !empty($data['verify'])) {
         if ($this->Verify->check($data['verify'])) {
             $user = M('user');
             $userdata = $user->where("username='******' and state=0", $data['username'])->find();
             if ($userdata && $userdata['password'] === md5(C('SECURE_CODE') . md5($data['password']))) {
                 unset($userdata['password']);
                 $userdata['ip'] = get_client_ip();
                 $user->where('id=' . $userdata['id'])->save(array('logintime' => time()));
                 $user_auth = json_encode($userdata);
                 $user_auth_cookie = authcode($user_auth, ENCODE);
                 cookie('auth', $user_auth_cookie, 3600);
                 $this->success('登陆成功', U('index/index'));
                 exit;
             } else {
                 $this->error("用户名或密码错误");
             }
         } else {
             $this->error("验证码填写错误");
         }
     }
     $this->display();
 }
 /**
  * 检查同一分组下是否有相同的字段
  * @author jry <*****@*****.**>
  */
 protected function checkTitle()
 {
     $map['title'] = array('eq', I('post.title'));
     $map['group'] = array('eq', I('post.group'));
     $result = $this->where($map)->find();
     return empty($result);
 }
     public function save()
     {
        $id = I('post.id','0','intval');
        $name = I('post.name','','trim');
        $folder = I('post.folder','','trim');
        if(!$name || strlen($name)>20)
        {
            $this->out(null,1);
        }
        $where = array('name'=>$name);
        $row = $this->dao->getByName($name);
        if($row)
        {
            $this->out(null,13);
        }


        if(!$id)
        {
            if(!$folder || strlen($folder)>20)
            {
                $this->out(null,1);
            }

            $row = $this->dao->getByFolder($folder);
            if($row)
            {
                $this->out(null,13);
            }            
        }

        parent::save();
     }
 /**
  * 登陆后回调地址
  */
 public function callback()
 {
     $code = I('get.code');
     $type = I('get.type');
     $sns = \ThinkOauth::getInstance($type);
     //腾讯微博需传递的额外参数
     $extend = null;
     if ($type == 'tencent') {
         $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey'));
     }
     $token = $sns->getAccessToken($code, $extend);
     //获取第三方Token
     $user_sns_info = \ThinkOauthInfo::$type($token);
     //获取第三方传递回来的用户信息
     $user_sync_info = D('Addons://SyncLogin/SyncLogin')->getUserByOpenidAndType($token['openid'], $type);
     //根据openid等参数查找同步登录表中的用户信息
     $user_sys_info = D('User')->find($user_sync_info['uid']);
     //根据UID查找系统用户中是否有此用户
     if ($user_sync_info['uid'] && $user_sys_info['id'] && $user_sync_info['uid'] == $user_sys_info['id']) {
         //曾经绑定过
         D('Addons://SyncLogin/SyncLogin')->updateTokenByTokenAndType($token, $type);
         D('User')->autoLogin($user_sys_info);
         redirect('http://' . $_SERVER['HTTP_HOST'] . __ROOT__);
     } else {
         //没绑定过,去注册页面
         session('token', $token);
         session('user_sns_info', $user_sns_info);
         $this->assign('user_sns_info', $user_sns_info);
         $this->assign('meta_title', "登陆");
         $this->display(T('Addons://SyncLogin@./default/reg'));
     }
 }