Browse Source

Fixed Problems

Implemented new RCON Libary and fixed much bugs. Hope it works now
master
Niklas H. 3 years ago
parent
commit
dd9a0811f5

+ 5
- 1
core/4_loginmain.php View File

@@ -5,6 +5,8 @@
{
if ($_GET[GET_ACTION_NAME] == "logout")
{
define("GROUP_ID", -1);
define("USER_ID", null);
setcookie("time",null, -1);
setcookie("login","logout", time()+60);
setcookie("key", null, time()+3600);
@@ -29,6 +31,8 @@
}
else if (!isset($_COOKIE["expire"]) XOR !isset($_COOKIE["key"]))
{
define("GROUP_ID", -1);
define("USER_ID", null);
setcookie("time",null, -1);
setcookie("key", null, time()+3600);
setcookie("lastlogin", null, -1);
@@ -39,7 +43,7 @@
else
{
define("GROUP_ID", -1);
define("USER_ID", 0);
define("USER_ID", null);
setcookie("time",null, -1);
setcookie("key", null, time()+3600);
setcookie("lastlogin", null, -1);

+ 8
- 0
error_log View File

@@ -66,3 +66,11 @@
[05-Jul-2016 20:04:48 UTC] PHP Parse error: syntax error, unexpected '=' in /home2/adm22958/test/websitetest/system/anzeigebig.php on line 37
[05-Jul-2016 20:05:04 UTC] PHP Parse error: syntax error, unexpected '=' in /home2/adm22958/test/websitetest/system/anzeigebig.php on line 91
[05-Jul-2016 20:36:21 UTC] PHP Parse error: syntax error, unexpected '{' in /home2/adm22958/test/websitetest/system/main.php on line 101
[07-Aug-2016 10:21:07 UTC] PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home2/adm22958/test/system/main.php on line 335
[07-Aug-2016 11:07:42 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (Europa/Berlin)' in /home2/adm22958/test/system/payments.php:13
Stack trace:
#0 /home2/adm22958/test/system/payments.php(13): DateTimeZone->__construct('Europa/Berlin')
#1 /home2/adm22958/test/system/main.php(57): include('/home2/adm22958...')
#2 /home2/adm22958/test/index.php(123): include_once('/home2/adm22958...')
#3 {main}
thrown in /home2/adm22958/test/system/payments.php on line 13

+ 2
- 2
index.php View File

@@ -1,9 +1,9 @@
<?php
ERROR_REPORTING(0);
ERROR_REPORTING(E_ALL & ~E_NOTICE);
define("SCRIPT_VALID", "Is Valid");
// ATTENTION: PLEASE EDIT THIS LINE TO GET THE RIGHT URL
define("BASE_URL", "http://$_SERVER[HTTP_HOST]/");
define("BASE_URL", "http://$_SERVER[HTTP_HOST]/EXTDonationsSystem/");
foreach(glob("settings/*.php") as $pathname)
{

+ 5
- 5
settings/settings.php View File

@@ -12,11 +12,11 @@ define("DATABASE_PASSWORD", "");
/*Der Datenbankname*/
define("DATABASE_DATABASE", "donate");

/*RCON Settings */
define( 'SQ_SERVER_ADDR', '127.0.0.1' );
define( 'SQ_SERVER_PORT', 25575);
define( 'SQ_TIMEOUT', 1);
define('RCON_PW', "test1234");
$rconhost = '127.0.0.1'; // Server host name or IP
$rconport = 25575; // Port rcon is listening on
$rconpassword = 'test1234'; // rcon.password setting set in server.properties
$rcontimeout = 3; // How long to timeout.

/*Welcher Name soll Verwendet werden um ein Modul zu starten in den GET-Parametern*/
define("GET_MODULE_NAME", "module");

+ 150
- 18
system/Rcon.php View File

@@ -1,29 +1,161 @@
<?php
require __DIR__ . '/SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;
/**
* See https://developer.valvesoftware.com/wiki/Source_RCON_Protocol for
* more information about Source RCON Packets
*
* @copyright 2013 Chris Churchwell
*/
class Rcon {
function sendcommand($command) {// For the sake of this example
Header( 'X-Content-Type-Options: nosniff' );
private $host;
private $port;
private $password;
private $timeout;
private $socket;
private $authorized;
private $last_response;
const PACKET_AUTHORIZE = 5;
const PACKET_COMMAND = 6;
const SERVERDATA_AUTH = 3;
const SERVERDATA_AUTH_RESPONSE = 2;
const SERVERDATA_EXECCOMMAND = 2;
const SERVERDATA_RESPONSE_VALUE = 0;
public function __construct($host, $port, $password, $timeout)
{
$this->host = $host;
$this->port = $port;
$this->password = $password;
$this->timeout = $timeout;
}
public function get_response() {
return $this->last_response;
}
public function connect() {
$this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
// Edit this ->
define( 'SQ_ENGINE', SourceQuery::SOURCE );
// Edit this <-
if (!$this->socket)
{
$this->last_response = $errstr;
return false;
}
//set timeout
stream_set_timeout($this->socket, 3, 0);
//authorize
$auth = $this->authorize();
if ($auth) {
return true;
}
return false;
}
public function disconnect()
{
if ($this->socket)
{
fclose($this->socket);
}
}
public function is_connected() {
return $this->authorized;
}
public function send_command($command)
{
if (!$this->is_connected()) return false;
$Query = new SourceQuery( );
// send command packet.
$this->write_packet(Rcon::PACKET_COMMAND, Rcon::SERVERDATA_EXECCOMMAND, $command);
try
// get response.
$response_packet = $this->read_packet();
if ($response_packet['id'] == Rcon::PACKET_COMMAND)
{
$Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$Query->SetRconPassword(RCON_PW);
$Query->Rcon( $command );
if ($response_packet['type'] == Rcon::SERVERDATA_RESPONSE_VALUE)
{
$this->last_response = $response_packet['body'];
return $response_packet['body'];
}
}
catch( Exception $e )
return false;
}
private function authorize() {
$this->write_packet(Rcon::PACKET_AUTHORIZE, Rcon::SERVERDATA_AUTH, $this->password);
$response_packet = $this->read_packet();
if ($response_packet['type'] == Rcon::SERVERDATA_AUTH_RESPONSE)
{
echo $e->getMessage( );
if ($response_packet['id'] == Rcon::PACKET_AUTHORIZE)
{
$this->authorized = true;
return true;
}
}
$Query->Disconnect( );
$this->disconnect();
return false;
}
/**
* Writes a packet to the socket stream..
*/
private function write_packet($packet_id, $packet_type, $packet_body)
{
/*
Size 32-bit little-endian Signed Integer Varies, see below.
ID 32-bit little-endian Signed Integer Varies, see below.
Type 32-bit little-endian Signed Integer Varies, see below.
Body Null-terminated ASCII String Varies, see below.
Empty String Null-terminated ASCII String 0x00
*/
//create packet
$packet = pack("VV", $packet_id, $packet_type);
$packet = $packet . $packet_body . "\x00";
$packet = $packet . "\x00";
// get packet size.
$packet_size = strlen($packet);
// attach size to packet.
$packet = pack("V", $packet_size) . $packet;
// write packet.
fwrite($this->socket, $packet, strlen($packet));
}
private function read_packet()
{
//get packet size.
$size_data = fread($this->socket, 4);
$size_pack = unpack("V1size", $size_data);
$size = $size_pack['size'];
// if size is > 4096, the response will be in multiple packets.
// this needs to be address. get more info about multi-packet responses
// from the RCON protocol specification at
// https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
// currently, this script does not support multi-packet responses.
$packet_data = fread($this->socket, $size);
$packet_pack = unpack("V1id/V1type/a*body", $packet_data);
return $packet_pack;
}
}

+ 0
- 187
system/SourceQuery/Buffer.php View File

@@ -1,187 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;

/**
* Class Buffer
*
* @package xPaw\SourceQuery
*/
class Buffer
{
/**
* Buffer
*
* @var string
*/
private $Buffer;
/**
* Buffer length
*
* @var int
*/
private $Length;
/**
* Current position in buffer
*
* @var int
*/
private $Position;
/**
* Sets buffer
*
* @param string $Buffer Buffer
*/
public function Set( $Buffer )
{
$this->Buffer = $Buffer;
$this->Length = StrLen( $Buffer );
$this->Position = 0;
}
/**
* Resets buffer
*/
public function Reset( )
{
$this->Buffer = "";
$this->Length = 0;
$this->Position = 0;
}
/**
* Get remaining bytes
*
* @return int Remaining bytes in buffer
*/
public function Remaining( )
{
return $this->Length - $this->Position;
}
/**
* Gets data from buffer
*
* @param int $Length Bytes to read
*
* @return string
*/
public function Get( $Length = -1 )
{
if( $Length === 0 )
{
return '';
}
$Remaining = $this->Remaining( );
if( $Length === -1 )
{
$Length = $Remaining;
}
else if( $Length > $Remaining )
{
return '';
}
$Data = SubStr( $this->Buffer, $this->Position, $Length );
$this->Position += $Length;
return $Data;
}
/**
* Get byte from buffer
*
* @return int
*/
public function GetByte( )
{
return Ord( $this->Get( 1 ) );
}
/**
* Get short from buffer
*
* @return int
*/
public function GetShort( )
{
$Data = UnPack( 'v', $this->Get( 2 ) );
return $Data[ 1 ];
}
/**
* Get long from buffer
*
* @return int
*/
public function GetLong( )
{
$Data = UnPack( 'l', $this->Get( 4 ) );
return $Data[ 1 ];
}
/**
* Get float from buffer
*
* @return float
*/
public function GetFloat( )
{
$Data = UnPack( 'f', $this->Get( 4 ) );
return $Data[ 1 ];
}
/**
* Get unsigned long from buffer
*
* @return int
*/
public function GetUnsignedLong( )
{
$Data = UnPack( 'V', $this->Get( 4 ) );
return $Data[ 1 ];
}
/**
* Read one string from buffer ending with null byte
*
* @return string
*/
public function GetString( )
{
$ZeroBytePosition = StrPos( $this->Buffer, "\0", $this->Position );
if( $ZeroBytePosition === false )
{
$String = "";
}
else
{
$String = $this->Get( $ZeroBytePosition - $this->Position );
$this->Position++;
}
return $String;
}
}

+ 0
- 19
system/SourceQuery/Exception/AuthenticationException.php View File

@@ -1,19 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class AuthenticationException extends SourceQueryException
{
const BAD_PASSWORD = 1;
const BANNED = 2;
}

+ 0
- 18
system/SourceQuery/Exception/InvalidArgumentException.php View File

@@ -1,18 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class InvalidArgumentException extends SourceQueryException
{
const TIMEOUT_NOT_INTEGER = 1;
}

+ 0
- 21
system/SourceQuery/Exception/InvalidPacketException.php View File

@@ -1,21 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class InvalidPacketException extends SourceQueryException
{
const PACKET_HEADER_MISMATCH = 1;
const BUFFER_EMPTY = 2;
const BUFFER_NOT_EMPTY = 3;
const CHECKSUM_MISMATCH = 4;
}

+ 0
- 18
system/SourceQuery/Exception/SocketException.php View File

@@ -1,18 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class SocketException extends SourceQueryException
{
const COULD_NOT_CREATE_SOCKET = 1;
}

+ 0
- 18
system/SourceQuery/Exception/SourceQueryException.php View File

@@ -1,18 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

abstract class SourceQueryException extends \Exception
{
// Base exception class
}

+ 0
- 18
system/SourceQuery/Exception/TimeoutException.php View File

@@ -1,18 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class TimeoutException extends SourceQueryException
{
const TIMEOUT_CONNECT = 1;
}

+ 0
- 150
system/SourceQuery/GoldSourceRcon.php View File

@@ -1,150 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;
use xPaw\SourceQuery\Exception\AuthenticationException;

/**
* Class GoldSourceRcon
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\AuthenticationException
*/
class GoldSourceRcon
{
/**
* Points to buffer class
*
* @var Buffer
*/
private $Buffer;
/**
* Points to socket class
*
* @var Socket
*/
private $Socket;
private $RconPassword;
private $RconRequestId;
private $RconChallenge;
public function __construct( $Buffer, $Socket )
{
$this->Buffer = $Buffer;
$this->Socket = $Socket;
}
public function Close( )
{
$this->RconChallenge = 0;
$this->RconRequestId = 0;
$this->RconPassword = 0;
}
public function Open( )
{
//
}
public function Write( $Header, $String = '' )
{
$Command = Pack( 'cccca*', 0xFF, 0xFF, 0xFF, 0xFF, $String );
$Length = StrLen( $Command );
return $Length === FWrite( $this->Socket->Socket, $Command, $Length );
}
/**
* @param int $Length
* @throws AuthenticationException
* @return bool
*/
public function Read( $Length = 1400 )
{
// GoldSource RCON has same structure as Query
$this->Socket->Read( );
if( $this->Buffer->GetByte( ) !== SourceQuery::S2A_RCON )
{
return false;
}
$Buffer = $this->Buffer->Get( );
$Trimmed = Trim( $Buffer );
if( $Trimmed === 'Bad rcon_password.' )
{
throw new AuthenticationException( $Trimmed, AuthenticationException::BAD_PASSWORD );
}
else if( $Trimmed === 'You have been banned from this server.' )
{
throw new AuthenticationException( $Trimmed, AuthenticationException::BANNED );
}
$ReadMore = false;
// There is no indentifier of the end, so we just need to continue reading
// TODO: Needs to be looked again, it causes timeouts
do
{
$this->Socket->Read( );
$ReadMore = $this->Buffer->Remaining( ) > 0 && $this->Buffer->GetByte( ) === SourceQuery::S2A_RCON;
if( $ReadMore )
{
$Packet = $this->Buffer->Get( );
$Buffer .= SubStr( $Packet, 0, -2 );
// Let's assume if this packet is not long enough, there are no more after this one
$ReadMore = StrLen( $Packet ) > 1000; // use 1300?
}
}
while( $ReadMore );
$this->Buffer->Set( Trim( $Buffer ) );
}
public function Command( $Command )
{
if( !$this->RconChallenge )
{
return false;
}
$this->Write( 0, 'rcon ' . $this->RconChallenge . ' "' . $this->RconPassword . '" ' . $Command . "\0" );
$this->Read( );
return $this->Buffer->Get( );
}
public function Authorize( $Password )
{
$this->RconPassword = $Password;
$this->Write( 0, 'challenge rcon' );
$this->Socket->Read( );
if( $this->Buffer->Get( 14 ) !== 'challenge rcon' )
{
return false;
}
$this->RconChallenge = Trim( $this->Buffer->Get( ) );
return true;
}
}

+ 0
- 193
system/SourceQuery/Socket.php View File

@@ -1,193 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;
use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException;

/**
* Class Socket
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
* @uses xPaw\SourceQuery\Exception\SocketException
*/
class Socket
{
public $Socket;
public $Engine;
public $Ip;
public $Port;
public $Timeout;
/**
* Points to buffer class
*
* @var Buffer
*/
private $Buffer;
public function __construct( $Buffer )
{
$this->Buffer = $Buffer;
}
public function Close( )
{
if( $this->Socket )
{
FClose( $this->Socket );
$this->Socket = null;
}
}
public function Open( $Ip, $Port, $Timeout, $Engine )
{
$this->Timeout = $Timeout;
$this->Engine = $Engine;
$this->Port = $Port;
$this->Ip = $Ip;
$this->Socket = @FSockOpen( 'udp://' . $Ip, $Port, $ErrNo, $ErrStr, $Timeout );
if( $ErrNo || $this->Socket === false )
{
throw new SocketException( 'Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET );
}
Stream_Set_Timeout( $this->Socket, $Timeout );
Stream_Set_Blocking( $this->Socket, true );
return true;
}
public function Write( $Header, $String = '' )
{
$Command = Pack( 'ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $Header, $String );
$Length = StrLen( $Command );
return $Length === FWrite( $this->Socket, $Command, $Length );
}
public function Read( $Length = 1400 )
{
$this->ReadBuffer( FRead( $this->Socket, $Length ), $Length );
}
protected function ReadBuffer( $Buffer, $Length )
{
$this->Buffer->Set( $Buffer );
if( $this->Buffer->Remaining( ) === 0 )
{
// TODO: Should we throw an exception here?
return;
}
$Header = $this->Buffer->GetLong( );
if( $Header === -1 ) // Single packet
{
// We don't have to do anything
}
else if( $Header === -2 ) // Split packet
{
$Packets = Array( );
$IsCompressed = false;
$ReadMore = false;
do
{
$RequestID = $this->Buffer->GetLong( );
switch( $this->Engine )
{
case SourceQuery::GOLDSOURCE:
{
$PacketCountAndNumber = $this->Buffer->GetByte( );
$PacketCount = $PacketCountAndNumber & 0xF;
$PacketNumber = $PacketCountAndNumber >> 4;
break;
}
case SourceQuery::SOURCE:
{
$IsCompressed = ( $RequestID & 0x80000000 ) !== 0;
$PacketCount = $this->Buffer->GetByte( );
$PacketNumber = $this->Buffer->GetByte( ) + 1;
if( $IsCompressed )
{
$this->Buffer->GetLong( ); // Split size
$PacketChecksum = $this->Buffer->GetUnsignedLong( );
}
else
{
$this->Buffer->GetShort( ); // Split size
}
break;
}
}
$Packets[ $PacketNumber ] = $this->Buffer->Get( );
$ReadMore = $PacketCount > sizeof( $Packets );
}
while( $ReadMore && $this->Sherlock( $Length ) );
$Buffer = Implode( $Packets );
// TODO: Test this
if( $IsCompressed )
{
// Let's make sure this function exists, it's not included in PHP by default
if( !Function_Exists( 'bzdecompress' ) )
{
throw new \RuntimeException( 'Received compressed packet, PHP doesn\'t have Bzip2 library installed, can\'t decompress.' );
}
$Buffer = bzdecompress( $Buffer );
if( CRC32( $Buffer ) !== $PacketChecksum )
{
throw new InvalidPacketException( 'CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH );
}
}
$this->Buffer->Set( SubStr( $Buffer, 4 ) );
}
else
{
throw new InvalidPacketException( 'Socket read: Raw packet header mismatch. (0x' . DecHex( $Header ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
}
}
private function Sherlock( $Length )
{
$Data = FRead( $this->Socket, $Length );
if( StrLen( $Data ) < 4 )
{
return false;
}
$this->Buffer->Set( $Data );
return $this->Buffer->GetLong( ) === -2;
}
}

+ 0
- 572
system/SourceQuery/SourceQuery.php View File

@@ -1,572 +0,0 @@
<?php
/**
* This class provides the public interface to the PHP-Source-Query library.
*
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*/

namespace xPaw\SourceQuery;

use xPaw\SourceQuery\Exception\InvalidArgumentException;
use xPaw\SourceQuery\Exception\TimeoutException;
use xPaw\SourceQuery\Exception\InvalidPacketException;

/**
* Class SourceQuery
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\InvalidArgumentException
* @uses xPaw\SourceQuery\Exception\TimeoutException
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
*/
class SourceQuery
{
/**
* Values returned by GetChallenge()
*
* @todo Get rid of this? Improve? Do something else?
*/
const GETCHALLENGE_FAILED = 0;
const GETCHALLENGE_ALL_CLEAR = 1;
const GETCHALLENGE_CONTAINS_ANSWER = 2;
/**
* Engines
*/
const GOLDSOURCE = 0;
const SOURCE = 1;
/**
* Packets sent
*/
const A2S_PING = 0x69;
const A2S_INFO = 0x54;
const A2S_PLAYER = 0x55;
const A2S_RULES = 0x56;
const A2S_SERVERQUERY_GETCHALLENGE = 0x57;
/**
* Packets received
*/
const S2A_PING = 0x6A;
const S2A_CHALLENGE = 0x41;
const S2A_INFO = 0x49;
const S2A_INFO_OLD = 0x6D; // Old GoldSource, HLTV uses it
const S2A_PLAYER = 0x44;
const S2A_RULES = 0x45;
const S2A_RCON = 0x6C;
/**
* Source rcon sent
*/
const SERVERDATA_EXECCOMMAND = 2;
const SERVERDATA_AUTH = 3;
/**
* Source rcon received
*/
const SERVERDATA_RESPONSE_VALUE = 0;
const SERVERDATA_AUTH_RESPONSE = 2;
/**
* Points to rcon class
*
* @var SourceRcon
*/
private $Rcon;
/**
* Points to buffer class
*
* @var Buffer
*/
private $Buffer;
/**
* Points to socket class
*
* @var Socket
*/
private $Socket;
/**
* True if connection is open, false if not
*
* @var bool
*/
private $Connected;
/**
* Contains challenge
*
* @var string
*/
private $Challenge;
/**
* Use old method for getting challenge number
*
* @var bool
*/
private $UseOldGetChallengeMethod;
public function __construct( )
{
$this->Buffer = new Buffer( );
$this->Socket = new Socket( $this->Buffer );
}
public function __destruct( )
{
$this->Disconnect( );
}
/**
* Opens connection to server
*
* @param string $Ip Server ip
* @param int $Port Server port
* @param int $Timeout Timeout period
* @param int $Engine Engine the server runs on (goldsource, source)
*
* @throws InvalidArgumentException
* @throws TimeoutException
*/
public function Connect( $Ip, $Port, $Timeout = 3, $Engine = self::SOURCE )
{
$this->Disconnect( );
if( !is_int( $Timeout ) || $Timeout < 0 )
{
throw new InvalidArgumentException( 'Timeout must be an integer.', InvalidArgumentException::TIMEOUT_NOT_INTEGER );
}
if( !$this->Socket->Open( $Ip, (int)$Port, $Timeout, (int)$Engine ) )
{
throw new TimeoutException( 'Could not connect to server.', TimeoutException::TIMEOUT_CONNECT );
}
$this->Connected = true;
}
/**
* Forces GetChallenge to use old method for challenge retrieval because some games use outdated protocol (e.g Starbound)
*
* @param bool $Value Set to true to force old method
*
* @returns bool Previous value
*/
public function SetUseOldGetChallengeMethod( $Value )
{
$Previous = $this->UseOldGetChallengeMethod;
$this->UseOldGetChallengeMethod = $Value === true;
return $Previous;
}
/**
* Closes all open connections
*/
public function Disconnect( )
{
$this->Connected = false;
$this->Challenge = 0;
$this->Buffer->Reset( );
$this->Socket->Close( );
if( $this->Rcon )
{
$this->Rcon->Close( );
$this->Rcon = null;
}
}
/**
* Sends ping packet to the server
* NOTE: This may not work on some games (TF2 for example)
*
* @return bool True on success, false on failure
*/
public function Ping( )
{
if( !$this->Connected )
{
return false;
}
$this->Socket->Write( self::A2S_PING );
$this->Socket->Read( );
return $this->Buffer->GetByte( ) === self::S2A_PING;
}
/**
* Get server information
*
* @throws InvalidPacketException
*
* @return bool|array Returns array with information on success, false on failure
*/
public function GetInfo( )
{
if( !$this->Connected )
{
return false;
}
$this->Socket->Write( self::A2S_INFO, "Source Engine Query\0" );
$this->Socket->Read( );
$Type = $this->Buffer->GetByte( );
if( $Type === 0 )
{
return false;
}
// Old GoldSource protocol, HLTV still uses it
if( $Type === self::S2A_INFO_OLD && $this->Socket->Engine === self::GOLDSOURCE )
{
/**
* If we try to read data again, and we get the result with type S2A_INFO (0x49)
* That means this server is running dproto,
* Because it sends answer for both protocols
*/
$Server[ 'Address' ] = $this->Buffer->GetString( );
$Server[ 'HostName' ] = $this->Buffer->GetString( );
$Server[ 'Map' ] = $this->Buffer->GetString( );
$Server[ 'ModDir' ] = $this->Buffer->GetString( );
$Server[ 'ModDesc' ] = $this->Buffer->GetString( );
$Server[ 'Players' ] = $this->Buffer->GetByte( );
$Server[ 'MaxPlayers' ] = $this->Buffer->GetByte( );
$Server[ 'Protocol' ] = $this->Buffer->GetByte( );
$Server[ 'Dedicated' ] = Chr( $this->Buffer->GetByte( ) );
$Server[ 'Os' ] = Chr( $this->Buffer->GetByte( ) );
$Server[ 'Password' ] = $this->Buffer->GetByte( ) === 1;
$Server[ 'IsMod' ] = $this->Buffer->GetByte( ) === 1;
if( $Server[ 'IsMod' ] )
{
$Mod[ 'Url' ] = $this->Buffer->GetString( );
$Mod[ 'Download' ] = $this->Buffer->GetString( );
$this->Buffer->Get( 1 ); // NULL byte
$Mod[ 'Version' ] = $this->Buffer->GetLong( );
$Mod[ 'Size' ] = $this->Buffer->GetLong( );
$Mod[ 'ServerSide' ] = $this->Buffer->GetByte( ) === 1;
$Mod[ 'CustomDLL' ] = $this->Buffer->GetByte( ) === 1;
}
$Server[ 'Secure' ] = $this->Buffer->GetByte( ) === 1;
$Server[ 'Bots' ] = $this->Buffer->GetByte( );
if( isset( $Mod ) )
{
$Server[ 'Mod' ] = $Mod;
}
return $Server;
}
if( $Type !== self::S2A_INFO )
{
throw new InvalidPacketException( 'GetInfo: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
}
$Server[ 'Protocol' ] = $this->Buffer->GetByte( );
$Server[ 'HostName' ] = $this->Buffer->GetString( );
$Server[ 'Map' ] = $this->Buffer->GetString( );
$Server[ 'ModDir' ] = $this->Buffer->GetString( );
$Server[ 'ModDesc' ] = $this->Buffer->GetString( );
$Server[ 'AppID' ] = $this->Buffer->GetShort( );
$Server[ 'Players' ] = $this->Buffer->GetByte( );
$Server[ 'MaxPlayers' ] = $this->Buffer->GetByte( );
$Server[ 'Bots' ] = $this->Buffer->GetByte( );
$Server[ 'Dedicated' ] = Chr( $this->Buffer->GetByte( ) );
$Server[ 'Os' ] = Chr( $this->Buffer->GetByte( ) );
$Server[ 'Password' ] = $this->Buffer->GetByte( ) === 1;
$Server[ 'Secure' ] = $this->Buffer->GetByte( ) === 1;
// The Ship (they violate query protocol spec by modifying the response)
if( $Server[ 'AppID' ] === 2400 )
{
$Server[ 'GameMode' ] = $this->Buffer->GetByte( );
$Server[ 'WitnessCount' ] = $this->Buffer->GetByte( );
$Server[ 'WitnessTime' ] = $this->Buffer->GetByte( );
}
$Server[ 'Version' ] = $this->Buffer->GetString( );
// Extra Data Flags
if( $this->Buffer->Remaining( ) > 0 )
{
$Server[ 'ExtraDataFlags' ] = $Flags = $this->Buffer->GetByte( );
// The server's game port
if( $Flags & 0x80 )
{
$Server[ 'GamePort' ] = $this->Buffer->GetShort( );
}
// The server's SteamID - does this serve any purpose?
if( $Flags & 0x10 )
{
$Server[ 'ServerID' ] = $this->Buffer->GetUnsignedLong( ) | ( $this->Buffer->GetUnsignedLong( ) << 32 ); // TODO: verify this
}
// The spectator port and then the spectator server name
if( $Flags & 0x40 )
{
$Server[ 'SpecPort' ] = $this->Buffer->GetShort( );
$Server[ 'SpecName' ] = $this->Buffer->GetString( );
}
// The game tag data string for the server
if( $Flags & 0x20 )
{
$Server[ 'GameTags' ] = $this->Buffer->GetString( );
}
// GameID -- alternative to AppID?
if( $Flags & 0x01 )
{
$Server[ 'GameID' ] = $this->Buffer->GetUnsignedLong( ) | ( $this->Buffer->GetUnsignedLong( ) << 32 );
}
if( $this->Buffer->Remaining( ) > 0 )
{
throw new InvalidPacketException( 'GetInfo: unread data? ' . $this->Buffer->Remaining( ) . ' bytes remaining in the buffer. Please report it to the library developer.',
InvalidPacketException::BUFFER_NOT_EMPTY );
}
}
return $Server;
}
/**
* Get players on the server
*
* @throws InvalidPacketException
*
* @return bool|array Returns array with players on success, false on failure
*/
public function GetPlayers( )
{
if( !$this->Connected )
{
return false;
}
switch( $this->GetChallenge( self::A2S_PLAYER, self::S2A_PLAYER ) )
{
case self::GETCHALLENGE_FAILED:
{
return false;
}
case self::GETCHALLENGE_ALL_CLEAR:
{
$this->Socket->Write( self::A2S_PLAYER, $this->Challenge );
$this->Socket->Read( 14000 ); // Moronic Arma 3 developers do not split their packets, so we have to read more data
// This violates the protocol spec, and they probably should fix it: https://developer.valvesoftware.com/wiki/Server_queries#Protocol
$Type = $this->Buffer->GetByte( );
if( $Type === 0 )
{
return false;
}
else if( $Type !== self::S2A_PLAYER )
{
throw new InvalidPacketException( 'GetPlayers: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
}
break;
}
}
$Players = Array( );
$Count = $this->Buffer->GetByte( );
while( $Count-- > 0 && $this->Buffer->Remaining( ) > 0 )
{
$Player[ 'Id' ] = $this->Buffer->GetByte( ); // PlayerID, is it just always 0?
$Player[ 'Name' ] = $this->Buffer->GetString( );
$Player[ 'Frags' ] = $this->Buffer->GetLong( );
$Player[ 'Time' ] = (int)$this->Buffer->GetFloat( );
$Player[ 'TimeF' ] = GMDate( ( $Player[ 'Time' ] > 3600 ? "H:i:s" : "i:s" ), $Player[ 'Time' ] );
$Players[ ] = $Player;
}
return $Players;
}
/**
* Get rules (cvars) from the server
*
* @throws InvalidPacketException
*
* @return bool|array Returns array with rules on success, false on failure
*/
public function GetRules( )
{
if( !$this->Connected )
{
return false;
}
switch( $this->GetChallenge( self::A2S_RULES, self::S2A_RULES ) )
{
case self::GETCHALLENGE_FAILED:
{
return false;
}
case self::GETCHALLENGE_ALL_CLEAR:
{
$this->Socket->Write( self::A2S_RULES, $this->Challenge );
$this->Socket->Read( );
$Type = $this->Buffer->GetByte( );
if( $Type === 0 )
{
return false;
}
else if( $Type !== self::S2A_RULES )
{
throw new InvalidPacketException( 'GetRules: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
}
break;
}
}
$Rules = Array( );
$Count = $this->Buffer->GetShort( );
while( $Count-- > 0 && $this->Buffer->Remaining( ) > 0 )
{
$Rule = $this->Buffer->GetString( );
$Value = $this->Buffer->GetString( );
if( !Empty( $Rule ) )
{
$Rules[ $Rule ] = $Value;
}
}
return $Rules;
}
/**
* Get challenge (used for players/rules packets)
*
* @param $Header
* @param $ExpectedResult
* @throws InvalidPacketException
* @return bool True if all went well, false if server uses old GoldSource protocol, and it already contains answer
*/
private function GetChallenge( $Header, $ExpectedResult )
{
if( $this->Challenge )
{
return self::GETCHALLENGE_ALL_CLEAR;
}
if( $this->UseOldGetChallengeMethod )
{
$Header = self::A2S_SERVERQUERY_GETCHALLENGE;
}
$this->Socket->Write( $Header, 0xFFFFFFFF );
$this->Socket->Read( );
$Type = $this->Buffer->GetByte( );
switch( $Type )
{
case self::S2A_CHALLENGE:
{
$this->Challenge = $this->Buffer->Get( 4 );
return self::GETCHALLENGE_ALL_CLEAR;
}
case $ExpectedResult:
{
// Goldsource (HLTV)
return self::GETCHALLENGE_CONTAINS_ANSWER;
}
case 0:
{
return self::GETCHALLENGE_FAILED;
}
default:
{
throw new InvalidPacketException( 'GetChallenge: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
}
}
}
/**
* Sets rcon password, for future use in Rcon()
*
* @param string $Password Rcon Password
*
* @return bool True on success, false on failure
*/
public function SetRconPassword( $Password )
{
if( !$this->Connected )
{
return false;
}
switch( $this->Socket->Engine )
{
case SourceQuery::GOLDSOURCE:
{
$this->Rcon = new GoldSourceRcon( $this->Buffer, $this->Socket );
break;
}
case SourceQuery::SOURCE:
{
$this->Rcon = new SourceRcon( $this->Buffer, $this->Socket );
break;
}
}
$this->Rcon->Open( );
return $this->Rcon->Authorize( $Password );
}
/**
* Sends a command to the server for execution.
*
* @param string $Command Command to execute
*
* @return string|bool Answer from server in string, false on failure
*/
public function Rcon( $Command )
{
if( !$this->Connected )
{
return false;
}
return $this->Rcon->Command( $Command );
}
}

+ 0
- 209
system/SourceQuery/SourceRcon.php View File

@@ -1,209 +0,0 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;
use xPaw\SourceQuery\Exception\AuthenticationException;
use xPaw\SourceQuery\Exception\TimeoutException;
use xPaw\SourceQuery\Exception\InvalidPacketException;

/**
* Class SourceRcon
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\AuthenticationException
* @uses xPaw\SourceQuery\Exception\TimeoutException
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
*/
class SourceRcon
{
/**
* Points to buffer class
*
* @var Buffer
*/
private $Buffer;
/**
* Points to socket class
*
* @var Socket
*/
private $Socket;
private $RconSocket;
private $RconRequestId;
public function __construct( $Buffer, $Socket )
{
$this->Buffer = $Buffer;
$this->Socket = $Socket;
}
public function Close( )
{
if( $this->RconSocket )
{
FClose( $this->RconSocket );
$this->RconSocket = null;
}
$this->RconRequestId = 0;
}
public function Open( )
{
if( !$this->RconSocket )
{
$this->RconSocket = @FSockOpen( $this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout );
if( $ErrNo || !$this->RconSocket )
{
throw new TimeoutException( 'Can\'t connect to RCON server: ' . $ErrStr, TimeoutException::TIMEOUT_CONNECT );
}
Stream_Set_Timeout( $this->RconSocket, $this->Socket->Timeout );
Stream_Set_Blocking( $this->RconSocket, true );
}
}
public function Write( $Header, $String = '' )
{
// Pack the packet together
$Command = Pack( 'VV', ++$this->RconRequestId, $Header ) . $String . "\x00\x00";
// Prepend packet length
$Command = Pack( 'V', StrLen( $Command ) ) . $Command;
$Length = StrLen( $Command );
return $Length === FWrite( $this->RconSocket, $Command, $Length );
}
public function Read( )
{
$this->Buffer->Set( FRead( $this->RconSocket, 4 ) );
if( $this->Buffer->Remaining( ) < 4 )
{
throw new InvalidPacketException( 'Rcon read: Failed to read any data from socket', InvalidPacketException::BUFFER_EMPTY );
}
$PacketSize = $this->Buffer->GetLong( );
$this->Buffer->Set( FRead( $this->RconSocket, $PacketSize ) );
$Buffer = $this->Buffer->Get( );
$Remaining = $PacketSize - StrLen( $Buffer );
while( $Remaining > 0 )
{
$Buffer2 = FRead( $this->RconSocket, $Remaining );
$PacketSize = StrLen( $Buffer2 );
if( $PacketSize === 0 )
{
throw new InvalidPacketException( 'Read ' . strlen( $Buffer ) . ' bytes from socket, ' . $Remaining . ' remaining', InvalidPacketException::BUFFER_EMPTY );
break;
}
$Buffer .= $Buffer2;
$Remaining -= $PacketSize;
}
$this->Buffer->Set( $Buffer );
}
public function Command( $Command )
{
$this->Write( SourceQuery::SERVERDATA_EXECCOMMAND, $Command );
$this->Read( );
$this->Buffer->GetLong( ); // RequestID
$Type = $this->Buffer->GetLong( );
if( $Type === SourceQuery::SERVERDATA_AUTH_RESPONSE )
{
throw new AuthenticationException( 'Bad rcon_password.', AuthenticationException::BAD_PASSWORD );
}
else if( $Type !== SourceQuery::SERVERDATA_RESPONSE_VALUE )
{
return false;
}
$Buffer = $this->Buffer->Get( );
// We do this stupid hack to handle split packets
// See https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses
if( StrLen( $Buffer ) >= 4000 )
{
do
{
$this->Write( SourceQuery::SERVERDATA_RESPONSE_VALUE );
$this->Read( );
$this->Buffer->GetLong( ); // RequestID
if( $this->Buffer->GetLong( ) !== SourceQuery::SERVERDATA_RESPONSE_VALUE )
{
break;
}
$Buffer2 = $this->Buffer->Get( );
if( $Buffer2 === "\x00\x01\x00\x00\x00\x00" )
{
break;
}
$Buffer .= $Buffer2;
}
while( true );
}
return rtrim( $Buffer, "\0" );
}
public function Authorize( $Password )
{
$this->Write( SourceQuery::SERVERDATA_AUTH, $Password );
$this->Read( );
$RequestID = $this->Buffer->GetLong( );
$Type = $this->Buffer->GetLong( );
// If we receive SERVERDATA_RESPONSE_VALUE, then we need to read again
// More info: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Additional_Comments
if( $Type === SourceQuery::SERVERDATA_RESPONSE_VALUE )
{
$this->Read( );
$RequestID = $this->Buffer->GetLong( );
$Type = $this->Buffer->GetLong( );
}
if( $RequestID === -1 || $Type !== SourceQuery::SERVERDATA_AUTH_RESPONSE )
{
throw new AuthenticationException( 'RCON authorization failed.', AuthenticationException::BAD_PASSWORD );
}
return true;
}
}

+ 0
- 27
system/SourceQuery/bootstrap.php View File

@@ -1,27 +0,0 @@
<?php
/**
* Library to query servers that implement Source Engine Query protocol.
*
* Special thanks to koraktor for his awesome Steam Condenser class,
* I used it as a reference at some points.
*
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*/

require_once __DIR__ . '/Exception/SourceQueryException.php';
require_once __DIR__ . '/Exception/AuthenticationException.php';
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
require_once __DIR__ . '/Exception/SocketException.php';
require_once __DIR__ . '/Exception/InvalidPacketException.php';
require_once __DIR__ . '/Exception/TimeoutException.php';

require_once __DIR__ . '/Buffer.php';
require_once __DIR__ . '/Socket.php';
require_once __DIR__ . '/SourceRcon.php';
require_once __DIR__ . '/GoldSourceRcon.php';
require_once __DIR__ . '/SourceQuery.php';

+ 10
- 0
system/addrank.php View File

@@ -34,6 +34,16 @@
$savedata->Query("UPDATE dranks SET state = '".$state."' WHERE id = '".$_GET['id']."'");
$savedata->Query("UPDATE duser SET ".$art." = '".$newamount."' WHERE id = '".USER_ID."'");
$savedata->Query(changeVocalInput("INSERT INTO changelog (id, username, changed, amount, reason, timestamp) VALUES (NULL, '".USER_ID."', '".$rank['art']."', '-".$amount."', 'Spende an: ".$rank['name']." Freischaltung', CURRENT_TIMESTAMP)"));
$getcato = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getcato->Query("SELECT * FROM catouser WHERE catoid = '".$rank['catoid']."' AND userid = '".USER_ID."'");
if ($getcato->ResultExists() AND $getcato->GetResult()[0] != null) {
$cato = $getcato->GetResult()[0];
$updatestate = $cato["state"]+$amount;
$query = "UPDATE catouser SET state = '".$updatestate."' WHERE catoid = '".$rank['catoid']."' AND userid = '".USER_ID."';";
} else {
$query = "INSERT INTO catouser (id, userid, catoid, state) VALUES (NULL, '".USER_ID."', '".$rank['catoid']."', '".$amount."');";
}
$getcato->Query($query);
echo '<div class="alert alert-success" role="alert">Vielen Dank für dein Beitrag('.$amount.'), ihr seid eurem Ziel ein Stück näher</div>';
?>
<script type="text/javascript">

+ 1
- 1
system/addrank2.php View File

@@ -67,7 +67,7 @@
$savedata->Query("UPDATE duser SET ".$art." = '".$newamount."' WHERE id = '".USER_ID."'");
$savedata->Query($query);
$savedata->Query(changeVocalInput("INSERT INTO changelog (id, username, changed, amount, reason, timestamp) VALUES (NULL, '".USER_ID."', '".$rank['art']."', '-".$amount."', 'Spende an: ".$rank['name']." Freischaltung', CURRENT_TIMESTAMP)"));
echo '<div class="alert alert-success" role="alert">Vielen Dank für dein Beitrag('.$amount.'), ihr seid eurem Ziel ein Stück näher</div>';
echo '<div class="alert alert-success" role="alert">Vielen Dank für dein Beitrag('.$amount.'), du bist deinem Ziel ein Stück näher</div>';
?>
<script type="text/javascript">
window.setTimeout('location.href="<?php echo BASE_URL; ?>/index.php?module=ranks"', 3000);

+ 1
- 1
system/anzeigebig.php View File

@@ -53,7 +53,7 @@
$user = $getdata4->GetResult()[0];
$state1 = $user['state'];
} else {
$state1 = 0;
$state1 = "0.00";
}
if ($obj2["parent"] != 0) {
$getdata5 = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);

+ 8
- 0
system/detail.php View File

@@ -28,6 +28,14 @@ if (!isset($_GET[GET_ACTION_NAME])) {
<?php } ?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Details</h3>
</div>
<div class="panel-body">
<p> Email: <?php echo changeVocalOutput($obj['email']); ?></p>
</div>
</div>
<?php } ?>
<div class="panel panel-default">
<!-- Default panel contents -->

+ 17
- 6
system/ipn.php View File

@@ -1,4 +1,5 @@
<?php
include "../core/2_Function.php";
// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST")
die("No Post Variables");
@@ -34,7 +35,13 @@ if (strpos($curl_result, "VERIFIED") !== false) {
$req .= "\n\nPaypal Verified OK";
} else {
$req .= "\n\nData NOT verified from Paypal!";
mail("webmaster@moddylp", "IPN interaction not verified", "$req", "From: webmaster@moddylp");
$to = "mastertp@gmx.de";
$subject = "Fehler bei einer Donation";
$txt = $req;
$headers = "From: webmaster@moddylp.de" . "\r\n" .
"CC: webmaster@moddylp.de, dev@ferrouscorp.de";

mail($to,$subject,$txt,$headers);
exit();
}

@@ -46,10 +53,6 @@ if (strpos($curl_result, "VERIFIED") !== false) {

// Check Number 1 ------------------------------------------------------------------------------------------------------------
$receiver_email = $_POST['receiver_email'];
if ($receiver_email != "niki.hartmann2012-facilitator@gmail.com") {
//handle the wrong business url
exit(); // exit script
}
// Check number 2 ------------------------------------------------------------------------------------------------------------
if ($_POST['payment_status'] != "Completed") {
// Handle how you think you should if a payment is not complete yet, a few scenarios can cause a transaction to be incomplete
@@ -70,5 +73,13 @@ $payer_email = $_POST['payer_email'];
$custom = $_POST['custom'];
// Place the transaction into the database
// Mail yourself the details
//mail("webmaster@moddylp.de", "NORMAL IPN RESULT YAY MONEY!", $req, "From: webmaster@moddylp.de");
$text = "Donation successfully recieved!";

$to = "mastertp@gmx.de";
$subject = $text;
$txt = validate($req);
$headers = "From: webmaster@moddylp.de" . "\r\n" .
"CC: webmaster@moddylp.de, dev@ferrouscorp.de";

mail($to,$subject,$txt,$headers);
?>

+ 57
- 12
system/main.php View File

@@ -302,13 +302,19 @@ session_start();
}
}
}
if(isset($_GET[GET_MODULE_NAME]) AND $_GET[GET_MODULE_NAME] == "register" AND isset($_POST["send2"]))
if(isset($_GET[GET_MODULE_NAME]) AND $_GET[GET_MODULE_NAME] == "register")
{
if ($_COOKIE["pay"] == "success") {
echo "<h1>Registrierungsdetails</h1>";
$amount = str_replace("GB","", $_SESSION["item_number"]);
$menge = $amount;
$getdata = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getdata->Query("SELECT * FROM duser WHERE username = '".validate($_POST['username'])."';");
if (USER_ID !== null)
{
$getdata->Query("SELECT * FROM duser WHERE id = '".USER_ID."';");
} else {
$getdata->Query("SELECT * FROM duser WHERE username = '".validate($_POST['username'])."';");
}
if ($getdata->ResultExists()) {
$user = $getdata->GetResult()[0];
}
@@ -316,19 +322,28 @@ session_start();
$action = "login";
} else if (validate($_POST["password"]) == validate($_POST["passwordcheck"])) {
$action = "register";
if (USER_ID !== null) {
$action = "login";
}
} else {
echo '<div class="alert alert-danger" role="alert">Da ist dir wohl ein Fehler unterlaufen.</div>';
include "system/registerform.php";
die();
if (USER_ID !== null) {
$action = "login";
} else {
echo '<div class="alert alert-danger" role="alert">Da ist dir wohl ein Fehler unterlaufen.</div>';
include "system/registerform.php";
die();
}
}
if ($action == "login") {
$amount = $user["gold"]+$amount;
if (encrypt_password(validate($_POST["password"])) == $user["password"]) {
$amount = $user["gold"]+$amount;
$query = changeVocalInput("UPDATE duser SET gold = '".$amount."', active = '1' WHERE username = '".validate($_POST["username"])."';");
} else if (USER_ID !== null) {
$query = changeVocalInput("UPDATE duser SET gold = '".$amount."' WHERE id = '".USER_ID."';");
} else {
echo '<div class="alert alert-danger" role="alert">Benutzername oder Passwort fehlerhaft.</div>';
include "system/registerform.php";
die();
echo '<div class="alert alert-danger" role="alert">Benutzername oder Passwort fehlerhaft.</div>';
include "system/registerform.php";
die();
}
} else if($action == "register") {
if ($user["username"] != null) {
@@ -346,16 +361,30 @@ session_start();
}
$savedata = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$savedata->Query($query);
$savedata->Query("SELECT * FROM duser WHERE username = '".validate($_POST["username"])."';");
if (USER_ID !== null) {
$savedata->Query("SELECT * FROM duser WHERE id = '".USER_ID."';");
} else {
$savedata->Query("SELECT * FROM duser WHERE username = '".validate($_POST["username"])."';");
}
if ($savedata->ResultExists()) {
$obj = $savedata->GetResult()[0];
$query2 = "INSERT INTO changelog (id, username, changed, amount, reason, timestamp) VALUES (NULL, '".$obj['id']."', 'Gold', '+".$menge."', 'Donation', CURRENT_TIMESTAMP)";
if (USER_ID !== null) {
$query2 = "INSERT INTO changelog (id, username, changed, amount, reason, timestamp) VALUES (NULL, '".USER_ID."', 'Gold', '+".$menge."', 'Donation', CURRENT_TIMESTAMP)";
}else {
$query2 = "INSERT INTO changelog (id, username, changed, amount, reason, timestamp) VALUES (NULL, '".$obj['id']."', 'Gold', '+".$menge."', 'Donation', CURRENT_TIMESTAMP)";
}
$savedata->Query($query2);
}
if ($savedata->ResultExists()) {
echo '<div class="alert alert-success" role="alert">Speicherung des Goldes war erfolgreich</div>';
setcookie("pay",null, -1);
include "system/Rcon.php";
sendcommand("ancientdonations web Donation ".validate($_POST["username"])." ".$amount);
$rcon = new Rcon($host, $port, $password, $timeout);

if ($rcon->connect())
{
$rcon->send_command("ancientdonations web Donation ".validate($user["username"])." ".$amount);
}
?>
<script type="text/javascript">
window.setTimeout('location.href="<?php echo BASE_URL; ?>/index.php"', 3000);
@@ -363,9 +392,18 @@ session_start();
<?php
} else {
echo '<div class="alert alert-danger" role="alert">Speicherung des Goldes war fehlerhaft</div>';
include "system/registerform.php";
die();
}
} else {
echo '<div class="alert alert-danger" role="alert">Cheaten geht nicht</div>';
?>
<script type="text/javascript">
window.setTimeout('location.href="<?php echo BASE_URL; ?>/index.php"', 3000);
</script>
<?php
}
}
if(isset($_GET[GET_MODULE_NAME]) AND $_GET[GET_MODULE_NAME] == "registeruser" AND isset($_POST["send2"]))
{
@@ -393,6 +431,13 @@ session_start();
} else {
echo '<div class="alert alert-danger" role="alert">Ein Fehler ist aufgetreten</div>';
}
$to = "mastertp@gmx.de";
$subject = "Donation eigegangen";
$txt = "Neue Donation von ".$_POST["payer_email"].". Er hat ".$_POST["item_number"]." erhalten. Bitte prüfe auf erfolgreiche Zustellung.";
$headers = "From: webmaster@moddylp.de" . "\r\n" .
"CC: webmaster@moddylp.de, dev@ferrouscorp.de";

mail($to,$subject,$txt,$headers);
}
if(isset($_GET[GET_MODULE_NAME]) AND $_GET[GET_MODULE_NAME] == "error")
{

+ 6
- 1
system/payments.php View File

@@ -10,7 +10,12 @@
if ($getdata->ResultExists()) {
foreach ($getdata->GetResult() AS $obj) {
$time = date("d.m.Y H:i:s",strtotime($obj["date"]));
echo '<tr><td>'.$obj["txn_id"].'</td><td>'.$obj["buyeremail"].'</td><td>'.$obj["buyername"].'</td><td>'.$obj["item_number"].'</td><td>'.$time.'</td></tr>';
$tz = new DateTimeZone('Europe/Berlin');

$date = new DateTime($time);
$date->setTimezone($tz);
$datum = $date->format('d.m.Y H:i:s')."\n";
echo '<tr><td>'.$obj["txn_id"].'</td><td>'.$obj["buyeremail"].'</td><td>'.$obj["buyername"].'</td><td>'.$obj["item_number"].'</td><td>'.$datum.'</td></tr>';
}
}
?>

+ 20
- 0
system/rankmail.php View File

@@ -0,0 +1,20 @@
<?php
function activate($user, $name) {
$to = "mastertp@gmx.de";
$subject = "Freischaltung";
$txt = "Es wurde eine Freischaltung [".$name."] aktiviert von ".$user."";
$headers = "From: webmaster@moddylp.de" . "\r\n" .
"CC: webmaster@moddylp.de, dev@ferrouscorp.de";

mail($to,$subject,$txt,$headers);
}
function deactivate($user, $name) {
$to = "mastertp@gmx.de";
$subject = "Abgelaufen Freischaltung";
$txt = "Es wurde eine Freischaltung [".$name."] deaktiviert von ".$user."";
$headers = "From: webmaster@moddylp.de" . "\r\n" .
"CC: webmaster@moddylp.de, dev@ferrouscorp.de";

mail($to,$subject,$txt,$headers);
}
?>

+ 226
- 0
system/rankproof.php View File

@@ -0,0 +1,226 @@
<?php
require_once('system/Rcon.php');
$rcon = new Rcon($rconhost, $rconport, $rconpassword, $rcontimeout);
require_once('system/rankmail.php');

//Globale Freischaltungen
$gettime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$gettime->Query("SELECT * FROM dranks;");
if ($gettime->ResultExists()) {
$enddate = array();
foreach ($gettime->GetResult() as $times) {
//Wenn der Timestamp gesetzt wurde wird überprüft ob es deaktiviert werden muss.
if ($times["timestamp"] != NULL) {
$prrofdate = strtotime( '-1 month', strtotime(date("d.m.Y H:i:s",time())));
//Prüfen ob die Zeit abgelaufen ist
if ($prrofdate >= $times["timestamp"]) {
if ($times["catoid"] == "1") {
if ($rcon->connect())
{
if (!$rcon->send_command("ancd web DeActivation Global ".$times['name'])) {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
} else {
echo '<div id="success" class="alert alert-success" role="alert">Freischaltung erfolgreich</div>';
if ($times['dcommand'] != null) {
$command = changeVocalOutput(str_replace(array('\\', '/'), '', $times['dcommand']));
/* ------------------------------------------------------ */
if ($rcon->connect())
{
if (!$rcon->send_command("ancd web Command Global ".$command)) {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET state = 0, timestamp = NULL WHERE id = '".$times["id"]."'");
}
} else {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
}
/* ------------------------------------------------------ */
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET state = 0, timestamp = NULL WHERE id = '".$times["id"]."'");
}
}
} else {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
}
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET state = 0, timestamp = NULL WHERE id = '".$times["id"]."'");
}
//Mail
//deactivate("Allgemein", $times["name"]);
}
//Üperprüfen ob die Freischaltung erfüllt wurde
} else {
if ($times['state'] >= $times['goal']) {
if ($times["catoid"] == "1") {
if ($rcon->connect())
{
if (!$rcon->send_command("ancd web Activation Global ".$times['name'])) {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
} else {
echo '<div id="success" class="alert alert-success" role="alert">Freischaltung erfolgreich</div>';
if ($times['command'] != null) {
$command = changeVocalOutput(str_replace(array('\\', '/'), '', $times['command']));
/* ------------------------------------------------------ */
if ($rcon->connect())
{
if (!$rcon->send_command("ancd web Command Global ".$command)) {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET timestamp = '".time()."' WHERE id = '".$times["id"]."'");
}
} else {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
}
/* ------------------------------------------------------ */
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET timestamp = '".time()."' WHERE id = '".$times["id"]."'");
}
}
} else {
echo '<div class="alert alert-danger" role="alert">Verbindung zum Minecraft Server fehlgeschlagen.</div>';
}
} else {
$updatetime= new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$updatetime->Query("UPDATE dranks SET timestamp = '".time()."' WHERE id = '".$times["id"]."'");
}

//Mail
//activate("Allgemein", $times["name"]);
}
}
$enddate[$times['id']] = date("d.m.Y H:i",strtotime( '+1 month', strtotime(date("d.m.Y H:i:s",time()))));
}
}
//Persönliche Freschaltungen
$gettime = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$gettime->Query("SELECT * FROM pdranks;");
if ($gettime->ResultExists()) {
$enddate2 = array();
foreach ($gettime->GetResult() as $times) {
//Persönlichen Speicherstände abfragen
$gettime2 = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$gettime2->Query("SELECT * FROM rankusercon WHERE rankid = '".$times['id']."';");
if ($gettime2->ResultExists()) {
foreach ($gettime2->GetResult() as $times2) {
//User abfragen
$getuser = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getuser->Query("SELECT * FROM duser WHERE id = '".$times2['userid']."';");
if ($getuser->ResultExists() AND $getuser->GetResult()[0] != null) {
$user = $getuser->GetResult()[0];
}
$uuid = $user['username'];