1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00
Arsse/lib/Conf.php

66 lines
2.1 KiB
PHP
Raw Normal View History

2016-09-27 13:00:02 +00:00
<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
class Conf {
2017-02-16 20:29:42 +00:00
public $lang = "en";
public $dbDriver = Db\SQLite3\Driver::class;
2017-03-10 02:39:42 +00:00
public $dbSchemaBase = BASE.'sql';
2017-02-16 20:29:42 +00:00
public $dbSQLite3File = BASE."newssync.db";
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;
public $userDriver = User\Internal\Driver::class;
2017-02-16 20:29:42 +00:00
public $userAuthPreferHTTP = false;
public $userComposeNames = true;
public $userTempPasswordLength = 20;
2016-09-27 13:00:02 +00:00
2017-02-16 20:29:42 +00:00
public function __construct(string $import_file = "") {
if($import_file != "") $this->importFile($import_file);
}
2017-02-16 20:29:42 +00:00
public function importFile(string $file): self {
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);
return $this->import($arr);
}
2016-09-27 13:00:02 +00:00
2017-02-16 20:29:42 +00:00
public function import(array $arr): self {
foreach($arr as $key => $value) {
$this->$key = $value;
}
return $this;
}
2016-09-27 13:00:02 +00:00
2017-02-16 20:29:42 +00:00
public function export(string $file = ""): string {
// TODO
}
public function __toString(): string {
return $this->export();
}
2016-09-27 13:00:02 +00:00
}