本文整理汇总了PHP中C函数的典型用法代码示例。如果您正苦于以下问题:PHP C函数的具体用法?PHP C怎么用?PHP C使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了C函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
Tpl::setLayout('store_joinin_layout');
$this->checkLogin();
$model_seller = Model('seller');
$seller_info = $model_seller->getSellerInfo(array('member_id' => $_SESSION['member_id']));
if (!empty($seller_info)) {
@header('location: index.php?act=seller_login');
}
if ($_GET['op'] != 'check_seller_name_exist' && $_GET['op'] != 'checkname') {
$this->check_joinin_state();
}
$phone_array = explode(',', C('site_phone'));
Tpl::output('phone_array', $phone_array);
$model_help = Model('help');
$condition = array();
$condition['type_id'] = '99';
//默认显示入驻流程;
$list = $model_help->getShowStoreHelpList($condition);
Tpl::output('list', $list);
//左侧帮助类型及帮助
Tpl::output('show_sign', 'joinin');
Tpl::output('html_title', C('site_name') . ' - ' . '商家入驻');
Tpl::output('article_list', '');
//底部不显示文章分类
}
示例2: index
/**
* 后台菜单首页
* @return none
*/
public function index()
{
$pid = I('get.pid', 0);
if ($pid) {
$data = D('Menu')->where("id={$pid}")->field(true)->find();
$this->assign('data', $data);
}
$title = trim(I('get.title'));
$type = C('CONFIG_GROUP_LIST');
$all_menu = D('Menu')->getField('id,title');
$map['pid'] = $pid;
if ($title) {
$map['title'] = array('like', "%{$title}%");
}
$list = D("Menu")->where($map)->field(true)->order('sort asc,id asc')->select();
int_to_string($list, array('hide' => array(1 => L('_YES_'), 0 => L('_NOT_')), 'is_dev' => array(1 => L('_YES_'), 0 => L('_NOT_'))));
if ($list) {
foreach ($list as &$key) {
if ($key['pid']) {
$key['up_title'] = $all_menu[$key['pid']];
}
}
$this->assign('list', $list);
}
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->meta_title = L('_MENU_LIST_');
$this->display();
}
示例3: do_personal_index
/**
* 我的兑换 do_personal_index
*/
public function do_personal_index()
{
/* 初始化变量 */
$user_id = I('get.user_id');
$page_num = I('get.page_num');
$page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
/* 查询条件 */
$field = 'pay_order.trade_no,pay_order.shop_coupon_info,pay_order.shop_id,pay_order.trade_state,shop.title as shop_title';
$where['pay_order.user_id'] = array('EQ', $user_id);
$where['pay_order.display'] = array('EQ', 1);
$order = 'pay_order.id desc';
/* 查询数据 */
$list = $this->alias('pay_order')->field($field)->where($where)->join('LEFT JOIN __SHOP__ shop on pay_order.shop_id = shop.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
foreach ($list as $k => $v) {
$shop_coupon_info = json_decode($v['shop_coupon_info'], true);
$list[$k]['coupon_id'] = $shop_coupon_info['id'];
$list[$k]['coupon_title'] = $shop_coupon_info['title'];
if ($shop_coupon_info['coupon_type'] == 1) {
$list[$k]['coupon_tag'] = strval(0);
} else {
$list[$k]['coupon_tag'] = $shop_coupon_info['coupon_worth'];
}
$list[$k]['coupon_content'] = $shop_coupon_info['content'];
unset($list[$k]['shop_coupon_info']);
/* 过滤数据 */
if (!empty($v['coupon_title'])) {
$list[$k]['coupon_title'] = htmlspecialchars_decode($v['coupon_title']);
}
}
/* 读取json */
$list = empty($list) ? array() : $list;
$jsonInfo['list'] = arr_content_replace($list);
return $jsonInfo;
}
示例4: test_newslist
public function test_newslist()
{
$urlbase = C("HTTP_HOST") . "/app/movie/newslist";
//验证用户ID
$this->assert_is_true(send_get_success($urlbase));
//id为空
$this->assert(40002, send_get($urlbase . "?id=d")->errcode);
//id非整数
$this->assert_is_true(send_get_success($urlbase . "?id=1"));
//id为整数
//验证mfields字符串
$this->assert(40099, send_get($urlbase . "?mfields=id,name22,alias")->errcode);
$this->assert(40099, send_get($urlbase . "?id=1&mfields=id,name22,alias")->errcode);
$this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,alias"));
$this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,mname,alias"));
//验证nfields字符串
$this->assert(40099, send_get($urlbase . "?id=1&nfields=id,title22,content")->errcode);
$this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,content"));
$this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,title,content"));
//验证分页
$this->assert(40002, send_get($urlbase . '?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);
//pager参数不合法
//$this->assert(40002,send_get($urlbase.'?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);//pager参数排序不合法
$this->assert_is_true(send_get_success($urlbase . '?pager={"limit":2,"page":1,"order":"id%20desc"}'));
//合法的pager
}
示例5: connect
/**
+----------------------------------------------------------
* 连接数据库方法
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function connect($config = '', $linkNum = 0)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
$conn = $this->pconnect ? 'mysql_pconnect' : 'mysql_connect';
$this->linkID[$linkNum] = $conn($config['hostname'] . ':' . $config['hostport'], $config['username'], $config['password']);
if (!$this->linkID[$linkNum]) {
throw_exception(mysql_error());
return False;
}
if (!mysql_select_db($config['database'], $this->linkID[$linkNum])) {
throw_exception($this->error());
return False;
}
$this->dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
if ($this->dbVersion >= "4.1") {
//使用UTF8存取数据库 需要mysql 4.1.0以上支持
mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
}
// 标记连接成功
$this->connected = true;
// 注销数据库连接配置信息
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
示例6: __construct
function __construct()
{
$this->APPID = C('APPID');
$this->SECRET = C('APPSECRET');
$this->api_url = C('WEIXIN_API_URL');
$this->access_token = $this->getToken();
}
示例7: co_star_edit
public function co_star_edit()
{
if ($_POST['submit'] and $_POST['index'] != "") {
$Stars = M('Co_stars');
$index = $_POST['index'];
$star = $Stars->where('photo_index=' . $index)->find();
if ($_POST['title'] != "") {
$data['photo_title'] = $_POST['title'];
}
$tmp_name = $_FILES['upfile']['tmp_name'];
$file = $_FILES["upfile"];
//上傳文件名稱
//C('__PUBLIC__')爲 /Quanquan/Public
move_uploaded_file($tmp_name, 'Public/WebResources/co_star/' . $file['name']);
//將上傳文件移動到指定目錄待解壓
if ($file['name']) {
unlink($star['photo_url']);
$data['photo_url'] = C('__PUBLIC__') . '/WebResources/co_star/' . $file['name'];
}
if ($Stars->where('photo_index=' . $index)->save($data)) {
echo '修改成功';
} else {
echo $star['photo_url'];
}
} else {
echo '未輸入數據';
}
$this->display();
}
示例8: index
public function index()
{
$sysinfo = M('sys')->order('id asc')->find();
$this->assign('sys', $sysinfo);
$appid = $sysinfo['web_appid'];
$appsecret = $sysinfo['web_appsecret'];
if (!defined('VIRIFY')) {
virifylocal();
}
$_scene = M('scene');
$where['scenecode_varchar'] = I('get.id', 0);
$where['delete_int'] = 0;
$_scene_list = $_scene->where($where)->select();
// print_r($_scene_list); exit('dddd');
$sysinfo = M('sys')->order('id asc')->find();
if ($sysinfo['is_user_anli_shenghe'] && !isset($_GET['preview'])) {
if ($_scene_list[0]["shenhe"] != 1) {
$this->error('抱歉,您的场景还没通过管理员审核', '/#/main');
}
}
$argu2 = array();
$argu2['title'] = $_scene_list[0]["scenename_varchar"];
$argu2['url'] = C('IS_OPEN_STATIC') ? 'v-' . $_scene_list[0]["scenecode_varchar"] : 'index.php?c=view&id=' . $_scene_list[0]["scenecode_varchar"];
$argu2['desc'] = $_scene_list[0]["desc_varchar"];
$argu2['imgsrc'] = $_scene_list[0]["thumbnail_varchar"];
$this->assign("confinfo2", $argu2);
$mydd = get_client_ip();
if ($mydd !== '127.0.0.1') {
$confinfo = $this->get_js_sdk($appid, $appsecret);
}
$this->assign("confinfo", $confinfo);
$this->display(HTML_VESION);
}
示例9: get_run_link
public function get_run_link($id)
{
static $des;
$des = empty($des) ? new \Common\ORG\DES(C('API_DATA_CRYPT_KEY')) : $des;
$item = $this->find($id);
$item_data = $this->get_item_data($id, true);
$service_db = D('Service');
$service = $service_db->find($item['sid']);
$item_data_field = array_keys($item_data);
foreach ($item_data_field as $key => $var) {
$item_data_field[$key] = '{' . $var . '}';
}
$item_data_value = array_values($item_data);
$service_db = D('Service');
$service = $service_db->find($item['sid']);
$environment_db = D('Environment');
$eid = $environment_db->get_current_environment();
$link = [];
$link_tpl = '[protocol]://[type]/[path](des)/[parameter](des)/[attach](des)/';
$replace['[protocol]'] = C('API_PROTOCOL');
$replace['[type]'] = $service['protocol'];
$replace['[path](des)'] = '';
$replace['[parameter](des)'] = '';
$replace['[attach](des)'] = '';
$soft = D('Soft')->get_soft($item['sid'], $eid);
foreach ($soft as $var) {
$replace['[parameter](des)'] = $des->encrypt(str_replace($item_data_field, $item_data_value, $var['tpl']));
$replace['[path](des)'] = $des->encrypt($var['path']);
$replace['[attach](des)'] = $des->encrypt('pathid-' . $var['pathid'] . ',item-' . $item['id'] . ',user-' . session("admin_username"));
$link[] = array('name' => $var['name'], 'link' => str_replace(array_keys($replace), array_values($replace), $link_tpl));
}
return $link;
}
示例10: isLogin
protected function isLogin()
{
if (empty($_SESSION[APP_NAME . '_USERINFO'])) {
/* session 不存在,检查cookie */
if (!empty($_COOKIE['ECTOUCHCP']['ADMIN_ID']) && !empty($_COOKIE['ECTOUCHCP']['ADMIN_PWD'])) {
// 找到了cookie, 验证cookie信息
$condition['user_id'] = intval($_COOKIE['ECTOUCHCP']['ADMIN_ID']);
$userInfo = $this->model->table('admin_user')->field('user_id, user_name, password, email, last_login, ec_salt')->where($condition)->find();
if (empty($userInfo)) {
// 没有找到这个记录
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
return false;
} else {
// 检查密码是否正确
if (md5(md5($userInfo['user_id'] . $userInfo['user_name']) . C('hash_code')) == $_COOKIE['ECTOUCHCP']['ADMIN_PWD']) {
$this->setLogin($userInfo);
$data['last_login'] = gmtime();
$data['last_ip'] = get_client_ip();
$this->model->table('admin_user')->data($data)->where($condition)->update();
$this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
return true;
} else {
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
return false;
}
}
}
return false;
} else {
$this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
return true;
}
}
示例11: index
public function index()
{
if (!session('openid_' . $this->token)) {
$this->info = M('wxuser')->where(array('token' => $this->token))->find();
vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
$wechat = new Wechat();
$wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
$redirect_uri = C('site_url') . '/index.php/Wap/Coupons/index?token=' . $this->token . '&coupon_id=' . $this->coupon_id;
if (!$_GET['code']) {
// By sending no options it'll come back here
$url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
redirect($url);
} else {
try {
// Have a go at creating an access token from the code
$token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri));
// Use this object to try and get some user details (username, full name, etc)
$user = $wechat->get_user_info($token);
$this->openid = $user->openid;
session('openid_' . $this->token, $user->openid);
} catch (OAuth2_Exception $e) {
print_r($e);
die;
}
}
} else {
$this->openid = session('openid_' . $this->token);
}
$url = C('site_url') . "/index.php?g=Wap&m=Coupon&a=index&type=1&token=" . $this->token . '&id=' . $this->coupon_id . '&wecha_id=' . $this->openid;
header('Location:' . $url);
}
示例12: factory
public static function factory($options)
{
$options = is_array($options) ? $options : array();
//只实例化一个对象
if (is_null(self::$cacheFactory)) {
self::$cacheFactory = new cacheFactory();
}
$driver = isset($options['driver']) ? $options['driver'] : C("CACHE_TYPE");
//静态缓存实例名称
$driverName = md5_s($options);
//对象实例存在
if (isset(self::$cacheFactory->cacheList[$driverName])) {
return self::$cacheFactory->cacheList[$driverName];
}
$class = 'Cache' . ucwords(strtolower($driver));
//缓存驱动
$classFile = YY_PATH . 'Cache/' . $class . '.class.php';
//加载驱动类库文件
if (!require_array($classFile)) {
halt("缓存类型指定错误,不存在缓存驱动文件:" . $classFile);
}
$cacheObj = new $class($options);
self::$cacheFactory->cacheList[$driverName] = $cacheObj;
return self::$cacheFactory->cacheList[$driverName];
}
示例13: uploadPic
/**
* 上传图片
*/
public function uploadPic()
{
$config = array('maxSize' => 0, 'exts' => array('jpg', 'png', 'gif', 'jpeg'), 'rootPath' => './Upload/', 'driver' => 'LOCAL', 'subName' => array('date', 'Y-m'), 'savePath' => I('dir', 'uploads') . "/");
$upload = new \Think\Upload($config);
$rs = $upload->upload($_FILES);
if (!$rs) {
$this->error($upload->getError());
} else {
$images = new \Think\Image();
$images->open('./Upload/' . $rs['Filedata']['savepath'] . $rs['Filedata']['savename']);
$newsavename = str_replace('.', '_thumb.', $rs['Filedata']['savename']);
$vv = $images->thumb(I('width', 300), I('height', 300), I('thumb_type', 1))->save('./Upload/' . $rs['Filedata']['savepath'] . $newsavename);
if (C('RTC_M_IMG_SUFFIX') != '') {
$msuffix = C('RTC_M_IMG_SUFFIX');
$mnewsavename = str_replace('.', $msuffix . '.', $rs[$Filedata]['savename']);
$mnewsavename_thmb = str_replace('.', "_thumb" . $msuffix . '.', $rs[$Filedata]['savename']);
$images->open('./Upload/' . $rs[$Filedata]['savepath'] . $rs[$Filedata]['savename']);
$images->thumb(I('width', 700), I('height', 700))->save('./Upload/' . $rs[$Filedata]['savepath'] . $mnewsavename);
$images->thumb(I('width', 250), I('height', 250))->save('./Upload/' . $rs[$Filedata]['savepath'] . $mnewsavename_thmb);
}
$rs['Filedata']['savepath'] = "Upload/" . $rs['Filedata']['savepath'];
$rs['Filedata']['savethumbname'] = $newsavename;
$rs['status'] = 1;
echo json_encode($rs);
}
}
示例14: register
public function register($username = '', $password = '', $repassword = '', $email = '', $verify = '')
{
if (!C('USER_ALLOW_REGISTER')) {
$this->error('注册已关闭');
}
if (IS_POST) {
//注册用户
/* 检测验证码 */
if (!check_verify($verify)) {
$this->error('验证码输入错误!');
}
/* 检测密码 */
if ($password != $repassword) {
$this->error('密码和重复密码不一致!');
}
/* 调用注册接口注册用户 */
$User = new UserApi();
$uid = $User->register($username, $password, $email);
if (0 < $uid) {
//注册成功
//TODO: 发送验证邮件
$this->success('注册成功!', U('login'));
} else {
//注册失败,显示错误信息
$this->error($this->showRegError($uid));
}
} else {
//显示注册表单
$this->display();
}
}
示例15: insert
public function insert()
{
C('TOKEN_ON', false);
$db = D('Call');
$where['uid'] = $_SESSION['uid'];
$where['token'] = $_SESSION['token'];
$res = $db->where($where)->find();
if ($res == false) {
$where['phone_account'] = $this->_post('phone_account', 'trim');
if (isset($_POST['phone_password'])) {
$where['phone_password'] = $this->_post('phone_password', 'trim');
}
if ($where['phone_account'] == false) {
$this->error('标题必须填写');
}
$id = $db->data($where)->add();
if ($id) {
$this->success('添加成功', U('Call/index'));
} else {
$this->error('添加失败', U('Call/index'));
}
} else {
$where['id'] = $res['id'];
$where['phone_account'] = $this->_post('phone_account', 'trim');
if (isset($_POST['phone_password'])) {
$where['phone_password'] = $this->_post('phone_password', 'trim');
}
if ($db->save($where)) {
$this->success('更新成功', U('Call/index'));
} else {
$this->error('更新失败', U('Call/index'));
}
}
}