Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 public function getUserByPKPoint()
 {
     $oUser = new Lm_User();
     $table_name = Base_Widget::getDbTable($this->character_rank);
     $sql = "select distinct(ServerId) as ServerId from {$table_name}";
     $ServerList = $this->db->getAll($sql);
     foreach ($ServerList as $key => $value) {
         $sql = "select * from {$table_name} where ServerId = " . $value['ServerId'] . " order by PKPoint desc limit 1000";
         $ResultAll = $this->db->getAll($sql);
         $PKPointAll[$value['ServerId']] = array();
         foreach ($ResultAll as $k => $v) {
             $PKPointAll[$value['ServerId']][$k + 1] = $v;
             $UserInfo = $oUser->getCharacterInfoByUser($v['UserId'], 'UserName');
             if (isset($UserInfo['UserName'])) {
                 $PKPointAll[$value['ServerId']][$k + 1]['UserName'] = $UserInfo['UserName'];
             } else {
                 $PKPointAll[$value['ServerId']][$k + 1]['UserName'] = 0;
             }
         }
     }
     $file_path = "/www/web_usercenter/app/etc/";
     $file_name = "PKPoint.php";
     $var = var_export($PKPointAll, true);
     $text = '<?php $PKPointAll=' . $var . '; return $PKPointAll;?>';
     file_put_contents($file_path . $file_name, $text);
     $file_name = "PKPoint-" . date("YmdHis", time()) . ".php";
     file_put_contents($file_path . $file_name, $text);
 }