removed 'application' folder to have everything in the root directory

This commit is contained in:
Steffen Schröder
2014-09-29 18:20:09 +02:00
parent 1569fd5488
commit 9642433363
284 changed files with 4 additions and 50 deletions

89
core/Server/Config.php Normal file
View File

@ -0,0 +1,89 @@
<?php
namespace ManiaControl\Server;
/**
* Model Class holding the Server Config
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Config {
/*
* Public properties
*/
public $id = null;
public $host = null;
public $port = null;
public $user = null;
public $pass = null;
/**
* Create a new server config instance
*
* @param mixed $id
* @param mixed $host
* @param mixed $port
* @param mixed $user
* @param mixed $pass
*/
public function __construct($id = null, $host = null, $port = null, $user = null, $pass = null) {
$this->id = $this->extractConfigData($id);
$this->host = $this->extractConfigData($host);
$this->port = $this->extractConfigData($port);
$this->user = $this->extractConfigData($user);
$this->pass = $this->extractConfigData($pass);
}
/**
* Extract the actual Data from the given Config Param
*
* @param mixed $configParam
* @return string
*/
private function extractConfigData($configParam) {
if (is_array($configParam)) {
return (string)reset($configParam);
}
return (string)$configParam;
}
/**
* Validate the Config Data
*
* @param string $message
* @return bool
*/
public function validate(&$message = null) {
// Host
if (!$this->host) {
$message = 'Missing Host!';
return false;
}
// Port
if (!$this->port || $this->port === 'port') {
$message = 'Missing Port!';
return false;
}
// User
if (!$this->user) {
$message = 'Missing User!';
return false;
}
if (!in_array($this->user, array('SuperAdmin', 'Admin', 'User'))) {
$message = 'Invalid User!';
return false;
}
// Pass
if (!$this->pass) {
$message = 'Missing Pass!';
return false;
}
return true;
}
}