Browse Source

First Release

master
ModdyLP 3 years ago
parent
commit
dd04eddab7
58 changed files with 4477 additions and 0 deletions
  1. 180
    0
      Datenbank.sql
  2. 19
    0
      ReadMe.md
  3. 61
    0
      core/1_Database.php
  4. 58
    0
      core/2_Function.php
  5. 43
    0
      core/3_groups.php
  6. 50
    0
      core/4_loginmain.php
  7. 106
    0
      css/style.css
  8. 68
    0
      error_log
  9. BIN
      img/Bronze.gif
  10. BIN
      img/Gold.gif
  11. BIN
      img/Silber.gif
  12. BIN
      img/dropdown.png
  13. BIN
      img/dropdown2.png
  14. 145
    0
      index.php
  15. 25
    0
      settings/settings.php
  16. 29
    0
      system/Rcon.php
  17. 187
    0
      system/SourceQuery/Buffer.php
  18. 19
    0
      system/SourceQuery/Exception/AuthenticationException.php
  19. 18
    0
      system/SourceQuery/Exception/InvalidArgumentException.php
  20. 21
    0
      system/SourceQuery/Exception/InvalidPacketException.php
  21. 18
    0
      system/SourceQuery/Exception/SocketException.php
  22. 18
    0
      system/SourceQuery/Exception/SourceQueryException.php
  23. 18
    0
      system/SourceQuery/Exception/TimeoutException.php
  24. 150
    0
      system/SourceQuery/GoldSourceRcon.php
  25. 193
    0
      system/SourceQuery/Socket.php
  26. 572
    0
      system/SourceQuery/SourceQuery.php
  27. 209
    0
      system/SourceQuery/SourceRcon.php
  28. 27
    0
      system/SourceQuery/bootstrap.php
  29. 14
    0
      system/addcato.php
  30. 22
    0
      system/addingotform.php
  31. 74
    0
      system/addrank.php
  32. 77
    0
      system/addrank2.php
  33. 49
    0
      system/addrankform.php
  34. 57
    0
      system/addrankform2.php
  35. 71
    0
      system/anzeige.php
  36. 71
    0
      system/anzeige2.php
  37. 91
    0
      system/anzeigebig.php
  38. 55
    0
      system/buy.php
  39. 65
    0
      system/createrankform.php
  40. 73
    0
      system/createrankform2.php
  41. 113
    0
      system/detail.php
  42. 74
    0
      system/ipn.php
  43. 12
    0
      system/loginform.php
  44. 406
    0
      system/main.php
  45. 7
    0
      system/navi.php
  46. 166
    0
      system/notmain.php
  47. 21
    0
      system/passwordform.php
  48. 18
    0
      system/payments.php
  49. 129
    0
      system/ranks.php
  50. 47
    0
      system/register.php
  51. 51
    0
      system/registerform.php
  52. 23
    0
      system/registerform2.php
  53. 22
    0
      system/removeingotform.php
  54. 72
    0
      system/send.php
  55. 34
    0
      system/sendform.php
  56. 181
    0
      system/show.php
  57. 113
    0
      system/trade.php
  58. 35
    0
      system/tradeform.php

+ 180
- 0
Datenbank.sql View File

@@ -0,0 +1,180 @@
-- phpMyAdmin SQL Dump
-- version 4.1.4
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: 06. Jul 2016 um 15:04
-- Server Version: 5.6.15-log
-- PHP Version: 5.5.8

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `donate`
--

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `changelog`
--

CREATE TABLE IF NOT EXISTS `changelog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` int(11) NOT NULL,
`changed` varchar(90) NOT NULL,
`amount` decimal(11,2) NOT NULL,
`reason` varchar(256) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `dcato`
--

CREATE TABLE IF NOT EXISTS `dcato` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(90) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Daten für Tabelle `dcato`
--

INSERT INTO `dcato` (`id`, `Name`) VALUES
(1, 'Minecraft'),
(2, 'Teamspeak');

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `dranks`
--

CREATE TABLE IF NOT EXISTS `dranks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(90) NOT NULL,
`state` decimal(11,2) NOT NULL DEFAULT '0.00',
`goal` decimal(11,2) NOT NULL DEFAULT '0.00',
`art` varchar(20) NOT NULL DEFAULT 'Bronze',
`parent` int(11) NOT NULL,
`timestamp` varchar(90) DEFAULT NULL,
`catoid` int(11) DEFAULT NULL,
`command` varchar(250) DEFAULT NULL,
`dcommand` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `duser`
--

CREATE TABLE IF NOT EXISTS `duser` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(90) NOT NULL,
`email` varchar(120) NOT NULL,
`password` varchar(90) NOT NULL,
`keystamp` varchar(90) NOT NULL,
`keytstamp` varchar(90) NOT NULL,
`gold` decimal(11,2) NOT NULL DEFAULT '0.00',
`silber` decimal(11,2) NOT NULL DEFAULT '0.00',
`bronze` decimal(11,2) NOT NULL DEFAULT '0.00',
`role` int(11) NOT NULL DEFAULT '0',
`active` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--
-- Daten für Tabelle `duser`
--

INSERT INTO `duser` (`id`, `username`, `email`, `password`, `keystamp`, `keytstamp`, `gold`, `silber`, `bronze`, `role`, `active`) VALUES
(1, 'Admin', 'admin[at]admin.admin', '18bdb7a947cc41b6fd815804fe09433150d190673ce89a7d332c7bbbb960d1c0', 'd32176266038f05df054cb184e052448f6d163d3f5aac1cbb046990e0c108e92', '1467810165', '0.00', '0.00', '0.00', 4, 1);

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `payments`
--

CREATE TABLE IF NOT EXISTS `payments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`txn_id` varchar(90) NOT NULL,
`buyeremail` varchar(90) NOT NULL,
`buyername` varchar(90) NOT NULL,
`item_number` varchar(60) NOT NULL,
`date` varchar(120) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `pdranks`
--

CREATE TABLE IF NOT EXISTS `pdranks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(90) NOT NULL,
`goal` decimal(11,2) NOT NULL DEFAULT '0.00',
`art` varchar(20) NOT NULL DEFAULT 'Bronze',
`parent` int(11) NOT NULL,
`catoid` int(11) DEFAULT NULL,
`tlimit` int(11) NOT NULL DEFAULT '0',
`command` varchar(250) DEFAULT NULL,
`dcommand` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `rankusercon`
--

CREATE TABLE IF NOT EXISTS `rankusercon` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rankid` int(11) NOT NULL,
`userid` int(11) NOT NULL,
`timestamp` varchar(90) DEFAULT NULL,
`state` decimal(11,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `rankid` (`rankid`,`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `role`
--

CREATE TABLE IF NOT EXISTS `role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rolename` varchar(90) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Daten für Tabelle `role`
--

INSERT INTO `role` (`id`, `rolename`) VALUES
(0, 'GAST'),
(4, 'ADMIN');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 19
- 0
ReadMe.md View File

@@ -0,0 +1,19 @@
Hello User,

here some basic informationes about the system. Sorry, for my bad english, i hope you can understand.

The System is written for Minecraft Servers.
The system needs the plugin "AncientDonations" to run complete.
#####Requirements######
1. PHP version >= 5.6
2. Minecraft Spigot Server version >= 1.8
3. Some basic programming skills

#####Installation Instructions######
1. Import the Database.sql in your Host System
2. Uploud contents from Folder "DonationSystem" to your web root.
3. Edit and Change the settings.php in the Folder "settings".
4. Uploud the plugin "AncientDonations.jar" to your plugin folder from your server.
5. Restart your Minecraft Servers
6. Login on the Webpage with Username "Admin" and "admin" as password. I recommend to create Accounts based on your Minecraft Names to save the combatibility.
7. Enjoy

+ 61
- 0
core/1_Database.php View File

@@ -0,0 +1,61 @@
<?php
class Database
{
private $mysqli;

private $result;

private $fetchResult = array();

public function __construct($host, $user, $password, $database)
{
$this->mysqli = new mysqli($host, $user, $password, $database);

if ($this->mysqli->connect_errno)
{
echo "Failed to connect to MySQL: (" . $this->mysqli->connect_errno . ") " . $this->mysqli->connect_error;
}
}

public function __destruct()
{
}

public function SetConnection($host, $user, $password, $database)
{
$this->mysqli = new mysqli($host, $user, $password, $database);

if ($this->mysqli->connect_errno)
{
echo "Failed to connect to MySQL: (" . $this->mysqli->connect_errno . ") " . $this->mysqli->connect_error;
}
}

public function Query($query)
{
$this->result = $this->mysqli->query($query);
}

public function GetResult()
{
// ToDo wenn es nur ein Ergebnis gibt dann soll nur das rausgegeben werden statt ein array

while($result = mysqli_fetch_assoc($this->result))
{
$this->fetchResult[] = $result;
}

return $this->fetchResult;
}

public function ResultExists()
{
if($this->result)
{
return true;
}
return false;
}
}

?>

+ 58
- 0
core/2_Function.php View File

@@ -0,0 +1,58 @@
<?php

// [sz] in ß
function changeVocalOutput($string)
{
return str_replace(array("[sz]", "[ae]", "[AE]", "[oe]", "[OE]", "[ue]", "[UE]", "[at]"), array("ß", "ä", "Ä", "ö", "Ö", "ü", "Ü", "@"), $string);
}

// ß in [sz]
function changeVocalInput($string)
{
return str_replace(array("ß", "ä", "Ä", "ö", "Ö", "ü", "Ü", "@"), array("[sz]", "[ae]", "[AE]", "[oe]", "[OE]", "[ue]", "[UE]", "[at]"), $string);
}
//Passwort Verschlüsslungsfunktion
function encrypt_password($password)
{
$secret_salt = "Sup3rS3e7y";
$salted_password = $secret_salt . $password;
$password_hash = hash('sha256', $salted_password);

return $password_hash;
}
function validate($string)
{
return htmlspecialchars(strip_tags(stripslashes(trim($string))));
}
function changePassword() {
$showdata = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
if (!isset($_POST["newPW"]) OR !isset($_POST["oldPW"]) OR !isset($_POST["passwordcheck"])) {
echo '<div class="alert alert-danger" role="alert">Bitte fülle alle Felder aus</div>';
} else if ($_POST["newPW"] != $_POST["passwordcheck"])
{
echo '<div class="alert alert-danger" role="alert">Das neue Passwort stimmt nicht mit der Wiederholung überein</div>';
} else {
$query = "SELECT password, username FROM duser WHERE id = '".USER_ID."'";
$showdata->Query($query);
if ($showdata->ResultExists()) {
$obj = $showdata->GetResult()[0];
$name = $obj['username'];
if ($obj['password'] == encrypt_password(validate($_POST["oldPW"]))) {
$newPW = encrypt_password($_POST["newPW"]);
$query = "UPDATE duser SET password = '".$newPW."' WHERE id ='".USER_ID."';";
$showdata->Query($query);
echo '<div class="alert alert-success" role="alert">Erfolgreich geändert</div>';
?>
<script type="text/javascript">
window.setTimeout('location.href="http://test.moddylp.de/websitetest/index.php"', 3000);
</script>
<?php
} else {
echo '<div class="alert alert-danger" role="alert">Ändern fehgeschlagen</div>';
}
}
}
}

+ 43
- 0
core/3_groups.php View File

@@ -0,0 +1,43 @@
<?php
if (USER_ID != null) {
function getuser() {
$getuser = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getuser->Query("SELECT * FROM duser WHERE id = ".USER_ID."");
if ($getuser->ResultExists())
{
$user = $getuser->GetResult()[0];
return $user;
}
else
{
return false;
}
}
function getgroup($user) {
$groupid = $user["role"];
$getgroup = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getgroup->Query("SELECT * FROM role WHERE id = ".$groupid."");
if ($getgroup->ResultExists())
{
$group = $getgroup->GetResult()[0];
define("GROUP_ID",$group["id"]);
return $group;
} else {
return false;
}
}
function checkaccess($ACCESS) {
if (GROUP_ID >= 4 AND $ACCESS == "ADMIN") {
return true;
} else if (GROUP_ID >= 0 AND $ACCESS == "GAST"){
return true;
} else {
return false;
}
}
} else {
function checkaccess($ACCESS) {
return false;
}
}
?>

+ 50
- 0
core/4_loginmain.php View File

@@ -0,0 +1,50 @@
<?php if(!defined('SCRIPT_VALID')) DIE("Du hast keine Berechtigung!"); /*Prüft ob es mit index.php geöffnet wurde*/?>
<?php
ob_start();
if (isset($_GET[GET_ACTION_NAME]))
{
if ($_GET[GET_ACTION_NAME] == "logout")
{
setcookie("time",null, -1);
setcookie("login","logout", time()+60);
setcookie("key", null, time()+3600);
setcookie("lastlogin", null, -1);
setcookie("expire",null, -1);
setcookie("firstname",null, -1);
header("Location: ".$_SERVER['PHP_SELF']);
}
}
if (isset($_COOKIE["key"]) AND isset($_COOKIE["expire"]))
{
session_set_cookie_params($_COOKIE["expire"]+60);
setcookie("expire", $_COOKIE["expire"]+60, $_COOKIE["expire"]+60);
$getuser = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getuser->Query("SELECT * FROM duser WHERE keystamp = '".$_COOKIE["key"]."';");
if ($getuser->ResultExists() == 1)
{
$user = $getuser->GetResult()[0];
getgroup($user);
define("USER_ID", $user["id"]);
}
}
else if (!isset($_COOKIE["expire"]) XOR !isset($_COOKIE["key"]))
{
setcookie("time",null, -1);
setcookie("key", null, time()+3600);
setcookie("lastlogin", null, -1);
setcookie("expire",null, -1);
setcookie("username",null, -1);
header("Location: ".$_SERVER['PHP_SELF']);
}
else
{
define("GROUP_ID", -1);
define("USER_ID", 0);
setcookie("time",null, -1);
setcookie("key", null, time()+3600);
setcookie("lastlogin", null, -1);
setcookie("expire",null, -1);
setcookie("username",null, -1);
}
?>

+ 106
- 0
css/style.css View File

@@ -0,0 +1,106 @@
#wrapper {
padding: 2.5em;
}
/* make sidebar nav vertical */
@media (min-width: 768px) {
.sidebar-nav .navbar .navbar-collapse {
padding: 0;
max-height: none;
}
.sidebar-nav .navbar ul {
float: none;
}
.sidebar-nav .navbar ul:not {
display: block;
}
.sidebar-nav .navbar li {
float: none;
display: block;
}
.sidebar-nav .navbar li a {
padding-top: 12px;
padding-bottom: 12px;
}
}
.neg {
color: red;
}
.pos {
color: green;
}
.modal-content {
padding: 1em;
}
.panel-body {
padding: 1em;
}
th a {
text-decoration: none;
text-color: black;
}
th a:before {
background-image: url('../img/dropdown.png');
background-size: 10px 10px;
display: inline-block;
width: 10px;
height: 10px;
content:" ";
}
th a:hover:before {
background-image: url('../img/dropdown2.png');
background-size: 10px 10px;
display: inline-block;
width: 10px;
height: 10px;
content:" ";
}


.dropmenu {
position: absolute;
left: -1500px;
visibility: visible;
z-index: 101;
float: left;

border-width: px;
border-style: solid;
border-color: ;
background-color: ;
}
.dropmenu ul {
margin: 0;
padding: 0;
list-style-type: none;
}
.dropmenu li {
display: inline;
}
.dropmenu a, .dropmenu a:visited, .dropmenu a:active {
display: block;
width: px;

padding: px;
margin: px;
font-family: ;
font-size: px;
font-weight: ;
text-align: ;
text-decoration: ;

color: ;
background-color: ;
}
.dropmenu a:hover {
padding: px;
margin: px;
font-family: ;
font-size: px;
font-weight: ;
text-align: ;
text-decoration: ;

color: ;
background-color: ;
}

+ 68
- 0
error_log View File

@@ -0,0 +1,68 @@
[04-Jul-2016 17:37:21 UTC] PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home2/adm22958/test/websitetest/system/ranks.php on line 15
[04-Jul-2016 17:37:44 UTC] PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home2/adm22958/test/websitetest/system/ranks.php on line 17
[04-Jul-2016 17:42:08 UTC] PHP Parse error: syntax error, unexpected '/' in /home2/adm22958/test/websitetest/system/ranks.php on line 17
[04-Jul-2016 18:06:14 UTC] PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home2/adm22958/test/websitetest/system/trade.php on line 3
[04-Jul-2016 18:06:30 UTC] PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home2/adm22958/test/websitetest/system/trade.php on line 3
[04-Jul-2016 18:06:45 UTC] PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home2/adm22958/test/websitetest/system/trade.php on line 3
[04-Jul-2016 18:25:19 UTC] PHP Parse error: syntax error, unexpected '$newToAmount' (T_VARIABLE) in /home2/adm22958/test/websitetest/system/trade.php on line 72
[04-Jul-2016 19:45:01 UTC] PHP Parse error: syntax error, unexpected '") {' (T_CONSTANT_ENCAPSED_STRING) in /home2/adm22958/test/websitetest/system/show.php on line 98
[04-Jul-2016 20:21:08 UTC] PHP Parse error: syntax error, unexpected '}' in /home2/adm22958/test/websitetest/core/2_Function.php on line 51
[04-Jul-2016 20:29:22 UTC] PHP Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home2/adm22958/test/websitetest/core/2_Function.php on line 47
[04-Jul-2016 20:30:54 UTC] PHP Fatal error: Call to a member function Query() on a non-object in /home2/adm22958/test/websitetest/core/2_Function.php on line 37
[04-Jul-2016 20:36:59 UTC] PHP Parse error: syntax error, unexpected '{' in /home2/adm22958/test/websitetest/core/2_Function.php on line 43
[04-Jul-2016 20:41:20 UTC] PHP Parse error: syntax error, unexpected ')' in /home2/adm22958/test/websitetest/core/2_Function.php on line 43
[05-Jul-2016 08:20:07 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home2/adm22958/test/websitetest/index.php:1) in /home2/adm22958/test/websitetest/core/4_loginmain.php on line 20
[05-Jul-2016 08:20:07 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/adm22958/test/websitetest/index.php:1) in /home2/adm22958/test/websitetest/system/main.php on line 3
[05-Jul-2016 08:48:52 UTC] PHP Parse error: syntax error, unexpected '{' in /home2/adm22958/test/websitetest/system/show.php on line 168
[05-Jul-2016 09:09:03 UTC] PHP Parse error: syntax error, unexpected '$left' (T_VARIABLE) in /home2/adm22958/test/websitetest/system/addrank.php on line 21
[05-Jul-2016 09:57:41 UTC] PHP Parse error: syntax error, unexpected '{' in /home2/adm22958/test/websitetest/system/main.php on line 57
[05-Jul-2016 10:00:40 UTC] PHP Parse error: syntax error, unexpected ';' in /home2/adm22958/test/websitetest/system/main.php on line 65
[05-Jul-2016 10:44:22 UTC] PHP Parse error: syntax error, unexpected '{' in /home2/adm22958/test/websitetest/system/ranks.php on line 14
[05-Jul-2016 10:57:48 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:57:51 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:57:54 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:57:55 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:58:00 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:58:07 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:58:26 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 10:58:30 UTC] PHP Fatal error: Class 'SourceQuery' not found in /home2/adm22958/test/websitetest/settings/settings.php on line 17
[05-Jul-2016 11:05:35 UTC] PHP Parse error: syntax error, unexpected '$parentname' (T_VARIABLE) in /home2/adm22958/test/websitetest/system/ranks.php on line 19
[05-Jul-2016 11:31:25 UTC] PHP Parse error: syntax error, unexpected 'empty' (T_EMPTY) in /home2/adm22958/test/websitetest/system/main.php on line 58
[05-Jul-2016 11:59:44 UTC] PHP Parse error: syntax error, unexpected end of file in /home2/adm22958/test/websitetest/system/ranks.php on line 128
[05-Jul-2016 12:48:15 UTC] PHP Parse error: syntax error, unexpected ')', expecting ']' in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 12:48:24 UTC] PHP Parse error: syntax error, unexpected ')', expecting ']' in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 12:48:39 UTC] PHP Parse error: syntax error, unexpected '<' in /home2/adm22958/test/websitetest/system/ranks.php on line 22
[05-Jul-2016 12:54:11 UTC] PHP Parse error: syntax error, unexpected '[' in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:18:23 UTC] PHP Parse error: syntax error, unexpected 'if' (T_IF), expecting ',' or ';' in /home2/adm22958/test/websitetest/system/ranks.php on line 10
[05-Jul-2016 13:18:33 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:18:33 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:19:03 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, integer given in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:19:03 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, integer given in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:21:01 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, boolean given in /home2/adm22958/test/websitetest/system/ranks.php on line 12
[05-Jul-2016 13:21:01 UTC] PHP Fatal error: Call to a member function format() on a non-object in /home2/adm22958/test/websitetest/system/ranks.php on line 14
[05-Jul-2016 13:21:47 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, boolean given in /home2/adm22958/test/websitetest/system/ranks.php on line 12
[05-Jul-2016 13:21:47 UTC] PHP Fatal error: Call to a member function format() on a non-object in /home2/adm22958/test/websitetest/system/ranks.php on line 14
[05-Jul-2016 13:24:20 UTC] PHP Warning: date_diff() expects parameter 1 to be DateTimeInterface, boolean given in /home2/adm22958/test/websitetest/system/ranks.php on line 12
[05-Jul-2016 13:24:20 UTC] PHP Fatal error: Call to a member function format() on a non-object in /home2/adm22958/test/websitetest/system/ranks.php on line 14
[05-Jul-2016 13:24:37 UTC] PHP Parse error: syntax error, unexpected ';' in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 13:24:44 UTC] PHP Parse error: syntax error, unexpected ';' in /home2/adm22958/test/websitetest/system/ranks.php on line 9
[05-Jul-2016 18:51:12 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:51:12 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:51:12 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:52:24 UTC] PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home2/adm22958/test/websitetest/system/anzeigebig.php on line 51
[05-Jul-2016 18:52:42 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:52:42 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:53:38 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:53:38 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:01 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:01 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:43 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:43 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:45 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:54:45 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:56:38 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 18:56:38 UTC] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/adm22958/test/websitetest/core/1_Database.php on line 43
[05-Jul-2016 19:20:26 UTC] PHP Parse error: syntax error, unexpected '}' in /home2/adm22958/test/websitetest/system/addrank2.php on line 84
[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

BIN
img/Bronze.gif View File


BIN
img/Gold.gif View File


BIN
img/Silber.gif View File


BIN
img/dropdown.png View File


BIN
img/dropdown2.png View File


+ 145
- 0
index.php View File

@@ -0,0 +1,145 @@
<?php
ERROR_REPORTING(0);
define("SCRIPT_VALID", "Is Valid");
// ATTENTION: PLEASE EDIT THIS LINE TO GET THE RIGHT URL
define("BASE_URL", "http://$_SERVER[HTTP_HOST]/my%20portable%20files/websitetest");
foreach(glob("settings/*.php") as $pathname)
{
include_once $pathname;
}
foreach(glob("core/*.php") as $pathname)
{
include_once $pathname;
}
$getdata = new Database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_DATABASE);
$getdata->Query("UPDATE duser SET active = '0' WHERE timestamp < NOW() - INTERVAL 90 DAY");
?>
<!doctype html>
<html>
<head>
<title>Donationsystem</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<?php
foreach(glob("css/*.css") as $pathname)
{
echo '<link rel="stylesheet" type="text/css" href="'.$pathname.'"/>';
}
?>
</head>
<body>
<div id="wrapper" class="container-fluid">
<div class="row">
<div id="navi" class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Login</h3>
</div>
<div class="panel-body">
<?php
include "./system/notmain.php";
?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Navigation</h3>
</div>
<div class="panel-body">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="sr-only">Aktiviere Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand">Menu</span>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<?php
include_once "./system/navi.php";
?>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Währungsarten</h3>
</div>
<table class="table">
<tr><th>Art</th><th>Verwendung</th></tr>
<tr><th><img src="img/Gold.gif" alt="Gold" /> Gold</th><td>Donationwährung<br /></td></tr>
<tr><th><img src="img/Silber.gif" alt="Silber" /> Silber</th><td>Lohnwährung<br /></td></tr>
<tr><th><img src="img/Bronze.gif" alt="Bronze" /> Bronze</th><td>Tauschwährung<br /></td></tr>
</table>
</div>
<?php if (checkaccess("ADMIN")) { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Admin Menü</h3>
</div>
<div class="panel-body">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="sr-only">Aktiviere Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand">Menu</span>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="<?php echo $_SERVER["PHP_SELF"].'?'.GET_MODULE_NAME.'=deletelogs'; ?>">Logs löschen (älter als 90 Tage)</a></li>
<li><a href="<?php echo $_SERVER["PHP_SELF"]."?".GET_MODULE_NAME."=payments"; ?>">PayPal Verlauf </a></li>
<li><a href="<?php echo $_SERVER["PHP_SELF"]."?".GET_MODULE_NAME."=createrank"; ?>">Allgemeine Freischaltungen hinzufügen</a></li>
<li><a href="<?php echo $_SERVER["PHP_SELF"]."?".GET_MODULE_NAME."=createrank2"; ?>">Persönliche Freischaltungen hinzufügen</a></li>
<li><a href="<?php echo $_SERVER["PHP_SELF"]."?".GET_MODULE_NAME."=addcato"; ?>">Katerogie hinzufügen</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div id="main" class="col-md-8">
<?php
foreach(glob("./system/main.php") as $pathname)
{
include_once $pathname;
}

?>
</div>
</div>
</div>
</body>
<!--
##############################################################Copyright###########################################
Copyright: Donationsystem für MysticWorld 2016 written by https://moddylp.de/ ModdyLP
##################################################################################################################
-->
</html>

+ 25
- 0
settings/settings.php View File

@@ -0,0 +1,25 @@
<?php

/*Der Host*/
define("DATABASE_HOST", "localhost");

/*Der Benutzer*/
define("DATABASE_USER", "root");

/*Das Passwort*/
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");

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

define("GET_ACTION_NAME", "action");


+ 29
- 0
system/Rcon.php View File

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

use xPaw\SourceQuery\SourceQuery;
function sendcommand($command) {// For the sake of this example
Header( 'X-Content-Type-Options: nosniff' );
// Edit this ->
define( 'SQ_ENGINE', SourceQuery::SOURCE );
// Edit this <-
$Query = new SourceQuery( );
try
{
$Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$Query->SetRconPassword(RCON_PW);
$Query->Rcon( $command );
}
catch( Exception $e )
{
echo $e->getMessage( );
}
$Query->Disconnect( );
}

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

@@ -0,0 +1,187 @@
<?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;
}
}

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

@@ -0,0 +1,19 @@
<?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;
}

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

@@ -0,0 +1,18 @@
<?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;
}

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

@@ -0,0 +1,21 @@
<?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;
}

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

@@ -0,0 +1,18 @@
<?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;
}

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

@@ -0,0 +1,18 @@
<?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
}

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

@@ -0,0 +1,18 @@
<?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;
}

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

@@ -0,0 +1,150 @@
<?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;
}
}

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

@@ -0,0 +1,193 @@
<?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;
}
}

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

@@ -0,0 +1,572 @@
<?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 );
}
}

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

@@ -0,0 +1,209 @@
<?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 = '' )
{