diff --git a/source/config.ini b/source/config.ini new file mode 100644 index 0000000..78a12bb --- /dev/null +++ b/source/config.ini @@ -0,0 +1,31 @@ +[mainconfig] + +appname = "SG-Gateway" +appversion = "alpha 1.1" +operationmode = "development" + + +[database] + +username = "sjbilling" +password = "zwNUECRSy1DVZneq" +hostname = "db4free.net" +port = "3306" +dbname = "spacejewelbillin" + +[virtualmin] + +vmin-url = "" +password = "" +username = "" + +[templates] + +templateDirectory = "/source/emailTemplates" + +[mailer] + +username = "0bffccb77f9228" +password = "bbd994d1500dab" +hostname = "smtp.mailtrap.io" +port = "2525" \ No newline at end of file diff --git a/source/config.php b/source/config.php deleted file mode 100644 index f9de827..0000000 --- a/source/config.php +++ /dev/null @@ -1,51 +0,0 @@ - - [ - "appname" => "SG-Gateway", - "appversion" => "alpha 1.0", - "operationmode" => "development" - - ], - - "core" => - [ - "database" => - [ - "username" => "spacejewel", - "password" => "zwNUECRSy1DVZneq", - "hostname" => "spacejewel.ga", - "port" => "3306", - "dbname" => "billing" - ], - "virtualmin" => - [ - "vmin-url" => "", - "password" => "", - "username" => "" - ], - - "templates" => - [ - - "templateDirectory" => $_SERVER['DOCUMENT_ROOT'] . '/source/emailTemplates' - - ], - - "mailer" => - [ - - "username" => "0bffccb77f9228", - "password" => "bbd994d1500dab", - "hostname" => " smtp.mailtrap.io", - "port" => 2525 - - - ] - ] - - ]; \ No newline at end of file diff --git a/source/dbtools/Application.php b/source/dbtools/Application.php index 5c454b2..5d3925f 100644 --- a/source/dbtools/Application.php +++ b/source/dbtools/Application.php @@ -12,46 +12,23 @@ class Application - $this->database['username'] = $cConfigArray['core']['database']['username']; - $this->database['password'] = $cConfigArray['core']['database']['password']; - $this->database['hostname'] = $cConfigArray['core']['database']['hostname']; - $this->database['dbname'] = $cConfigArray['core']['database']['dbname']; - - $this->instDB(); - } - - private function isHostAlive($domain) - { - $starttime = microtime(true); - $file = fsockopen ($domain, 80, $errno, $errstr, 10); - $stoptime = microtime(true); - $status = 0; + $this->database['username'] = $cConfigArray['database']['username']; + $this->database['password'] = $cConfigArray['database']['password']; + $this->database['hostname'] = $cConfigArray['database']['hostname']; + $this->database['dbname'] = $cConfigArray['database']['dbname']; - if (!$file) $status = -1; // Site is down - else - { - fclose($file); - $status = ($stoptime - $starttime) * 1000; - $status = floor($status); - } - return $status; - } - - protected function instDB() - { - - $dsn = "mysql:host=" . $this->database['hostname'] . "dbname=" . $this->database['dbname']; + + $dsn = 'mysql:dbname=' . $this->database['dbname'] . ';host=' . $this->database['hostname']; $username = $this->database['username']; $password = $this->database['password']; - echo $this->database['hostname']; - - $Conn = \ParagonIE\EasyDB\Factory::create($dsn, $username, $password); + $this->db = \ParagonIE\EasyDB\Factory::create($dsn, $username, $password); - $this->db = $Conn; + } + public function Exists($Table, $IDRowColumnName, $SearchValue) { $exists = $db->cell( diff --git a/source/dbtools/ApplicationApiTools.php b/source/dbtools/ApplicationApiTools.php index e946fec..a758891 100644 --- a/source/dbtools/ApplicationApiTools.php +++ b/source/dbtools/ApplicationApiTools.php @@ -11,9 +11,6 @@ class ApplicationAPI extends Application { - private $gDatabase; - - private $AdminID; @@ -22,8 +19,6 @@ class ApplicationAPI extends Application $this->AdminID = $AdminID; - $this->gDatabase = parent::instDB(); - if (!$this->ApiKeyExists($AdminID)) { @@ -35,7 +30,7 @@ class ApplicationAPI extends Application { $AdminID = $this->AdminID; - $record = $this->gDatabase->row( + $record = $this->db->row( "SELECT * FROM APIKeys WHERE AdminID = ?", $AdminID ); diff --git a/source/defs/Virtualmin/Virtualmin.php b/source/defs/Virtualmin/Virtualmin.php index b328ec2..d8738ab 100644 --- a/source/defs/Virtualmin/Virtualmin.php +++ b/source/defs/Virtualmin/Virtualmin.php @@ -13,9 +13,9 @@ class VirtualminHandler $Config = new Config(); $cConfigArray = $Config->getConfig(); - $url = $cConfigArray['vmin-url']; - $username = $cConfigArray['username']; - $password = $cConfigArray['password']; + $url = $cConfigArray['virtualmin']['vmin-url']; + $username = $cConfigArray['virtualmin']['username']; + $password = $cConfigArray['virtualmin']['password']; $this->virtualmin = new Virtualmin\VirtualServersClient($url, $username, $password); } diff --git a/source/helpers/ConfigHelper/class.Config.php b/source/helpers/ConfigHelper/class.Config.php index 7506f8b..16d6998 100644 --- a/source/helpers/ConfigHelper/class.Config.php +++ b/source/helpers/ConfigHelper/class.Config.php @@ -8,10 +8,9 @@ class Config public function __construct() { $ROOT = $_SERVER['DOCUMENT_ROOT']; - $config = $ROOT . "/source/config.php"; + $config = $ROOT . "/source/config.ini"; - $c = include($config); - $this->config = $c; + $this->config = parse_ini_file($config, true);