public function edit()
 {
     if (!IS_AJAX) {
         $this->error(L('_ERROR_ACTION_'));
     }
     $Type = M('Type');
     $lang = I('get.lang') ? I('get.lang') : $this->clang;
     $list = $Type->field('id,pid,name')->where('status=1 AND lang=\'' . $lang . '\'')->select();
     $tree = new \Common\Lib\Tree($list);
     if (IS_POST) {
         if ($Type->create()) {
             $Model = new \Think\Model();
             $query = $Model->query("SHOW TABLE STATUS LIKE '__TYPE__'");
             $nextid = $query[0]['auto_increment'];
             $top = I('post.pid') == 0 ? $nextid : $tree->get_top(I('post.pid'));
             $data = array('pid' => I('post.pid'), 'name' => I('post.name'), 'description' => I('post.description'), 'status' => I('post.status') ? 1 : 0, 'keyid' => $top['id'], 'lang' => I('post.lang'));
             $result = $Type->where('id=' . I('post.id'))->save($data);
             if ($result !== FALSE) {
                 $this->success(L('SAVE_OK'), U('Type/index', $this->vl . '&pid=' . $data['pid']));
             } else {
                 $this->error(L('SAVE_ERROR'));
             }
         } else {
             $this->error($Type->getError());
         }
     } else {
         $str = "<li data-val='\$id'>\$spacer\$name</li>";
         $vo = $Type->where('id=' . I('get.id'))->find();
         $this->assign('pids', $tree->get_tree(0, $str));
         $this->assign('vo', $vo);
         $this->display();
     }
 }
 public function index()
 {
     global $custom_config;
     $data['username'] = cookie("userinfo")['username'];
     $user = M("user")->where($data)->find();
     //$orders = M("orders")->where($data)->select();
     //$order_goods = M("orders_goods")->where($data)->select();
     $Model = new \Think\Model();
     $sql = "select og.*,o.addtime,o.is_deal from cz_orders o inner join cz_orders_goods og on o.id=og.orders_id where o.username= '******'username']}' order by og.id desc limit 10";
     $order_goods = $Model->query($sql);
     //$jdNums = M("orders")->where($data)->sum('jidou');
     $jdNums = $Model->query("select sum(og.jidou) as jd_nums from cz_orders o left join cz_orders_goods og on o.id=og.orders_id where o.username= '******'username']}' limit 10");
     $prizes = M("prize")->select();
     //兑换的礼品
     $user_id = cookie("userinfo")['user_id'];
     $exchange = M("exchange")->limit("10")->order("id desc")->where(array("user_id" => $user_id))->select();
     $answer_jidou = M("user_answer")->where(array("user_id" => $user_id))->sum("test_paper_jidou");
     $answers = M("user_answer")->where(array("user_id" => $user_id))->select();
     $this->assign("exchange", $exchange);
     $this->assign("jdNums", $jdNums[0]['jd_nums']);
     $this->assign("user", $user);
     $this->assign("order_goods", $order_goods);
     $this->assign("answer_jidou", $answer_jidou);
     $this->assign("answers", $answers);
     $this->assign("prizes", $prizes);
     $this->assign("custom_config", $custom_config);
     $this->assign("title", "用户中心");
     $this->display();
 }
 public function add()
 {
     if (!IS_AJAX) {
         $this->error(L('_ERROR_ACTION_'));
     }
     if (IS_POST) {
         $Group = D('AuthGroup');
         if ($Group->create()) {
             $Model = new \Think\Model();
             $query = $Model->query("SHOW TABLE STATUS LIKE '__AUTH_GROUP__'");
             $nextid = $query[0]['auto_increment'];
             $data = array('title' => 'A_G_T_' . $nextid, 'remark' => 'A_G_R_' . $nextid, 'status' => I('post.status') ? 1 : 0);
             if ($Group->add($data)) {
                 $info[$data['title']] = I('post.title');
                 $info[$data['remark']] = addcslashes(I('post.remark', '', NULL), '\'\\');
                 write_lang($info, 'group_title');
                 $this->success(L('ADD_SUCCESS'), U('Group/index', $this->vl));
             } else {
                 $this->error(L('ADD_ERROR'));
             }
         } else {
             $this->error($Group->getError());
         }
     } else {
         $this->display('edit');
     }
 }
 public function index()
 {
     $view_dir = "./Application/Home/View";
     $view_info = array();
     if (is_dir($view_dir)) {
         if ($dh = opendir($view_dir)) {
             $i = 0;
             while (($file = readdir($dh)) !== false) {
                 if ($file != "." && $file != "..") {
                     $view_info[$i] = stat($view_dir . "\\{$file}");
                     $view_info[$i]['filename'] = $file;
                     $i++;
                 }
             }
             closedir($dh);
         }
     }
     //for($i=0; $i<count($tpl_info); $i++){
     //		$temp[] = explode('.', $tpl_info[$i]['filename']);
     //		$tpl_info[$i]['filename'] = $tpl_info[$i]['filename'];
     //}
     $this->assign('view_info', $view_info);
     $Model = new \Think\Model();
     $city = $Model->query('SELECT * FROM `cloud_city` ORDER BY `gdp_order` ASC');
     $city_keywords = $Model->query('SELECT `title` FROM `cloud_tpl_info` WHERE `tpl_name`="index.html"');
     $city_keywords = explode(',', $city_keywords[0][title]);
     $external_link = $Model->query('SELECT * FROM `cloud_external_link` ORDER BY `keywords` ASC');
     $this->assign('city', $city);
     $this->assign('city_keywords', $city_keywords[0]);
     $this->assign('external_link', $external_link);
     $this->display('Index:web_station_statistics');
 }
Example #5
0
 public function getStatistics($user_id, $start_time, $end_time)
 {
     $club_id = get_club_id();
     if (empty($user_id)) {
         if (empty($end_time)) {
             $sql = "select b.id, b.name,b.level,count(a.channel_id)  as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on a.channel_id=b.id    and a.channel_id!=0 and a.create_time>='{$start_time}'  where b.club_id={$club_id}  group by b.id order by protential desc";
         } else {
             $sql = "select b.id, b.name,b.level,count(a.channel_id)  as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on a.channel_id=b.id  and a.channel_id!=0 and a.create_time>='{$start_time}' and a.create_time<'{$end_time}' where b.club_id={$club_id}   group by b.id order by protential desc";
         }
     } else {
         if (empty($end_time)) {
             $sql = "select b.id, b.name,b.level,count(a.channel_id)  as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on a.channel_id=b.id  and a.channel_id!=0 and a.create_time>='{$start_time}' where  b.club_id={$club_id}   and b.user_id={$user_id}  group by b.id order by protential desc";
         } else {
             $sql = "select b.id, b.name,b.level,count(a.channel_id)  as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on a.channel_id=b.id  and a.channel_id!=0 and a.create_time>='{$start_time}' and a.create_time<'{$end_time}'   where  b.club_id={$club_id}  and  b.user_id={$user_id}   group by b.id  order by protential desc";
         }
     }
     $model = new \Think\Model();
     $ret = $model->query($sql);
     foreach ($ret as $key => $value) {
         $end_time = empty($end_time) ? $start_time : $end_time;
         $total = $this->getChannelTotal($value["id"], $end_time);
         $ret[$key]["protential_total"] = $total['protential_total'];
         $ret[$key]["mcount_total"] = $total['transform_total'];
     }
     return $ret;
 }
 public function groups()
 {
     $aKeyword = $this->parseSearchKey('keyword');
     $aPage = I('get.page', 1, 'intval');
     $r = 20;
     $aOrder = I('get.order', 'create_time', 'text');
     $aReverse = I('get.reverse', 'desc', 'text');
     $aCate = I('get.cate', 0, 'intval');
     $aUid = I('get.uid', 0, 'intval');
     if ($aOrder == 'activity') {
         $this->assign('order', '按活跃度排序');
     } elseif ($aOrder == 'member') {
         //todo 根据成员数排序
         $Model = new \Think\Model();
         // 实例化一个model对象 没有对应任何数据表
         $count = $Model->query("SELECT group_id,count(group_id) as count from opensns_group_member group by group_id order by count desc");
         $ids = getSubByKey($count, 'group_id');
         $ids = implode(',', $ids);
         $aOrder = "find_in_set( id ,'" . $ids . "') ";
         $this->assign('order', '按成员数排序');
     } else {
         $aOrder = 'create_time';
         $this->assign('order', '按最新创建排序');
     }
     if (!empty($aCate)) {
         $gid = D('GroupType')->where('pid=' . $aCate)->field('id')->select();
         $gids = getSubByKey($gid, 'id');
         $gids[] = $aCate;
         $param['where']['type_id'] = array('in', $gids);
         $this->assign('name', get_type_name($aCate));
         $this->assign('group_cate', $aCate);
         $this->assign('keyword', array(0 => 'cate', 1 => $aCate));
         $this->setTitle('{$name}');
     }
     if (!empty($aKeyword)) {
         $param['where']['title'] = array('like', '%' . $aKeyword . '%');
         $this->assign('name', $aKeyword);
         $this->assign('keyword', array(0 => 'keywords', 1 => $aKeyword));
     }
     if ($aUid != 0) {
         $param['where']['uid'] = $aUid;
         $this->assign('name', get_nickname($aUid) . '的群组');
         $this->assign('keyword', array(0 => 'uid', 1 => $aUid));
     }
     $param['where']['status'] = 1;
     $param['page'] = $aPage;
     $param['count'] = $r;
     $param['order'] = $aOrder . ' ' . $aReverse;
     $param['field'] = 'id';
     $group_list = D('Group/Group')->getList($param);
     //获取总数
     $totalCount = D('Group/Group')->where($param['where'])->count();
     $this->assign('totalCount', $totalCount);
     $this->assign('r', $r);
     $this->assign('group_list', $group_list);
     $this->assignGroupTypes();
     $this->setTitle('群组首页');
     $this->assign('current', 'groups');
     $this->display();
 }
Example #7
0
/**
 * 判断是否已经满足今天的加分上限
 */
function isFull($stu_num, $act, $pro)
{
    //首先用php获取当天的年份
    $y = date("Y");
    //首先用php获取当天的月份
    $m = date("m");
    //首先用php获取当天的号数(也就是几日,那今天来讲就是:11日)
    $d = date("d");
    //将今天开始的年月日时分秒,转换成unix时间戳(开始示例:2014-03-11 00:00:00)
    $day_start = mktime(0, 0, 0, $m, $d, $y);
    //将今天结束的年月日时分秒,转换成unix时间戳 (结束示例:2014-03-11 23:59:59)
    $day_end = mktime(23, 59, 59, $m, $d, $y);
    $user = M('user_member')->where(array('stu_num' => $stu_num))->find();
    $userid = $user['id'];
    $desc = $act['description'];
    //create_time > ".$day_start." and create_time < ".$day_end." and user_id = ".$userid." and project = ".$pro." and action = ".$desc
    $Model = new \Think\Model();
    $todayLog = $Model->query("select * from user_log where create_time > " . $day_start . " and create_time < " . $day_end . " and user_id = " . $userid . " and project = '" . $pro . "'and action = '" . $desc . "'");
    if (!$todayLog) {
        return false;
    }
    $todayScore = 0;
    foreach ($todayLog as $each) {
        foreach ($each as $key => $value) {
            if ($key == 'score') {
                $todayScore += $value;
            }
        }
    }
    if ($todayScore < $act['limit_day']) {
        return false;
    } else {
        return true;
    }
}
 /**
  * 产品管理
  */
 public function productList($page = 1, $rows = 10, $search = array(), $sort = 'id', $order = 'asc')
 {
     if (IS_POST) {
         $product_db = D('product');
         $total = $product_db->count();
         $order = $sort . ' ' . $order;
         $limit = ($page - 1) * $rows . "," . $rows;
         $Model = new \Think\Model();
         $sql = "SELECT a.*, COUNT(b.id) as contractcount, SUM(b.money) as contractmoney FROM \n\t\t\t\t\t\tapp2_product a \n\t\t\t\t\tLEFT JOIN \n\t\t\t\t\t\tapp2_contract b \n\t\t\t\t\tON \n\t\t\t\t\t\ta.id=b.product\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\ta.id\n\t\t\t\t\tORDER BY \n\t\t\t\t\t\t{$order} \n\t\t\t\t\tLIMIT \n\t\t\t\t\t\t{$limit}";
         $list = $Model->query($sql);
         if (!$list) {
             $list = array();
         }
         $data = array('total' => $total, 'rows' => $list);
         $this->ajaxReturn($data);
     } else {
         $admin_db = D('admin');
         $area_db = D('Area');
         $currentAdmin = $admin_db->where(array('userid' => session('userid')))->find();
         $adminArea = $area_db->where(array('id' => $currentAdmin['area']))->find();
         if ($currentAdmin['position'] != "超级管理员") {
             echo "<p>你无权访问该内容</p>";
             exit;
         }
         $menu_db = D('Menu');
         $currentpos = $menu_db->currentPos(I('get.menuid'));
         //栏目位置
         $datagrid = array('options' => array('title' => $currentpos, 'url' => U('Product/productList', array('grid' => 'datagrid')), 'toolbar' => 'ProductproductModule.toolbar'), 'fields' => array('项目代号' => array('field' => 'code', 'width' => 15, 'sortable' => true), '项目名称' => array('field' => 'name', 'width' => 15), '募集额度' => array('field' => 'money_total', 'width' => 15), '已募集数量' => array('field' => 'contractcount', 'width' => 15), '已募集金额' => array('field' => 'contractmoney', 'width' => 15), '募集进度' => array('field' => 'progess', 'width' => 15, 'formatter' => 'ProductproductModule.progess'), '客户方案' => array('field' => 'remark', 'width' => 20), '操作' => array('field' => 'id', 'width' => 20, 'formatter' => 'ProductproductModule.operate')));
         $this->assign('datagrid', $datagrid);
         $this->display('product_list');
     }
 }
 public function index()
 {
     //$Line_type = M('Line_type');
     $catid = I('get.catid', 1);
     $sql = "select count(*) as num from __LINE_TYPE__ as a,__LINE__ as b\n        where a.type_id = {$catid} and a.line_id = b.line_id and b.status=1";
     $pageNum = 10;
     $_page = pages($sql, $pageNum);
     $nowPage = I('get.p', 1);
     $firstRow = ($nowPage - 1) * $pageNum;
     $Model = new \Think\Model();
     $line_lists = $Model->query("select a.*, b.* from __LINE_TYPE__ as a,\n       __LINE__ as b where a.type_id = {$catid} and a.line_id = b.line_id and b.status=1\n       order by b.update_time desc, b.line_id desc limit {$firstRow},{$pageNum}");
     $line_lists = array_filter($line_lists);
     foreach ($line_lists as $key => $val) {
         $map_two = array();
         $map_two['line_id&is_default'] = array($val['line_id'], 1, '_multi' => true);
         $res = get_tc_val($map_two);
         $line_lists[$key]['price'] = $res['price'];
         $line_lists[$key]['best_price'] = $res['best_price'];
         $line_lists[$key]['start_date'] = get_start_date($res['date_price_data']);
         $line_lists[$key]['img'] = get_cover(array_shift(explode(',', $val['images'])), 'path');
         $line_lists[$key]['url'] = U('Line/show', array('id' => $val['line_id']));
     }
     $this->assign('line_lists', $line_lists);
     $this->assign('_page', $_page);
     $this->display();
 }
 public function getCities($province)
 {
     $sql = "select city from t_cities where provinceid like \r\n            (select provinceid from t_provinces where province like '" . $province . "')";
     //         echo $sql;
     $m = new \Think\Model();
     $result = $m->query($sql);
     return $result;
 }
Example #11
0
 public function exportallAction()
 {
     $current_page = I("page");
     $this->current_page = $current_page;
     $start_time = I("start_time");
     $end_time = I("end_time");
     if (empty($start_time)) {
         $start_time = '1970-01-01';
     }
     if (empty($end_time)) {
         $end_time = '2970-01-01';
     }
     //查询
     $brands = D("Brand")->relation(true)->field("id,brand_name")->select();
     $brand_id = I("brand_id");
     $club_id = I("club_id");
     $valuesql = "select  b.status as bstatus, b.card_type_extension, b.free_rest,b.free_trans,b.rest_count,b.trans_count, b.is_review,b.description as `desc`, b.id as contract_id,b.contract_number, b.create_time as bc, a.*,e.name,e.sex,e.phone ,c.card_number ,d.name as card_name,d.type as card_type ,d.price as card_type_price,b.invalid,b.type as btype,b.present_day,b.present_num,b.start_time,b.end_time,b.active_type,b.used_num,b.total_num   from yoga_bill_project a inner join yoga_contract b on a.object_id=b.id and a.type in(0,3,4,5) and b.create_time >'{$start_time}' and b.create_time<'{$end_time}' and b.sale_club_id={$club_id} inner join yoga_member_basic e on a.member_id=e.id left join yoga_card c on b.card_id=c.id left join yoga_card_type d on b.card_type_id=d.id where  a.sale_club_id={$club_id}  ";
     $countsql = "select count(*) as count from yoga_bill_project a inner join yoga_contract b on a.object_id=b.id and a.type in(0,4,5) and b.create_time >'{$start_time}' and b.create_time<'{$end_time}' and b.sale_club_id={$club_id}  inner join yoga_member_basic e on a.member_id=e.id left join yoga_card c on b.card_id=c.id left join yoga_card_type d on b.card_type_id=d.id where  a.sale_club_id={$club_id} ";
     $tail = "";
     $model = new \Think\Model();
     $countsql = $countsql . " " . $sql . $tail;
     $count = $model->query($countsql);
     $count = $count[0]["count"];
     $pages = ceil($count / 20);
     $valuesql = $valuesql . " " . $sql . $tail . "order by b.id desc ";
     $vv = $model->query($valuesql);
     foreach ($vv as $key => $value) {
         $mc = M("UserExtension")->find($value['mc_id']);
         $recorder = M("UserExtension")->find($value['record_id']);
         $vv[$key]['mc_name'] = !empty($mc) ? $mc['name_cn'] : "NO MC!";
         $vv[$key]['recorder_name'] = !empty($recorder) ? $recorder['name_cn'] : "品牌帐号";
     }
     $head = array('姓名', '电话', '卡种', '卡号', '合同开始', '合同结束', '顾问', '入会时间', '录入人', '备注');
     $file_name = "/var/www/tmp/export.csv";
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $start_time . '-' . $end_time . '.csv"');
     header('Cache-Control: max-age=0');
     $fp = fopen('php://output', 'a');
     foreach ($head as $i => $v) {
         $head[$i] = iconv('utf-8', 'GBK', $v);
     }
     fputcsv($fp, $head);
     $cnt = 0;
     $limit = 100000;
     foreach ($vv as $key => $row) {
         $cnt++;
         if ($limit == $cnt) {
             ob_flush();
             flush();
             $cnt = 0;
         }
         $ret = array($row['name'], $row['phone'], $row['card_name'], $row['card_number'], $row['start_time'], $row['end_time'], $row['mc_name'], $row['bc'], $row['recorder_name'], $row['desc']);
         foreach ($ret as $i => $v) {
             $ret[$i] = iconv('utf-8', 'GBK', $v);
         }
         fputcsv($fp, $ret);
     }
 }
/**
 * 获取分类
 * @param int $isNav
 * @return mixed
 */
function getCategory($isNav = -1)
{
    $map = array();
    if ($isNav > -1) {
        $map['isNav'] = $isNav;
    }
    $model = new \Think\Model('Category');
    return $model->where($map)->order('sort DESC')->select();
}
Example #13
0
function upgrade_20140527_to_20140602()
{
    $db_prefix = C('db_prefix');
    $Model = new \Think\Model();
    $sql = "DROP TABLE IF EXISTS `{$db_prefix}user_sns`";
    $Model->query($sql);
    $sql = "CREATE TABLE `{$db_prefix}user_sns` (\n  `us_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `user_id` bigint(20) DEFAULT '0',\n  `access_token` varchar(50) DEFAULT NULL,\n  `refresh_token` varchar(50) DEFAULT NULL,\n  `remind_in` varchar(50) DEFAULT NULL,\n  `expires_in` varchar(50) DEFAULT NULL,\n  `openid` varchar(50) DEFAULT NULL,\n  `type` varchar(50) DEFAULT NULL,\n  `expires_time` timestamp NULL DEFAULT NULL,\n  PRIMARY KEY (`us_id`),\n  KEY `useropen` (`user_id`)\n) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;";
    $Model->query($sql);
}
 public function del()
 {
     $id = $_POST['id'];
     $coms = new \Think\Model('Comment');
     $result = $coms->delete($id);
     if ($result) {
         echo '1';
     } else {
         echo '2';
     }
 }
 public function getEmployeesAction()
 {
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $model = M("User");
     $brand_id = get_brand_id();
     $condition = array("brand_id" => $brand_id, "is_brand" => 0);
     $valuesql = "select * from yoga_user a,yoga_user_extension b where a.brand_id={$brand_id} and a.is_brand=0 and a.id=b.id and a.invalid=1 ";
     $countsql = "select count(*) as count from yoga_user a,yoga_user_extension b where a.brand_id={$brand_id} and a.is_brand=0 and a.id=b.id and a.invalid=1 ";
     $filters = I("filters", '', '');
     $filters = json_decode($filters);
     $sql = "";
     if ($filters->groupOp == 'AND') {
         $rules = $filters->rules;
         foreach ($rules as $key => $value) {
             if ($value->field == "club" && $value->data != 0) {
                 $sql .= " and a.club_id " . getOPerationMysql($value->op) . "  '{$value->data}'";
             }
             if ($value->field == "work_status" && $value->data != -1) {
                 $sql .= " and b.work_status " . getOPerationMysql($value->op) . "  '{$value->data}'";
             }
             if ($value->field == "name_cn") {
                 $sql .= " and b.name_cn  like '%{$value->data}%'";
             }
             if ($value->field == "name_en") {
                 $sql .= " and b.name_en  like '%{$value->data}%'";
             }
             if ($value->field == "role" && $value->data != -1) {
                 $ids = M("AuthGroupAccess")->where("group_id=" . $value->data)->select();
                 $id = array();
                 foreach ($ids as $key => $value) {
                     $id[] = $value['uid'];
                 }
                 $ids = implode(",", $id);
                 $sql .= " and b.id in({$ids})";
             }
         }
     }
     $model = new \Think\Model();
     $countsql = $countsql . " " . $sql;
     $count = $model->query($countsql);
     $count = $count[0]["count"];
     $valuesql = $valuesql . " " . $sql . $tail . " order by a.{$sidx} {$sord} limit {$start},{$limit}";
     $ret = $model->query($valuesql);
     foreach ($ret as $key => $value) {
         $ret[$key]['role'] = D("User")->getRole($value['id']);
     }
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret);
     $this->ajaxReturn($response);
 }
 public function delete_article()
 {
     $id = $_GET['id'];
     $Model = new \Think\Model();
     $result = $Model->execute("DELETE FROM `cloud_article` WHERE `id`=" . $id);
     if ($result) {
         $this->success('删除成功', '/index.php/Admin/ArticleAdmin/index');
     } else {
         $this->error('删除失败', '/index.php/Admin/ArticleAdmin/index');
     }
 }
  public function indexProvince($province = '湖南')
  {
      //标记当前菜单为激活状态
      $currentmenu['report'] = "active";
      $this->assign('currentmenu', $currentmenu);
      $this->assign('province', $province);
      $m = new \Think\Model();
      $result = $m->query('select bpbtype from t_batteryconfig 
 			group by bpbtype order by bpbtype');
      $this->assign('batteryTypes', $result);
      $this->embed_display('province_sales');
  }
 public function delete()
 {
     $table = I('get.table');
     $sql = 'drop table ' . $table . ';';
     $Model = new \Think\Model();
     $result = $Model->execute($sql);
     if ($result === 0) {
         $info = $table . ' 删除成功!';
         $this->assign('data', $this->data);
         $this->assign('success', $info);
         $this->redirect('index');
     }
 }
 public function do_Login()
 {
     $Model = new \Think\Model();
     $login_name = $_POST['login_name'];
     $login_pwd = $_POST['login_pwd'];
     $member = $Model->query('select * from cloud_member');
     for ($i = 0; $i < count($member); $i++) {
         if ($member[$i]['name'] == $login_name && $member[$i]['pwd'] == $login_pwd) {
             session('check', '1');
             $this->success('登陆成功', '../Index/checkUser');
         }
     }
     $this->error('登陆失败', '/index.php/Admin');
 }
 public function learnto()
 {
     $user_id = $data['user_id'] = I("user_id", 0, "int");
     //$orders = M("orders")->where($data)->select();
     $Model = new \Think\Model();
     $sql = "select * from cz_orders o inner join cz_orders_goods og on o.id=og.orders_id where o.user_id={$user_id} and og.jidou>0 order by og.id desc limit 5";
     $orders = $Model->query($sql);
     $esql = "select e.id,e.title,p.thumb from cz_exchange e inner join cz_prize p on e.prize_id=p.prize_id where e.user_id={$user_id} order by e.id desc limit 3";
     $exchanges = $Model->query($esql);
     $this->assign("exchanges", $exchanges);
     $this->assign("orders", $orders);
     $this->assign("title", "向他学习");
     $this->display();
 }
Example #21
0
 public function index()
 {
     session_start();
     header('Content-Type:text/html; charset=UTF-8');
     //防止出现乱码
     $username = $_SESSION['username'];
     $guarantee = PublicController::getDanbaoRate();
     $this->assign('username', $username);
     $this->assign('guarantee', $guarantee * 100);
     //借贷列表
     $Model = new \Think\Model();
     $loanarr = $Model->query("select a.f_uid userid,a.f_username username,b.f_id vid,round(b.f_yield*100,2) yield,round(b.f_money) money,round(b.f_danbaomoney,2) danbaomoney,b.f_horizon horizon,b.f_state state,DATE_FORMAT(b.f_addtime,'%Y-%m-%d') addtime from t_userinfo a,t_loan b where a.f_uid=b.f_userid and b.f_state=0 order by b.f_addtime desc limit 20");
     $this->assign('loanlist', $loanarr);
     $this->display();
 }
Example #22
0
 function get_all_lable_by_userid()
 {
     if (check_login(I('user_id'), I('login'))) {
         $Order = M('Order');
         $Model = new \Think\Model();
         //$map['l.lable_id']='o.lable_id';
         //$map['o.user_id']=I('user_id');
         $ans = $Model->query("SELECT * FROM `order` `o`,`lable` `l` WHERE o.lable_id=l.lable_id and o.user_id = " . I('user_id'));
         //$Model->table(array('order'=>'o','lable'=>'l'))->where($map)->select();
         //var_dump($ans);
         $this->ajaxReturn($ans);
     } else {
         $this->ajaxReturn(0);
     }
 }
 public function delete_tpl()
 {
     $filename = $_GET['filename'];
     $Model = new \Think\Model();
     $city = $Model->query('SELECT * FROM `cloud_city`');
     for ($i = 0; $i < count($city); $i++) {
         if ($city[$i]['tpl_name'] == $filename) {
             $temp_id = $city[$i]['id'];
             $Model->execute("UPDATE `cloud_city` SET `tpl_name`='rand' WHERE `id`={$temp_id}");
         }
     }
     $delete_dir = './Application/Home/Common/template/' . $filename;
     $this->deldir($delete_dir);
     $this->success('删除成功', '/index.php/Admin/TemplateAdmin/index');
 }
Example #24
0
 public function index()
 {
     session_start();
     header('Content-Type:text/html; charset=UTF-8');
     //防止出现乱码
     $username = $_SESSION['username'];
     $this->assign('username', $username);
     //投资内容
     $Model = new \Think\Model();
     $investarr = $Model->query("select a.f_uid userid,a.f_username username,b.f_id vid,round(b.f_yield*100,2) yield,round(b.f_money) money,round(b.f_danbaomoney,2) danbaomoney,b.f_horizon horizon,b.f_state state,DATE_FORMAT(b.f_addtime,'%Y-%m-%d') addtime from t_userinfo a,t_invest b where a.f_uid=b.f_userid and b.f_state=1 order by b.f_addtime desc limit 10");
     $this->assign('invest', $investarr);
     //贷款内容
     $loantarr = $Model->query("select a.f_uid userid,a.f_username username,b.f_id vid,round(b.f_yield*100,2) yield,round(b.f_money,2) money,round(b.f_danbaomoney,2) danbaomoney,b.f_horizon horizon,b.f_state state,DATE_FORMAT(b.f_addtime,'%Y-%m-%d') addtime from t_userinfo a,t_loan b where a.f_uid=b.f_userid and b.f_state=1 order by b.f_addtime desc limit 10");
     $this->assign('loan', $loantarr);
     $this->display();
 }
Example #25
0
 public function viewrw()
 {
     $bid = I('get.bid', '', 'string');
     preg_match_all("/\\d+/", $bid, $m);
     //$sid = I('get.sid');
     //加入权限判定则通过登录用户
     $model_kt = new \Think\Model();
     $rs_kt = array();
     for ($i = 0; $i < count($m[0]); $i++) {
         $push_data = $model_kt->query("SELECT user_teacher.name as tname,bs_kt.*,user_student.name as sname, user_student.class FROM user_student,bs_kt,bs_xt,user_teacher WHERE bs_xt.sid = user_student.user AND bs_xt.bid = bs_kt.id AND bs_kt.teacher = user_teacher.user AND bs_kt.id=" . $m[0][$i]);
         array_push($rs_kt, $push_data[0]);
     }
     //print_r($rs_kt);
     $this->assign('kt', $rs_kt);
     $this->display();
 }
Example #26
0
/**
 * 拆字查询
 * @param  string $key            [查询关键字词]
 * @param  string $table_name     [查询的表名]
 * @param  string $table_field_id [$table_name表的主键ID字段名]
 * @param  array  $fields         [指定要与关键字匹配的字段集]
 * @param  integer $page          [分页]
 * @param  integer $pageSize      [分页大小]
 * @param  string  $where         [附加条件]
 * @return array                  [返回三维数组,1、以出现次数降序的数据表结果的二维数组;2、分页信息]
 */
function searchOfDivisionWord($key, $table_name, $table_field_id, $fields = array(), $page = 1, $pageSize = 10, $where = "1=1")
{
    if (count($fields) > 0) {
        $m = D($table_name);
        //拆字
        preg_match_all("/./u", $key, $keyArr);
        // var_dump($keyArr);
        $resultArr = array();
        foreach ($keyArr[0] as $key1 => $word) {
            foreach ($fields as $key2 => $field) {
                $arr = $m->where($field . " like '%" . $word . "%'")->select();
                //var_dump($arr);
                foreach ($arr as $key3 => $cursor) {
                    //统计整体出现次数
                    $total = $resultArr[$cursor[$table_field_id]];
                    if (empty($total)) {
                        $total = 0;
                    }
                    $resultArr[$cursor[$table_field_id]] = $total + 1;
                }
            }
        }
        //var_dump($resultArr);
        if (count($resultArr) > 0) {
            //带键降序
            arsort($resultArr);
            //var_dump($resultArr);
            //获得数组的键
            $resultKeyArr = array_keys($resultArr);
            //$searchResultArr = $m->where($table_field_id." in (".implode($resultKeyArr,",").")")->select();
            //数组转换字符串
            $resultKeyStr = implode($resultKeyArr, ",");
            $pageObj = new \Think\Page(count($resultKeyArr), $pageSize);
            $pageView = $pageObj->show();
            if ($page > 1) {
                $pageObj->firstRow = ($page - 1) * $pageSize;
            }
            $Model = new \Think\Model();
            $searchResultArr = $Model->query("select * from " . $table_name . " where " . $where . " and " . $table_field_id . " in (" . $resultKeyStr . ") order by instr('" . $resultKeyStr . "'," . $table_field_id . ") limit " . $pageObj->firstRow . "," . $pageObj->listRows);
            //var_dump($searchResultArr);
            return array($searchResultArr, $pageView);
        } else {
            return false;
        }
    }
}
 public function delete_domain()
 {
     if ($_GET['id']) {
         $id = $_GET['id'];
     } else {
         $id = '';
     }
     $Model = new \Think\Model();
     if ($id != '') {
         $result = $Model->execute("DELETE FROM `cloud_domain_first` WHERE `id`=" . $id);
     }
     if ($result) {
         $this->success('删除成功', '/index.php/Admin/DomainFirstAdmin/index');
     } else {
         $this->error('删除失败', '/index.php/Admin/DomainFirstAdmin/index');
     }
 }
 public function delete_external_url()
 {
     if ($_GET['id']) {
         $id = $_GET['id'];
     } else {
         $id = '';
     }
     $Model = new \Think\Model();
     if ($id != '') {
         $result = $Model->execute("DELETE FROM `cloud_external_link` WHERE `id`=" . $id);
     }
     if ($result) {
         $this->success('删除成功', '/index.php/Admin/ExternalLinkAdmin/index');
     } else {
         $this->error('删除失败', '/index.php/Admin/ExternalLinkAdmin/index');
     }
 }
Example #29
0
 public function index()
 {
     session_start();
     header('Content-Type:text/html; charset=UTF-8');
     //防止出现乱码
     $uid = $_SESSION['uid'];
     $username = $_SESSION['username'];
     $this->assign('username', $username);
     //用户抵押物品信息
     $goods = new \Think\Model();
     $condition['f_uid'] = $uid;
     $goodsarr = $goods->table('t_user_stock a')->field('a.f_uid uid,a.f_sid sid,a.f_shares shares,f_shares_frozen frozenshares,b.f_id id,b.f_stockcode stockcode,b.f_stockname stockname,b.f_price price')->join('t_stockinfo b on a.f_sid = b.f_id')->where($condition)->select();
     $this->assign('goodsarr', $goodsarr);
     //投资列表
     $Model = new \Think\Model();
     $investarr = $Model->query("select a.f_uid userid,a.f_username username,b.f_id vid,round(b.f_yield*100,2) yield,round(b.f_money) money,round(b.f_danbaomoney,2) danbaomoney,b.f_horizon horizon,b.f_state state,DATE_FORMAT(b.f_addtime,'%Y-%m-%d') addtime from t_userinfo a,t_invest b where a.f_uid=b.f_userid and b.f_state=200 order by b.f_addtime desc limit 20");
     $this->assign('investlist', $investarr);
     $this->display();
 }
 public function get_message_list()
 {
     if (check_login(I('user_id'), I('login'))) {
         $Model = new \Think\Model();
         $time = time();
         if (I('state')) {
             $time = '>=' . $time;
         } else {
             $time = '<=' . $time;
         }
         $page = I('page') * C('PAGE_NUM');
         $sql = "SELECT u.user_nickname,l.lable_name,m.notepad_id,m.user_id,m.notepad_time,m.notepad_endtime,m.notepad FROM `user_lable` `o`,`lable` `l` ,`message` `m`,`user` `u` WHERE o.lable_id=l.lable_id and m.lable_id=o.lable_id and o.user_id=u.user_id and  o.user_id = " . I('user_id') . ' and m.notepad_endtime' . $time . '  order by m.notepad_endtime limit ' . $page . ',20';
         //echo $sql;
         $sql1 = "SELECT count(*)/" . C('PAGE_NUM') . " a  FROM `order` `o`,`lable` `l` ,`message` `m`,`user` `u` WHERE o.lable_id=l.lable_id and m.lable_id=o.lable_id and o.user_id=u.user_id and o.user_id = " . I('user_id') . ' and m.notepad_endtime' . $time . '  order by m.notepad_endtime ';
         $ans = $Model->query($sql);
         $ans['page'] = $Model->query($sql1);
         $this->ajaxReturn($ans);
     } else {
         $this->ajaxReturn(0);
     }
 }