function getRankLogAction() { $ServerId = trim($this->request->ServerId); $oCharacter = new Lm_Character(); $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php"); $ServerInfo = $ServerList[$ServerId]; if ($ServerInfo['ServerId']) { $filename = $ServerInfo['AppId'] . '/' . $ServerInfo['PartnerId'] . '/' . $ServerInfo['ServerId'] . '/' . date('Y-m-d', time()) . '/accbrief58.log'; $logurl = '/gamelog/'; $filename = $logurl . $filename; echo $filename . "\n"; $file = fopen($filename, 'r'); if ($file) { $succeed = 0; $fail = 0; $count = 0; $oCharacter->truncateUserCharacterRankList(); while ($content = fgets($file, filesize($filename))) { $count++; $arr = explode(",", $content); if (is_numeric($arr[0])) { $CharacterInfoUser = $oCharacter->getCharacterInfoByUser($arr[0], $ServerInfo['ServerId']); $CharacterInfoName = $oCharacter->getCharacterInfoByCharacter(iconv('GBK', 'UTF-8', htmlspecialchars(trim($arr[1]))), $ServerInfo['ServerId']); if (count($CharacterInfoUser) < 1 || count($CharacterInfoName) < 1) { $Character['UserId'] = trim($arr[0]); $Character['CharacterName'] = iconv('GBK', 'UTF-8', htmlspecialchars(trim($arr[1]))); $Character['ServerId'] = $ServerInfo['ServerId']; $Character['AppId'] = $ServerInfo['AppId']; $Character['PartnerId'] = $ServerInfo['PartnerId']; $Character['CharacterLevel'] = 1; $Character['CharacterCreateTime'] = trim($arr[10]); $insertLog = $oCharacter->CreateCharacter($Character); echo "insert:" . $insertLog . "\n"; } else { $updateLog = $oCharacter->updateCharacterInfo($arr[0], $ServerInfo['ServerId'], array("CharacterLevel" => $arr[4], "Comment" => json_encode(array('FightingCapacity' => $arr[2], 'Capacity' => $arr[3], 'PKPoint' => $arr[9])), "CharacterName" => iconv('GBK', 'UTF-8', htmlspecialchars(trim($arr[1]))))); echo "update:" . $updateLog . "\n"; } $Uarr = array('UserId' => $arr[0], 'ServerId' => $ServerId, 'CharacterName' => iconv('GBK', 'UTF-8', htmlspecialchars(trim($arr[1]))), 'FightingCapacity' => $arr[2], 'Capacity' => $arr[3], 'CharacterLevel' => $arr[4], 'PKPoint' => $arr[9]); $insert = $oCharacter->insertUserCharacterRankList($Uarr); echo "insertRank:" . $insert . "\n"; if ($insert) { $succeed++; } else { $fail++; } } else { continue; } } } echo $succeed . "-" . $fail; fclose($file); //根据战斗力和生命值 将用户排名写入配置文件 $oCharacter->getUserByFightRank(); $oCharacter->getUserByLiveRank(); $oCharacter->getUserByPKPoint(); } }
public function SocketCreateCharacter($buff) { $oCharacter = new Lm_Character(); $oUser = new Lm_User(); $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php"); $format = "V1uLength/V1uID/v1Type/C1MsgLevel/C1Line/V1UserID/V1ZoneID/C*"; $unpackArr = @unpack($format, $buff); $arrName = ""; foreach ($unpackArr as $key => $value) { if (is_int($key)) { $arrName .= chr($value); } } $Character['UserId'] = $unpackArr['UserID']; $Character['CharacterName'] = str_replace("", "", iconv('GBK', 'UTF-8//IGNORE', $arrName)); $Character['ServerId'] = $unpackArr['ZoneID']; $Character['CharacterLevel'] = 1; $Character['CharacterCreateTime'] = time(); if ($Character['UserId']) { //验证用户名有效性 if (strlen($Character['CharacterName']) >= 4 && strlen($Character['CharacterName']) <= 20) { //查询用户 $UserInfo = $oUser->GetUserById($Character['UserId']); if ($UserInfo['UserId']) { //判断用户所选服务器大区是否存在 $ServerInfo = $ServerList[$Character['ServerId']]; if ($ServerInfo['ServerId']) { $Character['AppId'] = $ServerInfo['AppId']; $Character['PartnerId'] = $ServerInfo['PartnerId']; $CharacterInfo = $oCharacter->getCharacterInfoByUser($Character['UserId'], $Character['ServerId']); if (count($CharacterInfo) == 0) { $AddLog = $oCharacter->CreateCharacter($Character); if ($AddLog) { $result = array('return' => 1, 'comment' => "角色创建成功"); } else { $result = array('return' => 0, 'comment' => "角色创建失败"); } } else { $result = array('return' => 0, 'comment' => "您已经在此服务器有角色,无法重复创建"); } } else { $result = array('return' => 0, 'comment' => "您所选择的服务器不存在"); } } else { $result = array('return' => 2, 'comment' => "无此用户"); } } else { $result = array('return' => 0, 'comment' => "请输入合法的用户名"); } } else { $result = array('return' => 0, 'comment' => "请选择用户"); } return $result; }