Пример #1
0
 public function removeSentLog($Serial, $ProductId, $Result)
 {
     $ProductQueue = $this->getProductQueue(trim($Serial), $ProductId);
     if ($ProductQueue['SendId']) {
         $ProductQueue['SentTime'] = time();
         unset($ProductQueue['ToSendTime']);
         if ($Result == 0) {
             $ProductQueue['SendStatus'] = 1;
         } else {
             $ProductQueue['SendStatus'] = 2;
         }
         $table_date = $this->createUserProductSendLogTable(date("Ym", $ProductQueue['SentTime']));
         $oCharacter = new Lm_Character();
         $User = $oCharacter->insertCharacterProductSendLog($ProductQueue['UserId'], $ProductQueue);
         if ($User) {
             $this->db->begin();
             $Date = $this->db->replace($table_date, $ProductQueue);
             $remove = $this->deleteProductQueue(trim($Serial), $ProductId);
             echo $Date . "-" . $remove . "\n";
             if ($Date && $remove) {
                 $this->db->commit();
                 return true;
             } else {
                 $this->db->rollback();
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #2
0
 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();
     }
 }
Пример #3
0
 public function getUserByPvpRank($Name)
 {
     $table_name = Base_Widget::getDbTable($this->table_pvp_log_total);
     $sql = "select distinct(ServerId) as ServerId from {$table_name}";
     $ServerList = $this->db->getAll($sql);
     $oCharacter = new Lm_Character();
     $oUser = new Lm_User();
     foreach ($ServerList as $key => $value) {
         $sql = "select sum(if(Won=1,10*PvpCount,if(Won=0,2*PvpCount,if(Won=3,-10*PvpCount,0)))) as PvpPoint,UserId from {$table_name} where ServerId = " . $value['ServerId'] . " group by UserId order by PvpPoint desc limit 1000";
         $sql = "select UserId,Sum(Point) as PvpPoint from (select (if(Won=1,10*PvpCount,if(Won=0,2*PvpCount,if(Won=3,-10*PvpCount,0)))) as Point,UserId,Won from {$table_name} where ServerId = " . $value['ServerId'] . ") as log group by UserId Order by PvpPoint Desc";
         $ResultAll = $this->db->getAll($sql);
         $PvpAll[$value['ServerId']] = array();
         foreach ($ResultAll as $k => $v) {
             $PvpRankAll[$value['ServerId']][$k + 1] = $v;
             $CharacterInfo = $oCharacter->getCharacterInfoByUser($v['UserId'], $value['ServerId'], 'CharacterName');
             $UserInfo = $oUser->getCharacterInfoByUser($v['UserId'], 'UserName');
             if (isset($CharacterInfo['0'])) {
                 $PvpRankAll[$value['ServerId']][$k + 1]['CharacterName'] = $CharacterInfo['0']['CharacterName'];
             } else {
                 $PvpRankAll[$value['ServerId']][$k + 1]['CharacterName'] = 0;
             }
             if (isset($UserInfo['UserName'])) {
                 $PvpRankAll[$value['ServerId']][$k + 1]['UserName'] = $UserInfo['UserName'];
             } else {
                 $PvpRankAll[$value['ServerId']][$k + 1]['UserName'] = 0;
             }
         }
     }
     $file_path = "/www/web_usercenter/app/etc/";
     $file_name = "PvpRank.php";
     $var = var_export($PvpRankAll, true);
     $text = '<?php $PvpRankAll=' . $var . '; return $PvpRankAll;?>';
     file_put_contents($file_path . $file_name, $text);
     $file_name = "PvpRank-" . $Name . ".php";
     file_put_contents($file_path . $file_name, $text);
 }
Пример #4
0
 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;
 }