J. King
8 years ago
4 changed files with 82 additions and 11 deletions
@ -0,0 +1,16 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
namespace JKingWeb\NewsSync; |
|||
|
|||
const BASE = __DIR__.DIRECTORY_SEPARATOR; |
|||
|
|||
spl_autoload_register(function ($class) { |
|||
if($class=="SimplePie") return; |
|||
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
|||
$file = BASE."vendor".DIRECTORY_SEPARATOR.$file.".php"; |
|||
if (file_exists($file)) { |
|||
require_once $file; |
|||
} |
|||
}); |
|||
|
|||
$conf = new Conf(); |
@ -0,0 +1,48 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
namespace JKingWeb\NewsSync; |
|||
|
|||
class Conf { |
|||
public $dbType = "SQLite3"; |
|||
public $dbSQLite3PDO = false; |
|||
public $dbSQLite3File = BASE."newssync.db"; |
|||
public $dbPostgreSQLPDO = false; |
|||
public $dbPostgreSQLHost = "localhost"; |
|||
public $dbPostgreSQLUser = "newssync"; |
|||
public $dbPostgreSQLPass = ""; |
|||
public $dbPostgreSQLPort = 5432; |
|||
public $dbPostgreSQLDb = "newssync"; |
|||
public $dbPostgreSQLSchema = ""; |
|||
public $dbMySQLPDO = false; |
|||
public $dbMySQLHost = "localhost"; |
|||
public $dbMySQLUser = "newssync"; |
|||
public $dbMySQLPass = ""; |
|||
public $dbMySQLPort = 3306; |
|||
public $dbMySQLDb = "newssync"; |
|||
|
|||
public $simplepieCache = BASE.".cache"; |
|||
|
|||
|
|||
function __construct(string $import_file = "") { |
|||
if($import_file != "") $this->import($import_file); |
|||
} |
|||
|
|||
function import(string $file): bool { |
|||
$json = @file_get_contents($file); |
|||
if($json===false) return false; |
|||
$json = json_decode($json, true); |
|||
if(!is_array(json)) return false; |
|||
foreach($json as $key => $value) { |
|||
$this->$$key = $value; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
function export(string $file = ""): string { |
|||
return json_encode($this, JSON_PRETTY_PRINT); |
|||
} |
|||
|
|||
function __toString(): string { |
|||
return $this->export(); |
|||
} |
|||
} |
Loading…
Reference in new issue