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


PHP Api::getCurrent方法代码示例

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


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

示例1: prepareActivity

     exit;
 }
 protected function prepareActivity($activity, $verifyParams = array())
 {
     if (empty($activity)) {
         return error(-1, '<h1>访问错误</h1>');
     }
     if (is_error($activity)) {
         return $activity;
     }
     if ($activity['start'] > TIMESTAMP) {
         return error(-2, '<h4>不要着急, 活动还未开始, 敬请期待</h4> <br><h5>本次活动时间为: <br>' . date('Y-m-d H:i', $activity['start']) . ' <br> ' . date('Y-m-d H:i', $activity['end']) . '</h5>');
     }
     if ($activity['end'] < TIMESTAMP) {
         return error(-2, '<h4>手慢了, 本次活动已经结束, 请关注我们期待下次活动</h4> <br><h5>本次活动时间为: <br>' . date('Y-m-d H:i', $activity['start']) . ' <br> ' . date('Y-m-d H:i', $activity['end']) . '</h5>');
     }
     if (!empty($activity['limit'])) {
         if (!empty($activity['limit']['range']) && !empty($verifyParams['user'])) {
             $valid = false;
             $pieces = explode(';', $activity['limit']['range']);
             if (is_array($pieces)) {
                 foreach ($pieces as $district) {
                     if ($valid) {
                         break;
                     }
                     $district = trim($district);
                     $districts = explode('-', $district);
                     $area = array();
                     $area['state'] = trim($districts[0]);
                     $area['city'] = trim($districts[1]);
                     if (!empty($area['state']) && !empty($area['city'])) {
                         if ($area['state'] == $verifyParams['user']['state'] && $area['city'] == $verifyParams['user']['city']) {
                             $valid = true;
                         }
                     } elseif (!empty($area['state'])) {
                         if ($area['state'] == $verifyParams['user']['state']) {
                             $valid = true;
                         }
                     }
                 }
             }
             if (!$valid) {
                 return error(-3, "<h4>你的位置是: {$verifyParams['user']['state']}-{$verifyParams['user']['city']}</h4><br><h5>不在本次活动范围. 请关注并期待我们下一次活动</h5>");
             }
         }
         if (!empty($activity['limit']['gender']) && !empty($verifyParams['user'])) {
             if ($activity['limit']['gender'] != $verifyParams['user']['gender']) {
                 return error(-3, "<h4>抱歉哦: 本次活动只在 <mark>{$activity['limit']['gender']}</mark> 性朋友范围内举行</h4>");
             }
         }
         if (!empty($activity['limit']['amount'])) {
             if ($activity['amount'] >= $activity['limit']['amount']) {
                 return error(-4, "<h4>哎呀, 手慢了. 本次活动所有红包已发完</h4> <br><h5>本次活动已经结束, 请关注我们期待下一次活动</h5>");
             }
         }
     }
     if ($activity['type'] == 'game') {
         if ($activity['tag']['pool'] <= $activity['tag']['threshold']) {
             return error(-4, "<h4>哎呀, 手慢了. 本次活动所有红包已发完</h4> <br><h5>本次活动已经结束, 请关注我们期待下一次活动</h5>");
         }
     }
     $api = new Api();
     $info = $api->getCurrent();
     if (is_error($info)) {
         return $info;
         #debug
     }
     if ($activity['type'] == 'direct') {
         $a = new Activity();
         $gots = $a->getUserRecords($verifyParams['user']['uid'], $activity['actid']);
         if (!empty($gots)) {
             if (!empty($activity['tag']['daily'])) {
                 $count = 0;
                 $today = strtotime(date('Y-m-d', TIMESTAMP));
                 foreach ($gots as $got) {
                     if ($got['created'] > $today && ($got['status'] == 'none' || $got['status'] == 'complete')) {
                         $count++;
                     }
                 }
                 if ($count >= intval($activity['tag']['daily'])) {
                     return error(-5, "<h4>这次活动每人每天只能参加 {$activity['tag']['daily']} 次. <br>您今天已经参加或 {$count} 次, 不能再玩了</h4>");
                 }
             }
             if (!empty($activity['tag']['total'])) {
                 $count = 0;
                 foreach ($gots as $got) {
                     if ($got['status'] == 'none' || $got['status'] == 'complete') {
                         $count++;
                     }
                 }
                 if ($count >= intval($activity['tag']['total'])) {
                     return error(-5, "<h4>这次活动每人只能参加 {$activity['tag']['total']} 次. <br>您已经参加或 {$count} 次, 不能再玩了</h4>");
                 }
             }
         }
     }
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:96,代码来源:site.php

示例2: intval

<?php

global $_W, $_GPC;
require_once MB_ROOT . '/source/Activity.class.php';
$user = $this->auth();
$id = $_GPC['actid'];
$id = intval($id);
$a = new Activity();
$activity = $a->getOne($id);
$prepare = $this->prepareActivity($activity, array('user' => $user));
if (is_error($prepare)) {
    $error = $prepare;
    exit($error['message']);
}
$api = new Api();
$current = $api->getCurrent();
$info = array();
$info['distance'] = $current['distance'];
$info['device'] = $current['device']['id'];
if ($activity['type'] == 'direct') {
    $rid = intval($_GPC['rid']);
    if (!empty($rid)) {
        $record = $a->getOneRecord($rid);
        if (empty($record) || $record['activity'] != $activity['actid'] || $record['uid'] != $user['uid']) {
            exit('非法的访问');
        }
        $ret = $record;
    } else {
        $ret = $a->grap($user, $activity, $info);
    }
    if (is_error($ret)) {
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:31,代码来源:send.inc.php


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