diff --git a/CHANGELOG b/CHANGELOG index 059c4af..7e02b2c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,19 @@ +1.1.4 + Fixed player flags + Replaced grep command with php for loop in player list of home page + Added timestamp to home screen chatlog of Current server session(since last restart) + Added a "Send To All" button on the mail form. + Added Alliance Parsing + Added Alliance page + Added Alliance config options to PHPConfig.ini + Added Alliance to Players page + Added Alliance To players parser + Added Alliance Parser to cron job + Added manager-config options to adjust cronjob times for data parser scripts + +1.1.3 + Fixed Variable name in manager for default IPAddress + 1.1.2 Removed Hostname from manager diff --git a/avorion-manager/AllianceData.php b/avorion-manager/AllianceData.php new file mode 100644 index 0000000..5c1e179 --- /dev/null +++ b/avorion-manager/AllianceData.php @@ -0,0 +1,3 @@ +> ${PWD}/avorion-manager/logs/$(/bin/date +\%d-\%m-\%Y)_manager.log +echo -e '[Manager]: Starting GetAllianceData()' >> ${PWD}/avorion-manager/logs/$(/bin/date +\%d-\%m-\%Y)_manager.log +#Settup TMP file +AllianceDataTmp=${PWD}/avorion-manager/AllianceData.tmp +DIR="$1" +#COUNT=0 +GALAXYNAME=$(grep GALAXY ${PWD}/manager-config.ini | sed -e 's/.*=//g' -e 's/\r//g') +echo " $AllianceDataTmp; +echo "\$AllianceData = array(" >> $AllianceDataTmp; +for i in {1..5000} +do + file=${DIR}/${GALAXYNAME}/alliances/alliance_$i.dat.0 + [ -e "$file" ] || continue + file=$(ls -t ${DIR}/${GALAXYNAME}/alliances/alliance_$i.dat.* | head -1) + [ -e "$file" ] || continue + dd if=$file bs=1 skip=44 of=${file}.tmp > /dev/null 2>&1 + php -f ${PWD}/avorion-manager/zlib_Uncompress.php "${file}.tmp" "AllianceUncompressed.tmp" + rm ${file}.tmp + OriginalFile=$file + file=AllianceUncompressed.tmp + NameStart=$(grep -b -a -o -P 'name' "${file}" | sed 's/:.*//' | head -n1) + if [ "${NameStart}" ]; then + ID=$(echo $OriginalFile | sed -e 's/.*_//g' -e 's/.dat.*//g') + Name=$(xxd -ps -l 50 -seek "$((${NameStart} + 16 ))" "${file}" | xxd -r -p | head -n1) + LeaderStart=$(grep -b -a -o -P 'leader' "${file}" | sed 's/:.*//' | head -n1) + Leader=$(xxd -ps -l 4 -seek "$((${LeaderStart} + 11 ))" "${file}") + + MoneyStart=$(grep -b -a -o -P 'money64' "${file}" | sed 's/:.*//' | head -n1) + Money=$(xxd -ps -l 4 -seek "$((${MoneyStart} + 15 ))" "${file}" ) + + StartingPosition=$(grep -b -a -o -P 'resources640' "${file}" | sed 's/:.*//' | tail -n1) + + Iron=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 20 ))" "${file}" ) + Titanium=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 52 ))" "${file}" ) + Naonite=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 84 ))" "${file}" ) + Trinium=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 116 ))" "${file}" ) + Xanion=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 148 ))" "${file}" ) + Ogonite=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 180 ))" "${file}" ) + Avorion=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 211 ))" "${file}" ) + echo "array(\"ID\" => \"$ID\",\"Name\" => \"$Name\",\"Leader\" => \"$Leader\",\"Money\" => \"$Money\",\"Iron\" => \"$Iron\",\"Titanium\" => \"$Titanium\",\"Naonite\" => \"$Naonite\",\"Trinium\" => \"$Trinium\",\"Xanion\" => \"$Xanion\",\"Ogonite\" => \"$Ogonite\",\"Avorion\" => \"$Avorion\")," >> $AllianceDataTmp; + fi +done +echo ");" >> $AllianceDataTmp; +[ -e ${PWD}/avorion-manager/AllianceData.php ] && rm ${PWD}/avorion-manager/AllianceData.php +cp $AllianceDataTmp ${PWD}/avorion-manager/AllianceData.php +rm $AllianceDataTmp +rm $file +echo -e -n $(date +"%F %H-%M-00| ") >> ${PWD}/avorion-manager/logs/$(/bin/date +\%d-\%m-\%Y)_manager.log +echo -e '[Manager]: Completed GetAllianceData()' >> ${PWD}/avorion-manager/logs/$(/bin/date +\%d-\%m-\%Y)_manager.log diff --git a/avorion-manager/GetPlayerData.sh b/avorion-manager/GetPlayerData.sh index d98f121..b1d6029 100644 --- a/avorion-manager/GetPlayerData.sh +++ b/avorion-manager/GetPlayerData.sh @@ -53,6 +53,8 @@ do #Were seen in console add today LastSeen=$(/bin/date +\%Y-\%m-\%d) fi + AllianceStart=$(grep -b -a -o -P 'alliance' "${file}" | sed 's/:.*//' | head -n1) + Alliance=$(xxd -ps -l 1 -seek "$((${AllianceStart} + 16 ))" "${file}") StartingPosition=$(grep -b -a -o -P 'play_time' "${file}" | sed 's/:.*//' | tail -n1) SteamID=$(xxd -ps -l 8 -seek "$((${StartingPosition} - 39 ))" "${file}" ) Money=$(xxd -ps -l 4 -seek "$((${StartingPosition} - 12 ))" "${file}" ) @@ -64,7 +66,7 @@ do Ogonite=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 205 ))" "${file}" ) Avorion=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 237 ))" "${file}" ) PlayTime=$(xxd -ps -l 4 -seek "$((${StartingPosition} + 17 ))" "${file}" ) - echo "array(\"ID\" => \"$ID\",\"Name\" => \"$Name\",\"LastSeen\" => \"$LastSeen\",\"Group\" => \"$Group\",\"SteamID\" => \"$SteamID\",\"PlayTime\" => \"$PlayTime\",\"Money\" => \"$Money\",\"Iron\" => \"$Iron\",\"Titanium\" => \"$Titanium\",\"Naonite\" => \"$Naonite\",\"Trinium\" => \"$Trinium\",\"Xanion\" => \"$Xanion\",\"Ogonite\" => \"$Ogonite\",\"Avorion\" => \"$Avorion\")," >> $PlayerDataTmp; + echo "array(\"ID\" => \"$ID\",\"Name\" => \"$Name\",\"Alliance\" => \"$Alliance\",\"LastSeen\" => \"$LastSeen\",\"Group\" => \"$Group\",\"SteamID\" => \"$SteamID\",\"PlayTime\" => \"$PlayTime\",\"Money\" => \"$Money\",\"Iron\" => \"$Iron\",\"Titanium\" => \"$Titanium\",\"Naonite\" => \"$Naonite\",\"Trinium\" => \"$Trinium\",\"Xanion\" => \"$Xanion\",\"Ogonite\" => \"$Ogonite\",\"Avorion\" => \"$Avorion\")," >> $PlayerDataTmp; fi done echo ");" >> $PlayerDataTmp; diff --git a/avorion-manager/PHPConfig.ini b/avorion-manager/PHPConfig.ini index af92ec0..626d138 100644 --- a/avorion-manager/PHPConfig.ini +++ b/avorion-manager/PHPConfig.ini @@ -32,6 +32,8 @@ AccessGraphsPage=0 AccessUserManagmentPage=30 ;The role level required to view the Space Invaders page. (0=public) AccessSpaceInvadersPage=0 +;The role level required to view the Alliances page. (0=public) +AccessAlliancePage=0 ;The role level required to view the Chat log on the home page. (0=public) HomeChatLog=0 ;The role level required to view the Players list on the home page. (0=public) @@ -58,6 +60,8 @@ ConsoleStopCommand=50 ChatLogInput=20 ;The role level required to view extra details on the players page. (0=public) AccessDetailedPlayerData=20 +;The role level required to view extra details on the alliance page. (0=public) +AccessDetailedAllianceData=20 ;The role level required to change the server.ini file via the config page. (0=public) ChangeServerINI=50 ;The role level required to change the manager-config.ini file via the config page. (0=public) diff --git a/avorion-manager/core/AccountModel.php b/avorion-manager/core/AccountModel.php index 49c9d0e..25ea694 100644 --- a/avorion-manager/core/AccountModel.php +++ b/avorion-manager/core/AccountModel.php @@ -12,6 +12,7 @@ function __construct(){ //Get the database and store it in $Login include __DIR__ .'/../Database.php'; $this->Login = $Login; + $this->Secret = ""; } /** diff --git a/avorion-manager/core/RefreshModel.php b/avorion-manager/core/RefreshModel.php index 90b4354..9901b95 100644 --- a/avorion-manager/core/RefreshModel.php +++ b/avorion-manager/core/RefreshModel.php @@ -718,7 +718,9 @@ public function GetConsoleData() public function GetChatLog() { //Potentall config option to only grab the last x lines instead of everything - $ChatLog = `grep '^<.*>' $(find {$this->Config['LogsDir']}/*_playerchat.log -mtime -1 ) {$this->Config['ConsoleLog']} | tac | grep -v '^' | sed -e 's/.*/\>/g' -e 's/^//g' -e 's/$/<\/span>/g'`; + $PID = `pidof $(grep SERVER= {$this->Config['Manager']} | sed -e 's/.*=//g') | tr -d '\n'`; + $ChatLog = `grep -e '^....-..-.. ..-..-..| <..*>' -e '^....-..-.. ..-..-..| <> \[.*\]' /proc/"{$PID}"/fd/3 | tac | grep -v '| ' | sed -e 's//\>/g' -e 's/^//g' -e 's/$/<\/span>/g' -e 's/....-..-.. //g'`; + $ChatLog .= `grep '^<.*>' $(find {$this->Config['LogsDir']}/*_playerchat.log -mtime -1 ) | tac | grep -v '^' | sed -e 's/.*/\>/g' -e 's/^//g' -e 's/$/<\/span>/g'`; return $ChatLog; } diff --git a/avorion-manager/core/ServerConfigController.php b/avorion-manager/core/ServerConfigController.php index 069cf4b..556970a 100644 --- a/avorion-manager/core/ServerConfigController.php +++ b/avorion-manager/core/ServerConfigController.php @@ -69,6 +69,10 @@ class ServerConfigController extends CommonController 'Definition' => 'The role level required to view the Space Invaders page. (0=public)', 'Type' => 'number', 'Range' => array('min'=>0,'max'=>99)), + 'AccessAlliancePage' => array( + 'Definition' => 'The role level required to view the Alliances page. (0=public)', + 'Type' => 'number', + 'Range' => array('min'=>0,'max'=>99)), 'HomeChatLog' => array( 'Definition' => 'The role level required to view the Chat log on the home page. (0=public)', 'Type' => 'number', @@ -121,6 +125,10 @@ class ServerConfigController extends CommonController 'Definition' => 'The role level required to view extra details on the players page. (0=public)', 'Type' => 'number', 'Range' => array('min'=>0,'max'=>99)), + 'AccessDetailedAllianceData' => array( + 'Definition' => 'The role level required to view extra details on the alliance page. (0=public)', + 'Type' => 'number', + 'Range' => array('min'=>0,'max'=>99)), 'ChangeServerINI' => array( 'Definition' => 'The role level required to change the server.ini file via the config page. (0=public)', 'Type' => 'number', diff --git a/avorion-manager/core/ViewController.php b/avorion-manager/core/ViewController.php index 314529c..809b7cf 100644 --- a/avorion-manager/core/ViewController.php +++ b/avorion-manager/core/ViewController.php @@ -71,6 +71,7 @@ public function Index() $this->Data['AccessDiscoveredMapPage'] = 'Disabled'; $this->Data['AccessFactionsMapPage'] = 'Disabled'; $this->Data['AccessSpaceInvadersPage'] = 'Disabled'; + $this->Data['AccessAlliancePage'] = 'Disabled'; $this->Data['Username'] = ''; @@ -100,6 +101,10 @@ public function Index() $this->Data['ConsoleAccess'] = ''; } //role is required to be greater then config option, otherwise do not display + if($this->RoleAccess($this->Config['AccessAlliancePage'])){//Role required for specific feature + $this->Data['AccessAlliancePage'] = ''; + } + //role is required to be greater then config option, otherwise do not display if($this->RoleAccess($this->Config['AccessServerConfigPage'])){//Role required for specific feature $this->Data['AccessServerConfigPage'] = ''; } @@ -537,7 +542,7 @@ public function Home() $this->Data['CustomMessageTwo'] = $this->Config['HomeCustomMessageTwo']; $this->Data['CustomMessageThree'] = $this->Config['HomeCustomMessageThree']; $this->Data['CustomMessageFour'] = $this->Config['HomeCustomMessageFour']; - $this->Data['GalaxyName'] = $this->ManagerConfig['GALAXY'];//`grep GALAXY {$this->Config['ManagerConfig']} | sed -e 's/.*=//g'`; + $this->Data['GalaxyName'] = $this->ManagerConfig['GALAXY']; //Check if pid status is available, display online if pid is available $this->Data['OnlineStatus'] = `if [ $(pidof $(grep SERVER= {$this->Config['Manager']} | sed -e 's/.*=//g')) > /dev/null ]; then echo 'Online'; else echo 'Offline'; fi | tr -d '[:space:]'`; if($this->Data['ShowDiskUsage']){ @@ -547,15 +552,23 @@ public function Home() //Grab last Online Players report $OnlinePlayers = explode(", ",`tac {$this->Config['ConsoleLog']} | grep 'online players (' | head -n 1 | sed -e 's/.*://g' -e 's/^.//g' -e 's/.$//g'`); $NewOnlinePlayers = array(); - $PID = `pidof $(grep SERVER= {$this->Config['Manager']} | tr -d '\n'`; + $PID = `pidof $(grep SERVER= {$this->Config['Manager']} | sed -e 's/.*=//g') | tr -d '\n'`; //Grab all Player IP's connected to server during this uptime of server $ConnectionList = `awk "/Connection accepted from/,/joined the galaxy/" /proc/"{$PID}"/fd/3 | grep 'accepted\|joined' | sed -e 's/.*> //g' -e 's/ joined.*//g' -e 's/.*from //g' -e 's/:.*//g'`; + $ConnectionList = explode(PHP_EOL, $ConnectionList); + if(strlen($OnlinePlayers[0]) > 1){ //assign Online Players to IP address and connect with geoplugin to detect country status foreach ($OnlinePlayers as $key => $value) { $Name = str_replace("\n", '', $value); - $TempName = quotemeta(str_replace("\n", '', $value)); - $IP = `echo "{$ConnectionList}" | grep -B1 -e "{$TempName}" | head -n1 | tr -d '\n'`; + //$TempName = quotemeta(str_replace("\n", '', $value)); + //$IP = `echo "{$ConnectionList}" | grep -B1 -e "{$TempName}" | head -n1 | tr -d '\n'`; + foreach ($ConnectionList as $key => $value) { + if($Name == $value){ + //error_log($Name.' - '.$ConnectionList[$key-1]); + $IP = $ConnectionList[$key-1]; + } + } $NewOnlinePlayers[$Name]['IP'] = $IP; $GEO = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$IP)); if($GEO['geoplugin_status'] == '404'){ @@ -578,6 +591,32 @@ public function Home() $this->LoadView('Home'); } + /** + * Loads and displays the alliance page + * @method Alliances + * @return void + */ + public function Alliances() + { + //Role required in comparison to the config, if not redirect + $this->RoleRequired($this->Config['AccessAlliancePage']); + //if config option is accessible via config + if($this->RoleAccess($this->Config['AccessDetailedAllianceData'])){ + //Log and assigns boolean to page to display more data + $this->LogMessage('Extra Alliance Data Granted.'); + $this->Data['AccessGranted'] = true; + }else{ + $this->Data['AccessGranted'] = false; + } + include __DIR__ ."/../PlayerData.php"; + $this->Data['PlayerData'] = $PlayerData; + //Includes the AllianceData.php page, and pass to the page + include __DIR__ ."/../AllianceData.php"; + $this->Data['AllianceData'] = $AllianceData; + //Loads the page + $this->LoadView('Alliances'); + } + /** * Loads and displays the players page * @method Players @@ -598,6 +637,9 @@ public function Players() //Includes the PlayerData.php page, and pass to the page include __DIR__ ."/../PlayerData.php"; $this->Data['PlayerData'] = $PlayerData; + //Includes the AllianceData.php page, and pass to the page + include __DIR__ ."/../AllianceData.php"; + $this->Data['AllianceData'] = $AllianceData; //Loads the page $this->LoadView('Players'); } diff --git a/avorion-manager/views/About.php b/avorion-manager/views/About.php index abee9e2..5baa0e6 100644 --- a/avorion-manager/views/About.php +++ b/avorion-manager/views/About.php @@ -22,6 +22,22 @@

CHANGE LOG:

+

1.1.4

+ Fixed player flags
+ Replaced grep command with php for loop in player list of home page
+ Added timestamp to home screen chatlog of Current server session(since last restart)
+ Added a "Send To All" button on the mail form.
+ Added Alliance Parsing
+ Added Alliance page
+ Added Alliance config options to PHPConfig.ini
+ Added Alliance to Players page
+ Added Alliance To players parser
+ Added Alliance Parser to cron job
+ Added manager-config options to adjust cronjob times for data parser scripts
+
+

1.1.3

+ Fixed Variable name in manager for default IPAddress
+

1.1.2

Removed Hostname from manager

diff --git a/avorion-manager/views/Alliances.php b/avorion-manager/views/Alliances.php new file mode 100644 index 0000000..e7bd36d --- /dev/null +++ b/avorion-manager/views/Alliances.php @@ -0,0 +1,149 @@ + +
PLAYERS
+
+ +
+ +
+
+Click Column Head to sort. +
+ + + + + + + + + + + + + + + + + + + + + + $value) { + echo ''; + + echo ''; + $Leader = implode('',array_reverse(str_split($value['Leader'],2))); + $Leader = base_convert($Leader[0].$Leader[1],16,10); + $NumberOfPlayers = 0; + foreach ($Data['PlayerData'] as $PlayerArray => $Player) { + if($Player['ID'] == $Leader){ + echo ''; + } + $AllianceID = base_convert(implode('',array_reverse(str_split($Player['Alliance'],2))),16,10); + if($AllianceID == $value['ID']){ + $NumberOfPlayers +=1; + } + } + echo ''; + + $Money = base_convert(implode('',array_reverse(str_split($value['Money'],2))),16,10); + $Iron = base_convert(implode('',array_reverse(str_split($value['Iron'],2))),16,10); + $Titanium = base_convert(implode('',array_reverse(str_split($value['Titanium'],2))),16,10); + $Naonite = base_convert(implode('',array_reverse(str_split($value['Naonite'],2))),16,10); + $Trinium = base_convert(implode('',array_reverse(str_split($value['Trinium'],2))),16,10); + $Xanion = base_convert(implode('',array_reverse(str_split($value['Xanion'],2))),16,10); + $Ogonite = base_convert(implode('',array_reverse(str_split($value['Ogonite'],2))),16,10); + $Avorion = base_convert(implode('',array_reverse(str_split($value['Avorion'],2))),16,10); + $NetWorth = $Money + ($Iron * 0.740741) + ($Titanium * 1) + ($Naonite * 1.35) + ($Trinium * 1.8225) + ($Xanion * 2.46038) + ($Ogonite * 3.32151) + ($Avorion * 4.48903); + echo ''; + if($Data['AccessGranted']) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + } + ?> + +
NameLeader# PlayersNet WorthIDMoneyIronTitaniumNaoniteTriniumXanionOgoniteAvorion
'.$value['Name'].''.$Player['Name'].''.$NumberOfPlayers.''.floor($NetWorth).''.$value['ID'].''.$Money.''.$Iron.''.$Titanium.''.$Naonite.''.$Trinium.''.$Xanion.''.$Ogonite.''.$Avorion.'
+ diff --git a/avorion-manager/views/Console.php b/avorion-manager/views/Console.php index 5f1c8d7..474ba00 100644 --- a/avorion-manager/views/Console.php +++ b/avorion-manager/views/Console.php @@ -1,5 +1,7 @@ + +