code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
function jsonSerialize()
{
return array(
'checkedFiles' => $this->getCheckedFiles(),
'filesWithSyntaxError' => $this->getFilesWithSyntaxError(),
'skippedFiles' => $this->getSkippedFiles(),
'errors' => $this->getErrors(),
);
} | (PHP 5 >= 5.4.0)<br/>
Specify data which should be serialized to JSON
@link http://php.net/manual/en/jsonserializable.jsonserialize.php
@return mixed data which can be serialized by <b>json_encode</b>,
which is a value of any type other than a resource. | jsonSerialize | php | opnsense/core | contrib/parallel-lint/src/Result.php | https://github.com/opnsense/core/blob/master/contrib/parallel-lint/src/Result.php | BSD-2-Clause |
public function accept()
{
$current = $this->current()->getPathname();
$current = $this->normalizeDirectorySeparator($current);
if ('.' . DIRECTORY_SEPARATOR !== $current[0] . $current[1]) {
$current = '.' . DIRECTORY_SEPARATOR . $current;
}
return !in_array($current, $this->excluded);
} | (PHP 5 >= 5.1.0)<br/>
Check whether the current element of the iterator is acceptable
@link http://php.net/manual/en/filteriterator.accept.php
@return bool true if the current element is acceptable, otherwise false. | accept | php | opnsense/core | contrib/parallel-lint/src/Manager.php | https://github.com/opnsense/core/blob/master/contrib/parallel-lint/src/Manager.php | BSD-2-Clause |
public function hasChildren()
{
return $this->iterator->hasChildren();
} | (PHP 5 >= 5.1.0)<br/>
Check whether the inner iterator's current element has children
@link http://php.net/manual/en/recursivefilteriterator.haschildren.php
@return bool true if the inner iterator has children, otherwise false | hasChildren | php | opnsense/core | contrib/parallel-lint/src/Manager.php | https://github.com/opnsense/core/blob/master/contrib/parallel-lint/src/Manager.php | BSD-2-Clause |
public function getChildren()
{
return new self($this->iterator->getChildren(), $this->excluded);
} | (PHP 5 >= 5.1.0)<br/>
Return the inner iterator's children contained in a RecursiveFilterIterator
@link http://php.net/manual/en/recursivefilteriterator.getchildren.php
@return \RecursiveFilterIterator containing the inner iterator's children. | getChildren | php | opnsense/core | contrib/parallel-lint/src/Manager.php | https://github.com/opnsense/core/blob/master/contrib/parallel-lint/src/Manager.php | BSD-2-Clause |
protected function getDateTime($time, $zone)
{
$utcTimeZone = new \DateTimeZone('UTC');
$datetime = \DateTime::createFromFormat('U', $time, $utcTimeZone);
$way = substr($zone, 0, 1);
$hours = (int) substr($zone, 1, 2);
$minutes = (int) substr($zone, 3, 2);
$interval = new \DateInterval("PT{$hours}H{$minutes}M");
if ($way === '+') {
$datetime->add($interval);
} else {
$datetime->sub($interval);
}
return new \DateTime($datetime->format('Y-m-d\TH:i:s') . $zone, $utcTimeZone);
} | This harakiri method is required to correct support time zone in PHP 5.4
@param int $time
@param string $zone
@return \DateTime
@throws \Exception | getDateTime | php | opnsense/core | contrib/parallel-lint/src/Process/GitBlameProcess.php | https://github.com/opnsense/core/blob/master/contrib/parallel-lint/src/Process/GitBlameProcess.php | BSD-2-Clause |
private static function chunk($binaryString, $bits)
{
$binaryString = chunk_split($binaryString, $bits, ' ');
if (substr($binaryString, (strlen($binaryString)) - 1) == ' ') {
$binaryString = substr($binaryString, 0, strlen($binaryString)-1);
}
return explode(' ', $binaryString);
} | Creates an array from a binary string into a given chunk size
@param string $binaryString String to chunk
@param integer $bits Number of bits per chunk
@return array | chunk | php | opnsense/core | contrib/base32/Base32.php | https://github.com/opnsense/core/blob/master/contrib/base32/Base32.php | BSD-2-Clause |
public function __construct(PropertyMappingFactory $factory, protected FilesystemMapInterface $filesystemMap, protected string $protocol = 'gaufrette')
{
parent::__construct($factory);
} | Constructs a new instance of FileSystemStorage.
@param PropertyMappingFactory $factory The factory
@param FilesystemMapInterface $filesystemMap Gaufrette filesystem factory
@param string $protocol Gaufrette stream wrapper protocol | __construct | php | dustin10/VichUploaderBundle | src/Storage/GaufretteStorage.php | https://github.com/dustin10/VichUploaderBundle/blob/master/src/Storage/GaufretteStorage.php | MIT |
public function __construct(
private readonly string $mapping,
private readonly ?string $fileNameProperty = null,
private readonly ?string $size = null,
private readonly ?string $mimeType = null,
private readonly ?string $originalName = null,
private readonly ?string $dimensions = null
) {
} | Constructs a new instance of UploadableField. | __construct | php | dustin10/VichUploaderBundle | src/Mapping/Annotation/UploadableField.php | https://github.com/dustin10/VichUploaderBundle/blob/master/src/Mapping/Annotation/UploadableField.php | MIT |
public function __construct(private readonly AdvancedMetadataFactoryInterface $reader)
{
} | Constructs a new instance of the MetadataReader.
@param AdvancedMetadataFactoryInterface $reader The "low-level" metadata reader | __construct | php | dustin10/VichUploaderBundle | src/Metadata/MetadataReader.php | https://github.com/dustin10/VichUploaderBundle/blob/master/src/Metadata/MetadataReader.php | MIT |
public function getKFSessionlist($kf_account)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET_LIST . "access_token={$this->access_token}" . '&kf_account=' . $kf_account);
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return $json;
}
return false;
} | 获取指定客服的会话列表
@param string $kf_account //用户openid
@return bool | array //成功返回json数组
array(
'sessionlist' => array (
array (
'openid'=>'OPENID', //客户 openid
'createtime'=>123456789, //会话创建时间,UNIX 时间戳
),
array (
'openid'=>'OPENID', //客户 openid
'createtime'=>123456789, //会话创建时间,UNIX 时间戳
),
)
) | getKFSessionlist | php | zoujingli/wechat-php-sdk | Wechat/WechatCustom.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatCustom.php | MIT |
public function updateCard($data)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return true;
}
return false;
} | 更改卡券信息
调用该接口更新信息后会重新送审,卡券状态变更为待审核。已被用户领取的卡券会实时更新票面信息。
@param string $data
@return bool | updateCard | php | zoujingli/wechat-php-sdk | Wechat/WechatCard.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatCard.php | MIT |
public function delCard($card_id)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$data = array('card_id' => $card_id);
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_DELETE . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return true;
}
return false;
} | 删除卡券
允许商户删除任意一类卡券。删除卡券后,该卡券对应已生成的领取用二维码、添加到卡包 JS API 均会失效。
注意:删除卡券不能删除已被用户领取,保存在微信客户端中的卡券,已领取的卡券依旧有效。
@param string $card_id 卡券ID
@return bool | delCard | php | zoujingli/wechat-php-sdk | Wechat/WechatCard.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatCard.php | MIT |
public function createCardQrcode($card_id, $code = '', $openid = '', $expire_seconds = 0, $is_unique_code = false, $balance = '')
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$card = array('card_id' => $card_id);
!empty($code) && $card['code'] = $code;
!empty($openid) && $card['openid'] = $openid;
!empty($is_unique_code) && $card['is_unique_code'] = $is_unique_code;
!empty($balance) && $card['balance'] = $balance;
$data = array('action_name' => "QR_CARD");
!empty($expire_seconds) && $data['expire_seconds'] = $expire_seconds;
$data['action_info'] = array('card' => $card);
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_QRCODE_CREATE . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return $json;
}
return false;
} | 生成卡券二维码
成功则直接返回ticket值,可以用 getQRUrl($ticket) 换取二维码url
@param string $card_id 卡券ID 必须
@param string $code 指定卡券 code 码,只能被领一次。use_custom_code 字段为 true 的卡券必须填写,非自定义 code 不必填写。
@param string $openid 指定领取者的 openid,只有该用户能领取。bind_openid 字段为 true 的卡券必须填写,非自定义 openid 不必填写。
@param int $expire_seconds 指定二维码的有效时间,范围是 60 ~ 1800 秒。不填默认为永久有效。
@param bool $is_unique_code 指定下发二维码,生成的二维码随机分配一个 code,领取后不可再次扫描。填写 true 或 false。默认 false。
@param string $balance 红包余额,以分为单位。红包类型必填(LUCKY_MONEY),其他卡券类型不填。
@return bool|string | createCardQrcode | php | zoujingli/wechat-php-sdk | Wechat/WechatCard.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatCard.php | MIT |
public function updateMemberCard($data)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_UPDATEUSER . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return $json;
}
return false;
} | 会员卡交易
会员卡交易后每次积分及余额变更需通过接口通知微信,便于后续消息通知及其他扩展功能。
@param string $data 具体结构请参看卡券开发文档(6.1.2 会员卡交易)章节
@return bool|array | updateMemberCard | php | zoujingli/wechat-php-sdk | Wechat/WechatCard.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatCard.php | MIT |
public function getOauthAccessToken()
{
$code = isset($_GET['code']) ? $_GET['code'] : '';
if (empty($code)) {
Tools::log("getOauthAccessToken Fail, Because there is no access to the code value in get.", "MSG - {$this->appid}");
return false;
}
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_TOKEN_URL . "appid={$this->appid}&secret={$this->appsecret}&code={$code}&grant_type=authorization_code");
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
Tools::log("WechatOauth::getOauthAccessToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
return false;
}
return $json;
}
return false;
} | 通过 code 获取 AccessToken 和 openid
@return bool|array | getOauthAccessToken | php | zoujingli/wechat-php-sdk | Wechat/WechatOauth.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatOauth.php | MIT |
public function getMediaWithHttpInfo($media_id, $is_video = false)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$url_prefix = $is_video ? str_replace('https', 'http', self::API_URL_PREFIX) : self::API_URL_PREFIX;
$url = $url_prefix . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id;
$oCurl = curl_init();
if (stripos($url, "https://") !== false) {
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1);
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
$result = array();
if (intval($aStatus["http_code"]) !== 200) {
return false;
}
if ($sContent) {
if (is_string($sContent)) {
$json = json_decode($sContent, true);
if (isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return $this->checkRetry(__FUNCTION__, func_get_args());
}
}
$result['content'] = $sContent;
$result['info'] = $aStatus;
return $result;
}
return false;
} | 获取临时素材(认证后的订阅号可用) 包含返回的http头信息
@param string $media_id 媒体文件id
@param bool $is_video 是否为视频文件,默认为否
@return bool|array | getMediaWithHttpInfo | php | zoujingli/wechat-php-sdk | Wechat/WechatMedia.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatMedia.php | MIT |
public function getForeverMedia($media_id, $is_video = false)
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$data = array('media_id' => $media_id);
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
if (is_string($result) && ($json = json_decode($result, true))) {
if (isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return $json;
}
return $result;
}
return false;
} | 获取永久素材(认证后的订阅号可用)
返回图文消息数组或二进制数据,失败返回false
@param string $media_id 媒体文件id
@param bool $is_video 是否为视频文件,默认为否
@return bool|array | getForeverMedia | php | zoujingli/wechat-php-sdk | Wechat/WechatMedia.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatMedia.php | MIT |
public function getForeverCount()
{
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$result = Tools::httpGet(self::API_URL_PREFIX . self::MEDIA_FOREVER_COUNT_URL . "access_token={$this->access_token}");
if ($result) {
$json = json_decode($result, true);
if (empty($json) || !empty($json['errcode'])) {
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
return $this->checkRetry(__FUNCTION__, func_get_args());
}
return $json;
}
return false;
} | 获取永久素材总数(认证后的订阅号可用)
@return bool|array
返回数组格式:
array(
'voice_count'=>0, //语音总数量
'video_count'=>0, //视频总数量
'image_count'=>0, //图片总数量
'news_count'=>0 //图文总数量
) | getForeverCount | php | zoujingli/wechat-php-sdk | Wechat/WechatMedia.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatMedia.php | MIT |
public function refund($out_trade_no, $transaction_id, $out_refund_no, $total_fee, $refund_fee, $op_user_id = null, $refund_account = '', $refund_desc = '', $refund_fee_type = 'CNY')
{
$data = array();
$data['out_trade_no'] = $out_trade_no;
$data['total_fee'] = $total_fee;
$data['refund_fee'] = $refund_fee;
$data['refund_fee_type'] = $refund_fee_type;
$data['op_user_id'] = empty($op_user_id) ? $this->mch_id : $op_user_id;
!empty($out_refund_no) && $data['out_refund_no'] = $out_refund_no;
!empty($transaction_id) && $data['transaction_id'] = $transaction_id;
!empty($refund_account) && $data['refund_account'] = $refund_account;
!empty($refund_desc) && $data['refund_desc'] = $refund_desc;
$result = $this->getArrayResult($data, self::MCH_BASE_URL . '/secapi/pay/refund', 'postXmlSSL');
if (false === $this->_parseResult($result)) {
return false;
}
return ($result['return_code'] === 'SUCCESS');
} | 订单退款接口
@param string $out_trade_no 商户订单号
@param string $transaction_id 微信订单号,与 out_refund_no 二选一(不选时传0或false)
@param string $out_refund_no 商户退款订单号,与 transaction_id 二选一(不选时传0或false)
@param int $total_fee 商户订单总金额
@param int $refund_fee 退款金额,不可大于订单总金额
@param int|null $op_user_id 操作员ID,默认商户ID
@param string $refund_account 退款资金来源
仅针对老资金流商户使用
REFUND_SOURCE_UNSETTLED_FUNDS --- 未结算资金退款(默认使用未结算资金退款)
REFUND_SOURCE_RECHARGE_FUNDS --- 可用余额退款
@param string $refund_desc 退款原因
@param string $refund_fee_type 退款货币种类
@return bool | refund | php | zoujingli/wechat-php-sdk | Wechat/WechatPay.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatPay.php | MIT |
public function getRevCardPass()
{
if (isset($this->_receive['CardId'])) {
return $this->_receive['CardId'];
}
return false;
} | 获取卡券事件推送 - 卡卷审核是否通过
当Event为 card_pass_check(审核通过) 或 card_not_pass_check(未通过)
@return bool|string 返回卡券ID | getRevCardPass | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevCardGet()
{
$array = array();
if (isset($this->_receive['CardId'])) {
$array['CardId'] = $this->_receive['CardId'];
}
if (isset($this->_receive['IsGiveByFriend'])) {
$array['IsGiveByFriend'] = $this->_receive['IsGiveByFriend'];
}
$array['OldUserCardCode'] = $this->_receive['OldUserCardCode'];
if (isset($this->_receive['UserCardCode']) && !empty($this->_receive['UserCardCode'])) {
$array['UserCardCode'] = $this->_receive['UserCardCode'];
}
return (isset($array) && count($array) > 0) ? $array : false;
} | 获取卡券事件推送 - 领取卡券
当Event为 user_get_card(用户领取卡券)
@return bool|array | getRevCardGet | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevCardDel()
{
if (isset($this->_receive['CardId'])) { //卡券 ID
$array['CardId'] = $this->_receive['CardId'];
}
if (isset($this->_receive['UserCardCode']) && !empty($this->_receive['UserCardCode'])) {
$array['UserCardCode'] = $this->_receive['UserCardCode'];
}
return (isset($array) && count($array) > 0) ? $array : false;
} | 获取卡券事件推送 - 删除卡券
当Event为 user_del_card (用户删除卡券)
@return bool|array | getRevCardDel | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevScanInfo()
{
if (isset($this->_receive['ScanCodeInfo'])) {
if (!is_array($this->_receive['ScanCodeInfo'])) {
$array = (array)$this->_receive['ScanCodeInfo'];
$this->_receive['ScanCodeInfo'] = $array;
} else {
$array = $this->_receive['ScanCodeInfo'];
}
}
return (isset($array) && count($array) > 0) ? $array : false;
} | 获取自定义菜单的扫码推事件信息
事件类型为以下两种时则调用此方法有效
Event 事件类型, scancode_push
Event 事件类型, scancode_waitmsg
@return bool|array | getRevScanInfo | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevSendGeoInfo()
{
if (isset($this->_receive['SendLocationInfo'])) {
if (!is_array($this->_receive['SendLocationInfo'])) {
$array = (array)$this->_receive['SendLocationInfo'];
if (empty($array['Poiname'])) {
$array['Poiname'] = "";
}
if (empty($array['Label'])) {
$array['Label'] = "";
}
$this->_receive['SendLocationInfo'] = $array;
} else {
$array = $this->_receive['SendLocationInfo'];
}
}
return (isset($array) && count($array) > 0) ? $array : false;
} | 获取自定义菜单的地理位置选择器事件推送
事件类型为以下时则可以调用此方法有效
Event 事件类型,location_select 弹出地理位置选择器的事件推送
@return bool|array
array (
'Location_X' => '33.731655000061',
'Location_Y' => '113.29955200008047',
'Scale' => '16',
'Label' => '某某市某某区某某路',
'Poiname' => '',
) | getRevSendGeoInfo | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevTplMsgID()
{
if (isset($this->_receive['MsgID'])) {
return $this->_receive['MsgID'];
}
return false;
} | 获取主动推送的消息ID
经过验证,这个和普通的消息MsgId不一样
当Event为 MASSSENDJOBFINISH 或 TEMPLATESENDJOBFINISH
@return bool|string | getRevTplMsgID | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevResult()
{
if (isset($this->_receive['Status'])) { //发送是否成功,具体的返回值请参考 高级群发/模板消息 的事件推送说明
$array['Status'] = $this->_receive['Status'];
}
if (isset($this->_receive['MsgID'])) { //发送的消息id
$array['MsgID'] = $this->_receive['MsgID'];
}
//以下仅当群发消息时才会有的事件内容
if (isset($this->_receive['TotalCount'])) { //分组或openid列表内粉丝数量
$array['TotalCount'] = $this->_receive['TotalCount'];
}
if (isset($this->_receive['FilterCount'])) { //过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数
$array['FilterCount'] = $this->_receive['FilterCount'];
}
if (isset($this->_receive['SentCount'])) { //发送成功的粉丝数
$array['SentCount'] = $this->_receive['SentCount'];
}
if (isset($this->_receive['ErrorCount'])) { //发送失败的粉丝数
$array['ErrorCount'] = $this->_receive['ErrorCount'];
}
if (isset($array) && count($array) > 0) {
return $array;
}
return false;
} | 获取群发或模板消息发送结果
当Event为 MASSSENDJOBFINISH 或 TEMPLATESENDJOBFINISH,即高级群发/模板消息
@return bool|array | getRevResult | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevKFCreate()
{
if (isset($this->_receive['KfAccount'])) {
return $this->_receive['KfAccount'];
}
return false;
} | 获取多客服会话状态推送事件 - 接入会话
当Event为 kfcreatesession 即接入会话
@return bool|string | getRevKFCreate | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevKFClose()
{
if (isset($this->_receive['KfAccount'])) {
return $this->_receive['KfAccount'];
}
return false;
} | 获取多客服会话状态推送事件 - 关闭会话
当Event为 kfclosesession 即关闭会话
@return bool|string | getRevKFClose | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
public function getRevKFSwitch()
{
if (isset($this->_receive['FromKfAccount'])) { //原接入客服
$array['FromKfAccount'] = $this->_receive['FromKfAccount'];
}
if (isset($this->_receive['ToKfAccount'])) { //转接到客服
$array['ToKfAccount'] = $this->_receive['ToKfAccount'];
}
return (isset($array) && count($array) > 0) ? $array : false;
} | 获取多客服会话状态推送事件 - 转接会话
当Event为 kfswitchsession 即转接会话
@return bool|array | getRevKFSwitch | php | zoujingli/wechat-php-sdk | Wechat/WechatReceive.php | https://github.com/zoujingli/wechat-php-sdk/blob/master/Wechat/WechatReceive.php | MIT |
protected function handleResponse(int $httpCode, $ctHeader, string $body)
{
if ($httpCode === 204) {
return null;
}
[$contentType] = explode(';', $ctHeader, 2);
if ($contentType != 'application/json') {
throw new RequestException(
"Expected 'application/json' response, got '$contentType'",
500,
new RequestException($body, $httpCode)
);
}
try {
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new RequestException("Invalid JSON response from server", 500, $exception);
}
if ($httpCode >= 400) {
throw new RequestException($data['error'] ?? $body, $httpCode);
}
return $data;
} | Handle the response of the cURL request.
@param int $httpCode HTTP status code
@param string|null $ctHeader Content-Type header
@param string $body Response body
@return mixed
@throws RequestException | handleResponse | php | jasny/sso | src/Broker/Broker.php | https://github.com/jasny/sso/blob/master/src/Broker/Broker.php | MIT |
public function _beforeSuite($settings = [])
{
parent::_beforeSuite($settings);
$this->server = new PhpBuiltInServer(ROOT_DIR . '/demo/server/', 8200);
$this->broker1 = new PhpBuiltInServer(
ROOT_DIR . '/demo/broker/',
8201,
[
'SSO_SERVER' => 'http://localhost:8200/attach.php',
'SSO_BROKER_ID' => 'Alice',
'SSO_BROKER_SECRET' => '8iwzik1bwd'
]
);
$this->broker2 = new PhpBuiltInServer(
ROOT_DIR . '/demo/broker/',
8202,
[
'SSO_SERVER' => 'http://localhost:8200/attach.php',
'SSO_BROKER_ID' => 'Greg',
'SSO_BROKER_SECRET' => '7pypoox2pc'
]
);
} | Hook runs before any test of the suite is run
@param array $settings | _beforeSuite | php | jasny/sso | tests/_support/Helper/Demo.php | https://github.com/jasny/sso/blob/master/tests/_support/Helper/Demo.php | MIT |
public function _afterSuite()
{
$this->server = null;
$this->broker1 = null;
$this->broker2 = null;
parent::_afterSuite();
} | Hook runs after all test of the suite is run | _afterSuite | php | jasny/sso | tests/_support/Helper/Demo.php | https://github.com/jasny/sso/blob/master/tests/_support/Helper/Demo.php | MIT |
public function month($field)
{
$t = strtotime($field);
return date('n', $t);
} | Method to extract the month value from the date.
@param string representing the date formatted as 0000-00-00.
@return string representing the number of the month between 1 and 12. | month | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function year($field)
{
$t = strtotime($field);
return date('Y', $t);
} | Method to extract the year value from the date.
@param string representing the date formatted as 0000-00-00.
@return string representing the number of the year. | year | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function day($field)
{
$t = strtotime($field);
return date('j', $t);
} | Method to extract the day value from the date.
@param string representing the date formatted as 0000-00-00.
@return string representing the number of the day of the month from 1 and 31. | day | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function unix_timestamp($field = null)
{
return is_null($field) ? time() : strtotime($field);
} | Method to return the unix timestamp.
Used without an argument, it returns PHP time() function (total seconds passed
from '1970-01-01 00:00:00' GMT). Used with the argument, it changes the value
to the timestamp.
@param string representing the date formatted as '0000-00-00 00:00:00'.
@return number of unsigned integer | unix_timestamp | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function second($field)
{
$t = strtotime($field);
return intval(date("s", $t));
} | Method to emulate MySQL SECOND() function.
@param string representing the time formatted as '00:00:00'.
@return number of unsigned integer | second | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function minute($field)
{
$t = strtotime($field);
return intval(date("i", $t));
} | Method to emulate MySQL MINUTE() function.
@param string representing the time formatted as '00:00:00'.
@return number of unsigned integer | minute | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function hour($time)
{
list($hours) = explode(":", $time);
return intval($hours);
} | Method to emulate MySQL HOUR() function.
@param string representing the time formatted as '00:00:00'.
@return number | hour | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function from_unixtime($field, $format = null)
{
//convert to ISO time
$date = date("Y-m-d H:i:s", $field);
return is_null($format) ? $date : $this->dateformat($date, $format);
} | Method to emulate MySQL FROM_UNIXTIME() function.
@param integer of unix timestamp
@param string to indicate the way of formatting(optional)
@return string formatted as '0000-00-00 00:00:00'. | from_unixtime | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function now()
{
return date("Y-m-d H:i:s");
} | Method to emulate MySQL NOW() function.
@return string representing current time formatted as '0000-00-00 00:00:00'. | now | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function curdate()
{
return date("Y-m-d");
} | Method to emulate MySQL CURDATE() function.
@return string representing current time formatted as '0000-00-00'. | curdate | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function char_length($field)
{
return strlen($field);
} | Method to emulate MySQL CHAR_LENGTH() function.
@param string
@return int unsigned integer for the length of the argument. | char_length | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function md5($field)
{
return md5($field);
} | Method to emulate MySQL MD5() function.
@param string
@return string of the md5 hash value of the argument. | md5 | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function rand()
{
return mt_rand(0, 1);
} | Method to emulate MySQL RAND() function.
SQLite does have a random generator, but it is called RANDOM() and returns random
number between -9223372036854775808 and +9223372036854775807. So we substitute it
with PHP random generator.
This function uses mt_rand() which is four times faster than rand() and returns
the random number between 0 and 1.
@return int | rand | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function substring($text, $pos, $len = null)
{
return "substr($text, $pos, $len)";
} | Method to emulate MySQL SUBSTRING() function.
This function rewrites the function name to SQLite compatible substr(),
which can manipulate UTF-8 characters.
@param string $text
@param integer $pos representing the start point.
@param integer $len representing the length of the substring(optional).
@return string | substring | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function dateformat($date, $format)
{
$mysql_php_date_formats = [
'%a' => 'D',
'%b' => 'M',
'%c' => 'n',
'%D' => 'jS',
'%d' => 'd',
'%e' => 'j',
'%H' => 'H',
'%h' => 'h',
'%I' => 'h',
'%i' => 'i',
'%j' => 'z',
'%k' => 'G',
'%l' => 'g',
'%M' => 'F',
'%m' => 'm',
'%p' => 'A',
'%r' => 'h:i:s A',
'%S' => 's',
'%s' => 's',
'%T' => 'H:i:s',
'%U' => 'W',
'%u' => 'W',
'%V' => 'W',
'%v' => 'W',
'%W' => 'l',
'%w' => 'w',
'%X' => 'Y',
'%x' => 'o',
'%Y' => 'Y',
'%y' => 'y',
];
$t = strtotime($date);
$format = strtr($format, $mysql_php_date_formats);
$output = date($format, $t);
return $output;
} | Method to emulate MySQL DATEFORMAT() function.
@param string date formatted as '0000-00-00' or datetime as '0000-00-00 00:00:00'.
@param string $format
@return string formatted according to $format | dateformat | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function date_add($date, $interval)
{
$interval = $this->deriveInterval($interval);
switch (strtolower($date)) {
case "curdate()":
$objDate = new DateTime($this->curdate());
$objDate->add(new DateInterval($interval));
$formatted = $objDate->format("Y-m-d");
break;
case "now()":
$objDate = new DateTime($this->now());
$objDate->add(new DateInterval($interval));
$formatted = $objDate->format("Y-m-d H:i:s");
break;
default:
$objDate = new DateTime($date);
$objDate->add(new DateInterval($interval));
$formatted = $objDate->format("Y-m-d H:i:s");
}
return $formatted;
} | Method to emulate MySQL DATE_ADD() function.
This function adds the time value of $interval expression to $date.
$interval is a single quoted strings rewritten by SQLiteQueryDriver::rewrite_query().
It is calculated in the private function deriveInterval().
@param string $date representing the start date.
@param string $interval representing the expression of the time to add.
@return string date formatted as '0000-00-00 00:00:00'.
@throws Exception | date_add | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function date_sub($date, $interval)
{
$interval = $this->deriveInterval($interval);
switch (strtolower($date)) {
case "curdate()":
$objDate = new DateTime($this->curdate());
$objDate->sub(new DateInterval($interval));
$returnval = $objDate->format("Y-m-d");
break;
case "now()":
$objDate = new DateTime($this->now());
$objDate->sub(new DateInterval($interval));
$returnval = $objDate->format("Y-m-d H:i:s");
break;
default:
$objDate = new DateTime($date);
$objDate->sub(new DateInterval($interval));
$returnval = $objDate->format("Y-m-d H:i:s");
}
return $returnval;
} | Method to emulate MySQL DATE_SUB() function.
This function subtracts the time value of $interval expression from $date.
$interval is a single quoted strings rewritten by SQLiteQueryDriver::rewrite_query().
It is calculated in the private function deriveInterval().
@param string $date representing the start date.
@param string $interval representing the expression of the time to subtract.
@return string date formatted as '0000-00-00 00:00:00'.
@throws Exception | date_sub | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
private function deriveInterval($interval)
{
$interval = trim(substr(trim($interval), 8));
$parts = explode(' ', $interval);
foreach ($parts as $part) {
if (! empty($part)) {
$_parts[] = $part;
}
}
$type = strtolower(end($_parts));
switch ($type) {
case "second":
$unit = 'S';
return 'PT' . $_parts[0] . $unit;
break;
case "minute":
$unit = 'M';
return 'PT' . $_parts[0] . $unit;
break;
case "hour":
$unit = 'H';
return 'PT' . $_parts[0] . $unit;
break;
case "day":
$unit = 'D';
return 'P' . $_parts[0] . $unit;
break;
case "week":
$unit = 'W';
return 'P' . $_parts[0] . $unit;
break;
case "month":
$unit = 'M';
return 'P' . $_parts[0] . $unit;
break;
case "year":
$unit = 'Y';
return 'P' . $_parts[0] . $unit;
break;
case "minute_second":
list($minutes, $seconds) = explode(':', $_parts[0]);
return 'PT' . $minutes . 'M' . $seconds . 'S';
case "hour_second":
list($hours, $minutes, $seconds) = explode(':', $_parts[0]);
return 'PT' . $hours . 'H' . $minutes . 'M' . $seconds . 'S';
case "hour_minute":
list($hours, $minutes) = explode(':', $_parts[0]);
return 'PT' . $hours . 'H' . $minutes . 'M';
case "day_second":
$days = intval($_parts[0]);
list($hours, $minutes, $seconds) = explode(':', $_parts[1]);
return 'P' . $days . 'D' . 'T' . $hours . 'H' . $minutes . 'M' . $seconds . 'S';
case "day_minute":
$days = intval($_parts[0]);
list($hours, $minutes) = explode(':', $parts[1]);
return 'P' . $days . 'D' . 'T' . $hours . 'H' . $minutes . 'M';
case "day_hour":
$days = intval($_parts[0]);
$hours = intval($_parts[1]);
return 'P' . $days . 'D' . 'T' . $hours . 'H';
case "year_month":
list($years, $months) = explode('-', $_parts[0]);
return 'P' . $years . 'Y' . $months . 'M';
}
} | Method to calculate the interval time between two dates value.
@access private
@param string $interval white space separated expression.
@return string representing the time to add or substract. | deriveInterval | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function date($date)
{
return date("Y-m-d", strtotime($date));
} | Method to emulate MySQL DATE() function.
@param string $date formatted as unix time.
@return string formatted as '0000-00-00'. | date | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function isnull($field)
{
return is_null($field);
} | Method to emulate MySQL ISNULL() function.
This function returns true if the argument is null, and true if not.
@param various types $field
@return boolean | isnull | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function _if($expression, $true, $false)
{
return ($expression == true) ? $true : $false;
} | Method to emulate MySQL IF() function.
As 'IF' is a reserved word for PHP, function name must be changed.
@param unknonw $expression the statement to be evaluated as true or false.
@param unknown $true statement or value returned if $expression is true.
@param unknown $false statement or value returned if $expression is false.
@return unknown | _if | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function regexp($field, $pattern)
{
$pattern = str_replace('/', '\/', $pattern);
$pattern = "/" . $pattern . "/i";
return preg_match($pattern, $field);
} | Method to emulate MySQL REGEXP() function.
@param string $field haystack
@param string $pattern : regular expression to match.
@return integer 1 if matched, 0 if not matched. | regexp | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function concat()
{
$returnValue = "";
$argsNum = func_num_args();
$argsList = func_get_args();
for ($i = 0; $i < $argsNum; $i++) {
if (is_null($argsList[$i])) {
return null;
}
$returnValue .= $argsList[$i];
}
return $returnValue;
} | Method to emulate MySQL CONCAT() function.
SQLite does have CONCAT() function, but it has a different syntax from MySQL.
So this function must be manipulated here.
@param string
@return NULL if the argument is null | string conatenated if the argument is given. | concat | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function field()
{
global $wpdb;
$numArgs = func_num_args();
if ($numArgs < 2 or is_null(func_get_arg(0))) {
return 0;
} else {
$arg_list = func_get_args();
}
$searchString = array_shift($arg_list);
$str_to_check = substr($searchString, 0, strpos($searchString, '.'));
$str_to_check = str_replace($wpdb->prefix, '', $str_to_check);
if ($str_to_check && in_array(trim($str_to_check), $wpdb->tables)) {
return 0;
}
for ($i = 0; $i < $numArgs - 1; $i++) {
if ($searchString === strtolower($arg_list[$i])) {
return $i + 1;
}
}
return 0;
} | Method to emulate MySQL FIELD() function.
This function gets the list argument and compares the first item to all the others.
If the same value is found, it returns the position of that value. If not, it
returns 0.
@param int...|float... variable number of string, integer or double
@return int unsigned integer | field | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function least()
{
$arg_list = func_get_args();
return "min($arg_list)";
} | Method to emulate MySQL LEAST() function.
This function rewrites the function name to SQLite compatible function name.
@return mixed | least | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function greatest()
{
$arg_list = func_get_args();
return "max($arg_list)";
} | Method to emulate MySQL GREATEST() function.
This function rewrites the function name to SQLite compatible function name.
@return mixed | greatest | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function get_lock($name, $timeout)
{
return '1=1';
} | Method to dummy out MySQL GET_LOCK() function.
This function is meaningless in SQLite, so we do nothing.
@param string $name
@param integer $timeout
@return string | get_lock | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function release_lock($name)
{
return '1=1';
} | Method to dummy out MySQL RELEASE_LOCK() function.
This function is meaningless in SQLite, so we do nothing.
@param string $name
@return string | release_lock | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function ucase($string)
{
return "upper($string)";
} | Method to emulate MySQL UCASE() function.
This is MySQL alias for upper() function. This function rewrites it
to SQLite compatible name upper().
@param string
@return string SQLite compatible function name. | ucase | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function lcase($string)
{
return "lower($string)";
} | Method to emulate MySQL LCASE() function.
This is MySQL alias for lower() function. This function rewrites it
to SQLite compatible name lower().
@param string
@return string SQLite compatible function name. | lcase | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function inet_ntoa($num)
{
return long2ip($num);
} | Method to emulate MySQL INET_NTOA() function.
This function gets 4 or 8 bytes integer and turn it into the network address.
@param unsigned long integer
@return string | inet_ntoa | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function inet_aton($addr)
{
return absint(ip2long($addr));
} | Method to emulate MySQL INET_ATON() function.
This function gets the network address and turns it into integer.
@param string
@return int long integer | inet_aton | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function datediff($start, $end)
{
$start_date = new DateTime($start);
$end_date = new DateTime($end);
$interval = $end_date->diff($start_date, false);
return $interval->format('%r%a');
} | Method to emulate MySQL DATEDIFF() function.
This function compares two dates value and returns the difference.
@param string start
@param string end
@return string | datediff | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function locate($substr, $str, $pos = 0)
{
if (! extension_loaded('mbstring')) {
if (($val = strpos($str, $substr, $pos)) !== false) {
return $val + 1;
} else {
return 0;
}
} else {
if (($val = mb_strpos($str, $substr, $pos)) !== false) {
return $val + 1;
} else {
return 0;
}
}
} | Method to emulate MySQL LOCATE() function.
This function returns the position if $substr is found in $str. If not,
it returns 0. If mbstring extension is loaded, mb_strpos() function is
used.
@param string needle
@param string haystack
@param integer position
@return integer | locate | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function utc_date()
{
return gmdate('Y-m-d', time());
} | Method to return GMT date in the string format.
@param none
@return string formatted GMT date 'dddd-mm-dd' | utc_date | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function utc_time()
{
return gmdate('H:i:s', time());
} | Method to return GMT time in the string format.
@param none
@return string formatted GMT time '00:00:00' | utc_time | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function utc_timestamp()
{
return gmdate('Y-m-d H:i:s', time());
} | Method to return GMT time stamp in the string format.
@param none
@return string formatted GMT timestamp 'yyyy-mm-dd 00:00:00' | utc_timestamp | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
public function version()
{
//global $required_mysql_version;
//return $required_mysql_version;
return '5.5';
} | Method to return MySQL version.
This function only returns the current newest version number of MySQL,
because it is meaningless for SQLite database.
@param none
@return string representing the version number: major_version.minor_version | version | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
function __construct()
{
register_shutdown_function([$this, '__destruct']);
if (! is_file(FQDB)) {
$this->prepare_directory();
}
$dsn = 'sqlite:' . FQDB;
if (isset($GLOBALS['@pdo'])) {
$this->pdo = $GLOBALS['@pdo'];
} else {
$locked = false;
$status = 0;
do {
try {
$this->pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
new PDOSQLiteUDFS($this->pdo);
$GLOBALS['@pdo'] = $this->pdo;
} catch (PDOException $ex) {
$status = $ex->getCode();
if ($status == 5 || $status == 6) {
$locked = true;
} else {
$err_message = $ex->getMessage();
}
}
} while ($locked);
if ($status > 0) {
$message = 'Database initialization error!<br />' .
'Code: ' . $status .
(isset($err_message) ? '<br />Error Message: ' . $err_message : '');
$this->set_error(__LINE__, __FILE__, $message);
return false;
}
} | Constructor
Create PDO object, set user defined functions and initialize other settings.
Don't use parent::__construct() because this class does not only returns
PDO instance but many others jobs.
Constructor definition is changed since version 1.7.1.
@param none | __construct | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
function __destruct()
{
if (defined('SQLITE_MEM_DEBUG') && SQLITE_MEM_DEBUG) {
$max = ini_get('memory_limit');
if (is_null($max)) {
$message = sprintf("[%s] Memory_limit is not set in php.ini file.",
date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']));
file_put_contents(FQDBDIR . 'mem_debug.txt', $message, FILE_APPEND);
return true;
}
if (stripos($max, 'M') !== false) {
$max = (int) $max * 1024 * 1024;
}
$peak = memory_get_peak_usage(true);
$used = round((int) $peak / (int) $max * 100, 2);
if ($used > 90) {
$message = sprintf("[%s] Memory peak usage warning: %s %% used. (max: %sM, now: %sM)\n",
date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), $used, $max, $peak);
file_put_contents(FQDBDIR . 'mem_debug.txt', $message, FILE_APPEND);
}
}
//$this->pdo = null;
return true;
} | Destructor
If SQLITE_MEM_DEBUG constant is defined, append information about
memory usage into database/mem_debug.txt.
This definition is changed since version 1.7.
@return boolean | __destruct | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
private function init()
{
if (version_compare($this->get_sqlite_version(), '3.7.11', '>=')) {
$this->can_insert_multiple_rows = true;
}
$statement = $this->pdo->query('PRAGMA foreign_keys');
if ($statement->fetchColumn(0) == '0') {
$this->pdo->query('PRAGMA foreign_keys = ON');
}
} | Method to initialize database, executed in the constructor.
It checks if WordPress is in the installing process and does the required
jobs. SQLite library version specific settings are also in this function.
Some developers use WP_INSTALLING constant for other purposes, if so, this
function will do no harms. | init | php | project-idx/community-templates | wordpress/dev/src/db.php | https://github.com/project-idx/community-templates/blob/master/wordpress/dev/src/db.php | Apache-2.0 |
protected function updatePackages($dev = true)
{
if ($packages = $this->getPackages()) {
$configurationKey = $dev ? 'devDependencies' : 'dependencies';
$packages[$configurationKey] = static::updatePackageArray(
array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : []
);
ksort($packages[$configurationKey]);
file_put_contents(
base_path('package.json'),
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL
);
return $this;
}
return null;
} | Update the "package.json" file.
@param bool $dev
@return null|$this | updatePackages | php | qirolab/laravel-themer | src/Presets/Traits/PackagesTrait.php | https://github.com/qirolab/laravel-themer/blob/master/src/Presets/Traits/PackagesTrait.php | MIT |
protected function exportJs()
{
copy($this->stubPath('react-stubs/app.js'), $this->themePath('js/app.js'));
if (! $this->exists($this->themePath('js/bootstrap.js'))) {
copy($this->stubPath('react-stubs/bootstrap.js'), $this->themePath('js/bootstrap.js'));
}
// if (!$this->exists(base_path('.babelrc'))) {
// copy(__DIR__ . '/../../stubs/Presets/react-stubs/.babelrc', base_path('.babelrc'));
// }
return $this;
} | Update the bootstrapping files.
@return $this | exportJs | php | qirolab/laravel-themer | src/Presets/Vite/ReactPreset.php | https://github.com/qirolab/laravel-themer/blob/master/src/Presets/Vite/ReactPreset.php | MIT |
protected function exportSass()
{
$this->ensureDirectoryExists($this->themePath('sass'));
copy(
$this->stubPath('bootstrap-stubs/sass/_variables.scss'),
$this->themePath('sass/_variables.scss')
);
copy(
$this->stubPath('bootstrap-stubs/sass/app.scss'),
$this->themePath('sass/app.scss')
);
return $this;
} | Update the Sass files for the application.
@return $this | exportSass | php | qirolab/laravel-themer | src/Presets/Vite/BootstrapPreset.php | https://github.com/qirolab/laravel-themer/blob/master/src/Presets/Vite/BootstrapPreset.php | MIT |
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->filled('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
} | Attempt to authenticate the request's credentials.
@return void
@throws \Illuminate\Validation\ValidationException | authenticate | php | qirolab/laravel-themer | stubs/app/Http/Requests/Auth/LoginRequest.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Requests/Auth/LoginRequest.php | MIT |
public function ensureIsNotRateLimited()
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
} | Ensure the login request is not rate limited.
@return void
@throws \Illuminate\Validation\ValidationException | ensureIsNotRateLimited | php | qirolab/laravel-themer | stubs/app/Http/Requests/Auth/LoginRequest.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Requests/Auth/LoginRequest.php | MIT |
public function throttleKey()
{
return Str::lower($this->input('email')).'|'.$this->ip();
} | Get the rate limiting throttle key for the request.
@return string | throttleKey | php | qirolab/laravel-themer | stubs/app/Http/Requests/Auth/LoginRequest.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Requests/Auth/LoginRequest.php | MIT |
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(route('dashboard', absolute: false));
} | Handle an incoming authentication request.
@param LoginRequest $request
@return \Illuminate\Http\RedirectResponse | store | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/AuthenticatedSessionController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/AuthenticatedSessionController.php | MIT |
public function destroy(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
} | Destroy an authenticated session.
@param Request $request
@return \Illuminate\Http\RedirectResponse | destroy | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/AuthenticatedSessionController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/AuthenticatedSessionController.php | MIT |
public function show(Request $request)
{
return view('auth.passwords.confirm');
} | Show the confirm password view.
@param Request $request
@return \Illuminate\View\View | show | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/ConfirmablePasswordController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/ConfirmablePasswordController.php | MIT |
public function create()
{
return view('auth.register');
} | Display the registration view.
@return \Illuminate\View\View | create | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/RegisteredUserController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/RegisteredUserController.php | MIT |
public function store(Request $request)
{
$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|confirmed|min:8',
]);
Auth::login($user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]));
event(new Registered($user));
return redirect('dashboard');
} | Handle an incoming registration request.
@param Request $request
@return \Illuminate\Http\RedirectResponse
@throws \Illuminate\Validation\ValidationException | store | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/RegisteredUserController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/RegisteredUserController.php | MIT |
public function __invoke(EmailVerificationRequest $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
} | Mark the authenticated user's email address as verified.
@param EmailVerificationRequest $request
@return \Illuminate\Http\RedirectResponse | __invoke | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/VerifyEmailController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/VerifyEmailController.php | MIT |
public function __invoke(Request $request)
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(route('dashboard', absolute: false))
: view('auth.verify-email');
} | Display the email verification prompt.
@param Request $request
@return mixed | __invoke | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/EmailVerificationPromptController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/EmailVerificationPromptController.php | MIT |
public function create(Request $request)
{
return view('auth.passwords.reset', ['request' => $request]);
} | Display the password reset view.
@return \Illuminate\View\View | create | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/NewPasswordController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/NewPasswordController.php | MIT |
public function store(Request $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
} | Send a new email verification notification.
@param Request $request
@return \Illuminate\Http\Response | store | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/EmailVerificationNotificationController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/EmailVerificationNotificationController.php | MIT |
public function create()
{
return view('auth.passwords.forget');
} | Display the password reset link request view.
@return \Illuminate\View\View | create | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/PasswordResetLinkController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/PasswordResetLinkController.php | MIT |
public function store(Request $request)
{
$request->validate([
'email' => 'required|email',
]);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = Password::sendResetLink(
$request->only('email')
);
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
} | Handle an incoming password reset link request.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse
@throws \Illuminate\Validation\ValidationException | store | php | qirolab/laravel-themer | stubs/app/Http/Controllers/Auth/PasswordResetLinkController.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/Http/Controllers/Auth/PasswordResetLinkController.php | MIT |
public function render()
{
return view('layouts.guest');
} | Get the view / contents that represents the component.
@return \Illuminate\View\View | render | php | qirolab/laravel-themer | stubs/app/View/Components/GuestLayout.php | https://github.com/qirolab/laravel-themer/blob/master/stubs/app/View/Components/GuestLayout.php | MIT |
protected function modifiedBrowserJs()
{
if (app()->environment('testing')) {
/** @var string $browser */
$browser = file_get_contents('vendor/spatie/browsershot/bin/browser.cjs');
} else {
/** @var string $browser */
$browser = file_get_contents(base_path('vendor/spatie/browsershot/bin/browser.cjs'));
}
// Remove their reference.
$browser = str_replace('const puppet = (pup || require(\'puppeteer\'));', '', $browser);
// Use pupeteer-core instead.
return "const puppet = require('puppeteer-core'); \n".$browser;
} | We get puppeteer out of the layer, which Spatie doesn't allow
for. We'll just overwrite their browser.cjs to add it.
@return string | modifiedBrowserJs | php | stefanzweifel/sidecar-browsershot | src/Functions/BrowsershotFunction.php | https://github.com/stefanzweifel/sidecar-browsershot/blob/master/src/Functions/BrowsershotFunction.php | MIT |
protected function parseBody(\SimpleXMLElement $body, array &$data) {
$data['parsed'] = $body;
$namespaces = $body->getDocNamespaces();
if (isset($namespaces[''])) {
// Account for the default namespace being defined and PHP not being able to handle it :(
$body->registerXPathNamespace('ns', $namespaces['']);
$prefix = 'ns:';
} else {
$prefix = '';
}
if ($tempXml = $body->xpath("//{$prefix}Code[1]")) {
$data['code'] = (string) $tempXml[0];
}
if ($tempXml = $body->xpath("//{$prefix}Message[1]")) {
$data['message'] = (string) $tempXml[0];
}
$tempXml = $body->xpath("//{$prefix}RequestId[1]");
if (empty($tempXml)) {
$tempXml = $body->xpath("//{$prefix}RequestID[1]");
}
if (isset($tempXml[0])) {
$data['request_id'] = (string) $tempXml[0];
}
} | Parses additional exception information from the response body
@param \SimpleXMLElement $body The response body as XML
@param array $data The current set of exception data | parseBody | php | tencentyun/cos-php-sdk-v5 | src/ExceptionParser.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ExceptionParser.php | MIT |
protected function prepareRequest(
CommandInterface $command,
RequestInterface $request
) {
/*
if ($command->offsetExists('key') === true) {
$mode = empty($command->offsetGet('auth')) === false
? $command->offsetGet('auth')
: 'loco';
if ($mode !== 'query') {
// else use Authorization header of various types
if ($mode === 'loco') {
$value = 'Loco '.$command->offsetGet('key');
$request = $request->withHeader('Authorization', $value);
} elseif ($mode === 'basic') {
$value = 'Basic '.base64_encode($command->offsetGet('key').':');
$request = $request->withHeader('Authorization', $value);
} else {
throw new \InvalidArgumentException("Invalid auth type: {$mode}");
}
// avoid request sending key parameter in query string
$command->offsetUnset('key');
}
}
// Remap legacy parameters to common `data` binding on request body
static $remap = [
'import' => ['src'=>'data'],
'translate' => ['translation'=>'data'],
];
$name = $command->getName();
if (isset($remap[$name])) {
foreach ($remap[$name] as $old => $new) {
if ($command->offsetExists($old)) {
$command->offsetSet($new, $command->offsetGet($old));
$command->offsetUnset($old);
}
}
}
*/
return parent::prepareRequest($command, $request);
} | Authorization header is Loco's preferred authorization method.
Add Authorization header to request if API key is set, unless query is explicitly configured as auth method.
Unset key from command to avoid sending it as a query param.
@override
@param CommandInterface $command
@param RequestInterface $request
@return RequestInterface
@throws \InvalidArgumentException | prepareRequest | php | tencentyun/cos-php-sdk-v5 | src/Serializer.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/Serializer.php | MIT |
public function getCosConfig($option = null)
{
return $option === null
? $this->cosConfig
: (isset($this->cosConfig[$option]) ? $this->cosConfig[$option] : array());
} | Get the config of the cos client.
@param array|string $option
@return mixed | getCosConfig | php | tencentyun/cos-php-sdk-v5 | src/Client.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/Client.php | MIT |
public function setImage($value) {
$this->image = "/image/" . $this->ciBase64($value);
} | 水印图片地址,需要经过 URL 安全的 Base64 编码。
@param $value | setImage | php | tencentyun/cos-php-sdk-v5 | src/ImageParamTemplate/ImageWatermarkTemplate.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ImageParamTemplate/ImageWatermarkTemplate.php | MIT |
public function setImageKey($value) {
$this->imageKey = "/image_key/" . $this->ciBase64($value);
} | 如果您在添加水印时不希望暴露水印所在的图片地址,可使用该参数。
@param $value | setImageKey | php | tencentyun/cos-php-sdk-v5 | src/ImageParamTemplate/ImageWatermarkTemplate.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ImageParamTemplate/ImageWatermarkTemplate.php | MIT |
public function setGravity($value) {
$this->gravity = "/gravity/" . $value;
} | 图片水印位置,九宫格位置(参考九宫格方位图 ),默认值 SouthEast
@param $value | setGravity | php | tencentyun/cos-php-sdk-v5 | src/ImageParamTemplate/ImageWatermarkTemplate.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ImageParamTemplate/ImageWatermarkTemplate.php | MIT |
public function setBlogo($value) {
$this->blogo = "/blogo/" . $value;
} | 水印图适配功能,适用于水印图尺寸过大的场景(如水印墙)。共有两种类型:
当 blogo 设置为1时,水印图会被缩放至与原图相似大小后添加
当 blogo 设置为2时,水印图会被直接裁剪至与原图相似大小后添加
@param $value | setBlogo | php | tencentyun/cos-php-sdk-v5 | src/ImageParamTemplate/ImageWatermarkTemplate.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ImageParamTemplate/ImageWatermarkTemplate.php | MIT |
public function setScatype($value) {
$this->scatype = "/scatype/" . $value;
} | 根据原图的大小,缩放调整水印图的大小:
当 scatype 设置为1时,按原图的宽缩放
当 scatype 设置为2时,按原图的高缩放
当 scatype 设置为3时,按原图的整体面积缩放
@param $value | setScatype | php | tencentyun/cos-php-sdk-v5 | src/ImageParamTemplate/ImageWatermarkTemplate.php | https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/ImageParamTemplate/ImageWatermarkTemplate.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.