2016-09-27 09:00:02 -04:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
|
|
|
|
class Conf {
|
2016-09-29 21:58:09 -04:00
|
|
|
public $lang = "en";
|
|
|
|
|
|
|
|
public $dbClass = NS_BASE."Db\\DriverSQLite3";
|
2016-10-05 22:08:43 -04:00
|
|
|
public $dbSQLite3Path = BASE."db";
|
2016-10-02 17:07:17 -04:00
|
|
|
public $dbSQLite3Key = "";
|
2016-09-27 09:00:02 -04:00
|
|
|
public $dbPostgreSQLHost = "localhost";
|
|
|
|
public $dbPostgreSQLUser = "newssync";
|
|
|
|
public $dbPostgreSQLPass = "";
|
|
|
|
public $dbPostgreSQLPort = 5432;
|
|
|
|
public $dbPostgreSQLDb = "newssync";
|
|
|
|
public $dbPostgreSQLSchema = "";
|
|
|
|
public $dbMySQLHost = "localhost";
|
|
|
|
public $dbMySQLUser = "newssync";
|
|
|
|
public $dbMySQLPass = "";
|
|
|
|
public $dbMySQLPort = 3306;
|
|
|
|
public $dbMySQLDb = "newssync";
|
|
|
|
|
2016-09-29 21:58:09 -04:00
|
|
|
public $authClass = NS_BASE."Auth\\DriverInternal";
|
|
|
|
public $authPreferHTTP = false;
|
|
|
|
public $authProvision = false;
|
|
|
|
|
2016-09-27 09:00:02 -04:00
|
|
|
public $simplepieCache = BASE.".cache";
|
|
|
|
|
|
|
|
|
2016-09-29 21:58:09 -04:00
|
|
|
public function __construct(string $import_file = "") {
|
2016-10-02 17:07:17 -04:00
|
|
|
if($import_file != "") $this->importFile($import_file);
|
2016-09-27 09:00:02 -04:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:58:09 -04:00
|
|
|
public function importFile(string $file): self {
|
|
|
|
if(!file_exists($file)) throw new Conf\Exception("fileMissing");
|
|
|
|
if(!is_readable($file)) throw new Conf\Exception("fileUnreadable");
|
2016-10-02 17:07:17 -04:00
|
|
|
$arr = (@include $file);
|
|
|
|
if(!is_array($arr)) throw new Conf\Exception("fileCorrupt");
|
|
|
|
return $this->import($arr);
|
2016-09-29 21:58:09 -04:00
|
|
|
}
|
|
|
|
|
2016-10-02 17:07:17 -04:00
|
|
|
public function import(array $arr): self {
|
|
|
|
foreach($arr as $key => $value) {
|
2016-09-27 09:00:02 -04:00
|
|
|
$this->$$key = $value;
|
|
|
|
}
|
2016-09-29 21:58:09 -04:00
|
|
|
return $this;
|
2016-09-27 09:00:02 -04:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:58:09 -04:00
|
|
|
public function export(string $file = ""): string {
|
2016-10-02 17:07:17 -04:00
|
|
|
// TODO
|
2016-09-27 09:00:02 -04:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:58:09 -04:00
|
|
|
public function __toString(): string {
|
2016-09-27 09:00:02 -04:00
|
|
|
return $this->export();
|
|
|
|
}
|
|
|
|
}
|