public function doWebRedActivity() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modulePublic = '../addons/wwx_fxxt/style/static/'; $foo = $_GPC['foo']; $foos = array('list', 'create', 'modify', 'delete', 'records'); $foo = in_array($foo, $foos) ? $foo : 'list'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; if ($foo == 'create') { if ($_W['ispost']) { $input = $_GPC; $input['rules'] = htmlspecialchars_decode($input['rules']); $input['start'] = strtotime($input['time']['start'] . ':00'); $input['end'] = strtotime($input['time']['end'] . ':59'); $input['share'] = serialize($input['share']); $input['limit'] = serialize($input['limit']); if ($input['type'] == 'game') { $input['tag'] = serialize($input['game']); } elseif ($input['type'] == 'shared') { $input['tag'] = serialize($input['shared']); } else { $input['tag'] = serialize($input['tag']); } $gifts = array(); foreach ($input['gifts']['id'] as $k => $v) { $gifts[] = array('gift' => $v, 'quantity' => $input['gifts']['quantity'][$k], 'rate' => $input['gifts']['rate'][$k]); } $a = new Activity(); $ret = $a->create($input, $gifts); /**Activity:1.保存活动**/ if (is_error($ret)) { message($ret['message']); } else { message("成功创建活动", $this->createWebUrl('redactivity')); } } $activity = array(); $time = array(); $time['start'] = date('Y-m-d 00:00'); $time['end'] = date('Y-m-d 15:00'); $activity['gifts'] = array(); $activity['type'] = 'shared'; load()->func('tpl'); include $this->template('redactivity_form'); } if ($foo == 'modify') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); /**Activity:2.根据活动ID查询活动内容及设置等**/ if (empty($activity)) { $this->error('访问错误'); } if ($_W['ispost']) { $input = $_GPC; $input['rules'] = htmlspecialchars_decode($input['rules']); $input['start'] = strtotime($input['time']['start'] . ':00'); $input['end'] = strtotime($input['time']['end'] . ':59'); $input['share'] = serialize($input['share']); $input['limit'] = serialize($input['limit']); if ($input['type'] == 'game') { $input['tag'] = serialize($input['game']); } elseif ($input['type'] == 'shared') { $input['tag'] = serialize($input['shared']); } else { $input['tag'] = serialize($input['tag']); } $gifts = array(); foreach ($input['gifts']['id'] as $k => $v) { $gifts[] = array('gift' => $v, 'quantity' => $input['gifts']['quantity'][$k], 'rate' => $input['gifts']['rate'][$k]); } $a = new Activity(); $ret = $a->modify($id, $input, $gifts); /**Activity:3.根据活动ID编辑活动内容及设置等**/ if (is_error($ret)) { message($ret['message']); } else { message("成功编辑活动", $this->createWebUrl('redactivity')); } } $time = array(); $time['start'] = date('Y-m-d H:i', $activity['start']); $time['end'] = date('Y-m-d H:i', $activity['end']); if ($activity['type'] == 'game') { $game = $activity['tag']; } elseif ($activity['type'] == 'shared') { $shared = $activity['tag']; } load()->func('tpl'); include $this->template('redactivity_form'); } if ($foo == 'records') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); /**Activity:2.根据活动ID查询活动内容及设置等**/ if (empty($activity)) { $this->error('访问错误'); } $filters = array(); $filters['activity'] = $id; $filters['nickname'] = $_GPC['nickname']; $pindex = intval($_GPC['page']); $pindex = max($pindex, 1); $psize = 20; $total = 0; $ds = $a->getRecords($filters, $pindex, $psize, $total); /**Activity:4.分页活动列表**/ $pager = pagination($total, $pindex, $psize); include $this->template('redactivity_records'); } if ($foo == 'delete') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $ret = $a->remove($id); /**Activity:5.删除活动**/ if (is_error($ret)) { message($ret['message']); } else { message('操作成功', $this->createWebUrl('redactivity')); } } if ($foo == 'list') { $a = new Activity(); $ds = $a->getAll(array()); /**Activity:6.查询所有活动**/ if (is_array($ds)) { foreach ($ds as &$row) { $url = $this->createMobileUrl('redactivity', array('actid' => $row['actid'])); $row['surl'] = $url; $url = substr($url, 2); $url = $_W['siteroot'] . 'app/' . $url; $row['url'] = $url; $row['count'] = $a->calcCount($row['actid']); /**Activity:7.查询活动礼品信息:总数量、已发放、还剩余。**/ } unset($row); } include $this->template('redactivity_list'); } }
$prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { $error = $prepare; } $footer_off = true; $_W['page']['title'] = $activity['title']; $_share = array(); $_share['title'] = $activity['share']['title']; $_share['desc'] = $activity['share']['content']; $_share['imgUrl'] = tomedia($activity['share']['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('activity', array('actid' => $activity['actid'])), 2); $got = $a->getRecord($user['uid'], $id); $filters = array(); $filters['activity'] = $id; $filters['status'] = 'complete'; $recents = $a->getRecords($filters, 1, 5, $total); if ($activity['type'] == 'direct') { //直接发红包 include $this->template('activity-direct'); } if ($activity['type'] == 'game') { //红包游戏 require_once MB_ROOT . '/source/Game.class.php'; $g = new Game(); $game = $activity['tag']; $game['quantity'] = $g->calcQuantity($activity['actid'], $user['uid']); $game['already'] = !empty($got); include $this->template('activity-game'); } if ($activity['type'] == 'shared') { $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('shared', array('actid' => $activity['actid'], 'owner' => $user['uid'])), 2);
$profile = $f->getProfile($user['uid']); 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'); }
if ($foo == 'records') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if (empty($activity)) { $this->error('访问错误'); } $filters = array(); $filters['activity'] = $id; $filters['nickname'] = $_GPC['nickname']; $pindex = intval($_GPC['page']); $pindex = max($pindex, 1); $psize = 15; $total = 0; $ds = $a->getRecords($filters, $pindex, $psize, $total); $pager = pagination($total, $pindex, $psize); include $this->template('activity-records'); } if ($foo == 'delete') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $ret = $a->remove($id); if (is_error($ret)) { message($ret['message']); } else { message('操作成功', $this->createWebUrl('activity')); } } if ($foo == 'list') {