public function handle_request() { $apf = APF::get_instance(); $objRequest = $apf->get_request(); $objResponse = $apf->get_response(); $deem = $apf->get_config('deem', 'common'); $vote_to_id = $objRequest->get_parameter('id'); $guid = $objRequest->get_guid(); $user_id = $objRequest->getUserId(); $broker_id = $objRequest->getBrokerId(); $client_ip = $objRequest->get_client_ip(); $ajk = $objRequest->get_parameter('ajk'); $md5 = md5(md5($vote_to_id . $guid) . 'chinagoodbroker'); $arr = array(); if ((strpos($_SERVER['HTTP_REFERER'], 'goodbroker/index') || strpos($_SERVER['HTTP_REFERER'], 'goodbroker/show')) && $ajk == $md5 && $guid && $_POST && time() < strtotime($deem)) { if ($vote_to_id == $broker_id) { $arr['msg1'] = '不能给自己投票哟,邀请好友来支持你吧~'; $arr['msg2'] = ''; $arr['msg3'] = ''; $arr['code'] = '1'; } else { $dao = new Bll_Goodbroker(); $res = $dao->getVotelog()->getVotes($guid); if ($res >= 10) { $arr['msg1'] = '对不起,不能再投啦~'; $arr['msg2'] = '您今天的投票数已超过10票,明天再来吧。'; $arr['code'] = '2'; } else { $res = $dao->getVotelog()->getVotes($guid, $vote_to_id); if ($res >= 1) { $arr['msg1'] = '对不起,不能再投啦~'; $arr['msg2'] = '您已经为该经纪人投过票了,明天再来吧。'; $arr['code'] = '3'; } else { $res = $dao->getInfoDAO()->updateVotes($vote_to_id); if ($res) { $dao->getVotelog()->setVotes($user_id, $guid, $vote_to_id, $client_ip); $arr['msg'] = '投票成功'; $arr['code'] = '4'; } else { $arr['msg1'] = '投票失败'; $arr['code'] = '5'; } } } } } else { $arr['msg1'] = '抱歉,暂时不能投票~'; $arr['msg2'] = ''; $arr['msg3'] = ''; $arr['code'] = '1'; } $objResponse->set_content_type('application/json'); echo json_encode($arr); return false; }
public function handle_request() { $apf = APF::get_instance(); $request = $apf->get_request(); $params = $request->get_parameters(); $baseDomain = $apf->get_config('base_domain', 'common'); $baseUri = defined('BASE_URI') ? BASE_URI : ''; $indexUrl = "http://my.{$baseDomain}{$baseUri}/goodbroker/index"; $showUrl = "http://my.{$baseDomain}{$baseUri}/goodbroker/show"; $guid = $request->get_guid(); $per = 16; $page = isset($params[Const_Listing::PARAM_N_PAGE]) && intval($params[Const_Listing::PARAM_N_PAGE]) > 0 ? intval($params[Const_Listing::PARAM_N_PAGE]) : 1; $daBaseinfo = Model_Goodbroker_Baseinfo::data_access()->filter('is_verify', 1); $daTotal = clone $daBaseinfo; if (time() < strtotime(date('2014-03-24'))) { $sort = isset($params['s']) ? $params['s'] : 'n'; } else { $sort = isset($params['s']) ? $params['s'] : 'h'; } if ($sort == 'n') { $Baseinfo = $daBaseinfo->limit($per)->offset(($page - 1) * $per)->sort('create_time', 'DESC')->find_all(); } else { $Baseinfo = $daBaseinfo->limit($per)->offset(($page - 1) * $per)->sort('votes', 'DESC')->find_all(); } $bllgoodbroker = new Bll_Goodbroker(); $votelog = $bllgoodbroker->getVotelog(); $brokers = ''; $votes = array(); if (!empty($Baseinfo)) { foreach ($Baseinfo as $row) { $brokers .= intval($row->broker_id) . ','; } $brokers = substr($brokers, 0, -1); $isvotes = $votelog->getVotesByUser($guid, $brokers); foreach ($isvotes as $row) { $votes[$row['broker_id']]['id'] = $row['id']; } } $total = $daTotal->count(); $pager = Util_MultiPager::multiPage($params, '', $total, $per, 5, $indexUrl); $request->set_attribute('page', $page); $request->set_attribute('pager', $pager); $request->set_attribute('showPager', $total > $per); $request->set_attribute('showUrl', $showUrl); $request->set_attribute('indexUrl', $indexUrl); $request->set_attribute('baseinfo', $Baseinfo); $request->set_attribute('votes', $votes); $request->set_attribute('sort', $sort); return 'Goodbroker_Index'; }