/** * 检测宣言内容是否合法 * @param unknown $introduce */ protected function check_introduce($introduce) { if ($introduce) { $introduceLen = Com_Filter::get_length($introduce); if ($introduceLen > 280) { //长度不符 $this->throw_error('170108'); } else { if (is_numeric($introduce)) { //不为纯数字){ $this->throw_error('10238'); } else { if (!Com_Filter::check_badWord($introduce)) { //内容不合法 $this->throw_error('170109'); } } } } }
// url_msg_redirect("您填写的昵称长度不合法!!","/active.php"); if ($bAjax) { exit("result=0&msg=" . $arrLanguage["10215"]['content']); } else { Com_System::url_redirect($webUrl . "/active.php?e_code=-17"); } } if (preg_match($nknamePattern, $name)) { // url_msg_redirect("您填写的昵称不合法!!","/active.php"); if ($bAjax) { exit("result=0&msg=" . $arrLanguage["10214"]['content']); } else { Com_System::url_redirect($webUrl . "/active.php?e_code=-16"); } } if (!Com_Filter::check_badWord($name)) { // url_msg_redirect("您填写的昵称不合法!!","/active.php"); if ($bAjax) { exit("result=0&msg=" . $arrLanguage["10214"]['content']); } else { Com_System::url_redirect($webUrl . "/active.php?e_code=-16"); } } if (is_numeric($name)) { // url_msg_redirect("您填写的昵称不合法!!","/active.php"); if ($bAjax) { exit("result=0&msg=" . $arrLanguage["10214"]['content']); } else { Com_System::url_redirect($webUrl . "/active.php?e_code=-16"); } }
/** * 编辑签名 * @param $player_id 玩家id * @param $signature 签名 */ public function edit_signature($player_id, $signature) { $is_success = 1; $objplayer = $this->get_data('Player'); $signature = strval(trim($signature)); $size = (strlen($signature) + mb_strlen($signature, 'UTF8')) / 2; if ($size > 26) { $is_success = 0; } else { if ($signature) { $signature = Com_Filter::check_badWord_replace($signature); } $this->start_trans(); $ret = $objplayer->update_player_info($player_id, array('signature' => $signature)); if ($ret) { $this->commit(); } else { $this->rollback(); $is_success = 0; } } if ($is_success == 0) { $signature = $objplayer->get_player_info($player_id, 'signature'); } $data = array($signature, $is_success); return $data; }
public function check_exact_param($cost_gold, $red_num, $message) { if ($cost_gold > 9999) { $this->throw_error('1744001'); } if ($cost_gold <= 0) { $this->throw_error('20004'); } if ($red_num <= 0) { $this->throw_error('1744003'); } if ($red_num > 15) { $this->throw_error('1744002'); } if ($red_num > $cost_gold) { $this->throw_error('1744005'); } $message = trim($message); $len = Com_Filter::get_length($message); if ($len > 50) { $this->throw_error('10219'); } else { if (is_numeric($message)) { //不为纯数字){ $this->throw_error('10238'); } else { if (!Com_Filter::check_badWord($message)) { //内容不合法 $this->throw_error('10220'); } } } }
/** * @Purpose: * 更改精灵名称 * @param $player_id 玩家ID * @param $fairy_id 精灵ID * @param $fairy_name 新的精灵名称 */ public function set_fairy_name($player_id, $fairy_id, $fairy_name) { $player_id = intval($player_id); $fairy_name = strval($fairy_name); //获取指定类型精灵配置表数据 $fairy_list_table = $this->get_fairy_table_data_by_type(1); if (!$fairy_list_table[0]['change_name_expend']) { $this->throw_error('10109'); //配置表读取错误 } list($prop_id, $prop_num) = explode(":", $fairy_list_table[0]['change_name_expend']); $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'ticket', 'gold', 'silver', 'privilege_level')); $arr_consume = array(); if ($prop_id > 0 && $prop_num > 0) { if ($prop_id == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $prop_num); } else { if ($prop_id == 2) { $deduct_coin = 0; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] < $prop_num) { $deduct_coin = $player_info['ticket']; } else { $deduct_coin = $prop_num; } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $deduct_coin); } if ($deduct_coin < $prop_num) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $prop_num - $deduct_coin); } $arr_consume = array('price' => $prop_num, 'gold' => $prop_num - $deduct_coin, 'ticket' => $deduct_coin, 'count' => 1); #数据中心推送 } else { //获取玩家背包道具 $player_prop_num = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, $prop_id); if ($player_prop_num < $prop_num) { $this->throw_error('80011'); #道具不足 } } } } else { $this->throw_error('10111'); #配置表配置错误 } #检测新名字合法性 if (empty($fairy_name) || Com_Filter::check_str($fairy_name, 3, 12) != 1 || is_numeric($fairy_name)) { $this->throw_error('10220'); #内容不合法 } //获取玩家精灵数据 $obj_player_fairy_data = $this->get_data('Fairy'); $data = $obj_player_fairy_data->get_player_fairy_info($fairy_id); if (!$data) { $this->throw_error('10112'); //获取精灵信息失败 } $update_data['name'] = $fairy_name; $this->start_trans(); if ($prop_id == 2 || $prop_id == 3) { if ($prop_num > 0) { $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 534, array(), $arr_consume); if (!$update_res) { $this->throw_error('10104'); } } } else { if ($prop_id > 0 && $prop_num > 0) { $log_param = array('cmd_id' => 534, 'level' => $player_info['level'], 'vip' => $player_info['vip']); $arr_log = array(); $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop_id, $prop_num, $arr_log, 1, $log_param); } } $update_res = $this->get_data('Fairy')->update_player_fairy($fairy_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } $this->commit(); if ($data['type'] == 1) { Protocol_Player::p2c_part_update($player_id, array('light_fairy_name' => $fairy_name)); } else { if ($data['type'] == 2) { Protocol_Player::p2c_part_update($player_id, array('dark_fairy_name' => $fairy_name)); } } return array($fairy_name); }