Skip to content

Commit

Permalink
Version 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtyredz committed Jun 16, 2017
1 parent bdeaad8 commit d3d636c
Show file tree
Hide file tree
Showing 30 changed files with 401 additions and 18 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions avorion-manager/AllianceData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$AllianceData = array(
);
53 changes: 53 additions & 0 deletions avorion-manager/GetAllianceData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
cd "${0%/*}"
cd ".."
#Log to manager.log
echo -e -n $(date +"%F %H-%M-00| ") >> ${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 "<?php" > $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
4 changes: 3 additions & 1 deletion avorion-manager/GetPlayerData.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" )
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions avorion-manager/PHPConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions avorion-manager/core/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function __construct(){
//Get the database and store it in $Login
include __DIR__ .'/../Database.php';
$this->Login = $Login;
$this->Secret = "";
}

/**
Expand Down
4 changes: 3 additions & 1 deletion avorion-manager/core/RefreshModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '^<Rusty>' | sed -e 's/.*</\&lt;/g' -e 's/>/\&gt;/g' -e 's/^/<span>/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 '| <Rusty>' | sed -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/^/<span>/g' -e 's/$/<\/span>/g' -e 's/<span>....-..-.. /<span>/g'`;
$ChatLog .= `grep '^<.*>' $(find {$this->Config['LogsDir']}/*_playerchat.log -mtime -1 ) | tac | grep -v '^<Rusty>' | sed -e 's/.*</\&lt;/g' -e 's/>/\&gt;/g' -e 's/^/<span>/g' -e 's/$/<\/span>/g'`;
return $ChatLog;
}

Expand Down
8 changes: 8 additions & 0 deletions avorion-manager/core/ServerConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
50 changes: 46 additions & 4 deletions avorion-manager/core/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = '';
Expand Down Expand Up @@ -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'] = '';
}
Expand Down Expand Up @@ -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']){
Expand All @@ -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'){
Expand All @@ -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
Expand All @@ -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');
}
Expand Down
16 changes: 16 additions & 0 deletions avorion-manager/views/About.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
<br/>
<br/>
<h3>CHANGE LOG:</h3>
<h4>1.1.4</h4>
Fixed player flags</br>
Replaced grep command with php for loop in player list of home page</br>
Added timestamp to home screen chatlog of Current server session(since last restart)</br>
Added a "Send To All" button on the mail form.</br>
Added Alliance Parsing</br>
Added Alliance page</br>
Added Alliance config options to PHPConfig.ini</br>
Added Alliance to Players page</br>
Added Alliance To players parser</br>
Added Alliance Parser to cron job</br>
Added manager-config options to adjust cronjob times for data parser scripts</br>
</br>
<h4>1.1.3</h4>
Fixed Variable name in manager for default IPAddress</br>
</br>
<h4>1.1.2</h4>
Removed Hostname from manager</br>
</br>
Expand Down
Loading

0 comments on commit d3d636c

Please sign in to comment.