function display($args) { $show = array_get_default($args, 'show', 'home'); $page = null; foreach ($this->pages as $page) { if ($page['name'] == $show) { break; } } if (!$page) { $show = 'home'; $main_show = 'home'; } else { $main_show = array_key_exists('parent', $page) ? $page['parent'] : $show; } $args['show'] = $show; // Go to monitor if no id is specified $id = array_get_default($args, 'id', ''); if ($id == '') { header('Location: ../?' . http_build_query($args)); exit; } // Display menu $menu = $this->display_menu($main_show); $this->append(ax_ul_items($menu, array('id' => 'tablist'))); foreach ($this->forms as $form) { if ($form['name'] == $show) { break; } } if (!$form or $form['name'] != $show) { return; } $title = $form['descr']; $form = new $form['class']($args); if ($form->get_data($id)) { // Editing existing entity $title .= " {$id}"; } else { // Adding new entity $form->set_control_value('id', ''); $id = ""; unset($args['id']); $title .= " (new)"; } if (Request::is_post()) { $form->fill($_POST); $msg = $form->save_data(); $id = $form->get_control_value('id'); $form->get_data($id); if ($msg != "") { $this->append(ax_p($msg)); } } $fr = new AnewtFormRendererDefault(); $fr->set_form($form); $this->append(ax_h2($title)); $this->append($fr); }
public function login_condition(Request $request) { if ($request->user() instanceof OpenpearMaintainer) { return true; } if ($request->is_post() && $request->is_vars('login') && $request->is_vars('password')) { try { $user = C(OpenpearMaintainer)->find_get(Q::ob(Q::b(Q::eq('name', $request->in_vars('login'))), Q::b(Q::eq('mail', $request->in_vars('login'))))); if ($user instanceof OpenpearMaintainer) { if ($user->certify($request->in_vars('password'))) { $request->user($user); return true; } else { Exceptions::add(new Exception('password is incorrect'), 'password'); } } } catch (Exception $e) { Log::debug($e); } } return false; }
/** * 提交地址 * * @param Request $request * @param Response $response */ function post_address(Request $request, Response $response) { $uid = $GLOBALS['user']->uid; if ($request->is_post()) { //送花奖励阶梯 $sendmoney_phases = [30, 50, 100]; $address_id = $request->post('address_id', 0); $match_id = $request->post('match_id', 0); $player_id = $request->post('player_id', 0); $order_id = $request->post('order_id', 0); $sendmoney = $request->post('sendmoney', 0); $backurl = $request->post('backurl', 0); $consignee = $request->post('consignee', ''); $mobile = $request->post('mobile', ''); $province = $request->post('province', 0); $city = $request->post('city', 0); $address = $request->post('address', ''); $zipcode = $request->post('zipcode', ''); $res = ['flag' => 'FAIL', 'msg' => '', 'match_id' => $match_id, 'backurl' => $backurl]; if (empty($uid)) { $res['msg'] = '未登录,请先登录'; $response->sendJSON($res); } if ('' == $consignee) { $res['msg'] = '姓名不能为空'; $response->sendJSON($res); } if ('' == $mobile) { $res['msg'] = '手机不能为空'; $response->sendJSON($res); } elseif (!preg_match('/^\\d{11,14}$/', $mobile)) { $res['msg'] = '手机号码不正确'; $response->sendJSON($res); } if (empty($province)) { $res['msg'] = '身份地址不能为空'; $response->sendJSON($res); } $province_name = Match_Model::getLocationName($province); if (empty($city)) { $res['msg'] = '城市地址不能为空'; $response->sendJSON($res); } $city_name = Match_Model::getLocationName($city); if ('' == $address) { $res['msg'] = '详细地址不能为空'; $response->sendJSON($res); } if ('' != $zipcode && !preg_match('/^\\d{6}$/', $zipcode)) { $res['msg'] = '邮政编码不正确'; $response->sendJSON($res); } $tbname = 'member_address'; $tbdata = ['address_name' => '', 'user_id' => $uid, 'consignee' => $consignee, 'country' => 2, 'country_name' => '中国', 'province' => $province, 'province_name' => $province_name, 'city' => $city, 'city_name' => $city_name, 'district' => 0, 'district_name' => '', 'address' => $address, 'zipcode' => $zipcode, 'mobile' => $mobile]; if (!$address_id) { // Insert mode $address_id = D()->insert($tbname, $tbdata); } else { // Edit mode D()->update($tbname, $tbdata, ['address_id' => $address_id]); } //送奖品记录 if ($address_id && $sendmoney >= $sendmoney_phases[0] && $player_id && $order_id) { $phasemoney = $sendmoney_phases[0]; if ($sendmoney >= $sendmoney_phases[1] && $sendmoney < $sendmoney_phases[2]) { $phasemoney = $sendmoney_phases[1]; } elseif ($sendmoney >= $sendmoney_phases[2]) { $phasemoney = $sendmoney_phases[2]; } $tbdata = ['user_id' => $uid, 'address_id' => $address_id, 'player_id' => $player_id, 'order_id' => $order_id, 'phase_money' => $phasemoney, 'true_money' => $sendmoney, 'timeline' => simphp_time()]; $rid = D()->from("member_giftpay")->where("`user_id`=%d AND `player_id`=%d AND `order_id`=%d", $uid, $player_id, $order_id)->select('`rid`')->result(); if (!$rid) { //一个订单只有没有生成过记录时才记录,避免重复 D()->insert('member_giftpay', $tbdata); } else { $res['flag'] = 'SUC'; $res['msg'] = '当前订单之前申请过礼物,不能重复申请'; $response->sendJSON($res); } } $res['flag'] = 'SUC'; $res['msg'] = '地址保存成功!'; $response->sendJSON($res); } else { $this->v->set_tplname('mod_match_post_address'); $this->v->set_page_render_mode(View::RENDER_MODE_GENERAL); $this->nav_flag1 = 'match_address'; $this->topnav_no = 1; $match_id = $request->arg(1); $sendmoney = $request->get('sendmoney', 0); $player_id = $request->get('player_id', 0); $order_id = $request->get('order_id', 0); $backurl = $request->get('backurl', ''); $this->v->assign('match_id', $match_id); $this->v->assign('player_id', $player_id); $this->v->assign('order_id', $order_id); $this->v->assign('sendmoney', $sendmoney); $this->v->assign('backurl', $backurl); $player_info = Match_Model::getPlayerInfo($player_id); $this->v->assign('player_info', $player_info); $user_address = Match_Model::getUserAddress($uid); $this->v->assign('user_address', $user_address); $province = Match_Model::getProvinces(); $this->v->assign('province', $province); $city_html = '<option value="0">选择城市▼</option>'; if (!empty($user_address)) { $cities = Match_Model::getCities($user_address['province']); $selected = ''; foreach ($cities as $loc) { if ($loc['locaid'] == $user_address['city']) { $selected = ' selected="selected"'; } else { $selected = ''; } $city_html .= '<option value="' . $loc['locaid'] . '"' . $selected . '>' . $loc['location'] . '</option>'; } } $this->v->assign('city_html', $city_html); $seo = ['title' => '地址上传', 'keyword' => '', 'desc' => '']; $this->v->assign('seo', $seo); $response->send($this->v); } }
public function collect_cancel(Request $request, Response $response) { if ($request->is_post()) { $res = ['flag' => 'FAIL', 'msg' => '取消失败']; $ec_user_id = $GLOBALS['user']->ec_user_id; if (!$ec_user_id) { $res['msg'] = '未登录, 请登录'; $response->sendJSON($res); } $rec_id = $request->post('rec_id', 0); if (!$rec_id) { $res['msg'] = '记录id为空'; $response->sendJSON($res); } $b = Goods::goodsCollectCancel($rec_id); if ($b) { $res = ['flag' => 'SUC', 'msg' => '取消成功']; } $response->sendJSON($res); } }
function is_post() { return Request::is_post(); }
/** * action 'import' * @param Request $request * @param Response $response */ public function import(Request $request, Response $response) { if ($request->is_post()) { $source_id = $request->post('source_id'); $source_url = $request->post('source_url'); $ret = ['flag' => 'ERR', 'msg' => '']; if (!$source_id || !in_array($source_id, Node_Model::getSourceList('music', true))) { $ret['msg'] = '请选择有效的来源'; $response->sendJSON($ret); } if (!$source_url || !preg_match('!^http://.{4,}!i', $source_url)) { $ret['msg'] = '请输入有效的URL地址'; $response->sendJSON($ret); } Node_Model::importMusic($source_id, $source_url); $ret = ['flag' => 'OK', 'msg' => '导入成功!']; $response->sendJSON($ret); } else { // Node Info $import_ntype = $request->arg(2); $this->v->assign('nav_second', $import_ntype); // Music Source List $sourceList = Node_Model::getSourceList('music'); $this->v->set_tplname('mod_node_import'); $this->v->assign('sourceList', $sourceList); $response->send($this->v); } }
/** * Fill form automatically from query data. If the form uses the GET method * the data comes from <code>$_GET</code>. If the form uses the POST method * the data comes from <code>$_POST</code>. * * The return value (see also fill() for an explanation) can be used to * detect incomplete \c $_GET or \c $_POST values. This may happen when * handling different form flavours with different controls using a single * form, e.g. a simple and advanced search form pointing to the same page in * which an instance of the advanced flavour of the form handles the * submitted data. It may also happen when users are messing with the * submitted data. You may then decide to process() the form only if all * values were provided. Example: * <code>if ($form->autofill() && $form->process()) { ...} else { ...}</code> * * \return * True if this fill could be automatically filled from \c $_GET or \c * $_POST, false if this was not the case. * * \see AnewtForm::fill() */ function autofill() { $form_method = $this->_get('method'); if (Request::is_get() && $form_method == ANEWT_FORM_METHOD_GET) { return $this->fill($_GET); } elseif (Request::is_post() && $form_method == ANEWT_FORM_METHOD_POST) { return $this->fill($_POST); } return false; }
/** * tips页显示 * @param Request $request * @param Response $response */ public function order_topay(Request $request, Response $response) { if ($request->is_post()) { global $user; if (!$user->uid) { Fn::show_error_message('未登录,请先登录'); } $this->v = new PageView('', 'topay'); $pay_mode = $request->post('pay_mode', 'wxpay'); //默认微信支付 $order_id = $request->post('order_id', 0); $back_url = $request->post('back_url', ''); $supported_paymode = ['wxpay' => '微信安全支付', 'alipay' => '支付宝支付']; if (!in_array($pay_mode, array_keys($supported_paymode))) { Fn::show_error_message('不支持该支付方式: ' . $pay_mode); } if (!$order_id) { Fn::show_error_message('订单为空'); } $order_info = Order::info($order_id); if (empty($order_info)) { Fn::show_error_message('订单不存在'); } else { $order_info['order_goods'] = Goods::getOrderGoods($order_info['order_id']); if (empty($order_info['order_goods'])) { Fn::show_error_message('订单下没有对应商品'); } } if ('wxpay' == $pay_mode) { $jsApiParams = Wxpay::unifiedOrder($order_info, $user->openid); $this->v->assign('jsApiParams', $jsApiParams); } $this->v->assign('pay_mode', $pay_mode); $this->v->assign('supported_paymode', $supported_paymode); $this->v->assign('back_url', $back_url); $response->send($this->v); } else { Fn::show_error_message('非法访问'); } }
/** * action 'player_delete' * @param Request $request * @param Response $response */ public function player_delete(Request $request, Response $response) { if ($request->is_post()) { $ids = $request->post('rids'); $ret = Member_Model::deletePlayers($ids); $response->sendJSON(['flag' => 'OK', 'rids' => $ret]); } }
if (empty($_POST['current_dir'])) { $current_dir = ''; } else { $current_dir = replace_dangerous_char(trim($_POST['current_dir']), 'strict'); } $uncompress = 1; /* * Check the request method in place of a variable from POST * because if the file size exceed the maximum file upload * size set in php.ini, all variables from POST are cleared ! */ $user_file = Request::is_post() ? Request::file('user_file') : array(); $user_file = $user_file ? $user_file : array(); $is_error = isset($user_file['error']) ? $user_file['error'] : false; if (Request::is_post() && $is_error) { return api_failure::set_failure('upload_file_too_big'); unset($_FILES['user_file']); } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) { // A file upload has been detected, now deal with the file... // Directory creation. $stopping_error = false; $s = $_FILES['user_file']['name']; // Get name of the zip file without the extension. $info = pathinfo($s); $filename = $info['basename']; $extension = $info['extension']; $file_base_name = str_replace('.'.$extension, '', $filename);
public function ad_del(Request $request, Response $response) { if ($request->is_post()) { $ids = $request->post('rids'); $ret = Other_Model::deleteAdList($ids); $response->sendJSON(['flag' => 'OK', 'rids' => $ret]); } }
$page = new AnewtPage(); $page->set('title', 'Anewt form test page'); $page->add_stylesheet(ax_stylesheet($css)); $page->append(ax_h1('Test form')); $form = new TestForm(); assert('$form->get_control_value("text5") === "7"'); $form->set_control_value('text5', '8'); if ($form->autofill()) { if ($form->process()) { $page->append(ax_p('Form succesfully processed!')); } else { $page->append(ax_p('Error while processing form!')); } } else { $page->append(ax_p('Form not processed.')); } $fr = new AnewtFormRendererDefault(); $fr->set_form($form); $page->append(ax_h2('The form')); $page->append($fr); if (Request::is_post()) { $values = $form->get_control_values(); ob_start(); var_dump($values); $values = ob_get_clean(); $page->append(ax_h2('Form output')); $page->append(ax_pre($values)); $page->append(ax_h2('$_POST values')); $page->append(ax_pre(print_r($_POST, true))); } $page->flush();
/** * 更新关联数据的排序值 * @param Request $request [description] * @param Response $response [description] * @return [type] [description] */ public function relatedRank(Request $request, Response $response) { if ($request->is_post()) { $res = ['flag' => 'FAIL', 'msg' => '']; $aid = $request->post('aid', ''); $nid = $request->post('nid', ''); $new_rank = $request->post('new_rank', 0); if (Activity_Model::updateRelatedRank($aid, $nid, $new_rank)) { $res['flag'] = 'SUC'; $res['msg'] = '更新成功'; } else { $res['msg'] = '系统繁忙,请稍后再试'; } $response->sendJSON($res); } }