/**
  * 增加一次助力记录
  *      如果from, to 已经存在, 失败
  *   id uniacid from to dateline  
  * 
  * @param $entity 助力结构 from, to, dateline
  * @return int|error
  */
 public function createHelp($entity)
 {
     global $_W;
     $rec = array_elements(array('from', 'to', 'dateline'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $fromExists = $f->getOne($entity['from']);
     $toExists = $f->getOne($entity['to']);
     if (!empty($fromExists) && !empty($toExists)) {
         $pars = array();
         $pars[':uniacid'] = $_W['uniacid'];
         $pars[':from'] = $rec['from'];
         $pars[':to'] = $rec['to'];
         $sqll = 'SELECT * FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `from`=:from AND `to` =:to';
         $exists = pdo_fetch($sqll, $pars);
         if (!empty($exists)) {
             return error(-3, '已经助力过了');
         }
         $ret = pdo_insert('mbrp_helps', $rec);
         if (!empty($ret)) {
             return pdo_insertid();
         } else {
             return error(-2, '数据保存失败, 请稍后重试');
         }
     } else {
         return error(-1, '用户不存在');
     }
 }
Example #2
0
class Microb_ShakeModuleSite extends WeModuleSite
{
    protected function auth()
    {
        global $_W;
        #return array('uid' => '1', 'gender' => '男', 'state' => '山西', 'city' => '太原');
        #debug
        session_start();
        $openid = $_SESSION['__:proxy:openid'];
        require_once MB_ROOT . '/source/Fans.class.php';
        $f = new Fans();
        if (!empty($openid)) {
            $exists = $f->getOne($openid, true);
            if (!empty($exists)) {
                return $exists;
            }
        }
        $api = $this->module['config']['api'];
        if (empty($api)) {
            message('系统还未开放');
        }
        $callback = $_W['siteroot'] . 'app' . substr($this->createMobileUrl('auth'), 1);
        $callback = urlencode($callback);
        $state = $_SERVER['REQUEST_URI'];
        $_SESSION['__:proxy:forward'] = $state;
        $forward = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$api['appid']}&redirect_uri={$callback}&response_type=code&scope=snsapi_userinfo&state=#wechat_redirect";
        header('Location: ' . $forward);
Example #3
0
 /**
  * 增加一次助力记录
  *      如果owner, helper 已经存在, 失败
  *   id uniacid owner helper dateline
  *
  * @param $entity 助力结构 owner, helper, dateline
  * @return int|error
  */
 public function createHelp($entity)
 {
     global $_W;
     $rec = array_elements(array('owner', 'helper', 'dateline'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $rec['activity'] = $this->activity['actid'];
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $ownerExists = $f->getOne($entity['owner']);
     $helperExists = $f->getOne($entity['helper']);
     if (!empty($ownerExists) && !empty($helperExists)) {
         $pars = array();
         $pars[':uniacid'] = $_W['uniacid'];
         $pars[':activity'] = $this->activity['actid'];
         $pars[':helper'] = $rec['helper'];
         if (!empty($this->activity['tag']['limit'])) {
             $sql = 'SELECT COUNT(*) FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `helper` =:helper';
             $count = pdo_fetchcolumn($sql, $pars);
             if ($this->activity['tag']['limit'] <= $count) {
                 return error(-1, "超过次数限制, 本次活动限制每人帮助好友次数不能超过 {$this->activity['tag']['limit']} 次");
             }
         }
         $pars[':owner'] = $rec['owner'];
         $sql = 'SELECT * FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `owner`=:owner AND `helper` =:helper';
         $exists = pdo_fetch($sql, $pars);
         if (!empty($exists)) {
             return error(-3, '已经帮助过这位好友了');
         }
         $ret = pdo_insert('mbrp_helps', $rec);
         if (!empty($ret)) {
             return pdo_insertid();
         } else {
             return error(-2, '数据保存失败, 请稍后重试');
         }
     } else {
         return error(-1, '用户不存在');
     }
 }
Example #4
0
require_once MB_ROOT . '/source/Activity.class.php';
require_once MB_ROOT . '/source/Fans.class.php';
require_once MB_ROOT . '/source/Shared.class.php';
$a = new Activity();
$f = new Fans();
$user = $this->auth();
$id = $_GPC['actid'];
$id = intval($id);
$activity = $a->getOne($id);
$prepare = $this->prepareActivity($activity, array('user' => $user));
if (is_error($prepare)) {
    header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid'])));
    exit;
}
$uid = intval($_GPC['owner']);
$owner = $f->getOne($uid);
if (empty($owner)) {
    message('访问错误', $activity['guide'], 'info');
}
if ($owner['uid'] == $user['uid']) {
    header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid'])));
    exit;
}
require_once MB_ROOT . '/source/Shared.class.php';
$s = new Shared($activity);
if ($_W['ispost']) {
    $input = array();
    $input['owner'] = $owner['uid'];
    $input['helper'] = $user['uid'];
    $input['dateline'] = TIMESTAMP;
    $ret = $s->createHelp($input);
Example #5
0
 public function doWebRedSend()
 {
     global $_W, $_GPC;
     require_once WWX_FXXT_ROOT . '/class/Fans.class.php';
     $f = new Fans();
     $uid = intval($_GPC['uid']);
     $user = $f->getOne($uid);
     /**FANS:3.根据用户UID或OPENID查询记录中的用户信息**/
     if (empty($user)) {
         exit('错误的访问');
     }
     $ret = $this->redsend($user);
     if (is_error($ret)) {
         exit($ret['message']);
     } else {
         exit('success');
     }
 }
Example #6
0
 public function doWebSend()
 {
     global $_W, $_GPC;
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $uid = intval($_GPC['uid']);
     $user = $f->getOne($uid);
     if (empty($user)) {
         exit('错误的访问');
     }
     $activity = $this->getActivity(true, array('user' => $user));
     if (is_error($activity)) {
         message($activity['message']);
     }
     $ret = $this->send($user);
     if (is_error($ret)) {
         exit($ret['message']);
     } else {
         exit('success');
     }
 }
Example #7
0
    if (!empty($profile)) {
        exit('success');
    }
}
if ($foo == 'history') {
    require_once MB_ROOT . '/source/Activity.class.php';
    $id = $_GPC['actid'];
    $id = intval($id);
    $a = new Activity();
    $activity = $a->getOne($id);
    if ($activity['type'] == 'game') {
        $filters = array();
        $filters['owner'] = $user['uid'];
        $filters['activity'] = $activity['actid'];
        $records = $a->getRecords($filters);
        include $this->template('my-game');
    }
    if ($activity['type'] == 'shared') {
        require_once MB_ROOT . '/source/Shared.class.php';
        $s = new Shared($activity);
        $filters = array();
        $filters['owner'] = $user['uid'];
        $ds = $s->getAllHelps($filters);
        if (!empty($ds)) {
            foreach ($ds as &$r) {
                $r['user'] = $f->getOne($r['helper']);
            }
        }
        include $this->template('my-shared');
    }
}