mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
Remove all non web files as they have been moved
This commit is contained in:
parent
f6c99f123d
commit
967a826eeb
@ -18,6 +18,12 @@ Who is the target group for Easy-WI?
|
||||
------------------------
|
||||
No matter if you are a commercial entity that is providing hosting solutions, are sponsoring (game)server daemons, organize a LAN party, need to manage clan server, or are a private individual, Easy-WI is meant for everybody.
|
||||
|
||||
Where can I find the installer and other scripts?
|
||||
------------------------
|
||||
* [Installer](https://github.com/easy-wi/installer/)
|
||||
* [Optional Server Side Scripts](https://github.com/easy-wi/server/)
|
||||
* [External PHP Scripst](https://github.com/easy-wi/external/)
|
||||
|
||||
|
||||
Which functions and modules are available?
|
||||
------------------------
|
||||
|
53
external/api_config.php
vendored
53
external/api_config.php
vendored
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: api_config.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// The database access
|
||||
$config['dbHost']='localhost';
|
||||
$config['dbName']='database';
|
||||
$config['tblPrefix']='teklab';
|
||||
$config['dbUser']='databaseUser';
|
||||
$config['dbPwd']='securePassword';
|
||||
$config['sourceSystem']='securePassword';
|
||||
|
||||
// Access to the file
|
||||
$config['passwordToken']='myPasswordToken';
|
||||
$config['allowedIPs']=array('1.1.1.1','1.1.1.2');
|
||||
|
||||
// Type of System allowed are:
|
||||
// webspell,teklab,whmcs
|
||||
$config['sourceType']='webspell';
|
493
external/api_users.php
vendored
493
external/api_users.php
vendored
@ -1,493 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: api_users.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once 'api_config.php';
|
||||
|
||||
// Initial parameters
|
||||
$error=array();
|
||||
|
||||
// There is no need to check every user every time
|
||||
// Start looking only for new IDs
|
||||
$lastID=(isset($_GET['lastID']) and is_numeric($_GET['lastID'])) ? (int)$_GET['lastID'] : 0;
|
||||
|
||||
// this requires that a column exists which is updated every time the account gets an update:
|
||||
// ALTER TABLE `yourUserTable` ADD COLUMN `updatetime` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
// This might lead to false positives if data like the login time is stored in that table.
|
||||
// The more accurate way would be to fill/update the column only in wanted cases
|
||||
// convert to string and back to date so proper format is ensured
|
||||
$updateTime=date('Y-m-d H:i:s',strtotime((isset($_GET['updateTime']) and @strtotime($_GET['updateTime'])) ? $_GET['updateTime'] : '0000-00-00 00:00:00'));
|
||||
|
||||
// Processing all users at once can lead to memory issues if system has small recources or large database large.
|
||||
$chunkSize=(isset($_GET['chunkSize']) and is_numeric($_GET['chunkSize'])) ? (int)$_GET['chunkSize'] : 10;
|
||||
|
||||
// To be able to properly get data in chunks the starting point needs to be defined.
|
||||
$start=(isset($_GET['start']) and is_numeric($_GET['start'])) ? (int)$_GET['start'] : 0;
|
||||
|
||||
// Check if the IP is white listed
|
||||
if(isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'],$config['allowedIPs'])) {
|
||||
$config['externalIP']=(string)$_SERVER['REMOTE_ADDR'];
|
||||
} else {
|
||||
$error[]='Script called locally or IP is not white listed.';
|
||||
}
|
||||
|
||||
// Check if access token was send and is correct
|
||||
if (!isset($_GET['passwordToken'])) {
|
||||
$error[]='No password token has been send.';
|
||||
} else if ($_GET['passwordToken']!=$config['passwordToken']) {
|
||||
$error[]='Bad password token has been send.';
|
||||
}
|
||||
|
||||
$list = (in_array($_GET['list'], array('user','substitutes','gameserver','voiceserver','voicemaster','rootserver'))) ? (string)$_GET['list'] : 'user';
|
||||
|
||||
// Send header data
|
||||
header("Content-type: application/json; charset=UTF-8");
|
||||
|
||||
// If there was an error send error and stop script
|
||||
if (count($error)>0) {
|
||||
echo json_encode(array('error' => $error));
|
||||
|
||||
// Else check for new users
|
||||
} else {
|
||||
|
||||
// Establish database connection
|
||||
try {
|
||||
$pdo=new PDO("mysql:host=".$config['dbHost'].";dbname=".$config['dbName'],$config['dbUser'],$config['dbPwd'],array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8"));
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Define default values so we always have a proper return
|
||||
$total = 0;
|
||||
$json = array();
|
||||
|
||||
// User export
|
||||
if ($list == 'user') {
|
||||
// This query fetches the actual data.
|
||||
// The Query needs to be altered to your database. This is just an example!
|
||||
// specify the needed columns to reduce database load.
|
||||
// webspell
|
||||
if ($config['sourceType'] == 'webspell') {
|
||||
|
||||
$lastID = str_replace($config['sourceType'] . ':', '', $lastID);
|
||||
|
||||
// Get amount of users that are new or received an update
|
||||
// The Query needs to be altered to your database. This is just an example!
|
||||
$sql="SELECT COUNT(`userID`) AS `amount` FROM `{$config['tblPrefix']}_user`
|
||||
WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND `banned` IS NULL";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute(array($lastID, $updateTime));
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_usertable`
|
||||
WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND (`banned` IS NULL OR `banned`='')
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute(array($lastID, $updateTime));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
// Easy-Wi stores the salutation with numbers
|
||||
if (isset($row['salutation']) and $row['salutation'] == 'mr') {
|
||||
$salutation = 1;
|
||||
} else if (isset($row['salutation']) and $row['salutation'] == 'ms') {
|
||||
$salutation = 2;
|
||||
} else {
|
||||
$salutation = null;
|
||||
}
|
||||
// the keys needs to be adjusted to your table layout and query!
|
||||
$json[]=array(
|
||||
'externalID' => $config['sourceType'] . ':' . $row['userID'],
|
||||
'salutation' => $salutation,
|
||||
'email' => $row['email'],
|
||||
'loginName' => $row['username'],
|
||||
'firstName' => $row['firstname'],
|
||||
'lastName' => $row['lastname'],
|
||||
'birthday' => $row['birthday'],
|
||||
'country' => $row['country'],
|
||||
'phone' => $row['tel'],
|
||||
'fax' => $row['fax'],
|
||||
'handy' => $row['mobile'],
|
||||
'city' => $row['town'],
|
||||
'cityn' => $row['postcode'],
|
||||
'street' => $row['street'],
|
||||
'streetn' => $row['streetnr'],
|
||||
'updatetime' => $row['updatetime'],
|
||||
'usertype'=>'u',
|
||||
'password' => $row['password']
|
||||
);
|
||||
}
|
||||
|
||||
} else if ($config['sourceType'] == 'whmcs') {
|
||||
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `tblclients`
|
||||
WHERE `status`='Active'";
|
||||
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total = $query->fetchColumn();
|
||||
|
||||
$sql = "SELECT * FROM `tblclients`
|
||||
WHERE `status`='Active'
|
||||
LIMIT $start,$chunkSize";
|
||||
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
// WHMCS stores street + number so we need to split and rebuild strings
|
||||
$exploded = preg_split('/\s/', $row["address1"], -1, PREG_SPLIT_NO_EMPTY);
|
||||
$lastKey = count($exploded) - 1;
|
||||
|
||||
if ($lastKey > -1 and isset($exploded[$lastKey])) {
|
||||
$streetn = $exploded[$lastKey]);
|
||||
unset($exploded[$lastKey]);
|
||||
} else {
|
||||
$streetn = null;
|
||||
}
|
||||
|
||||
// the keys needs to be adjusted to your table layout and query!
|
||||
$json[]=array(
|
||||
'externalID' => $config['sourceType'] . ':' . $row['id'],
|
||||
'salutation' => null,
|
||||
'email' => $row['email'],
|
||||
'loginName' => $row['username'],
|
||||
'firstName' => $row['firstname'],
|
||||
'lastName' => $row['lastname'],
|
||||
'birthday' => null,
|
||||
'country' => strtolower($row['country']),
|
||||
'phone' => $row['phonenumber'],
|
||||
'fax' => null,
|
||||
'handy' => null,
|
||||
'city' => implode(" ", $exploded),
|
||||
'cityn' => $streetn,
|
||||
'street' => $row['street'],
|
||||
'streetn' => $row['streetnr'],
|
||||
'updatetime' => $row['updatetime'],
|
||||
'usertype'=>'u',
|
||||
);
|
||||
}
|
||||
|
||||
} else if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
$lastID = str_replace($config['sourceType'] . ':', '', $lastID);
|
||||
|
||||
// Get amount of users that are new or received an update
|
||||
$sql="SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_members`
|
||||
WHERE `rank`=1";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// users
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_members`
|
||||
WHERE `rank`=1
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
// Teklab has also 3 for company which Easy-WI currently does not maintain
|
||||
if ($row['title'] == 0) {
|
||||
$salutation = 1;
|
||||
} else if ($row['title']==1) {
|
||||
$salutation = 2;
|
||||
} else {
|
||||
$salutation = null;
|
||||
}
|
||||
|
||||
// Easy-WI uses ISO code for storing countries
|
||||
if ($row['country'] == 1) {
|
||||
$country = 'de';
|
||||
} else if ($row['country'] == 2) {
|
||||
$country = 'uk';
|
||||
} else if ($row['country'] == 3) {
|
||||
$country = 'at';
|
||||
} else if ($row['country'] == 4) {
|
||||
$country = 'ch';
|
||||
} else {
|
||||
$country = null;
|
||||
}
|
||||
|
||||
// Street and streetnumber are stored in the same column Easy-WI has individual columns
|
||||
$exploded = explode(" ", $row['street']);
|
||||
if (count($exploded) > 1) {
|
||||
$streetNumber = $exploded[count($exploded) - 1];
|
||||
unset($exploded[count($exploded) - 1]);
|
||||
$streetName = implode(' ', $exploded);
|
||||
} else {
|
||||
$streetName = null;
|
||||
$streetNumber = null;
|
||||
}
|
||||
|
||||
$json[]=array(
|
||||
'externalID' => $config['sourceType'] . ':' . $row['id'],
|
||||
'salutation' => $salutation,
|
||||
'email' => $row['email'],
|
||||
'loginName' => $row['member'],
|
||||
'firstName' => $row['surname'],
|
||||
'lastName' => $row['name'],
|
||||
'birthday'=> date('Y-m-d H:m:s', strtotime($row['birthday'])),
|
||||
'country' => $country,
|
||||
'phone' => $row['phone'],
|
||||
'fax' => $row['fax'],
|
||||
'handy' => null,
|
||||
'city' => $row['city'],
|
||||
'cityn' => $row['zipcode'],
|
||||
'street' => $streetName,
|
||||
'streetn' => $streetNumber,
|
||||
'updatetime' => null,
|
||||
'usertype'=>'u',
|
||||
'password' => $row['password']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($list == 'rootserver') {
|
||||
if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
// Get amount of gameservers that are new or received an update
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_rootserver`
|
||||
WHERE `active`=1
|
||||
AND `games`=1";
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// gameservers
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_rootserver`
|
||||
WHERE `active`=1
|
||||
AND `games`=1
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$ips = explode("\n", str_replace("\r",'',$row['serverip']));
|
||||
$ram = (substr($row['ram'], -2) == 'GB') ? trim(substr($row['ram'], 0, (strlen($row['ram']) - 2))) : round((trim(substr($row['ram'], 0, (strlen($row['ram']) - 2))) / 1024), 2);
|
||||
|
||||
$json[]=array(
|
||||
'externalID' => $row['id'],
|
||||
'belongsToID' => $row['memberid'],
|
||||
'ips' => $ips,
|
||||
'sshPort' => $row['sshport'],
|
||||
'ftpPort' => $row['ftpport'],
|
||||
'cores' => $row['cpucores'],
|
||||
'ram' => $ram
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($list == 'gameserver') {
|
||||
if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
// Get amount of gameservers that are new or received an update
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_gameserver`";
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// gameservers
|
||||
$sql = "SELECT u.`member`,u.`ftppasswd`,i.`scriptfolder`,g.* FROM `{$config['tblPrefix']}_gameserver` AS g
|
||||
INNER JOIN `{$config['tblPrefix']}_members` AS u
|
||||
ON g.`memberid`=u.`id`
|
||||
INNER JOIN `{$config['tblPrefix']}_games` AS i
|
||||
ON i.`sname`=g.`game`
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$extraPath = (strlen($row['scriptfolder']) > 0) ? $row['scriptfolder'] . '/' : '';
|
||||
|
||||
$json[]=array(
|
||||
'externalID' => $row['id'],
|
||||
'belongsToID' => $row['memberid'],
|
||||
'rootID' => $row['rserverid'],
|
||||
'ip' => $row['serverip'],
|
||||
'port' => $row['serverport'],
|
||||
'port2' => $row['queryport'],
|
||||
'slots' => $row['player'],
|
||||
'assignedCore' => ($row['cpucore'] - 1),
|
||||
'protectionMode' => ($row['protect'] == 1) ? 'Y' : 'N',
|
||||
'tickrate' => $row['gtick'],
|
||||
'startMap' => $row['gmap'],
|
||||
'shorten' => $row['game'],
|
||||
'player' => $row['player'],
|
||||
'ftpUser' => $row['member'],
|
||||
'ftpPass' => $row['ftppasswd'],
|
||||
'path' => 'server/' . $row['path'] . '/' .$extraPath
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($list == 'voiceserver') {
|
||||
if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
// Get amount of voiceservers that are new or received an update
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_voiceserver`
|
||||
WHERE `typ`='Teamspeak3'";
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// voiceservers
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_voiceserver`
|
||||
WHERE `typ`='Teamspeak3'
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if (filter_var($row['serverip'], FILTER_VALIDATE_IP)) {
|
||||
$ip = $row['serverip'];
|
||||
$dns = '';
|
||||
} else {
|
||||
$ip = gethostbyname($row['serverip']);
|
||||
$dns = $row['serverip'];
|
||||
}
|
||||
|
||||
$json[]=array(
|
||||
'externalID' => $row['id'],
|
||||
'belongsToID' => $row['memberid'],
|
||||
'ip' => $ip,
|
||||
'dns' => $dns,
|
||||
'port' => $row['serverport'],
|
||||
'slots' => $row['slots']
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if ($list == 'voicemaster') {
|
||||
if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
// Get amount of voiceservers that are new or received an update
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_teamspeak`
|
||||
WHERE `typ`='Teamspeak3'";
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// voiceservers
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_teamspeak`
|
||||
WHERE `typ`='Teamspeak3'
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if (filter_var($row['serverip'], FILTER_VALIDATE_IP)) {
|
||||
$ip = $row['serverip'];
|
||||
$dns = '';
|
||||
} else {
|
||||
$ip = gethostbyname($row['serverip']);
|
||||
$dns = $row['serverip'];
|
||||
}
|
||||
|
||||
$json[]=array(
|
||||
'externalID' => $row['id'],
|
||||
'belongsToID' => $row['memberid'],
|
||||
'ip' => $ip,
|
||||
'dns' => $dns,
|
||||
'port' => $row['queryport'],
|
||||
'queryAdmin' => $row['admin'],
|
||||
'queryPassword' => $row['passwd'],
|
||||
'sshUser' => 'user-webi',
|
||||
'path' => '/home/user-webi/' . $row['path'] . '/'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Substitutes at last so we can get access permissions as well
|
||||
} else if ($list == 'substitutes') {
|
||||
if ($config['sourceType'] == 'teklab') {
|
||||
|
||||
// Get amount of substitutes that are new or received an update
|
||||
$sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_subusers`";
|
||||
$query = $pdo->prepare($sql);
|
||||
$query->execute();
|
||||
$total=$query->fetchColumn();
|
||||
|
||||
// substitutes
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_subusers`
|
||||
LIMIT $start,$chunkSize";
|
||||
$query=$pdo->prepare($sql);
|
||||
|
||||
$sql = "SELECT * FROM `{$config['tblPrefix']}_subusers_servers` WHERE `subuserid`=? AND `active`=1";
|
||||
$query2 = $pdo->prepare($sql);
|
||||
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$serverAccess = array(
|
||||
'de' => array(),
|
||||
'gs' => array(),
|
||||
'vo' => array(),
|
||||
'vs' => array(),
|
||||
);
|
||||
|
||||
$query2->execute(array($row['id']));
|
||||
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) {
|
||||
if ($row2['typ'] == 'games') {
|
||||
$what = 'gs';
|
||||
} else if ($row2['typ'] == 'voice') {
|
||||
$what = 'vo';
|
||||
} else if ($row2['typ'] == 'mvserver') {
|
||||
$what = 'vs';
|
||||
} else if ($row2['typ'] == 'mrserver') {
|
||||
$what = 'de';
|
||||
} else {
|
||||
$what = $row2['typ'];
|
||||
}
|
||||
$serverAccess[$what][] = $row2['typid'];
|
||||
}
|
||||
|
||||
|
||||
$json[] = array(
|
||||
'externalID' => $row['id'],
|
||||
'belongsToID' => $row['memberid'],
|
||||
'loginName' => $row['user'],
|
||||
'firstName' => null,
|
||||
'lastName' => null,
|
||||
'serverAccess' => $serverAccess,
|
||||
'password' => $row['password']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Echo the JSON reply with
|
||||
echo json_encode(array('total' => $total,'entries' => $json));
|
||||
|
||||
// Catch database error and display
|
||||
} catch(PDOException $error) {
|
||||
echo json_encode(array('error' => $error->getMessage()));
|
||||
}
|
||||
}
|
186
external/crud.php
vendored
186
external/crud.php
vendored
@ -1,186 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: crud.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
// Define the ID variable which will be used at the form and SQLs
|
||||
$id = $ui->id('id', 10, 'get');
|
||||
|
||||
// Default variables. Mostly needed for the add operation
|
||||
$defaultVar = ($ui->id('id', 10, 'get')) ? $ui->id('id', 10, 'get') : 10;
|
||||
|
||||
// At this point all variables are defined that can come from the user
|
||||
|
||||
$table = array();
|
||||
|
||||
// CSFR protection with hidden tokens. If token(true) returns false, we likely have an attack
|
||||
if ($ui->w('action', 4, 'post') and !token(true)) {
|
||||
|
||||
unset($header, $text);
|
||||
|
||||
$errors = array('token' => $spracheResponse->token);
|
||||
|
||||
} else {
|
||||
$errors = array();
|
||||
}
|
||||
|
||||
if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
|
||||
|
||||
// Add jQuery plugin chosen to the header
|
||||
/*
|
||||
$htmlExtraInformation['css'][] = '<link href="css/default/chosen/chosen.min.css" rel="stylesheet" type="text/css">';
|
||||
$htmlExtraInformation['js'][] = '<script src="js/default/plugins/chosen/chosen.jquery.min.js" type="text/javascript"></script>';
|
||||
*/
|
||||
|
||||
if ($id and $ui->st('d', 'get') == 'md') {
|
||||
|
||||
$query = $sql->prepare("SELECT `a`,b`,`c` FROM `table` WHERE `id`=? AND `reseller_id`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if (!$ui->st('action', 'post')) {
|
||||
$a = $row['a'];
|
||||
$b = $row['b'];
|
||||
$c = $row['c'];
|
||||
}
|
||||
|
||||
$oldA = $row['a'];
|
||||
$oldB = $row['b'];
|
||||
$oldC = $row['c'];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($errors) == 0 and ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad')) {
|
||||
|
||||
if (!$active) {
|
||||
$errors['active'] = $sprache->active;
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
if ($ui->st('action', 'post') == 'ad' and isset($rootServer)) {
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `table` (`a`,`b`,`c`,`reseller_id`) VALUES (?,?,?,?)");
|
||||
$query->execute(array($a, $b, $c, $resellerLockupID));
|
||||
$rowCount = $query->rowCount();
|
||||
|
||||
$loguseraction = '%add% %yourmodule% ' . $a;
|
||||
|
||||
} else if ($ui->st('action', 'post') == 'md' and $id and isset($rootServer)) {
|
||||
|
||||
$query = $sql->prepare("UPDATE `table` SET `a`=?,`b`=?,`c`=? WHERE `id`=? AND `reseller_id`=? LIMIT 1");
|
||||
$query->execute(array($a, $b, $c, $id, $resellerLockupID));
|
||||
$rowCount = $query->rowCount();
|
||||
|
||||
$loguseraction = '%mod% %yourmodule% ' . $a;
|
||||
}
|
||||
|
||||
if (isset($rowCount) and $rowCount > 0) {
|
||||
|
||||
$insertlog->execute();
|
||||
$template_file = $spracheResponse->table_add;
|
||||
|
||||
// No update or insert failed
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// An error occurred during validation
|
||||
// unset the redirect information and display the form again
|
||||
if (!$ui->smallletters('action', 2, 'post') or count($errors) != 0) {
|
||||
|
||||
unset($header, $text);
|
||||
|
||||
// Gather data for adding if needed and define add template
|
||||
if ($ui->st('d', 'get') == 'ad') {
|
||||
|
||||
$table = getUserList($resellerLockupID);
|
||||
|
||||
$template_file = 'admin_your_module_add.tpl';
|
||||
|
||||
// Gather data for modding in case we have an ID and define mod template
|
||||
} else if ($ui->st('d', 'get') == 'md' and $id) {
|
||||
|
||||
// Check if database entry exists and if not display 404 page
|
||||
$template_file = (isset($oldActive)) ? 'admin_your_module_md.tpl' : 'admin_404.tpl';
|
||||
|
||||
// Show 404 if GET parameters did not add up or no ID was given with mod
|
||||
} else {
|
||||
$template_file = 'admin_404.tpl';
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($ui->st('d', 'get') == 'dl' and $id) {
|
||||
|
||||
$query = $sql->prepare("SELECT `a`,`b`,`c` FROM `table` WHERE `id`=? AND `reseller_id`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$a = $row['a'];
|
||||
}
|
||||
|
||||
$serverFound = $query->rowCount();
|
||||
|
||||
if ($ui->st('action', 'post') == 'dl' and count($errors) == 0 and $serverFound > 0) {
|
||||
|
||||
$query = $sql->prepare("DELETE FROM `table` table `id`=? AND `reseller_id`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
|
||||
if ($query->rowCount() > 0) {
|
||||
|
||||
$loguseraction = '%del% %yourmodule% ' . $a;
|
||||
$insertlog->execute();
|
||||
|
||||
$template_file = $spracheResponse->table_del;
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing submitted yet or csfr error, display the delete form
|
||||
if (!$ui->st('action', 'post') or count($errors) != 0) {
|
||||
// Check if we could find an entry and if not display 404 page
|
||||
$template_file = ($serverFound > 0) ? 'admin_your_module_dl.tpl' : 'admin_404.tpl';
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
configureDateTables('-1', '1, "asc"', 'ajax.php?w=datatable&d=yourmodule');
|
||||
|
||||
$template_file = 'admin_your_module_list.tpl';
|
||||
}
|
285
external/easywiapi.php
vendored
285
external/easywiapi.php
vendored
@ -1,285 +0,0 @@
|
||||
<?php
|
||||
|
||||
class EasyWiRestAPI {
|
||||
|
||||
// define internal vars
|
||||
private $method,$timeout,$connect=false,$user,$pwd,$handle=null,$ssl,$port,$url;
|
||||
protected $response=array();
|
||||
|
||||
// Constructor that sets defaults which can be overwritten
|
||||
__construct($url,$user,$pwd,$timeout=10,$ssl=false,$port=80,$method='xml',$connect='curl') {
|
||||
$this->timeout=$timeout;
|
||||
// check if curl is choosen and available and initiate cURL-Session
|
||||
if ($connect=='curl' and function_exists('curl_init')) {
|
||||
if ($this->startCurl($url,$ssl,$port)===true) {
|
||||
$this->connect='curl';
|
||||
}
|
||||
|
||||
// Use and or fallback to fsockopen if possible and create socket
|
||||
} else if (($connect=='fsockopen' or !function_exists('curl_init')) and function_exists('fsockopen')) {
|
||||
if ($this->startSocket($url,$ssl,$port)===true) {
|
||||
$this->connect='fsockopen';
|
||||
}
|
||||
}
|
||||
|
||||
// If connection was successfull, go on and set values
|
||||
if ($this->connect!==false) {
|
||||
$this->user=$user;
|
||||
$this->pwd=$pwd;
|
||||
$this->ssl=$ssl;
|
||||
$this->port=$port;
|
||||
$this->url=$url;
|
||||
// Use json, or xml to communicate
|
||||
if ($method=='json') {
|
||||
$this->method='json';
|
||||
} else {
|
||||
$this->method='xml';
|
||||
}
|
||||
} else {
|
||||
$this->throwException(10);
|
||||
}
|
||||
}
|
||||
|
||||
// False usage of the object needs to be handled and execution stopped
|
||||
private function throwException ($rawError,$extraText=false) {
|
||||
// If an exception is caught from imbedded class use the raw error
|
||||
if (is_object($rawError)) {
|
||||
$errorcode=$rawError->getMessage();
|
||||
|
||||
// else use the custom messages
|
||||
} else {
|
||||
|
||||
// default custom messages
|
||||
$errorArray=array(
|
||||
1=>'Bad data: Only Strings and Integers are allowed!',
|
||||
2=>'Bad data: Only Strings are allowed!',
|
||||
3=>'Bad data: Only Integers are allowed!',
|
||||
4=>'Bad data: Only arrays are allowed!',
|
||||
5=>'Bad data: Unknown Error!',
|
||||
6=>'Bad data: Empty values!',
|
||||
10=>'Connection Error: Could not connect to!'.$this->url
|
||||
);
|
||||
|
||||
// if the message is not predifined use the raw input
|
||||
if (array_key_exists($rawError,$errorArray)) {
|
||||
$errorcode=$errorArray["${rawError}"];
|
||||
} else {
|
||||
$errorcode=$rawError;
|
||||
}
|
||||
}
|
||||
|
||||
// Add some extra info if given
|
||||
if ($extraText!==false) {
|
||||
$errorcode.=$extraText;
|
||||
}
|
||||
throw new Exception('<p>'.$errorcode.'</p>');
|
||||
die;
|
||||
}
|
||||
//
|
||||
private function startCurl ($url,$ssl,$port) {
|
||||
// create the URL to call
|
||||
if (substr($url,-1)=='/') {
|
||||
$url=substr($url,0,-1);
|
||||
}
|
||||
$url=str_replace(array('http://','https://',':8080',':80',':443'),'',$url);
|
||||
if ($ssl==true) {
|
||||
$url='https://'.$url;
|
||||
} else {
|
||||
$url='http://'.$url;
|
||||
}
|
||||
$url=$url.'/api.php';
|
||||
|
||||
// create cURL-Handle
|
||||
$this->handle=curl_init($url);
|
||||
|
||||
// check success
|
||||
if ($this->handle===false) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
// Set options
|
||||
$this->setbasicCurlOpts();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// in case of curl setopts
|
||||
private function setbasicCurlOpts () {
|
||||
curl_setopt($this->handle,CURLOPT_CONNECTTIMEOUT,$this->timeout);
|
||||
curl_setopt($this->handle,CURLOPT_USERAGENT,"cURL (Easy-WI; 1.0; Linux)");
|
||||
curl_setopt($this->handle,CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($this->handle,CURLOPT_SSL_VERIFYPEER,false);
|
||||
curl_setopt($this->handle,CURLOPT_FOLLOWLOCATION,1);
|
||||
curl_setopt($this->handle,CURLOPT_HEADER,1);
|
||||
//curl_setopt($this->handle,CURLOPT_ENCODING,'deflate');
|
||||
if (($this->ssl===true and $this->port!=443) or ($this->ssl===false and $this->port!=80)) {
|
||||
curl_setopt($this->handle,CURLOPT_PORT,$this->port);
|
||||
}
|
||||
}
|
||||
|
||||
// method to execute a curl request
|
||||
private function execCurl($type,$send) {
|
||||
|
||||
// Setting up POST data and add it to the opts
|
||||
$postArray['user']=$this->user;
|
||||
$postArray['pwd']=$this->pwd;
|
||||
$postArray['type']=$type;
|
||||
$postArray['xmlstring']=$send;
|
||||
curl_setopt($this->handle,CURLOPT_POSTFIELDS,$postArray);
|
||||
|
||||
// Execute request, get the response and return it.
|
||||
$this->response=curl_exec($this->handle);
|
||||
$this->header=curl_getinfo($this->handle);
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
// Ioncube obfuscated files add sometimes data to the REST responses.
|
||||
// This will be picked up if fsockopen is used.
|
||||
// So there is a need to strip this data.
|
||||
private function convertRawData ($rawdata) {
|
||||
if ($this->method=='json') {
|
||||
$checkStart='{';
|
||||
$checkStop='}';
|
||||
} else {
|
||||
$checkStart='<';
|
||||
$checkStop='>';
|
||||
}
|
||||
$response=$rawdata;
|
||||
while (substr($response,0,1)!=$checkStart and strlen($response)>0) {
|
||||
$response=substr($response,1);
|
||||
}
|
||||
while (substr($response,-1)!=$checkStop and strlen($response)>0) {
|
||||
$response=substr($response,0,-1);
|
||||
}
|
||||
|
||||
// Decode the rest of the response string into an object.
|
||||
if ($this->method=='json') {
|
||||
$decoded=@json_decode($response);
|
||||
} else {
|
||||
$decoded=@simplexml_load_string($response);
|
||||
}
|
||||
|
||||
// If decoding was not possible return the raw response, else return the object.
|
||||
if ($decoded) {
|
||||
unset($rawdata);
|
||||
return $decoded;
|
||||
} else if ($this->connect=='fsockopen') {
|
||||
return substr($rawdata,4,-3);
|
||||
} else {
|
||||
return $rawdata;
|
||||
}
|
||||
unset($decoded);
|
||||
}
|
||||
|
||||
// create the JSON that will be send to the API
|
||||
private function JSONPostValue ($paramArray,$action,$params) {
|
||||
$jsonArray=array();
|
||||
foreach ($paramArray as $param) {
|
||||
if (array_key_exists($param,$params)) {
|
||||
if (is_array($params[$param])) {
|
||||
$jsonArray[$param]=array();
|
||||
foreach ($params[$param] as $val) {
|
||||
$jsonArray[$param][]=$params[$param];
|
||||
}
|
||||
} else {
|
||||
$jsonArray[$param]=$params[$param];
|
||||
}
|
||||
} else {
|
||||
$jsonArray[$param]='';
|
||||
}
|
||||
}
|
||||
$json=json_encode($jsonArray);
|
||||
unset($type,$params,$paramArray,$jsonArray);
|
||||
return $json;
|
||||
}
|
||||
|
||||
// create the XML that will be send to the API
|
||||
private function XMLPostValue ($paramArray,$action,$params) {
|
||||
$xml=new SimpleXMLElement(<<<XML
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<server></server>
|
||||
XML
|
||||
);
|
||||
foreach ($paramArray as $param) {
|
||||
if (array_key_exists($param,$params)) {
|
||||
if (is_array($params[$param])) {
|
||||
foreach ($params[$param] as $val) {
|
||||
$xml->addChild($param,$val);
|
||||
}
|
||||
} else {
|
||||
$xml->addChild($param,$params[$param]);
|
||||
}
|
||||
} else {
|
||||
$jsonArray[$param]='';
|
||||
}
|
||||
}
|
||||
unset($type,$params,$paramArray);
|
||||
return $xml;
|
||||
}
|
||||
|
||||
|
||||
// Method the external script calls
|
||||
public function makeRestCall($type,$action,$params) {
|
||||
|
||||
// some param validation. On fail throw an exception
|
||||
if (!is_string($type)) {
|
||||
$this->throwException(2,': $type');
|
||||
}
|
||||
if (!is_string($action)) {
|
||||
$this->throwException(2,': $action');
|
||||
}
|
||||
if (!is_array($params)) {
|
||||
$this->throwException(4,': $params');
|
||||
}
|
||||
if (!in_array($type,array('user','gserver','mysql','voice','restart'))) {
|
||||
$this->throwException('Error: $type is not defined correctly. Allowed methods are (user, gserver, mysql, vserver, restart)');
|
||||
}
|
||||
if (!in_array($action,array('mod','add','del','ls','st','re'))) {
|
||||
$this->throwException('Error: $action is not defined correctly. Allowed methods are (md, ad, dl, st, re, list)');
|
||||
}
|
||||
|
||||
// Array keys that all methods have in common
|
||||
$generalArray=array('username','user_localid','active');
|
||||
|
||||
// Array keys server have in common
|
||||
$generalServerArray=array('identify_user_by','user_externalid','identify_server_by','server_external_id','server_local_id','master_server_id','master_server_external_id');
|
||||
|
||||
// Keys specfic to user
|
||||
$paramArray['user']=array('identify_by','external_id','localid','email','password');
|
||||
|
||||
// Keys specfic to gserver
|
||||
$paramArray['gserver']=array('private','shorten','slots','primary','taskset','cores','eacallowed','tvenable','pallowed','opt1','opt2','opt3','opt4','opt5','port2','port3','port4','port5','minram','maxram','brandname');
|
||||
|
||||
// Keys specfic to voice
|
||||
$paramArray['voice']=array('private','shorten','slots','max_download_total_bandwidth','max_upload_total_bandwidth','maxtraffic','forcebanner','forcebutton','forceservertag','forcewelcome');
|
||||
|
||||
// Keys specfic to mysql
|
||||
$paramArray['mysql']=array();
|
||||
|
||||
// create the post value
|
||||
if ($this->method=='json') {
|
||||
$post=$this->JSONPostValue(array_unique(array_merge($generalArray,$generalServerArray,$paramArray[$type])),$action,$params);
|
||||
} else {
|
||||
$post=$this->XMLPostValue(array_unique(array_merge($generalArray,$generalServerArray,$paramArray[$type])),$action,$params);
|
||||
}
|
||||
|
||||
// Call method to send the data depending on the connection type
|
||||
if ($this->connect=='curl' and is_recource($this->handle)) {
|
||||
$this->execCurl($type,$post);
|
||||
} else if ($this->connect=='fsockopen' and is_recource($this->handle)) {
|
||||
fclose($this->handle);
|
||||
} else {
|
||||
$this->throwException(10);
|
||||
}
|
||||
}
|
||||
|
||||
// destructor
|
||||
__destruct () {
|
||||
if ($this->connect=='curl' and is_recource($this->handle)) {
|
||||
curl_close($this->handle);
|
||||
} else if ($this->connect=='fsockopen' and is_recource($this->handle)) {
|
||||
fclose($this->handle);
|
||||
}
|
||||
unset($method,$timeout,$connect,$user,$pwd,$handle,$ssl,$port,$response);
|
||||
}
|
||||
}
|
177
external/easywiapitest.php
vendored
177
external/easywiapitest.php
vendored
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
|
||||
$host = 'wi.domain.de';
|
||||
$path = '/api.php';
|
||||
$user = 'user';
|
||||
$pwd = '123456';
|
||||
if (isset($_GET['id'])) {
|
||||
$localID=$_GET['id'];
|
||||
} else {
|
||||
$localID='';
|
||||
}
|
||||
if (isset($_GET['userID'])) {
|
||||
$userID=$_GET['userID'];
|
||||
} else {
|
||||
$userID='';
|
||||
}
|
||||
if (isset($_GET['action'])) {
|
||||
$action=$_GET['action'];
|
||||
} else {
|
||||
$action='add';
|
||||
}
|
||||
if ($_GET['test']=='user') {
|
||||
$type = 'user';
|
||||
$postxml = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE users>
|
||||
<users>
|
||||
<action>$action</action>
|
||||
<identify_by>localid</identify_by>
|
||||
<username></username>
|
||||
<external_id>26</external_id>
|
||||
<localid>$localID</localid>
|
||||
<groupID>570</groupID>
|
||||
<email>testing2@mail.de</email>
|
||||
<password></password>
|
||||
<active>Y</active>
|
||||
</users>
|
||||
XML;
|
||||
} else if ($_GET['test']=='gserver') {
|
||||
$type = 'gserver';
|
||||
$postxml = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE server>
|
||||
<server>
|
||||
<action>$action</action>
|
||||
<identify_user_by>user_localid</identify_user_by>
|
||||
<identify_server_by>server_local_id</identify_server_by>
|
||||
<username></username>
|
||||
<user_externalid></user_externalid>
|
||||
<user_localid>$userID</user_localid>
|
||||
<shorten>css</shorten>
|
||||
<shorten>cstrike</shorten>
|
||||
<primary>cstrike</primary>
|
||||
<slots>12</slots>
|
||||
<restart>re</restart>
|
||||
<private>N</private>
|
||||
<server_external_id></server_external_id>
|
||||
<server_local_id>$localID</server_local_id>
|
||||
<active>N</active>
|
||||
<master_server_id></master_server_id>
|
||||
<master_server_external_id></master_server_external_id>
|
||||
<taskset></taskset>
|
||||
<cores></cores>
|
||||
<eacallowed></eacallowed>
|
||||
<brandname></brandname>
|
||||
<tvenable></tvenable>
|
||||
<pallowed></pallowed>
|
||||
<opt1>123</opt1>
|
||||
<opt2></opt2>
|
||||
<opt3></opt3>
|
||||
<opt4></opt4>
|
||||
<opt5></opt5>
|
||||
<port>2000</port>
|
||||
<port2>2001</port2>
|
||||
<port3>2003</port3>
|
||||
<port4>2004</port4>
|
||||
<port5></port5>
|
||||
<minram></minram>
|
||||
<maxram></maxram>
|
||||
<initialpassword></initialpassword>
|
||||
</server>
|
||||
XML;
|
||||
if(isset($_GET['restart']) and $_GET['restart']=='re' or $_GET['st']) {
|
||||
$restart=$_GET['restart'];
|
||||
$postxml = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE server>
|
||||
<server>
|
||||
<action>$action</action>
|
||||
<identify_server_by>server_local_id</identify_server_by>
|
||||
<restart>$restart</restart>
|
||||
<server_external_id></server_external_id>
|
||||
<server_local_id>$localID</server_local_id>
|
||||
</server>
|
||||
XML;
|
||||
}
|
||||
} else if ($_GET['test']=='voice') {
|
||||
$type = 'voice';
|
||||
$postxml = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE server>
|
||||
<server>
|
||||
<action>$action</action>
|
||||
<identify_user_by>user_localid</identify_user_by>
|
||||
<identify_server_by>server_local_id</identify_server_by>
|
||||
<username></username>
|
||||
<user_externalid></user_externalid>
|
||||
<user_localid>$userID</user_localid>
|
||||
<shorten>ts3</shorten>
|
||||
<slots>12</slots>
|
||||
<private>N</private>
|
||||
<server_external_id></server_external_id>
|
||||
<server_local_id>$localID</server_local_id>
|
||||
<active>N</active>
|
||||
<master_server_id>44</master_server_id>
|
||||
<master_server_external_id></master_server_external_id>
|
||||
<max_download_total_bandwidth></max_download_total_bandwidth>
|
||||
<max_upload_total_bandwidth></max_upload_total_bandwidth>
|
||||
<maxtraffic></maxtraffic>
|
||||
<forcebanner></forcebanner>
|
||||
<forcebutton></forcebutton>
|
||||
<forceservertag></forceservertag>
|
||||
<forcewelcome></forcewelcome>
|
||||
</server>
|
||||
XML;
|
||||
} else {
|
||||
echo '<pre>';
|
||||
print_r();
|
||||
echo '<pre>';
|
||||
}
|
||||
if (!isset($stop)) {
|
||||
if (isset($postxml)) echo $postxml.'<br />';
|
||||
$data = 'pwd='.urlencode($pwd).'&user='.$user.'&xml='.urlencode(base64_encode($postxml)).'&type='.$type;
|
||||
$useragent=$_SERVER['HTTP_HOST'];
|
||||
$fp = @fsockopen($host, 80, $errno, $errstr, 30);
|
||||
$buffer="";
|
||||
if ($fp) {
|
||||
$send = "POST ".$path." HTTP/1.1\r\n";
|
||||
$send .= "Host: ".$host."\r\n";
|
||||
$send .="User-Agent: $useragent\r\n";
|
||||
$send .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
|
||||
$send .= "Content-Length: ".strlen($data)."\r\n";
|
||||
$send .= "Connection: Close\r\n\r\n";
|
||||
$send .= $data;
|
||||
fwrite($fp, $send);
|
||||
while (!feof($fp)) {
|
||||
$buffer .= fgets($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
list($header,$response)=explode("\r\n\r\n",$buffer);
|
||||
$raw=$response;
|
||||
$header=str_replace(array("\r\n","\r"),"\n",$header);
|
||||
$header=str_replace("\t",' ',$header);
|
||||
$ex=explode("\n",$header);
|
||||
list($type,$errocode,$errortext)=explode(' ',$ex[0]);
|
||||
echo 'Here comes the response:<br /><pre>';
|
||||
if ($errocode>400) {
|
||||
print_r(substr($response,4,-3));
|
||||
} else {
|
||||
while(substr($response,0,1)!='<' and strlen($response)>0) {
|
||||
$response=substr($response,1);
|
||||
}
|
||||
while(substr($response,-1)!='>' and strlen($response)>0) {
|
||||
$response=substr($response,0,-1);
|
||||
}
|
||||
$object=@simplexml_load_string($response);
|
||||
if ($object) {
|
||||
echo '<pre>';
|
||||
print_r($object);
|
||||
echo '</pre>';
|
||||
} else {
|
||||
echo 'Could not decode response<br />';
|
||||
echo $raw;
|
||||
}
|
||||
}
|
||||
}
|
118
external/external_auth.php
vendored
118
external/external_auth.php
vendored
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: external_auth.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
$dbName='name';
|
||||
$dbUser='user';
|
||||
$dbPwd='pwd';
|
||||
$dbHost='localhost';
|
||||
$configUser='meinUsername';
|
||||
$configPass='meinPasswort';
|
||||
|
||||
if (!isset($_POST['postXML'])) {
|
||||
$bad='No XML has been send';
|
||||
}
|
||||
|
||||
if (!isset($bad) and isset($_POST['authPWD']) and isset($_POST['userAuth']) and $_POST['authPWD']==$configPass and $_POST['userAuth']==$configUser) {
|
||||
// postXML into object
|
||||
$xml= @simplexml_load_string(base64_decode($_POST['postXML']));
|
||||
if($xml) {
|
||||
$user=$xml->user;
|
||||
$pwd=$xml->pwd;
|
||||
$mail=$xml->mail;
|
||||
$externalID=$xml->externalID;
|
||||
|
||||
// use whatever your system does to hash passwords. Only MD5 is common but bad practise
|
||||
$hashedPWD=md5($pwd);
|
||||
|
||||
// DB Connection and search user
|
||||
try {
|
||||
$connection=new PDO("mysql:host=$dbHost;dbname=$dbName",$dbUser,$dbPwd);
|
||||
$connection->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// This is just an example! Needs to be fitted to your database structure!
|
||||
$query=$connection->prepare("SELECT `pwd` FROM `tbl_userdata` WHERE `loginname`=? LIMIT 1");
|
||||
$query->execute(array($user));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$storedHash=$row['pwd'];
|
||||
}
|
||||
|
||||
/* WHMCS is look like:
|
||||
$query=$connection->prepare("SELECT `password` FROM `tblclients` WHERE `email`=? LIMIT 1");
|
||||
$query->execute(array($mail));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
@list($storedHash, $salt) = explode(':', $row['password']);
|
||||
if (isset($salt)) {
|
||||
$hashedPWD = md5($pwd . $salt);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
$bad=$error->getMessage();
|
||||
}
|
||||
if (!isset($bad) and $hashedPWD==$storedHash) {
|
||||
$responseXML = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE login>
|
||||
<login>
|
||||
<user>$user</user>
|
||||
<success>1</success>
|
||||
</login>
|
||||
XML;
|
||||
} else if (!isset($bad)) {
|
||||
$bad='bad login data.';
|
||||
}
|
||||
} else {
|
||||
$bad='No valid XML data has been send';
|
||||
}
|
||||
} else {
|
||||
$bad='Bad API auth data.';
|
||||
}
|
||||
header("Content-type: text/xml");
|
||||
if(isset($bad)) {
|
||||
$responseXML = <<<XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE login>
|
||||
<login>
|
||||
<user></user>
|
||||
<success>0</success>
|
||||
<error>$bad</error>
|
||||
</login>
|
||||
XML;
|
||||
}
|
||||
echo $responseXML;
|
94
external/external_protectioncheck.php
vendored
94
external/external_protectioncheck.php
vendored
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: external_protectioncheck.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
if (isset($_POST['adresse'])) {
|
||||
$fail=0;
|
||||
$adresse=explode(":", $_POST['adresse']);
|
||||
if(isset($adresse['0']) and filter_var($adresse['0'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) and preg_match("/^(0|([1-9]\d{0,3}|[1-5]\d{4}|[6][0-5][0-5]([0-2]\d|[3][0-5])))$/", $adresse['1'])){
|
||||
$ip=$adresse['0'];
|
||||
$port=$adresse['1'];
|
||||
} else {
|
||||
$fail=1;
|
||||
}
|
||||
if ($fail == '0') {
|
||||
// If you need a yes or no following is sufficient:
|
||||
$status=file_get_contents("https://webinterface.domain.tld/protectioncheck.php?ip=$ip&po=$port");
|
||||
} else {
|
||||
echo "formular";
|
||||
if ( $status == 'yes' ) {
|
||||
echo "Server ist geschützt";
|
||||
} else if ( $status == 'no' ) {
|
||||
echo "Server ist ungeschützt";
|
||||
} else if ( $status == 'unknown' ) {
|
||||
echo "Ein Server mit dieser IP wurde nicht gefunden bitte versuche es erneut:";
|
||||
}
|
||||
} else {
|
||||
echo "hier das Formular ausgeben";
|
||||
}
|
||||
// In case you need status information and or the log:
|
||||
libxml_set_streams_context(stream_context_create(array('http'=>array('user_agent'=>'PHP libxml agent',null))));
|
||||
$xml = simplexml_load_file("https://webinterface.domain.tld/protectioncheck.php?ip=$ip&po=$port&gamestring=xml");
|
||||
if ($xml != 'unknown') {
|
||||
echo $xml->hostname.'</br>';
|
||||
echo $xml->gametype.'</br>';
|
||||
echo $xml->map.'</br>';
|
||||
echo $xml->numplayers.'</br>';
|
||||
echo $xml->maxplayers.'</br>';
|
||||
echo $xml->protection.'</br>';
|
||||
if ($xml->psince != '0000:00:00') {
|
||||
echo $xml->psince.'</br>';
|
||||
}
|
||||
foreach ($xml->actions->action as $action) {
|
||||
echo $action->time.' '.$action->log.'</br>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<form action="external_protectioncheck.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type="text" name="serveraddress" value="11.111.11.111:27015" required="required" maxlength="22" /></td>
|
||||
<td><input type="submit" value="Check"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
2406
server/control.sh
2406
server/control.sh
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Author: Ulrich Block <ulrich.block@easy-wi.com>
|
||||
#
|
||||
# This file is part of Easy-WI.
|
||||
#
|
||||
# Easy-WI is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Easy-WI is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Diese Datei ist Teil von Easy-WI.
|
||||
#
|
||||
# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
# der GNU General Public License, wie von der Free Software Foundation,
|
||||
# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
|
||||
# veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
#
|
||||
# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
# Gewährleistung der MARKTFAEHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
|
||||
# Siehe die GNU General Public License fuer weitere Details.
|
||||
#
|
||||
# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
# Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Zum installieren:
|
||||
# chmod 755 /etc/init.d/password
|
||||
# update-rc.d password defaults
|
||||
#
|
||||
# Zum enfernen:
|
||||
# update-rc.d -f password remove
|
||||
# rm /etc/init.d/password
|
||||
# bei https --no-check-certificate als zusaetzlicher Paramter
|
||||
if [[ "$1" == "start" ]]; then
|
||||
#cd /home/easy-wi
|
||||
#su easy-wi -c ./control
|
||||
#rm control.*
|
||||
sleep 60
|
||||
STRING=`wget --no-check-certificate -q -O - https://wi.domain.de/get_password.php | sed 's/^\xef\xbb\xbf//g'`
|
||||
PASSWORD=`echo $STRING | awk -F ':' '{print $1}'`
|
||||
if ([[ "$PASSWORD" != "" ]] && [[ "$PASSWORD" != "old" ]]); then
|
||||
/usr/sbin/usermod -p `perl -e 'print crypt("'$PASSWORD'","Sa")'` root
|
||||
fi
|
||||
#LICENCE=`echo $STRING | awk -F ':' '{print $2}'`
|
||||
#if ([[ "$LICENCE" != "" ]] && [[ "$LICENCE" != "old" ]]); then
|
||||
# echo "$LICENCE" > /path/to/licencefile
|
||||
# chmod 000 /path/to/licencefile
|
||||
# chown username:gruppe /path/to/licencefile
|
||||
#fi
|
||||
update-rc.d -f password remove
|
||||
rm /etc/init.d/password
|
||||
fi
|
@ -1,92 +0,0 @@
|
||||
#!/bin/bash
|
||||
###########################################################
|
||||
# #
|
||||
# ========================================= #
|
||||
# | DNW Despe Networks | #
|
||||
# ========================================= #
|
||||
# |>>>>>>>> MPaseco Startscript v2 >>>| #
|
||||
# |>>>>>>>> http://www.despe.de >>>>>>>>>>| #
|
||||
# |>>>>>>>> DO NOT EDIT, only if u know >>| #
|
||||
# |>>>>>>>> what are you doing! >>>>>>>>>>| #
|
||||
# ========================================= #
|
||||
# more info: https://github.com/ManiaAseco/MPAseco #
|
||||
###########################################################
|
||||
|
||||
#########################################################################
|
||||
# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! #
|
||||
#########################################################################
|
||||
|
||||
NAME="MPAseco"
|
||||
PIDFILE="mpaseco.pid"
|
||||
|
||||
# Absolute path to this script, e.g. /home/user/bin/foo.sh
|
||||
#SCRIPT=$(readlink -f $0)
|
||||
# Absolute path this script is in, thus /home/user/bin
|
||||
#SCRIPTPATH=$(dirname $SCRIPT)
|
||||
#SCRIPTPATH=$(dirname "$(readlink -fn "$0")")
|
||||
SCRIPTPATH=$PWD/servercontroller
|
||||
cd $SCRIPTPATH
|
||||
|
||||
#########################################################################
|
||||
# ONLY FOR DNW - SUPPORT !!! #
|
||||
#########################################################################
|
||||
|
||||
function start {
|
||||
echo "Starting $NAME ..."
|
||||
if test -f $SCRIPTPATH/$PIDFILE;
|
||||
then
|
||||
echo "PID file exists, Restart?"
|
||||
elif test $SCRIPTPATH/$PIDFILE;
|
||||
then
|
||||
echo "PID file not exists..."
|
||||
#touch $PIDFILE
|
||||
fi
|
||||
php mpaseco.php SM </dev/null >mpaseco2.log 2>&1 & echo $! > $SCRIPTPATH/$PIDFILE
|
||||
sleep 1
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
echo "...$NAME started. ID $PID"
|
||||
}
|
||||
###################
|
||||
|
||||
function stop {
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
kill $PID
|
||||
echo "$NAME stopped. ID $PID"
|
||||
rm -f $SCRIPTPATH/$PIDFILE
|
||||
echo "$PIDFILE removed"
|
||||
}
|
||||
|
||||
###################
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
|
||||
restart)
|
||||
stop
|
||||
sleep 2
|
||||
start
|
||||
;;
|
||||
|
||||
status)
|
||||
if [ -f $SCRIPTPATH/$PIDFILE ]; then
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
echo "$NAME is runing! ID $PID . Server offline? Restart?"
|
||||
else
|
||||
echo 'MPAseco has crashed or is stopped incorrect.'
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
;;
|
||||
|
||||
esac
|
||||
exit 0
|
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
###########################################################
|
||||
# #
|
||||
# ========================================= #
|
||||
# | DNW Despe Networks | #
|
||||
# ========================================= #
|
||||
# |>>>>>>>> ManiaPlanet Startscript v3 >>>| #
|
||||
# |>>>>>>>> http://www.despe.de >>>>>>>>>>| #
|
||||
# |>>>>>>>> DO NOT EDIT, only if u know >>| #
|
||||
# |>>>>>>>> what are you doing! >>>>>>>>>>| #
|
||||
# ========================================= #
|
||||
# #
|
||||
###########################################################
|
||||
|
||||
#########################################################################
|
||||
# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! #
|
||||
#########################################################################
|
||||
|
||||
|
||||
# Start ManiaPlanet-Server for TrackMania or ShootMania and start a ServerController
|
||||
|
||||
|
||||
if [ "$5" = "/mpaseco" ]
|
||||
then
|
||||
./MPAseco.sh restart & ./ManiaPlanetServer $1 $2 $3 $4 $6 $7
|
||||
|
||||
elif [ "$5" != "/mpaseco" ]
|
||||
then
|
||||
./ManiaPlanetServer $1 $2 $3 $4 $5 $6
|
||||
fi
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Modified by: Ulrich Block <ulrich.block@easy-wi.com>
|
||||
# We need the $@ to be able to send commands to the server binary
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./ ./starbound_server $@
|
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
###########################################################
|
||||
# #
|
||||
# ========================================= #
|
||||
# | DNW Despe Networks | #
|
||||
# ========================================= #
|
||||
# |>>>>>>>> ManiaPlanet Startscript v3 >>>| #
|
||||
# |>>>>>>>> http://www.despe.de >>>>>>>>>>| #
|
||||
# |>>>>>>>> DO NOT EDIT, only if u know >>| #
|
||||
# |>>>>>>>> what are you doing! >>>>>>>>>>| #
|
||||
# ========================================= #
|
||||
# #
|
||||
###########################################################
|
||||
|
||||
#########################################################################
|
||||
# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! #
|
||||
#########################################################################
|
||||
|
||||
|
||||
# Start ManiaPlanet-Server for TrackMania or ShootMania and start a ServerController
|
||||
|
||||
|
||||
if [ "$5" = "/xaseco" ]
|
||||
then
|
||||
./XAseco2.sh restart & ./ManiaPlanetServer $1 $2 $3 $4 $6 $7
|
||||
|
||||
elif [ "$5" != "/xaseco" ]
|
||||
then
|
||||
./ManiaPlanetServer $1 $2 $3 $4 $5 $6
|
||||
fi
|
@ -1,92 +0,0 @@
|
||||
#!/bin/bash
|
||||
###########################################################
|
||||
# #
|
||||
# ========================================= #
|
||||
# | DNW Despe Networks | #
|
||||
# ========================================= #
|
||||
# |>>>>>>>> XAseco Startscript v3 >>>| #
|
||||
# |>>>>>>>> http://www.despe.de >>>>>>>>>>| #
|
||||
# |>>>>>>>> DO NOT EDIT, only if u know >>| #
|
||||
# |>>>>>>>> what are you doing! >>>>>>>>>>| #
|
||||
# ========================================= #
|
||||
# more info: http://www.xaseco.org/ #
|
||||
###########################################################
|
||||
|
||||
#########################################################################
|
||||
# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! #
|
||||
#########################################################################
|
||||
|
||||
NAME="XAseco"
|
||||
PIDFILE="xaseco2.pid"
|
||||
|
||||
# Absolute path to this script, e.g. /home/user/bin/foo.sh
|
||||
#SCRIPT=$(readlink -f $0)
|
||||
# Absolute path this script is in, thus /home/user/bin
|
||||
#SCRIPTPATH=$(dirname $SCRIPT)
|
||||
#SCRIPTPATH=$(dirname "$(readlink -fn "$0")")
|
||||
SCRIPTPATH=$PWD/servercontroller
|
||||
cd $SCRIPTPATH
|
||||
|
||||
#########################################################################
|
||||
# ONLY FOR DNW - SUPPORT !!! #
|
||||
#########################################################################
|
||||
|
||||
function start {
|
||||
echo "Starting $NAME ..."
|
||||
if test -f $SCRIPTPATH/$PIDFILE;
|
||||
then
|
||||
echo "PID file exists, Restart?"
|
||||
elif test $SCRIPTPATH/$PIDFILE;
|
||||
then
|
||||
echo "PID file not exists..."
|
||||
#touch $PIDFILE
|
||||
fi
|
||||
php $SCRIPTPATH/xaseco2.php TM2C </dev/null >xaseco2.log 2>&1 & echo $! > $SCRIPTPATH/$PIDFILE
|
||||
sleep 1
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
echo "...$NAME started. ID $PID"
|
||||
}
|
||||
###################
|
||||
|
||||
function stop {
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
kill $PID
|
||||
echo "$NAME stopped. ID $PID"
|
||||
rm -f $SCRIPTPATH/$PIDFILE
|
||||
echo "$PIDFILE removed"
|
||||
}
|
||||
|
||||
###################
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
|
||||
restart)
|
||||
stop
|
||||
sleep 2
|
||||
start
|
||||
;;
|
||||
|
||||
status)
|
||||
if [ -f $SCRIPTPATH/$PIDFILE ]; then
|
||||
PID="`cat $SCRIPTPATH/$PIDFILE`"
|
||||
echo "$NAME is runing! ID $PID . Server offline? Restart?"
|
||||
else
|
||||
echo 'MPAseco has crashed or is stopped incorrect.'
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
;;
|
||||
|
||||
esac
|
||||
exit 0
|
@ -1,242 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Author: Ulrich Block <ulrich.block@easy-wi.com>
|
||||
#
|
||||
# This file is part of Easy-WI.
|
||||
#
|
||||
# Easy-WI is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Easy-WI is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Diese Datei ist Teil von Easy-WI.
|
||||
#
|
||||
# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
# der GNU General Public License, wie von der Free Software Foundation,
|
||||
# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
# veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
#
|
||||
# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
# Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
# Siehe die GNU General Public License fuer weitere Details.
|
||||
#
|
||||
# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
# Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################
|
||||
# Moegliche Cronjob Konfiguration
|
||||
# 25 1 * * * cd ~/ && ./updates.sh mta
|
||||
# 25 1 * * * cd ~/ && ./updates.sh mms
|
||||
# 25 1 * * * cd ~/ && ./updates.sh sm
|
||||
# 15 */1 * * * cd ~/ && ./updates.sh mms_snapshot
|
||||
# 15 */1 * * * cd ~/ && ./updates.sh mms_dev
|
||||
# 15 */1 * * * cd ~/ && ./updates.sh sm_snapshot
|
||||
# 15 */1 * * * cd ~/ && ./updates.sh sm_dev
|
||||
|
||||
|
||||
function greenMessage {
|
||||
echo -e "\\033[32;1m${@}\033[0m"
|
||||
}
|
||||
|
||||
function cyanMessage {
|
||||
echo -e "\\033[36;1m${@}\033[0m"
|
||||
}
|
||||
|
||||
function checkCreateVersionFile {
|
||||
if [ ! -f "$HOME/versions/$1" ]; then
|
||||
touch "$HOME/versions/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function checkCreateFolder {
|
||||
if [ ! -d "$1" -a "$1" != "" ]; then
|
||||
mkdir -p "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function removeFile {
|
||||
if [ -f "$1" ]; then
|
||||
rm -f "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function downloadExtractFile {
|
||||
|
||||
checkCreateFolder "$HOME/$4/$1/"
|
||||
|
||||
cd "$HOME/$4/$1/"
|
||||
|
||||
removeFile "$2"
|
||||
|
||||
wget "$3"
|
||||
|
||||
if [ -f "$2" ]; then
|
||||
|
||||
if [[ `echo $2 | egrep -o 'samp[[:digit:]]{1,}svr.+'` ]]; then
|
||||
tar xfv "$2" --strip-components=1
|
||||
else
|
||||
tar xfv "$2"
|
||||
fi
|
||||
|
||||
rm -f "$2"
|
||||
|
||||
moveFilesFolders "$2" "$4" "$1"
|
||||
|
||||
find -type f ! -perm -750 -exec chmod 640 {} \;
|
||||
find -type d -exec chmod 750 {} \;
|
||||
fi
|
||||
}
|
||||
|
||||
function moveFilesFolders {
|
||||
|
||||
FOLDER=`echo $1 | sed -r 's/.tar.gz//g'`
|
||||
|
||||
if [ "$FOLDER" != "" -a "" != "$2" -a "$3" != "" -a -d "$HOME/$2/$3/$FOLDER" ]; then
|
||||
|
||||
cd "$HOME/$2/$3/"
|
||||
|
||||
find "$FOLDER/" -mindepth 1 -type d | while read DIR; do
|
||||
|
||||
NEW_FODLER=${DIR/$FOLDER\//}
|
||||
|
||||
if [ ! -d "$HOME/$2/$3/$NEW_FODLER" ]; then
|
||||
mkdir -p "$HOME/$2/$3/$NEW_FODLER"
|
||||
fi
|
||||
done
|
||||
|
||||
find "$FOLDER/" -type f | while read FILE; do
|
||||
|
||||
MOVE_TO=${FILE/$FOLDER\//.\/}
|
||||
|
||||
if [ "$MOVE_TO" != "" ]; then
|
||||
mv "$FILE" "$MOVE_TO"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf "$FOLDER"
|
||||
fi
|
||||
}
|
||||
|
||||
function update {
|
||||
|
||||
checkCreateVersionFile "$1"
|
||||
|
||||
FILE_NAME=`echo $2 | egrep -o '((sourcemod|mmsource|multitheftauto_linux|baseconfig)-[[:digit:]]|samp[[:digit:]]{1,}svr.+).*$' | tail -1`
|
||||
LOCAL_VERSION=`cat $HOME/versions/$1 | tail -1`
|
||||
CURRENT_VERSION=`echo $2 | egrep -o '((mmsource|sourcemod|multitheftauto_linux|baseconfig)-[0-9a-z.-]{1,}[0-9]|samp[[:digit:]]{1,}svr.+)' | tail -1`
|
||||
|
||||
if ([ "$CURRENT_VERSION" != "$LOCAL_VERSION" -o "$LOCAL_VERSION" == "" ] && [ "$CURRENT_VERSION" != "" ]); then
|
||||
|
||||
greenMessage "Updating $1 from $LOCAL_VERSION to $CURRENT_VERSION. Name of file is $FILE_NAME"
|
||||
|
||||
downloadExtractFile "$3" "$FILE_NAME" "$2" "$4"
|
||||
echo "$CURRENT_VERSION" > "$HOME/versions/$1"
|
||||
|
||||
elif [ "$CURRENT_VERSION" == "" ]; then
|
||||
cyanMessage "Could not detect current version for ${1}. Local version is $LOCAL_VERSION."
|
||||
else
|
||||
cyanMessage "${1} already up to date. Local version is $LOCAL_VERSION. Most recent version is $CURRENT_VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
function updatesAddonSnapshots {
|
||||
|
||||
if [ "$3" == "" ]; then
|
||||
cyanMessage "Searching updates for $1 and revision $2"
|
||||
else
|
||||
cyanMessage "Searching snapshot updates for $1 ($3) and revision $2"
|
||||
fi
|
||||
|
||||
if [ "$1" == "sourcemod" ]; then
|
||||
DOWNLOAD_URL=`lynx -dump "http://www.sourcemod.net/smdrop/$2/" | egrep -o "http:.*sourcemod-.*-linux.*" | tail -2 | head -n 1`
|
||||
else
|
||||
DOWNLOAD_URL=`lynx -dump "http://www.metamodsource.net/mmsdrop/$2/" | egrep -o "http:.*mmsource-.*-git.*-linux.*" | tail -1`
|
||||
fi
|
||||
|
||||
if [ "$3" == "" ]; then
|
||||
update "${1}.txt" "$DOWNLOAD_URL" "${1}" "masteraddons"
|
||||
else
|
||||
update "${1}_snapshot_${3}.txt" "$DOWNLOAD_URL" "${1}-${3}" "masteraddons"
|
||||
fi
|
||||
}
|
||||
function fileUpdate {
|
||||
|
||||
checkCreateVersionFile "$1"
|
||||
|
||||
checkCreateFolder "$HOME/$4/$2"
|
||||
|
||||
cd "$HOME/$4/$2"
|
||||
|
||||
wget "$2"
|
||||
|
||||
NO_HTTP=${2:6}
|
||||
FILE_NAME=${NO_HTTP##/*/}
|
||||
|
||||
if [ "$FILE_NAME" != "" -a -f "$FILE_NAME" ]; then
|
||||
|
||||
LOCAL_VERSION=`cat $HOME/versions/$1 | tail -1`
|
||||
CURRENT_VERSION=`stat -c "%Y" $FILE_NAME`
|
||||
|
||||
if ([ "$CURRENT_VERSION" != "$LOCAL_VERSION" -o "$LOCAL_VERSION" == "" ] && [ "$CURRENT_VERSION" != "" ]); then
|
||||
|
||||
greenMessage "Updating $3 from $LOCAL_VERSION to $CURRENT_VERSION. Name of file is $FILE_NAME"
|
||||
|
||||
unzip "$FILE_NAME"
|
||||
|
||||
echo "$CURRENT_VERSION" > "$HOME/versions/$1"
|
||||
|
||||
else
|
||||
cyanMessage "$3 already up to date. Local version is $LOCAL_VERSION. Most recent version is $CURRENT_VERSION"
|
||||
fi
|
||||
|
||||
rm -f "$FILE_NAME"
|
||||
fi
|
||||
}
|
||||
|
||||
function updateMTA {
|
||||
|
||||
cyanMessage "Searching update for MTA San Andreas"
|
||||
|
||||
DOWNLOAD_URL=`lynx -dump http://linux.mtasa.com/ | egrep -o "http:.*multitheftauto_linux-(.*).tar.gz" | tail -1`
|
||||
update server_mta.txt "$DOWNLOAD_URL" "mtasa" "masterserver"
|
||||
|
||||
DOWNLOAD_URL=`lynx -dump http://linux.mtasa.com/ | egrep -o "http:.*baseconfig-(.*).tar.gz" | tail -1`
|
||||
update server_mta_baseconfig.txt "$DOWNLOAD_URL" "mtasa" "masterserver"
|
||||
|
||||
if [ "`date +'%H'`" == "00" ]; then
|
||||
fileUpdate server_mta_resources.txt "http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip" "mtasa" "masterserver"
|
||||
fi
|
||||
}
|
||||
|
||||
function updateSAMP {
|
||||
|
||||
cyanMessage "Searching update for San Andreas Multi Player"
|
||||
|
||||
DOWNLOAD_URL=`lynx -dump "http://files.sa-mp.com/" | egrep -o "http:.*samp.*tar\.gz" | tail -n 1`
|
||||
update server_samp.txt "$DOWNLOAD_URL" "samp" "masterserver"
|
||||
}
|
||||
|
||||
checkCreateFolder $HOME/versions
|
||||
|
||||
case $1 in
|
||||
"mta") updateMTA;;
|
||||
"samp") updateSAMP;;
|
||||
"mms") updatesAddonSnapshots "metamod" "1.10" "";;
|
||||
"mms_snapshot") updatesAddonSnapshots "metamod" "1.10" "dev";;
|
||||
"mms_dev") updatesAddonSnapshots "metamod" "1.11" "dev";;
|
||||
"sm") updatesAddonSnapshots "sourcemod" "1.7" "";;
|
||||
"sm_snapshot") updatesAddonSnapshots "sourcemod" "1.7" "dev";;
|
||||
"sm_dev") updatesAddonSnapshots "sourcemod" "1.8" "dev";;
|
||||
*) cyanMessage "Usage: ${0} mta|mms|mms_snapshot|mms_dev|sm|sm_snapshot|sm_dev";;
|
||||
esac
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user