本文整理汇总了PHP中is_error函数的典型用法代码示例。如果您正苦于以下问题:PHP is_error函数的具体用法?PHP is_error怎么用?PHP is_error使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: respond
public function respond()
{
global $_W;
$rid = $this->rule;
$sql = "SELECT * FROM " . tablename('wxcard_reply') . " WHERE rid = :rid ORDER BY RAND() LIMIT 1";
$reply = pdo_fetch($sql, array(':rid' => $rid));
if (empty($reply)) {
return false;
}
load()->classs('weixin.account');
load()->classs('coupon');
$coupon = new coupon($_W['acid']);
if (is_error($coupon)) {
$this->error($reply, $coupon['message']);
die;
}
$card = $coupon->BuildCardExt($reply['cid']);
if (is_error($card)) {
$this->error($reply, $card['message']);
die;
}
$data = array('touser' => $_W['openid'], 'msgtype' => 'wxcard', 'wxcard' => array('card_id' => $card['card_id'], 'card_ext' => $card['card_ext']));
$acc = WeAccount::create($_W['acid']);
$status = $acc->sendCustomNotice($data);
if (is_error($status)) {
$this->error($reply, $status['message']);
die;
}
if (!empty($reply['success'])) {
return $this->respText($reply['success']);
die;
}
return true;
}
示例2: fieldsFormSubmit
public function fieldsFormSubmit($rid = 0)
{
global $_GPC, $_W;
$id = intval($_GPC['reply_id']);
$credit = intval($_GPC['credit']);
$insert = array('rid' => $rid, 'start_time' => strtotime($_GPC['start_time']), 'end_time' => strtotime($_GPC['end_time']), 'awardrules' => $_GPC['awardrules'], 'awardinfo' => $_GPC['awardinfo'], 'days' => $_GPC['days'], 'credit' => $credit);
if (!empty($_FILES['thumb']['tmp_name'])) {
file_delete($_GPC['thumb_old']);
$upload = file_upload($_FILES['thumb']);
if (is_error($upload)) {
message($upload['message'], '', 'error');
}
$insert['thumb'] = $upload['path'];
} else {
$tmp_file = array(name => "registration_top.jpg", tmp_name => "{$_SERVER['DOCUMENT_ROOT']}/source/modules/cgtsignin/template/style/images/registration_top.jpg");
$upload = file_upload($tmp_file);
if (is_error($upload)) {
message($upload['message'], '', 'error');
}
$insert['thumb'] = $upload['path'];
}
if (empty($id)) {
pdo_insert($this->tablename, $insert);
} else {
pdo_update($this->tablename, $insert, array('id' => $id));
}
}
示例3: fetchUserInfo
private function fetchUserInfo($openid)
{
$token = $this->fetchAccess();
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN";
$response = ihttp_get($url);
if (is_error($response)) {
return error(-1, "访问公众平台接口失败, 错误: {$response['message']}");
}
$result = @json_decode($response['content'], true);
if (empty($result)) {
return error(-2, "接口调用失败, 错误信息: {$response}");
} elseif (!empty($result['errcode'])) {
return error(-3, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}");
}
$ret = array();
$ret['nickname'] = $result['nickname'];
$ret['gender'] = $result['sex'];
$ret['residecity'] = $result['city'];
$ret['resideprovince'] = $result['province'];
$ret['avatar'] = $result['headimgurl'];
if (!empty($ret['avatar'])) {
$ret['avatar'] = rtrim($ret['avatar'], '0');
$ret['avatar'] .= '132';
}
$ret['original'] = $result;
return $ret;
}
示例4: delete
/**
* Delete version
*
* @param void
* @return null
*/
function delete()
{
if ($this->request->isSubmitted()) {
if (!$this->active_page_version->canDelete($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$delete = $this->active_page_version->delete();
if ($delete && !is_error($delete)) {
if ($this->request->isAsyncCall()) {
$this->httpOk();
} else {
flash_success('Version #:version has been deleted', array('version' => $this->active_page_version->getVersion()));
}
// if
} else {
if ($this->request->isAsyncCall()) {
$this->httpError(HTTP_ERR_OPERATION_FAILED);
} else {
flash_success('Failed to delete version #:version', array('version' => $this->active_page_version->getVersion()));
}
// if
}
// if
$this->redirectToUrl($this->active_page->getViewUrl());
} else {
$this->httpError(HTTP_ERR_BAD_REQUEST);
}
// if
}
示例5: doMobileOAuth
public function doMobileOAuth()
{
global $_W, $_GPC;
$account = $this->getAccount();
$code = trim($_GPC['code']);
if (!empty($code)) {
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$account['key']}&secret={$account['secret']}&code={$code}&grant_type=authorization_code";
WeUtility::logging('trace', 'url:' . $url);
$ret = ihttp_get($url);
if (!is_error($ret)) {
$auth = @json_decode($ret['content'], true);
if (is_array($auth) && !empty($auth['openid'])) {
$row = array();
$row['weid'] = $_W['weid'];
$row['openid'] = $auth['openid'];
$row['from_user'] = $auth['openid'];
if ($auth['scope'] == 'snsapi_userinfo') {
$user = $this->getFansInfo($auth['access_token'], $auth['openid']);
$row['nickname'] = $user['nickname'];
$row['avatar'] = $user['headimgurl'];
}
WeUtility::logging('trace', 'user:' . json_encode($row));
isetcookie($this->cookiename, base64_encode(serialize($row)), 86400 * 7 * 7);
$forward = base64_decode($_GPC['query']);
header('location: ' . $_W['siteroot'] . 'mobile.php?' . $forward . '&' . $this->cookiename . '=' . $auth['openid'] . '&wxref=mp.weixin.qq.com#wechat_redirect');
exit;
} else {
message($ret['content']);
}
}
}
message('微信授权失败!');
}
示例6: doWebPost
public function doWebPost()
{
global $_GPC, $_W;
$id = intval($_GPC['id']);
if (!empty($id)) {
$item = pdo_fetch("SELECT * FROM " . tablename($this->headtable) . " WHERE id = :id", array(':id' => $id));
if (empty($item)) {
message('抱歉,楼盘不存在或是已经删除!', '', 'error');
}
}
if (checksubmit('submit')) {
if (empty($_GPC['title'])) {
message('请输入商户名称!');
}
$data = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'buildingintro' => htmlspecialchars_decode($_GPC['buildingintro']), 'traffic' => $_GPC['traffic'], 'projectintro' => $_GPC['projectintro'], 'phone' => $_GPC['phone'], 'province' => $_GPC['resideprovince'], 'city' => $_GPC['residecity'], 'dist' => $_GPC['residedist'], 'address' => $_GPC['address'], 'lng' => $_GPC['lng'], 'lat' => $_GPC['lat'], 'createtime' => TIMESTAMP);
if (!empty($_FILES['thumb']['tmp_name'])) {
file_delete($_GPC['thumb_old']);
$upload = file_upload($_FILES['thumb']);
if (is_error($upload)) {
message($upload['message'], '', 'error');
}
$data['thumb'] = $upload['path'];
}
if (empty($id)) {
pdo_insert($this->headtable, $data);
} else {
unset($data['createtime']);
pdo_update($this->headtable, $data, array('id' => $id));
}
message('商户信息更新成功!', create_url('site/module/display', array('name' => 'lxybuilding')), 'success');
}
include $this->template('post');
}
示例7: findBySQL
/**
* Return object of a specific class by SQL
*
* @param string $sql
* @param array $arguments
* @param boolean $one
* @param string $table_name
* @param string $item_class
* @return array
*/
function findBySQL($sql, $arguments = null, $one = false, $table_name = null, $item_class = null)
{
if ($arguments !== null) {
$sql = db_prepare_string($sql, $arguments);
}
// if
$rows = db_execute_all($sql);
if (is_error($rows)) {
return $rows;
}
// if
if (!is_array($rows) || !count($rows)) {
return null;
}
// if
if ($one) {
$item = new $item_class();
$item->loadFromRow($rows[0], true);
return $item;
} else {
$items = array();
foreach ($rows as $row) {
$item = new $item_class();
$item->loadFromRow($row, true);
$items[] = $item;
}
// foreach
return count($items) ? $items : null;
}
// if
}
示例8: unstarObject
/**
* Remove star from a given object
*
* @param ProjectObject $object
* @param User $user
* @return boolean
*/
function unstarObject($object, $user)
{
if (!$object->canView($user)) {
return false;
}
// if
if (StarredObjects::isStarred($object, $user)) {
$cache_id = 'object_starred_by_' . $user->getId();
$starred_objects = cache_get($cache_id);
if (!is_array($starred_objects)) {
$starred_objects = StarredObjects::findObjectIdsByUser($user);
}
// if
// Not starred?
if (!in_array($object->getId(), $starred_objects)) {
return true;
}
// if
$execute = db_execute('DELETE FROM ' . TABLE_PREFIX . 'starred_objects WHERE object_id = ? AND user_id = ?', $object->getId(), $user->getId());
if ($execute && !is_error($execute)) {
unset($starred_objects[array_search($object->getId(), $starred_objects)]);
cache_set($cache_id, $starred_objects);
}
// if
return $execute;
}
// if
return true;
}
示例9: doWebAddshop
public function doWebAddshop()
{
global $_GPC, $_W;
$rid = intval($_GPC['rid']);
$id = intval($_GPC['id']);
if (!empty($id)) {
$item = pdo_fetch("SELECT * FROM " . tablename('hotel_shop') . " WHERE id = :id", array(':id' => $id));
if (empty($item)) {
message('抱歉,房型不存在或是已经删除!', '', 'error');
}
}
if (checksubmit('submit')) {
if (empty($_GPC['style'])) {
message('请输入房型!');
}
$data = array('weid' => $_W['weid'], 'rid' => $rid, 'style' => $_GPC['style'], 'oprice' => $_GPC['oprice'], 'cprice' => $_GPC['cprice'], 'thumb' => $_GPC['thumb'], 'device' => htmlspecialchars_decode($_GPC['device']));
if (!empty($_FILES['thumb']['tmp_name'])) {
file_delete($_GPC['thumb_old']);
$upload = file_upload($_FILES['thumb']);
if (is_error($upload)) {
message($upload['message'], '', 'error');
}
$data['thumb'] = $upload['path'];
}
if (empty($id)) {
pdo_insert('hotel_shop', $data);
} else {
pdo_update('hotel_shop', $data, array('id' => $id));
}
message('房型信息更新成功!', $this->createWebUrl('shop', array('id' => $_GPC['rid'])), 'success');
}
include $this->template('addshop');
}
示例10: doWebChatlog
public function doWebChatlog()
{
global $_GPC, $_W;
load()->func('tpl');
$acids = uni_accounts($_W['uniacid']);
if (!empty($acids)) {
$data = array();
foreach ($acids as $acid) {
if (in_array($acid['level'], array(3, 4))) {
$data[] = $acid;
}
}
}
$starttime = empty($_GPC['starttime']) ? strtotime(date('Y-m-d')) : strtotime($_GPC['starttime']);
if (!empty($_GPC['token'])) {
unset($_GPC['token']);
$avatar = '';
$endtime = $starttime + 23 * 3600 + 3599;
$acid = intval($_GPC['acid']);
if (!empty($_GPC['nickname']) && empty($_GPC['openid'])) {
$user = pdo_fetch('SELECT b.openid,a.avatar FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE a.nickname = :nickname', array(':nickname' => trim($_GPC['nickname'])));
if (empty($user['openid'])) {
message('没有找到昵称为 "' . $_GPC['nickname'] . '" 的用户', $this->createWebUrl('chatlog', array('acid' => $acid, 'nickname' => $_GPC['nickname'], 'openid' => $_GPC['openid'], 'starttime' => $_GPC['starttime'])), 'error');
} else {
if (!empty($user['avatar'])) {
$avatar = tomedia($user['avatar']);
$nickname = $user['nickname'];
}
}
} else {
$openid = trim($_GPC['openid']);
$user = pdo_fetch('SELECT b.openid,a.avatar,a.nickname FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE b.openid = :openid', array(':openid' => trim($_GPC['openid'])));
if (!empty($user['avatar'])) {
$avatar = tomedia($user['avatar']);
$nickname = $user['nickname'];
}
}
if ($acid > 0 && !empty($starttime) && !empty($endtime) && !empty($openid)) {
$pindex = max(1, intval($_GPC['page']));
$acc = WeAccount::create($acid);
$params = array('openid' => trim($_GPC['openid']), 'starttime' => $starttime, 'endtime' => $endtime, 'pageindex' => $pindex, 'pagesize' => 1000);
$logs = $acc->fetchChatLog($params);
$next = 1;
if (is_error($logs) || empty($logs['recordlist']) || count($logs['recordlist']) < $params['pagesize']) {
$next = 0;
}
$codedata = array();
$codedata[1000] = '创建未接入会话';
$codedata[1001] = '接入会话';
$codedata[1002] = '主动发起会话';
$codedata[1004] = '关闭会话';
$codedata[1005] = '抢接会话';
$codedata[2001] = '公众号收到消息';
$codedata[2002] = '客服发送消息';
$codedata[2003] = '客服收到消息';
}
}
include $this->template('chatlog');
}
示例11: cache_clean
function cache_clean($prefix = '')
{
$memcache = cache_memcache();
if (is_error($memcache)) {
return $memcache;
}
return $memcache->flush();
}
示例12: deleteByModule
/**
* Delete templates by module name
*
* @param string $name
* @return boolean
*/
function deleteByModule($name)
{
$delete = EmailTemplates::delete(array('module = ?', $name));
if ($delete && !is_error($delete)) {
db_execute('DELETE FROM ' . TABLE_PREFIX . 'email_template_translations WHERE module = ?', $name);
}
// if
return $delete;
}
示例13: newConfigOptions
/**
* Create new v1.1.4 configuration options
*
* @param void
* @return boolean
*/
function newConfigOptions()
{
$insert = $this->utility->db->execute("INSERT INTO " . TABLE_PREFIX . "config_options (name, module, type, value) VALUES \n ('last_frequently_activity', 'system', 'system', 'N;'),\n ('last_hourly_activity', 'system', 'system', 'N;'),\n ('last_daily_activity', 'system', 'system', 'N;')\n ");
if (is_error($insert)) {
return $insert->getMessage();
}
// if
return true;
}
示例14: doWebList
public function doWebList()
{
global $_GPC, $_W;
load()->func('tpl');
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($operation == 'display') {
if (!empty($_GPC['displayorder'])) {
foreach ($_GPC['displayorder'] as $id => $displayorder) {
pdo_update('meepomailattachment', array('displayorder' => $displayorder), array('id' => $id));
}
message('分类排序更新成功!', $this->createWebUrl('List', array('op' => 'display')), 'success');
}
$list = pdo_fetchall("SELECT * FROM " . tablename('meepomailattachment') . " WHERE weid = '{$_W['weid']}' ORDER BY id ASC, displayorder DESC");
include $this->template('list');
} elseif ($operation == 'post') {
$id = intval($_GPC['id']);
if (!empty($id)) {
$list = pdo_fetch("SELECT * FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'");
} else {
$list = array('displayorder' => 0);
}
if (checksubmit('submit')) {
if (empty($_GPC['attachmentname']) || empty($_GPC['description'])) {
message('文件名称以及文件描述是必填项!', $this->createWebUrl('list'), 'error');
}
$data = array('weid' => $_W['weid'], 'attachmentname' => $_GPC['attachmentname'], 'isshow' => intval($_GPC['isshow']), 'displayorder' => intval($_GPC['displayorder']), 'description' => $_GPC['description']);
if (!empty($_FILES['thumb']['tmp_name'])) {
load()->func('file');
file_delete($_GPC['thumb_old']);
$upload = $this->file_upload($data['attachmentname'], $_FILES['thumb']);
if (is_error($upload)) {
message($upload['message'], '', 'error');
}
$data['thumb'] = $upload['path'];
}
if (!empty($id)) {
unset($data['id']);
pdo_update('meepomailattachment', $data, array('id' => $id));
} else {
pdo_insert('meepomailattachment', $data);
$id = pdo_insertid();
}
message('更新附件成功!', $this->createWebUrl('list', array('op' => 'display')), 'success');
}
include $this->template('list');
} elseif ($operation == 'delete') {
$id = intval($_GPC['id']);
$category = pdo_fetch("SELECT id FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'");
if (empty($category)) {
message('抱歉,附件不存在或是已经被删除!', $this->createWebUrl('list', array('op' => 'display')), 'error');
}
pdo_delete('meepomailattachment', array('id' => $id), 'OR');
message('附件信息删除成功!', $this->createWebUrl('list', array('op' => 'display')), 'success');
}
}
示例15: deleteAction
public function deleteAction($uid)
{
$uid = intval($uid);
$ret = $this->acl->removeUser($uid);
if (is_error($ret)) {
$this->error($ret['message']);
} else {
$this->success('删除成功');
exit;
}
}