当前位置: 首页>>代码示例>>PHP>>正文


PHP Check::must方法代码示例

本文整理汇总了PHP中Check::must方法的典型用法代码示例。如果您正苦于以下问题:PHP Check::must方法的具体用法?PHP Check::must怎么用?PHP Check::must使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Check的用法示例。


在下文中一共展示了Check::must方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 /**
  * 编辑菜单
  */
 public function edit()
 {
     $id = I('id');
     if (IS_POST) {
         $data = I('data');
         //数据验证
         $msg = Check::rule(array(array(Check::must($data['name']), L('namecannotnull')), array(Check::must($data['url']), L('linkcannotnull'))));
         //提示信息
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         /* 更新图标 */
         if ($_FILES['pic']['name']) {
             $result = $this->ectouchUpload('pic', 'nav');
             if ($result['error'] > 0) {
                 $this->message($result['message'], NULL, 'error');
             }
             $data['pic'] = substr($result['message']['pic']['savepath'], 2) . $result['message']['pic']['savename'];
         }
         $this->model->table('touch_nav')->data($data)->where('id=' . $id)->update();
         $this->message(L('edit_ok'), url('index'));
     }
     //查询附表信息
     $result = $this->model->table('touch_nav')->where('id=' . $id)->find();
     /* 模板赋值 */
     $this->assign('info', $result);
     $this->assign('ur_here', L('navigator'));
     $this->assign('action_link', array('text' => L('go_list'), 'href' => url('index')));
     $this->display();
 }
开发者ID:noikiy,项目名称:shop-3,代码行数:33,代码来源:NavigatorController.class.php

示例2: edit

 /**
  * 编辑分类信息
  */
 public function edit()
 {
     if (IS_POST) {
         $cat_id = I('cat_id');
         $cat_info = I('data');
         /* 数据验证 */
         $msg = Check::rule(array(array(Check::must($cat_info['cat_name']), L('catname_empty'))));
         /* 提示信息 */
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         /* 判断上级目录是否合法 */
         $children = array_keys(cat_list($cat_id, 0, false));
         // 获得当前分类的所有下级分类
         if (in_array($cat_info['parent_id'], $children)) {
             $this->message(L('is_leaf_error'), NULL, 'error');
         }
         /* 更新栏目 */
         $this->cat_update($cat_id, $cat_info);
         /* 更新栏目图标 */
         if ($_FILES['cat_image']['name']) {
             /* cat_image图标 */
             $result = $this->ectouchUpload('cat_image', 'cat_image');
             if ($result['error'] > 0) {
                 $this->message($result['message'], NULL, 'error');
             }
             $data['cat_image'] = substr($result['message']['cat_image']['savepath'], 2) . $result['message']['cat_image']['savename'];
             $this->model->table('touch_category')->data($data)->where('cat_id=' . $cat_id)->update();
         }
         /* 清除缓存 */
         clear_all_files();
         $this->message(L('catedit_succed'), url('index'));
     }
     $cat_id = I('cat_id');
     //查询附表信息
     $result = $this->model->table('touch_category')->where('cat_id=' . $cat_id)->find();
     if (empty($result)) {
         $data['cat_id'] = $cat_id;
         $this->model->table('touch_category')->data($data)->insert();
     }
     // 查询分类信息数据
     $cat_info = $this->get_cat_info($cat_id);
     /* 模板赋值 */
     $this->assign('ur_here', L('category_edit'));
     $this->assign('cat_info', $cat_info);
     $this->assign('cat_select', cat_list(0, $cat_info['parent_id'], true));
     $this->display();
 }
开发者ID:noikiy,项目名称:shop-3,代码行数:51,代码来源:CategoryController.class.php

示例3: add

 /**
  * 添加文章分类
  */
 public function add()
 {
     if (IS_POST) {
         $data = I('data');
         /* 数据验证 */
         $msg = Check::rule(array(array(Check::must($data['cat_name']), L('cat_name'))));
         /* 提示信息 */
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         $this->model->table('touch_article_cat')->data($data)->insert();
         clear_all_files();
         $this->message(L('catadd_succed'), url('index'));
     }
     /* 模板赋值 */
     $this->assign('cat_select', model('ArticleBase')->article_cat_list(0));
     $this->assign('ur_here', L('articlecat_add'));
     $this->assign('action_link', array('text' => L('02_articlecat_list'), 'href' => url('index')));
     $this->display();
 }
开发者ID:noikiy,项目名称:shop-3,代码行数:23,代码来源:ArticlecatController.class.php

示例4: edit

 /**
  * 编辑专题
  */
 public function edit()
 {
     $id = I('id');
     if (!$id) {
         $this->redirect(url('index'));
     }
     if (IS_POST) {
         $data = I('data');
         /* 数据验证 */
         $msg = Check::rule(array(array(Check::must($_POST['topic_name']), L('topic_name_empty')), array(Check::must($_POST['start_time']), L('start_time_empty')), array(Check::must($_POST['end_time']), L('end_time_empty'))));
         /* 提示信息 */
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         $topic_type = empty($data['topic_type']) ? 0 : intval($data['topic_type']);
         switch ($topic_type) {
             case '0':
             case '1':
                 // 主图上传
                 if ($_FILES['topic_img']['name'] && $_FILES['topic_img']['size'] > 0) {
                     $result = $this->ectouchUpload('topic_img', 'topic_image');
                     if ($result['error'] > 0) {
                         $this->message($result['message'], NULL, 'error');
                     }
                     /* 生成logo链接 */
                     $topic_img = substr($result['message']['topic_img']['savepath'], 2) . $result['message']['topic_img']['savename'];
                 } else {
                     if (!empty($_POST['url'])) {
                         /* 来自互联网图片 不可以是服务器地址 */
                         if (strstr(I('post.url'), 'http') && !strstr(I('post.url'), $_SERVER['SERVER_NAME'])) {
                             /* 取互联网图片至本地 */
                             $topic_img = get_url_image(I('post.url'));
                         } else {
                             sys_msg(L('web_url_no'));
                         }
                     }
                 }
                 $data['topic_img'] = empty($topic_img) ? I('post.img_url') : $topic_img;
                 $htmls = '';
                 break;
             case '2':
                 $htmls = I('post.content');
                 $data['topic_img'] = '';
                 break;
         }
         // 标题图上传
         if ($_FILES['title_pic']['name'] && $_FILES['title_pic']['size'] > 0) {
             $result = $this->ectouchUpload('title_pic', 'topic_image');
             if ($result['error'] > 0) {
                 $this->message($result['message'], NULL, 'error');
             }
             /* 生成logo链接 */
             $data['title_pic'] = substr($result['message']['title_pic']['savepath'], 2) . $result['message']['title_pic']['savename'];
         } else {
             if (!empty($_REQUEST['title_url'])) {
                 /* 来自互联网图片 不可以是服务器地址 */
                 if (strstr(I('post.title_url'), 'http') && !strstr(I('post.title_url'), $_SERVER['SERVER_NAME'])) {
                     /* 取互联网图片至本地 */
                     $data['title_pic'] = get_url_image(I('post.title_url'));
                 } else {
                     sys_msg(L('web_url_no'));
                 }
             }
         }
         unset($target);
         $data['title'] = I('post.topic_name');
         $title_pic = empty($data['title_pic']) ? I('post.title_img_url') : $data['title_pic'];
         $data['template'] = I('post.topic_template_file') ? I('post.topic_template_file') : '';
         $data['start_time'] = local_strtotime(I('post.start_time'));
         $data['end_time'] = local_strtotime(I('post.end_time'));
         $json = new EcsJson();
         $tmp_data = $json->decode($_POST['topic_data']);
         $data['data'] = serialize($tmp_data);
         $data['intro'] = I('post.topic_intro');
         $this->model->table('touch_topic')->data($data)->where('topic_id =' . $id)->update();
         $this->message(L('succed'), url('index'));
     }
     /* 模板赋值 */
     $topic = $this->model->table('touch_topic')->field('*')->where('topic_id =' . $id)->find();
     $topic['start_time'] = local_date('Y-m-d', $topic['start_time']);
     $topic['end_time'] = local_date('Y-m-d', $topic['end_time']);
     $topic['topic_intro'] = html_out($topic['intro']);
     $topic['intro'] = html_out($topic['intro']);
     $json = new EcsJson();
     if ($topic['data']) {
         $topic['data'] = addcslashes($topic['data'], "'");
         $topic['data'] = $json->encode(@unserialize($topic['data']));
         $topic['data'] = addcslashes($topic['data'], "'");
     }
     if (empty($topic['topic_img']) && empty($topic['htmls'])) {
         $topic['topic_type'] = 0;
     } elseif ($topic['htmls'] != '') {
         $topic['topic_type'] = 2;
     } elseif (preg_match('/.swf$/i', $topic['topic_img'])) {
         $topic['topic_type'] = 1;
     } else {
         $topic['topic_type'] = '';
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:shop-3,代码行数:101,代码来源:TopicController.class.php

示例5: license

 /**
  * 站点授权
  */
 public function license()
 {
     if (IS_POST) {
         $license = I('license');
         // 数据验证
         $msg = Check::rule(array(
             array(
                 Check::must($license),
                 '授权码不能为空'
             )
         ));
         // 提示信息
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         $data = array('license'=>$license, 'appid' => ECTOUCH_AUTH_KEY);
         $result = $this->cloud->data($data)->act('post.dolicense');
         if ($result['error'] > 0) {
             $this->message($result['msg'], NULL, 'error');
         } else {
             $this->message('授权成功', NULL, 'success');
         }
     } else {
         $this->assign('ur_here', L('empower'));
         $this->display();
     }
 }
开发者ID:sayi21cn,项目名称:ecshopAndEctouch,代码行数:30,代码来源:IndexController.class.php

示例6: ad_edit

 /**
  * 编辑广告
  */
 public function ad_edit()
 {
     $id = I('id');
     if (IS_POST) {
         $data = I('data');
         /* 数据验证 */
         $msg = Check::rule(array(array(Check::must($data['ad_name']), L('no_ad_name'))));
         /* 提示信息 */
         if ($msg !== true) {
             $this->message($msg, NULL, 'error');
         }
         $data2['position_id'] = $data['position_id'];
         $data2['ad_name'] = $data['ad_name'];
         $data2['ad_link'] = $data['ad_link'];
         switch ($data['media_type']) {
             /* 添加图片类型的广告 */
             case '0':
                 /* 上传广告图片 */
                 if ($_FILES['ad_img']['name']) {
                     //得到原先的图片路径 删除
                     $img = $this->get_ad_code($data['ad_id']);
                     //排除远程图片
                     if (strpos($img, 'http://') === false && strpos($img, 'https://') === false) {
                         $filename = __URL__ . $img;
                         @unlink($filename);
                     }
                     /* ad_img广告图片 */
                     $result = $this->ectouchUpload('ad_img', 'ad_img');
                     if ($result['error'] > 0) {
                         $this->message($result['message'], NULL, 'error');
                     }
                     $data2['ad_code'] = substr($result['message']['ad_img']['savepath'], 2) . $result['message']['ad_img']['savename'];
                 }
                 /* 远程图片地址 */
                 if (!empty($data['img_url'])) {
                     $data2['ad_code'] = $data['img_url'];
                 }
                 break;
                 /* 添加的广告是Flash广告 */
             /* 添加的广告是Flash广告 */
             case '1':
                 /* 上传的FLash文件 */
                 if ($_FILES['upfile_flash']['name']) {
                     if ($_FILES['upfile_flash']['type'] == 'application/x-shockwave-flash') {
                         /* 生成文件名 */
                         $urlstr = date('Ymd');
                         for ($i = 0; $i < 6; $i++) {
                             $urlstr .= chr(mt_rand(97, 122));
                         }
                         $source_file = $_FILES['upfile_flash']['tmp_name'];
                         //$target      = ROOT_PATH . DATA_DIR . '/afficheimg/'; //生成路径
                         $file_name = $urlstr . '.swf';
                         //移动到目录
                         //
                         $data2['ad_code'] = $file_name;
                     } else {
                         $this->message('上传文件类型不正确!请重新上传', NULL, 'error');
                     }
                 }
                 /* 远程Flash地址 */
                 if (!empty($data['flash_url'])) {
                     $data2['ad_code'] = $data['flash_url'];
                 }
                 break;
                 /* 广告类型为代码广告 */
             /* 广告类型为代码广告 */
             case '2':
                 $data2['ad_code'] = !empty($data['ad_code']) ? $data['ad_code'] : '';
                 break;
                 /* 广告类型为文本广告 */
             /* 广告类型为文本广告 */
             case '3':
                 $data2['ad_link'] = !empty($data['ad_link2']) ? $data['ad_link2'] : '';
                 $data2['ad_code'] = !empty($data['ad_text']) ? $data['ad_text'] : '';
                 break;
         }
         /* 处理广告的开始时期与结束日期 */
         $data2['start_time'] = local_strtotime($data['start_time']);
         $data2['end_time'] = local_strtotime($data['end_time']);
         $data2['link_man'] = $data['link_man'];
         $data2['link_email'] = $data['link_email'];
         $data2['link_phone'] = $data['link_phone'];
         $data2['enabled'] = $data['enabled'];
         // print_r($data2);
         $this->model->table('touch_ad')->data($data2)->where('ad_id=' . $data['ad_id'])->update();
         $this->message(sprintf(L('adedit_succed'), $data['ad_name']), url('ad_list', array('id' => $data['position_id'])));
     }
     /* 查询表信息 */
     $result = $this->model->table('touch_ad')->where('ad_id=' . $id)->find();
     $result['start_time'] = date('Y-m-d', $result['start_time']);
     $result['end_time'] = date('Y-m-d', $result['end_time']);
     if ($result['media_type'] == '0') {
         if (strpos($result['ad_code'], 'http://') === false && strpos($result['ad_code'], 'https://') === false) {
             $src = __URL__ . '/' . $result['ad_code'];
             $this->assign('ad_img', $src);
         } else {
             $src = $result['ad_code'];
//.........这里部分代码省略.........
开发者ID:m7720647,项目名称:demo,代码行数:101,代码来源:AdvertController.class.php

示例7: edit

    /**
     * 编辑品牌
     */
    public function edit() {
        $id = I('id');
        if (IS_POST) {
            $data = I('data');
            /* 数据验证 */
            $msg = Check::rule(array(
                        array(Check::must($data['brand_name']), L('no_brandname')),
            ));
            /* 提示信息 */
            if ($msg !== true) {
                $this->message($msg, NULL, 'error');
            }
            /* 更新图标 */
            if ($_FILES['brand_logo']['name']) {
                $result = $this->ectouchUpload('brand_logo', 'brand_image');
                if ($result['error'] > 0) {
                    $this->message($result['message'], NULL, 'error');
                }
                /* 生成logo链接 */
                $data['brand_logo'] = substr($result['message']['brand_logo']['savepath'], 2) . $result['message']['brand_logo']['savename'];
            }
            $this->model->table('brand')->data($data)->where('brand_id=' . $id)->update();
            /* 更新附表 */
            if ($_FILES['brand_banner']['name']) {
                $result = $this->ectouchUpload('brand_banner', 'brand_image');
                if ($result['error'] > 0) {
                    $this->message($result['message'], NULL, 'error');
                }
                /* 生成banner链接 */
                $data2['brand_banner'] = substr($result['message']['brand_banner']['savepath'], 2) . $result['message']['brand_banner']['savename'];
            }
            /* 品牌详情 */
            $data2['brand_content'] = I('post.content');
            $this->model->table('touch_brand')->data($data2)->where('brand_id=' . $id)->update();

            $this->message(sprintf(L('brandedit_succed'), $data['brand_name']), url('index'));
        }
        /* 查询附表信息 */
        $result = $this->model->table('brand')->where('brand_id=' . $id)->find();
        $touch_result = $this->model->table('touch_brand')->where('brand_id=' . $id)->find();
        /* 附表信息不存在则生成 */
        if (empty($touch_result)) {
            $data['brand_id'] = $id;
            $this->model->table('touch_brand')->data($data)->insert();
        } else {
            $result['brand_banner'] = $touch_result['brand_banner'];
            $result['brand_content'] = html_out($touch_result['brand_content']);
        }
        /* 模板赋值 */
        $this->assign('info', $result);
        $this->assign('ur_here', L('brand_edit'));
        $this->assign('action_link', array('text' => L('06_goods_brand_list'), 'href' => url('index')));
        $this->display();
    }
开发者ID:sayi21cn,项目名称:ecshopAndEctouch,代码行数:57,代码来源:BrandController.class.php

示例8: customer_service

 /**
  * 多客服设置
  */
 public function customer_service()
 {
     if (IS_POST) {
         $command = I('post.command');
         $data = I('post.data');
         $config = I('post.config');
         $info = Check::rule(array(Check::must($command), '关键词不正确'));
         if ($info !== true) {
             $this->message($info, NULL, 'error');
         }
         if (!empty($config)) {
             $data['config'] = serialize($config);
         }
         $num = $this->model->table('wechat_extend')->where('command = "' . $command . '" and wechat_id = ' . $this->wechat_id)->count();
         if ($num > 0) {
             $this->model->table('wechat_extend')->data($data)->where('command = "' . $command . '" and wechat_id = ' . $this->wechat_id)->update();
         } else {
             $data['wechat_id'] = $this->wechat_id;
             $data['command'] = $command;
             $this->model->table('wechat_extend')->data($data)->insert();
         }
         $this->redirect($_SERVER['HTTP_REFERER']);
     }
     $customer_service = $this->model->table('wechat_extend')->field('name, enable, config')->where('command = "kefu" and wechat_id = ' . $this->wechat_id)->find();
     if ($customer_service['config']) {
         $customer_service['config'] = unserialize($customer_service['config']);
     }
     $this->assign('customer_service', $customer_service);
     $this->display();
 }
开发者ID:noikiy,项目名称:shop-3,代码行数:33,代码来源:WechatController.class.php

示例9: action

 /**
  * 行为操作
  */
 public function action()
 {
     if (IS_POST) {
         $data = I('post.data');
         $rs = Check::rule(array(Check::must($data['username']), '用户名不能为空'), array(Check::must($data['password']), '请输入密码'));
         if ($rs !== true) {
             show_message($rs, '会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name)));
         }
         if (!isset($_SESSION['openid'])) {
             show_message('您未登陆,不能进行绑定操作!', '首页', url('index/index'));
         }
         //会员信息
         $user = init_users();
         if (empty($_SESSION['user_id'])) {
             if ($user->get_cookie()) {
                 // 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券
                 if ($_SESSION['user_id'] > 0 && !isset($_SESSION['user_money'])) {
                     model('Users')->update_user_info();
                 }
             } else {
                 $_SESSION['user_id'] = 0;
                 $_SESSION['user_name'] = '';
                 $_SESSION['email'] = '';
                 $_SESSION['user_rank'] = 0;
                 $_SESSION['discount'] = 1.0;
             }
         }
         $old_uid = $_SESSION['user_id'];
         if ($user->login($data['username'], $data['password'], '')) {
             //绑定
             $unionid = model('Base')->model->table('wechat_user')->field('unionid')->where('openid = "' . $_SESSION['openid'] . '"')->getOne();
             if ($unionid) {
                 model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('unionid = "' . $unionid . '"')->update();
             } else {
                 model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('openid = "' . $_SESSION['openid'] . '"')->update();
             }
             model('Users')->update_user_info();
             model('Users')->recalculate_price();
             show_message('您的帐号:' . $data['username'] . '已绑定成功', '返回首页', url('index/index'));
         } else {
             if ($user->add_user($data['username'], $data['password'], time() . '@qq.com', '0', '0', time())) {
                 if ($user->login($data['username'], $data['password'], '')) {
                     model('Users')->update_user_info();
                     model('Users')->recalculate_price();
                     //绑定
                     $unionid = model('Base')->model->table('wechat_user')->field('unionid')->where('openid = "' . $_SESSION['openid'] . '"')->getOne();
                     if ($unionid) {
                         model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('unionid = "' . $unionid . '"')->update();
                     } else {
                         model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('openid = "' . $_SESSION['openid'] . '"')->update();
                     }
                     show_message('您的新帐号:' . $data['username'] . '注册并绑定成功', '返回首页', url('index/index'));
                 } else {
                     show_message('登陆失败,请用已注册会员进行重新绑定', '返回会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name)));
                 }
             } else {
                 show_message('注册失败!会员名或已存在', '返回会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name)));
             }
         }
     }
 }
开发者ID:noikiy,项目名称:shop-3,代码行数:64,代码来源:bd.class.php


注:本文中的Check::must方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。