Ejemplo n.º 1
0
 public function insert()
 {
     $art = D('Article');
     $_POST['uid'] = 1;
     $_POST['addtime'] = time();
     //$content = htmlspecialchars($_POST['content'], ENT_QUOTES);
     $_POST['content'] = htmlspecialchars($_POST['content'], ENT_QUOTES);
     $new_id = D('Article')->add($_POST);
     if (!empty($_FILES)) {
         $config = array('rootPath' => './Public/', 'savePath' => 'Uploads/');
         $upload = new \Think\Upload($config);
         $res = $upload->uploadOne($_FILES['image']);
         if (!$res) {
             show_bug($upload->getError());
         }
         $image = $res['savepath'] . $res['savename'];
     } else {
         $image = '';
     }
     $_POST['img'] = $image;
     //print_r($_POST); // Array ( [tit] => 测试文件 [content] => 这是一个测试文件 [addtime] => 1434072175 )
     //[title] => [pid] => 329 [content] => [uid] => 1 [addtime] => 1434192227 [img] => sijiosj )
     $sql = "update shop_article set img='{$image}' where id={$new_id}";
     $res = $art->execute($sql);
     //$art -> create();
     //$result = $art -> add($_POST);
     if ($res) {
         $this->assign('mess', '添加权限成功');
         $this->display('list');
     } else {
         $this->assign('mess', '添加权限失败');
         $this->display('list');
     }
 }
 function insert()
 {
     $news = D("News");
     $thesis = D('Thesis');
     $datasets = D("Datasets");
     if (!empty($_POST)) {
         if (!$news->create()) {
             show_bug($news->getError());
             $this->error('添加失败', 'javascript:history.back(-1)');
         } else {
             $z = $news->add();
             if ($z) {
                 $this->success('添加成功', U('news/manage'));
             } else {
                 $this->error('添加失败', U('news/manage'));
             }
         }
     } else {
         $tsql = "select ThesisId,ThesisTitle from tthesis order by ThesisId desc limit 5 ";
         $dsql = "select DataId,DataName from tdatasets order by DataId desc limit 5 ";
         $tinfo = $thesis->query($tsql);
         $dinfo = $datasets->query($dsql);
         //                var_dump($dinfo);
         $this->assign('dinfo', $dinfo);
         $this->assign('tinfo', $tinfo);
         $this->display();
     }
 }
 function upd($UserId)
 {
     $user = new \Model\UserModel();
     //两个逻辑:展示表单、收集表单
     if (!empty($_POST)) {
         $z = $user->create();
         //收集post表单数据	creat()会进行表单验证
         if (!$z) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             $this->error('修改失败');
         } else {
             //验证成功,添加到数据库`
             $rst = $user->where("UserId='{$UserId}'")->save();
             if ($rst) {
                 $this->success('修改成功', U('User/manage'));
             } else {
                 $this->error('修改失败', U('User/manage'));
             }
         }
     } else {
         $info = $user->where("UserId='{$UserId}'")->find();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
Ejemplo n.º 4
0
 function register(){
     $user = new \Model\UserModel();
     //判断表单是否提交
     if(!empty($_POST)){
         //只有全部验证通过$z才会为真
         if(!$user -> create()){
             //验证失败,输出错误信息
             //getError()方法返回验证失败的信息
             show_bug($user->getError());
         } else {
             //把爱好由数组变为字符串"1,3,4"
             //使用AR方式处理爱好的字段信息
             //create()方法收集的数据也是把数据变为模型对象的属性
             $user -> user_hobby = implode(',',$_POST['user_hobby']);
             $rst = $user -> add();
             if($rst){
                 $this -> success('注册成功',U('Index/index'));
             } else {
                 $this -> error('注册失败',U('Index/index'));
             }
         }
     } else {
         $this -> display();
     }
 }
Ejemplo n.º 5
0
 function register()
 {
     //$user=new \Model\UserModel();
     show_bug($_POST);
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //print_r($_POST);
         $data = $user->create();
         //集成表单验证
         if (!$data) {
             show_bug($user->getError());
         } else {
             //添加数据
             $user->user_hobby = implode(',', $_POST['user_hobby']);
             $charu = $user->add();
             if ($charu) {
                 $this->success('注册成功', U('Index/index'));
             } else {
                 $this->error('注册失败', U('Index/index'));
             }
         }
     } else {
         $this->display();
     }
 }
 function add()
 {
     if (!empty($_POST)) {
         $admin_info = D('Role');
         if ($admin_info->create()) {
             if ($admin_info->add()) {
                 $this->success('添加成功', U('showlist'));
                 exit;
             } else {
                 $sql = $admin_info->getLastSql();
                 show_bug($sql);
                 //$this->error('插入数失败 </br>SQL:'.$sql);
             }
             //$this->redirect('showlist',array(),2,'添加成功');
         } else {
             $error = $admin_info->getError();
             $this->error($error, U('showlist'));
         }
     } else {
         $auth_info = D('Auth');
         $data = $auth_info->getTree();
         //show_bug($data);
         //show_bug($data);die;
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 7
0
 function showDiaryList()
 {
     //        $diary = new \Model\DiaryModel(); //实例化数据模型,new \命名空间\对象    object(Model\DiaryModel)
     $diary2 = D('diary');
     // object(Think\Model)
     //        $diary3 = M();                      // object(Think\Model) 父类Model
     $info = $diary2->select();
     show_bug($info);
     $this->assign();
     $this->display('index');
 }
 protected function _before_update(&$data, $option)
 {
     if ($data['auth_pid'] == 0) {
         $data['auth_level'] = 0;
     } else {
         $b = $this->field('auth_level')->find($data['auth_pid']);
         show_bug($b);
         $data['auth_level'] = $this->auth_level + 1;
         $auth_data = $this->select();
         show_bug($data);
         $a = $this->update_child_auth($auth_data, $option['where']['auth_id'], $data['auth_level']);
     }
 }
Ejemplo n.º 9
0
 function showlist1(){
     //使用数据model模型
     //实例化model对象
     //$goods = new \Model\GoodsModel();  //object(Model\GoodsModel)
     
     //$goods = D("Goods");  //object(Think\Model)
     //$goods = D();  //object(Think\Model)
     
     $goods = M('User');//实例化Model对象,实际操作Goods数据表
     //$goods = M();  //object(Think\Model)
     
     show_bug($goods);
     
     
     $this -> display();
 }
 protected function _before_update(&$data, $options)
 {
     show_bug($_POST);
     if ($_FILES['brand_logo']['error'] == 0) {
         unlink('./Uploads/' . I('post.old_logo'));
     }
     $upload = new \Think\Upload();
     // 实例化上传类
     $upload->maxSize = 3145728;
     // 设置附件上传大小
     $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
     // 设置附件上传类型
     $upload->rootPath = './Uploads/';
     // 设置附件上传目录
     $upload->savePath = 'Brand/';
     // 设置附件上传目录
     // 上传文件
     $info = $upload->upload();
     $data['brand_logo'] = $info['brand_logo']['savepath'] . '/' . $info['brand_logo']['savename'];
 }
 function insert()
 {
     $thesis = D('Thesis');
     if (!empty($_POST)) {
         if (!$thesis->create()) {
             show_bug($thesis->getError());
             $this->error('添加失败', 'javascript:history.back(-1)');
         } else {
             $z = $thesis->add();
             if ($z) {
                 $this->success('添加成功', U('manage'));
             } else {
                 $this->error('添加失败', 'javascript:history.back(-1)');
             }
         }
     } else {
         $this->assign('link', $_GET['ThesisLink']);
         $this->display();
     }
 }
 function mdel2()
 {
     $ids = I('post.ids');
     if (ids) {
         $model = D('Auth');
         show_bug($ids);
         $id_arr = array();
         foreach ($ids as $id) {
             $_children = $model->getChild($id);
             $id_arr = array_merge($id_arr, $_children);
             $id_arr[] = $id;
         }
         $ids = array_unique($id_arr);
         $ids = implode(',', $ids);
         if ($auth_info->delete($ids)) {
             $this->success('删除成功', U('showlist'));
             exit;
         }
     }
 }
Ejemplo n.º 13
0
 function register()
 {
     $user = D('User');
     if (!empty($_POST)) {
         $z = $user->create();
         if (!$z) {
             // validate fail,
             show_bug($user->getError());
             exit;
         }
         $rst = $user->add();
         if ($rst) {
             echo "success";
         } else {
             echo "failure";
         }
     } else {
         $this->display();
     }
     $this->display();
 }
Ejemplo n.º 14
0
 public function test_pic_load()
 {
     if (!empty($_POST)) {
         if (!empty($_FILES)) {
             echo "文件大小:" . $_FILES['file_1']['size'] . '<br/>';
             echo "文件类型:" . $_FILES['file_1']['type'];
             show_bug($_FILES);
             // show_bug($_FILES);
             $config = array('rootPath' => './Public/', 'savePath' => 'Upload/');
             $upload = new \Think\Upload($config);
             $z = $upload->uploadOne($_FILES['file_1']);
             if ($z) {
                 $info = D('pic');
                 //取出文件路径以及名称
                 $filename = IMG_UPLOAD_URL . $z['savepath'] . $z['savename'];
                 // echo $filename;
                 $info->id = 4;
                 $info->name = $filename;
                 // $info_save=$info->save();
                 // $info_save=$info->add();
                 $info_save = $info->save();
                 $res = $info->select();
                 if ($info_save >= 0) {
                     $this->assign('img_url', $res[0]['name']);
                     // show_bug($info);
                     echo "<br/> 保存路径:" . $res[0]['name'];
                     // $this->redirect();
                     $this->display();
                 }
                 // $this->display();
             } else {
                 echo "No";
                 show_bug($upload->getError());
             }
         }
     } else {
         $this->display();
     }
 }
 function register()
 {
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //收集post表单数据	creat()会进行表单验证
         if (!$user->create()) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             //返回添加页面
             $this->error('注册失败', 'javascript:history.back(-1)');
         } else {
             $rst = $user->add();
             if ($rst) {
                 $this->success('注册成功', U('Login/login'));
             } else {
                 $this->error('注册失败', U('Login/login'));
             }
         }
     } else {
         $this->display();
     }
 }
Ejemplo n.º 16
0
    function register(){
        $user = new \Model\UserModel();
        //判断表单是否提交
        if(!empty($_POST)){
            print_r($_POST);
            $z = $user -> create();  //集成表单验证
            //只有全部验证通过$z才会为真
            if(!$z){
                //验证失败,输出错误信息
                //getError()方法返回验证失败的信息
                show_bug($user->getError());

            }
//            $rst = $user -> add();
//            if($rst){
//                echo "success";
//            } else {
//                echo "error";
//            }
        } else {
        }
        $this -> display();
    }
 function update($id, $type_id)
 {
     $admin_info = D('Attr');
     if (IS_POST) {
         if ($admin_info->create()) {
             if ($admin_info->save() !== false) {
                 $this->success('修改成功', U('showlist', array('type_id' => $type_id)));
                 exit;
             } else {
                 $sql = $admin_info->getLastSql();
                 show_bug($sql);
                 //$this->error('修改失败 </br>SQL:'.$sql);
             }
             //$this->redirect('showlist',array(),2,'添加成功');
         } else {
             $error = $admin_info->getError();
             $this->error($error, U('showlist'));
         }
     } else {
         $admin_info = $admin_info->find($id);
         $this->assign('admin_info', $admin_info);
         $this->display();
     }
 }
 function upd($UserId)
 {
     $admin = new \Model\AdminsModel();
     if (!empty($_POST)) {
         //收集post表单数据	creat()会进行表单验证
         if (!$admin->create()) {
             //验证失败,输出错误信息
             show_bug($admin->getError());
             $this->error('修改失败', 'javascript:history.back(-1)');
         } else {
             $rst = $admin->where("UserId='{$UserId}'")->save();
             if ($rst) {
                 $this->success('修改成功', U('Admins/administrator'));
             } else {
                 $this->error('修改失败', U('Admins/administrator'));
             }
         }
     } else {
         $info = $admin->where("UserId='{$UserId}'")->find();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
Ejemplo n.º 19
0
function mdel()
{
    $auth_info = D('Auth');
    $ids = I('post.ids');
    if (IS_POST) {
        $id_arr = array();
        foreach ($ids as $id) {
            $son_id = $auth_info->getChild($id);
            $son_ids = array_merge($id_arr, $son_id);
            $son_ids[] = $id;
        }
        show_bug($son_ids);
        die;
        $ids = array_unique($son_ids);
        $ids = implode(',', $ids);
        if ($auth_info->delete($ids)) {
            $this->success('删除成功', U('showlist'));
            exit;
        } else {
            $sql = $auth_info->getLastSql();
            $this->error('删除失败 SQL:=' . $sql, U('showlist'));
        }
    }
}
Ejemplo n.º 20
0
 public function delete()
 {
     $goods = D('Goods');
     //$rst=$goods->delete('8');
     //$rst=$goods->where('goods_id>7')->delete();
     $rst = $goods->delete('1,2,3');
     show_bug($rst);
 }
 function index_award()
 {
     $homeset = D('Homeset');
     if (!empty($_POST)) {
         $z = $homeset->create();
         //收集post表单数据    creat()会进行表单验证
         if (!$z) {
             show_bug($homeset->getError());
             $this->error('修改失败');
         } else {
             $rst = $homeset->where("ModelName='学生获奖情况'")->save();
             if ($rst) {
                 $this->success('修改成功', U('Homeset/index_award'));
             } else {
                 //$this -> error('修改失败',U('Homeset/index_result'));
             }
         }
     } else {
         $info = $homeset->where('ModelName="学生获奖情况"')->select();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
Ejemplo n.º 22
0
 function y1(){
     //外部用户访问的方法
     show_bug($this -> y2());
 }
Ejemplo n.º 23
0
 function del(){
     $goods = D("Goods");
     //以下三种方式都可以删除数据
     $rst = $goods -> delete(63);
     $rst = $goods -> delete('61,62,59');
     $rst = $goods -> where('goods_id>56')->delete();
     
     show_bug($rst);
 }
 public function get_local_weather()
 {
     show_bug(R('Others/get_all_weather_info'));
     //echo R('Others/get_all_weather_info');
 }
 function upd($DataId)
 {
     //两个逻辑:展示表单、收集表单
     $datasets = new \Admin\Model\DatasetsModel();
     //$datasets = D('Datasets');  //object(Admin\DatasetsModel)
     if (!empty($_POST)) {
         //show_bug($_POST);
         $z = $datasets->create();
         //收集post表单数据	creat()会进行表单验证
         if (!$z) {
             //验证失败,输出错误信息
             show_bug($datasets->getError());
             $this->error('修改失败');
         } else {
             //验证成功,添加到数据库
             $rst = $datasets->where("DataId='{$DataId}'")->save();
             if ($rst) {
                 $this->success('修改成功', U('Datasets/manage'));
             } else {
                 $this->error('修改失败', U('Datasets/manage'));
             }
         }
     } else {
         $info = $datasets->where("DataId='{$DataId}'")->find();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
Ejemplo n.º 26
0
 public function update()
 {
     $type = $_POST['type'];
     if ($type == '修改' || $type == '添加') {
         $update = D('Article');
         $aid = $_POST['aid'];
         $arr['title'] = $_POST['title'];
         $arr['author'] = $_POST['author'];
         $arr['class'] = $_POST['class'];
         $arr['content'] = $_POST['content'];
         $arr['utime'] = date('Y-m-d');
         show_bug($arr);
         //修改符合AID的那一条数据
         $a = $update->where("AID='{$aid}'")->save($arr);
         //修改成功则返回文章管理首页面,修改失败则显示失败提示并跳转到文章首页面
         if ($a) {
             $this->success("修改成功", __CONTROLLER__);
         } else {
             $this->error("修改失败", __CONTROLLER__);
         }
     } elseif ($type == '保存') {
         $update = D('Article');
         $aid = $_POST['aid'];
         $arr['title'] = $_POST['title'];
         $arr['author'] = $_POST['author'];
         $arr['class'] = $_POST['class'];
         $arr['content'] = $_POST['content'];
         $arr['utime'] = date('Y-m-d');
         $a = $update->where("AID='{$aid}'")->save($arr);
         if ($a) {
             $msg = "保存成功";
             $res = $update->where("AID='{$aid}'")->find();
             $this->assign("msg", $msg);
             $this->assign("res", $res)->display('read');
         } else {
             $msg = "保存失败";
             $res = $update->where("AID='{$aid}'")->find();
             $this->assign("msg", $msg);
             $this->assign("res", $res)->display('read');
         }
     }
 }
Ejemplo n.º 27
0
 function del()
 {
     $Goods = D("Goods");
     //$msg=$Goods->delete(61);
     $sql = "delete from sw_goods where goods_id=59";
     $msg = $Goods->execute($sql);
     show_bug($msg);
 }
Ejemplo n.º 28
0
 public function weather_test()
 {
     require_once './Component/Citycode.php';
     //////根据客户端的ip判断地理位置
     //定义两个标志变量
     $count = 0;
     $city_id = '101120301';
     //默认大淄博
     $city_name_cin = $_POST['cityname'];
     $city_sim_name = R('Test/get_user_cityname');
     //这是系统根据ip自动判断的位置
     echo $city_sim_name;
     if ($city_sim_name != null) {
         $city_name_cin = $city_sim_name;
     }
     //这是用户输入的位置
     if (!empty($_POST['cityname'])) {
         //放置信息覆盖
         $city_name_cin = $_POST['cityname'];
     }
     echo "<br/>";
     echo $city_name_cin;
     var_dump($city_name_cin);
     ////////不管是ip定位还是用户输入最终需要遍历获取城市代码的变量只要$city_name_cin
     foreach ($citycode as $key => $value) {
         if ($key == $city_name_cin) {
             $city_id = $citycode[$city_name_cin];
             $count++;
         }
     }
     if ($count == 0) {
         echo "对不起,您输入的地址没有找到!默认淄博哦";
     } else {
         echo $city_name_cin . "的天气信息如下";
     }
     $weather_interface_url = "http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityId=" . $city_id . "&imei=e32c8a29d0e8633283737f5d9f381d47&device=HM2013023&miuiVersion=JHBCNBD16.0&modDevice=&source=miuiWeatherAp";
     $all_weather_info = json_decode(file_get_contents($weather_interface_url));
     //分配数据
     show_bug($all_weather_info);
     $this->assign("all_info", $all_weather_info);
     $this->display();
 }