2016-09-27 13:00:02 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
|
|
|
|
class Conf {
|
2016-10-15 13:45:23 +00:00
|
|
|
public $lang = "en";
|
2016-09-30 01:58:09 +00:00
|
|
|
|
2017-02-16 19:48:47 +00:00
|
|
|
public $dbDriver = Db\DriverSQLite3::class;
|
2016-10-18 15:42:21 +00:00
|
|
|
public $dbSQLite3File = BASE."newssync.db";
|
2016-10-15 13:45:23 +00:00
|
|
|
public $dbSQLite3Key = "";
|
|
|
|
public $dbSQLite3AutoUpd = true;
|
|
|
|
public $dbPostgreSQLHost = "localhost";
|
|
|
|
public $dbPostgreSQLUser = "newssync";
|
|
|
|
public $dbPostgreSQLPass = "";
|
|
|
|
public $dbPostgreSQLPort = 5432;
|
|
|
|
public $dbPostgreSQLDb = "newssync";
|
|
|
|
public $dbPostgreSQLSchema = "";
|
|
|
|
public $dbPostgreSQLAutoUpd = false;
|
|
|
|
public $dbMySQLHost = "localhost";
|
|
|
|
public $dbMySQLUser = "newssync";
|
|
|
|
public $dbMySQLPass = "";
|
|
|
|
public $dbMySQLPort = 3306;
|
|
|
|
public $dbMySQLDb = "newssync";
|
|
|
|
public $dbMySQLAutoUpd = false;
|
|
|
|
|
2017-02-16 19:48:47 +00:00
|
|
|
public $userDriver = User\DriverInternal::class;
|
2016-10-28 12:27:35 +00:00
|
|
|
public $userAuthPreferHTTP = false;
|
|
|
|
public $userComposeNames = true;
|
2016-10-15 13:45:23 +00:00
|
|
|
|
|
|
|
public $simplepieCache = BASE.".cache";
|
2016-09-27 13:00:02 +00:00
|
|
|
|
|
|
|
|
2016-09-30 01:58:09 +00:00
|
|
|
public function __construct(string $import_file = "") {
|
2016-10-02 21:07:17 +00:00
|
|
|
if($import_file != "") $this->importFile($import_file);
|
2016-09-27 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
2016-09-30 01:58:09 +00:00
|
|
|
public function importFile(string $file): self {
|
2017-02-06 00:00:57 +00:00
|
|
|
if(!file_exists($file)) throw new Conf\Exception("fileMissing", $file);
|
|
|
|
if(!is_readable($file)) throw new Conf\Exception("fileUnreadable", $file);
|
|
|
|
try {
|
|
|
|
ob_start();
|
|
|
|
$arr = (@include $file);
|
|
|
|
} catch(\Throwable $e) {
|
|
|
|
$arr = null;
|
|
|
|
} finally {
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
if(!is_array($arr)) throw new Conf\Exception("fileCorrupt", $file);
|
2016-10-02 21:07:17 +00:00
|
|
|
return $this->import($arr);
|
2016-09-30 01:58:09 +00:00
|
|
|
}
|
|
|
|
|
2016-10-02 21:07:17 +00:00
|
|
|
public function import(array $arr): self {
|
|
|
|
foreach($arr as $key => $value) {
|
2017-02-06 00:00:57 +00:00
|
|
|
$this->$key = $value;
|
2016-09-27 13:00:02 +00:00
|
|
|
}
|
2016-09-30 01:58:09 +00:00
|
|
|
return $this;
|
2016-09-27 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
2016-09-30 01:58:09 +00:00
|
|
|
public function export(string $file = ""): string {
|
2016-10-02 21:07:17 +00:00
|
|
|
// TODO
|
2016-09-27 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
2016-09-30 01:58:09 +00:00
|
|
|
public function __toString(): string {
|
2016-09-27 13:00:02 +00:00
|
|
|
return $this->export();
|
|
|
|
}
|
|
|
|
}
|