Example #1
0
 public function search($para)
 {
     $k = "bs_kt.name like '%" . $para['k'] . "%'";
     //根据实验室分类
     if ($para['d'] == '0') {
         $d = '1=1';
     } else {
         $dep = $para['d'];
         $d = "user_teacher.dep='{$dep}'";
     }
     /**查询sql语句
     		select bs_kt.id,bs_kt.name as bname,bs_kt.snum,user_teacher.name as tname,user_teacher.dep,count(bs_xt.bid) from bs_kt left join user_teacher on user_teacher.user=bs_kt.teacher left join bs_xt on bs_xt.bid=bs_kt.id group by bs_kt.id
     		select bs_kt.id,bs_kt.name as bname,bs_kt.snum,user_teacher.name as tname,user_teacher.dep,count(bs_xt.bid) from bs_kt left join user_teacher on user_teacher.user=bs_kt.teacher left join bs_xt on bs_xt.bid=bs_kt.id where bs_kt.status=1 and bs_kt.name like '%安%' group by bs_kt.id 
     		*/
     $np = 10;
     //每页数
     $cp = (int) $para['p'];
     //当前页
     $sql1 = "select count(*) from bs_kt inner join user_teacher on bs_kt.teacher=user_teacher.user where " . $d . " and " . $k . " and bs_kt.status=3";
     $sql2 = "select bs_kt.id,bs_kt.name as bname,bs_kt.teacher as tuser,user_teacher.name as tname,user_teacher.dep,user_student.user as suser,user_student.name as sname from bs_kt" . " left join user_teacher on bs_kt.teacher=user_teacher.user" . " left join user_student on user_student.user in (select sid from bs_xt where bs_xt.bid = bs_kt.id)" . " where " . $d . " and " . $k . " and bs_kt.status=3 group by bs_kt.id limit " . $np * ($cp - 1) . ',' . $np . '';
     //自定义执行sql语句
     $Model = new \Think\Model();
     $tp = $Model->query($sql1)[0]['count(*)'];
     $rs_kt = $Model->query($sql2);
     $rs = array('page' => array('sql' => $sql2, 'tp' => $tp, 'c_p' => $cp, 't_p' => ceil(1.0 * $tp / $np)), 'r' => $rs_kt ? $rs_kt : array());
     return $rs;
 }
Example #2
0
    public function detail()
    {
        $Form = new Model();
        $result = $Form->query('select admin_articles.*, admin_nickname from admin_articles 
			inner join admin_personal on admin_articles.admin_id = admin_personal.admin_id
			where article_id="%s"', $_GET['p']);
        if ($result) {
            $result[0]['article_type'] = C('MODULE_CODE')[$result[0]['article_type']];
            //dump($result[0]);
            if ($result[0]['article_about'] == C(PROJECT_CODE)) {
                $object = $Form->query('select project_name as name, project_logo as portrait from project_info
					where project_id = "%s"', $result[0]['article_object']);
                //dump($object);
                $this->obj = $object[0];
            } else {
                if ($result[0]['article_about'] == C(INVESTOR_CODE)) {
                    $object = $Form->query('select name, portrait from investor_personal
					where user_id = "%s"', $result[0]['article_object']);
                    //dump($object);
                    $this->obj = $object[0];
                } else {
                    if ($result[0]['article_about'] == C(INNOVATOR_CODE)) {
                        $object = $Form->query('select name, portrait from entrepreneur_personal
					where user_id = "%s"', $result[0]['article_object']);
                        //dump($object);
                        $this->obj = $object[0];
                    }
                }
            }
            $this->p = $result[0];
        }
        $update = $Form->execute('update admin_articles set article_visits=%d where article_id="%s"', $result[0]['article_visits'] + 1, $_GET['p']);
        $this->display();
    }
Example #3
0
 public function getCitiesByProvince($province)
 {
     $sql = "select a.city as city from t_cities a, t_provinces b\r\n            where b.province like '" . $province . "%' and b.provinceid = a.provinceid";
     $m = new \Think\Model();
     $result = $m->query($sql);
     return $result;
 }
 public function listView($cate)
 {
     $cate_atc = M('cate_atc');
     $count = $cate_atc->where(['status' => 1, 'cate' => $cate])->count();
     $Page = new \Think\Page($count, 16);
     // 实例化分页类 传入总记录数和每页显示的记录数
     $show = $Page->show();
     // 分页显示输出
     $list = $cate_atc->where(['cate' => $cate])->order('createtime')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     $model = new Model();
     foreach ($list as $k => $v) {
         $modelInfo = get_model_info($v['model_id']);
         //获每条数据的模型信息
         //echo $modelInfo['identity'];
         $raw = $model->query("select author from {$modelInfo['identity']} where id = {$v['atc_id']}");
         $list[$k]['author'] = $raw[0]['author'];
         $d = strtotime($v['createtime']);
         $list[$k]['createtime'] = '<div>' . date("Y/m/d", $d) . '</div>' . '<div>' . date("H:i:s", $d) . '</div>';
         //编辑时间格式
     }
     //var_dump($show);
     /* $Page->setConfig('f_decorate','<li>');
        $Page->setConfig('b_decorate','</li>');*/
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('model_list', get_cate_Model($cate));
     //$this->assign("cate_id",1);
     $this->assign("cate", $cate);
     $this->display();
 }
 public function getFriend($userid)
 {
     $sql = "select u.name,u.id from __USERS__ as u,(select user2 from __FRIEND__ where user1 = {$userid} \r\n               UNION select user1 from  __FRIEND__ where user2 = {$userid}) as f where u.id = f.user2";
     $model = new Model();
     $data = $model->query($sql);
     return $data;
 }
 public function header_city()
 {
     $city1 = new \Think\Model();
     $sql = "select r.* from __PREFIX__store_shipping_region as ssr left join __PREFIX__region as r on ssr.city=r.region_id where ssr.city>0 group by ssr.city";
     $rs = $city1->query($sql);
     var_dump($rs);
 }
 /**
  * 列表显示
  */
 public function index()
 {
     if (!IS_AJAX) {
         $this->error(L('_ERROR_ACTION_'));
     }
     $Model = new Model();
     $islang = $Model->query('Describe __' . strtoupper(CONTROLLER_NAME) . '__ lang');
     if ($islang[0]['field'] == 'lang') {
         if (I('get.lang')) {
             $wl = 'lang=\'' . I('get.lang') . '\'';
         } elseif ($this->clang) {
             $wl = 'lang=\'' . $this->clang . '\'';
         } else {
             $wl = 'lang=\'' . LANG_SET . '\'';
         }
     } else {
         $wl = '1';
     }
     $isorder = $Model->query('Describe __' . strtoupper(CONTROLLER_NAME) . '__ listorder');
     $ol = $isorder == 'listorder' ? 'listorder,' : '';
     $name = M(CONTROLLER_NAME);
     $list = $name->where($wl)->order($ol, 'id')->select();
     $this->assign('list', $list);
     $this->display();
 }
Example #8
0
 public function check($para)
 {
     $user = $para['user'];
     $type = $para['type'];
     $pwd = md5($para['pwd']);
     $vcode = $para['verifycode'];
     //首先验证验证码
     if ($this->check_verify($vcode)) {
         //验证账号密码
         switch ($type) {
             case '3':
                 $tb = 'user_admin';
                 $tb2 = 'user_admin';
                 break;
             case '2':
                 $tb = 'user_teacher_pwd';
                 $tb2 = 'user_teacher';
                 break;
             case '1':
                 $tb = 'user_student_pwd';
                 $tb2 = 'user_student';
         }
         $Model = new \Think\Model();
         $sql = "select  * from {$tb2} B left join {$tb} A on A.user=B.user where A.user='******' and A.pwd='{$pwd}' and B.status=1";
         //var_dump($sql);
         if (count($Model->query($sql))) {
             return 1;
         } else {
             return 0;
         }
     } else {
         return -1;
     }
 }
 public function index($cate)
 {
     $cate_atc = M('cate_atc');
     $count = $cate_atc->where(['status' => 1, 'cate' => $cate])->count();
     $Page = new \Think\Page($count, 16);
     // 实例化分页类 传入总记录数和每页显示的记录数
     $show = $Page->show();
     // 分页显示输出
     $list = $cate_atc->where(['cate' => $cate])->order('createtime')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     $model = new Model();
     foreach ($list as $k => $v) {
         $modelInfo = get_model_info($v['model_id']);
         //获每条数据的模型信息
         $raw = $model->query("select author from {$modelInfo['identity']} where id = {$v['atc_id']}");
         $list[$k]['author'] = $raw[0]['author'];
         $d = strtotime($v['createtime']);
         $list[$k]['createtime'] = '<h6>' . date("m/d", $d) . '</h6>';
         //编辑时间格式
     }
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('model_list', get_cate_Model($cate));
     $this->assign("cate", $cate);
     $this->display('News/index');
 }
Example #10
0
 function checkCoachMaxUsers()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     // init_verify_token($token);
     $coachid = $param['coachid'];
     // $coachid = 53;
     if (empty($coachid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     //判断教练的客户是否超过10个
     $model = new Model();
     $sql_user = '******' . $coachid;
     $result_user = $model->query($sql_user);
     $studentNums = M("user_info")->where("type=1 and id={$coachid}")->getField("studentnums");
     if (count($result_user) >= $studentNums) {
         $model_user = new Model('user_info');
         $save_data['status'] = 1;
         $where_data['id'] = $coachid;
         $where_data['type'] = 1;
         $model_user->where($where_data)->save($save_data);
         $data['errno'] = 0;
         $data['is_max'] = 1;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     } else {
         $data['errno'] = 0;
         $data['is_max'] = 0;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     }
 }
Example #11
0
function getTableInfoArray($tableName)
{
    $dbType = C('DB_TYPE');
    $Model = new Model();
    // 实例化一个model对象 没有对应任何数据表
    if ($dbType == 'mysql') {
        $dbName = C('DB_NAME');
        $result = $Model->query("select * from information_schema.columns where table_schema='" . $dbName . "' and table_name='" . C('DB_PREFIX') . $tableName . "'");
        return $result;
    } else {
        //sqlite
        $result = $Model->query("pragma table_info (" . C('DB_PREFIX') . $tableName . ")");
        return $result;
    }
    $this->error('数据库类型不支持');
}
Example #12
0
 function getCategory()
 {
     /*	$data['slug'] <> 'uncategorized';
        return $this->where($data)->select();*/
     $Model = new Model();
     return $Model->query("select * from wp_terms where wp_terms.slug <> 'uncategorized'");
 }
Example #13
0
 public function login()
 {
     $Form = new Model();
     $user = $Form->query("select * from admin_personal where admin_id = '%s'", $_POST['loginuser']);
     //echo  json_encode($user[0]);
     if ($user[0]['admin_pwd'] === $_POST['loginpwd']) {
         $_SESSION['userid'] = $user[0]['admin_id'];
         //session(array('name'=>'userid','expire'=>2),$user[0]['admin_id']);
         $_SESSION['usertype'] = $user[0]['admin_type'];
         if ($_SESSION['usertype'] == 1) {
             echo 201;
         } else {
             if ($_SESSION['usertype'] == 2) {
                 echo 202;
             } else {
                 if ($_SESSION['usertype'] == 3) {
                     echo 203;
                 } else {
                     echo 404;
                 }
             }
         }
     } else {
         echo 409;
     }
 }
 public function searching()
 {
     $model = new Model();
     $sql = "use  " . $_SESSION['dbName'];
     $model->query($sql);
     $shop_id = trim($_GET['shopid']);
     if ($shop_id == "") {
         $shop_id = $_SESSION["shop_id"];
     }
     if ($shop_id == "") {
         $this->error("请先点击具体的店铺,再回来点此");
     }
     $this->assign("shopid", $shop_id);
     $shopName = $_SESSION["shop_name"];
     $this->assign("shopName", $shopName);
     $this->assign("shop", U('Retailer/index', array('shopid' => $shop_id)));
     if (!IS_GET) {
         $this->display();
     } else {
         $man = trim($_GET['man']);
         $date = trim($_GET['date']);
         if ($man != "") {
             $where['realName'] = array('like', "%{$man}%");
             $this->assign("man", $man);
         }
         $start = trim($_GET['start']);
         $end = trim($_GET['end']);
         if ($end != "") {
             $where['saledate'] = array('between', array($start . " 00:00:00", $end . " 59:59:59"));
             $this->assign("date", $people);
         }
         $where['belong'] = $_SESSION['auth'];
         $everypage = "10";
         //$res = $out->field("id,outtime,outprice,outamount")->relation(true)->order("outtime desc")->select();
         // $tbName = D("RetailerView"); // 实例化Data数据对象
         $tbName = new RetailerViewModel("RetailerViewModel", $tablePrefix = $shop_id);
         /*
          *  使用视图子查询
          */
         $subQuery = $tbName->group('name')->where($where)->order('sum(amount) desc')->select(false);
         $count = $tbName->table($subQuery . 'xc')->count('name');
         //$count = $tbName->count('barcode'); // 查询满足要求的总记录数
         $Page = new Page($count, $everypage);
         // 实例化分页类 传入总记录数和每页显示的记录数(25)
         $show = $Page->show();
         // 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
         $list = $tbName->field("sum(amount) as total,name,realName")->where($where)->order("sum(amount) desc")->limit($Page->firstRow . ',' . $Page->listRows)->group("name")->select();
         $this->assign('list', $list);
         // 赋值数据集
         $this->assign('page', $show);
         // 赋值分页输出
         // $tbName = D('RetailerView');
         $sumSQL = $tbName->field('sum(amount) as total')->where($where)->order("sum(amount) desc")->group("name")->select(FALSE);
         $outsum = $tbName->table($sumSQL . 'cc')->sum('total');
         $this->assign("outsum", $outsum);
         $this->display();
     }
 }
Example #15
0
 public function getNews()
 {
     //$model_news = M('home_news');
     //$rs_news = $model_news->limit(0,5)->select();
     $model_news = new \Think\Model();
     $sql = "select * from home_news order by publishtime desc limit 0,5";
     $rs_news = $model_news->query($sql);
     return $rs_news;
 }
 public function editPresident()
 {
     $president = M('president')->join('join school on president.school_id = school.id')->field('president, president.id, school_name')->select();
     $model = new Model();
     $presidentData = $model->query('SELECT president, praise, count(*) as comment from president join user_president on president.id = user_president.president_id GROUP BY president_id');
     $this->assign('president', $president);
     $this->assign('presidentdata', $presidentData);
     $this->display();
 }
Example #17
0
 function getPayedUser($pageNum = NULL)
 {
     $model = new Model();
     $sql = "SELECT username,name,gender,phone,nicker ,coachid, FROM_UNIXTIME(time_end,'%Y-%m-%d %H:%m:%s') AS pay_time,money/100 AS money FROM xorder,user_info WHERE xorder.uid=user_info.id ORDER BY time_end DESC";
     $result = $model->query($sql);
     $rowCount = count($result);
     $pageSize = 10;
     $offset = 0;
     $url = "Admin/getPayedUser";
     $rowPage = getPage($rowCount, $pageSize, $pageNum, $url);
     $offset = $rowPage['offset'];
     $sql = "SELECT username,name,gender,phone,nicker,coachid, FROM_UNIXTIME(time_end,'%Y-%m-%d %H:%m:%s') AS pay_time,money/100 AS money FROM xorder,user_info WHERE xorder.uid=user_info.id ORDER BY time_end DESC LIMIT {$offset},{$pageSize}";
     $result = $model->query($sql);
     foreach ($result as $k => $v) {
         $result[$k]['coach'] = M("user_info")->where("id={$v['coachid']}")->getField("name");
     }
     $this->assign("offset", $offset + 1);
     $this->assign("count", $rowCount);
     $this->assign("pageList", $rowPage['show']);
     $this->assign("result", $result);
     $this->display();
     /*		echo "<pre>";
     		print_r($result);
     		echo "</pre>";*/
     /*		$title = "用户名&nbsp&nbsp&nbsp&nbsp姓名&nbsp&nbsp&nbsp&nbsp电话&nbsp&nbsp&nbsp&nbsp昵称&nbsp&nbsp&nbsp&nbsp付款时间&nbsp&nbsp&nbsp&nbsp金额<br>";
     		echo $title;
     		for ($i=0; $i < count($result); $i++) { 
     			$username = $result[$i]['username'];
     			$name = $result[$i]['name'];
     			$gender = $result[$i]['gender'] == 0 ? '男' : '女';
     			$phone = $result[$i]['phone'];
     			$nicker = $result[$i]['nicker'];
     			$pay_time = $result[$i]['pay_time'];
     			$money = $result[$i]['money'];
     
     			$line = $username.'&nbsp&nbsp&nbsp&nbsp'.$name.'&nbsp&nbsp&nbsp&nbsp'.$gender.'&nbsp&nbsp&nbsp&nbsp'.$phone.'&nbsp&nbsp&nbsp&nbsp'.$nicker.'&nbsp&nbsp&nbsp&nbsp'.$pay_time.'&nbsp&nbsp&nbsp&nbsp'.$money.'<br>';
     			echo $line;
     			
     		}
     
     		echo "<br>总共".count($result).'个付款的健友';*/
 }
Example #18
0
 public function queryKtNum($t)
 {
     if ($t == 1) {
         $sql = "select count(*) from bs_kt where status=2";
     } else {
         $sql = "select count(*) from bs_kt where status=1";
     }
     $model = new \Think\Model();
     $rs = $model->query($sql);
     return $rs[0]['count(*)'];
 }
Example #19
0
 public function getScanDetail()
 {
     //获取客户端发送的json
     /*   $arr=json_decode($GLOBALS['HTTP_RAW_POST_DATA']);
          $username=$arr->userid; */
     $username = 201522040840;
     $sql = "select count(*) from " . __PREFIX__ . "scans where id=" . $username;
     $Model = new Model();
     $res = $Model->query($sql);
     $count = $res[0]['count(*)'];
     $scanname = "0";
     $sql = "select scanname from " . __PREFIX__ . "scan where id =" . username . " and scanname != " . $scanname;
     $res = $Model->query($sql);
     $scans = $res[0]['scanname'];
     $scans = json_encode($scans);
     print_r($scans);
     $jsonsend = array("username" => $username, "count" => $count, "scans" => $scans);
     $json = json_encode($jsonsend);
     echo $json;
 }
Example #20
0
 public function checkST($sid, $tid)
 {
     $model = new \Think\Model();
     $sql = "select * from bs_xt where sid='{$sid}' and bid in(select id from bs_kt where teacher='{$tid}')";
     $rs = $model->query($sql);
     if (!count($rs)) {
         return 0;
     } else {
         return 1;
     }
 }
Example #21
0
 public function cancel($user, $list)
 {
     $model = new \Think\Model();
     $list_s = join(',', $list);
     $sql = "update bs_kt set status=0 where status=1 and teacher='{$user}' and id in (" . $list_s . ")";
     if ($model->query($sql)) {
         return 1;
     } else {
         return 0;
     }
 }
Example #22
0
 public function createForm($course_id)
 {
     $create_table = new Model();
     /*新建表*/
     $check_name_table = "check_name_" . $course_id;
     $str = "create table {$check_name_table}(\n                student_id VARCHAR (32) NOT NULL ,\n                student_name VARCHAR (32) ,\n                attend_stage VARCHAR (32) ,\n                primary key(student_id)\n                )ENGINE=InnoDB DEFAULT CHARSET=utf8 ";
     $create_table->execute($str);
     /*把之前原始数据插入表中*/
     $select_course = $course_id . "_course";
     $student_string = $create_table->query("select {$select_course} from course_student ");
     $student_string = $student_string[0][$select_course];
     $student_id_sum = explode(',', $student_string);
     /*先把部分学生信息插入表中*/
     for ($index = 0; $index < count($student_id_sum); $index++) {
         $student_id = $student_id_sum[$index];
         $student_name = $create_table->query("select student_name from student_information where student_id='{$student_id}' ");
         $student_name = $student_name[0]['student_name'];
         $create_table->execute("insert into {$check_name_table} VALUES('{$student_id}','{$student_name}','absent')");
     }
 }
Example #23
0
 public function homeShowArticle()
 {
     if (session('?userid') && session('?usertype')) {
         $Form = new Model();
         $content = $Form->query("select * from home_show where tag='%d'", C(NEWS_CODE));
         $this->news = json_encode($content);
         //dump($this->projects);
         $this->display();
     } else {
         $this->redirect('Index/index');
     }
 }
Example #24
0
 function getVerifyCode()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $phone = $param['phone'];
     // $phone = '13269627267';
     if (empty($phone)) {
         err_ret(-205, 'lack of param', '手机号码为空');
     }
     $model = new Model('verify_tmp');
     //查询对应手机的最后一条记录
     $sql_max = "SELECT * from verify_tmp where id = (select max(id) from verify_tmp WHERE phone = '" . $phone . "')";
     $result = $model->query($sql_max);
     if (count($result) > 0) {
         $time = time() - $result[0]['gen_time'];
         if ($time < 60) {
             //小于1分钟
             err_ret(-302, 'too many time get verifycode', '请求验证码过于频繁');
         }
     }
     //判断是否注册过
     $model = new Model('user_info');
     $where['username'] = $phone;
     $result_user_info = $model->where($where)->select();
     if (count($result_user_info) > 0) {
         err_ret(-205, 'phone number is already registered', '此手机号码已经注册过');
     }
     //生成验证码和短信模板
     $code = rand(1000, 9999);
     $data = array($code, '5');
     //发送短信验证码
     $serverIP = C('RL_ServerIP');
     $serverPort = C('RL_ServerPort');
     $softVersion = C('RL_SoftVersion');
     $accountSid = C('RL_AccountSID');
     $accountToken = C('RL_AccountToken');
     $appId = C('RL_AppID');
     $SmsId = C('RL_SMS_TEMPLATE_ID');
     $rest = new \REST($serverIP, $serverPort, $softVersion);
     $rest->setAccount($accountSid, $accountToken);
     $rest->setAppId($appId);
     $result = $rest->sendTemplateSMS($phone, $data, $SmsId);
     if ($result->statusCode != 0) {
         err_ret($result->statusCode, $result->statusMsg);
     } else {
         //生成验证码,插入数据库
         $value['phone'] = $phone;
         $value['verifycode'] = $code;
         $value['gen_time'] = time();
         M("verify_tmp")->add($value);
         http_ret(0, 'verify code send success', '验证码发送成功');
     }
 }
Example #25
0
    public function myApply($myID)
    {
        $model = new Model();
        $result['refused'] = $model->query('SELECT * 
		FROM mty_apply apply,mty_exchange exc 
		WHERE apply.applyUserID=' . $myID . ' 
		AND apply.excID=exc.excID 
		AND apply.applyStatus=-1');
        $result['unfinished'] = $model->query('SELECT * 
		FROM mty_apply apply,mty_exchange exc 
		WHERE apply.applyUserID=' . $myID . ' 
		AND apply.excID=exc.excID 
		AND exc.status=1
		AND apply.applyStatus=0');
        $result['finished'] = $model->query('SELECT * 
		FROM mty_apply apply,mty_exchange exc 
		WHERE apply.applyUserID=' . $myID . ' 
		AND apply.excID=exc.excID 
		AND exc.status=2 
		AND apply.applyStatus=1');
        return $result;
    }
    public function queryExcStartedByMe()
    {
        $start = new Model();
        /* $result=$start->query("SELECT * FROM mty_start st,mty_exchange exch 
        		WHERE exch.status>=0 
        		AND st.startUserID=".session('user.id').' 
        		AND st.excID=exch.excID 
        		AND (TO_DAYS(NOW())-TO_DAYS(exch.startTime)<=7)
        		ORDER BY exch.status,exch.startTime DESC'); */
        $result = $start->query("SELECT * FROM mty_start st,mty_exchange exch \r\n\t\tWHERE exch.status>=0 \r\n\t\tAND st.startUserID=" . session('user.id') . ' 
		AND st.excID=exch.excID 
		ORDER BY exch.status,exch.startTime DESC');
        return $result;
    }
Example #27
0
 public function unedit($para, $authType)
 {
     $list = $para['list'];
     $list_str = join(',', $list);
     $sql = 'update bs_kt set status=' . ((int) $authType - 1) . ' where id in (' . $list_str . ') and id not in(select bid from bs_xt)';
     $Model = new \Think\Model();
     try {
         $Model->query($sql);
         $msg = array('status' => 1, 'msg' => '操作成功!');
     } catch (Exception $e) {
         $e->getMessage();
         $msg = array('status' => 0, 'msg' => $e);
     }
     return $msg;
 }
 public function header_city()
 {
     //echo C('DB_PREFIX');//__PREFIX__
     $city1 = new \Think\Model();
     $prefix = C('DB_PREFIX');
     $sql = "select r.* from {$prefix}store_shipping_region as ssr left join {$prefix}region as r on ssr.city=r.region_id where ssr.city>0 group by ssr.city";
     $row_region = $city1->query($sql);
     foreach ($row_region as $v) {
         $zimu = GetPinyin($v['region_name'], 1);
         //var_dump($zimu);
         $zimu = strtoupper(substr($zimu, 0, 1));
         $zimu_city[$zimu][] = array('region_id' => $v['region_id'], 'region_name' => $v['region_name']);
     }
     return $zimu_city;
     //var_dump($zimu_city);
 }
Example #29
0
 public function index()
 {
     //dump($_GET);
     $key1 = $_GET['key1'];
     $key2 = $_GET['key2'];
     $key3 = $_GET['key3'];
     $Form = new Model();
     $r = $Form->query('select * from email_active where user_id = "%s"', $key1);
     //dump($r);
     if ($r) {
         $mesg;
         $record = $r[0];
         //dump($record);
         //dump($record[mail_address]);
         if ($record[mail_address] != $key2) {
             $mesg = "请使用注册邮箱激活!";
             //dump($this->mesg);
         } else {
             if ($record[active_code] != $key3) {
                 $mesg = "激活码错误!";
                 //dump($this->mesg);
             } else {
                 if (intval($record[over_time]) < time()) {
                     $mesg = "激活码过期!";
                     //dump($this->mesg);
                 } else {
                     $res = $Form->execute('update email_active set active_status="1" where user_id="%s"', $key1);
                     if ($res) {
                         //dump($res);
                         $mesg = " 激活成功!";
                         //dump($this->mesg);
                     }
                 }
             }
         }
     } else {
         $mesg = "激活失败!";
     }
     $this->tip = $mesg;
     //dump($this->tip);
     $this->display();
 }
 public function detail()
 {
     $data = M("Goods")->where(array("gid" => I("gid")))->find();
     $data['uname'] = M("User")->where("uid=" . $data['user_id'])->find()['uname'];
     if ($data['user_id'] == session("uid")) {
         $data['isMyGoods'] = 1;
     } else {
         $data['isMyGoods'] = 0;
     }
     $data['comment_num'] = M("Comments")->where("goods_id=" . $data["gid"])->count();
     $data['auction_num'] = M("Auction")->where("goods_id=" . $data["gid"])->count();
     $data['top_auction'] = M("Auction")->where("goods_id=" . $data["gid"])->order("aid desc")->find()['auction_price'];
     if (!$data['top_auction']) {
         $data['top_auction'] = 0;
     } else {
         $model = new Model();
         $gid = I('gid');
         $data["auction"] = $model->query("select aid,uname,upic,auction_price,comment,time from auction,user\n                where auction.goods_id = {$gid}\n                and user.uid=auction.user_id order by aid desc");
         for ($i = 0; $i < count($data["auction"]); $i++) {
             # code...
             $data["auction"][$i]['upic'] = __ROOT__ . C('PIC_PATH_PREFIX') . C("UPLOAD_USER_PICS_CONFIG.subName") . '/thumb_' . $data["auction"][$i]['upic'];
         }
     }
     $model = new Model();
     $comments = M("Comments")->join("user on user.uid=comments.user_id")->field("upic,uname,replied_id,cid,time,content,user_id")->where("goods_id=" . I("gid"))->order("cid asc")->select();
     for ($i = 0; $i < count($comments); $i++) {
         $comments[$i]['upic'] = __ROOT__ . C('PIC_PATH_PREFIX') . C("UPLOAD_USER_PICS_CONFIG.subName") . '/thumb_' . $comments[$i]['upic'];
         if ($comments[$i]['replied_id']) {
             $replied_id = $comments[$i]['replied_id'];
             $comments[$i]['replied_name'] = $model->query("select uname from comments,user \n                    where comments.cid= {$replied_id}\n                    and comments.user_id=user.uid")[0]['uname'];
         }
         if ($comments[$i]['user_id'] == session("uid")) {
             $comments[$i]['cantReply'] = 1;
         }
     }
     $data['comments'] = $comments;
     $data['gpic'] = __ROOT__ . C('PIC_PATH_PREFIX') . C("UPLOAD_GOODS_PICS_CONFIG.subName") . '/' . $data['gpic'];
     // dump($data);
     //    die();
     $this->assign($data);
     $this->show();
 }