2016-09-27 13:00:02 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse;
|
2016-09-27 13:00:02 +00:00
|
|
|
|
|
|
|
class Conf {
|
2017-02-16 20:29:42 +00:00
|
|
|
public $lang = "en";
|
2016-10-15 13:45:23 +00:00
|
|
|
|
2017-03-07 23:01:13 +00:00
|
|
|
public $dbDriver = Db\SQLite3\Driver::class;
|
2017-03-10 02:39:42 +00:00
|
|
|
public $dbSchemaBase = BASE.'sql';
|
2017-03-28 04:12:12 +00:00
|
|
|
public $dbSQLite3File = BASE."arsse.db";
|
2017-02-16 20:29:42 +00:00
|
|
|
public $dbSQLite3Key = "";
|
|
|
|
public $dbSQLite3AutoUpd = true;
|
|
|
|
public $dbPostgreSQLHost = "localhost";
|
2017-03-28 04:12:12 +00:00
|
|
|
public $dbPostgreSQLUser = "arsse";
|
2017-02-16 20:29:42 +00:00
|
|
|
public $dbPostgreSQLPass = "";
|
|
|
|
public $dbPostgreSQLPort = 5432;
|
2017-03-28 04:12:12 +00:00
|
|
|
public $dbPostgreSQLDb = "arsse";
|
2017-02-16 20:29:42 +00:00
|
|
|
public $dbPostgreSQLSchema = "";
|
|
|
|
public $dbPostgreSQLAutoUpd = false;
|
|
|
|
public $dbMySQLHost = "localhost";
|
2017-03-28 04:12:12 +00:00
|
|
|
public $dbMySQLUser = "arsse";
|
2017-02-16 20:29:42 +00:00
|
|
|
public $dbMySQLPass = "";
|
|
|
|
public $dbMySQLPort = 3306;
|
2017-03-28 04:12:12 +00:00
|
|
|
public $dbMySQLDb = "arsse";
|
2017-02-16 20:29:42 +00:00
|
|
|
public $dbMySQLAutoUpd = false;
|
2016-10-15 13:45:23 +00:00
|
|
|
|
2017-03-07 23:01:13 +00:00
|
|
|
public $userDriver = User\Internal\Driver::class;
|
2017-02-16 20:29:42 +00:00
|
|
|
public $userComposeNames = true;
|
2017-02-20 22:04:13 +00:00
|
|
|
public $userTempPasswordLength = 20;
|
2016-09-27 13:00:02 +00:00
|
|
|
|
2017-05-27 22:15:52 +00:00
|
|
|
public $fetchTimeout = 10;
|
|
|
|
public $fetchSizeLimit = 2 * 1024 * 1024;
|
|
|
|
public $fetchUserAgentString;
|
2016-09-27 13:00:02 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
public function __construct(string $import_file = "") {
|
2017-05-27 22:15:52 +00:00
|
|
|
$this->fetchUserAgentString = sprintf('Arsse/%s (%s %s; %s; https://code.jkingweb.ca/jking/arsse) PicoFeed (https://github.com/fguillot/picoFeed)',
|
2017-03-29 14:27:54 +00:00
|
|
|
VERSION, // Arsse version
|
|
|
|
php_uname('s'), // OS
|
|
|
|
php_uname('r'), // OS version
|
|
|
|
php_uname('m') // platform architecture
|
|
|
|
);
|
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
if($import_file != "") $this->importFile($import_file);
|
|
|
|
}
|
2016-09-30 01:58:09 +00:00
|
|
|
|
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
|
|
|
}
|