new ini-based config format
This commit is contained in:
parent
bee067a898
commit
7347fbe32f
@ -17,6 +17,7 @@ mkdir "$REPO_DIR";
|
||||
echo "Cloning repository";
|
||||
git clone "$GIT_URL" -b "$VERSION" "$REPO_DIR";
|
||||
rm -rf "$REPO_DIR/.git";
|
||||
rm -rf "$REPO_DIR/_scripts";
|
||||
|
||||
echo "Creating archive";
|
||||
cd "$REPO_DIR";
|
||||
|
@ -55,7 +55,7 @@
|
||||
}
|
||||
|
||||
// Get required permissions
|
||||
$this->app->loadClass($route->action, "\\Crispage\\Framework\\Action");
|
||||
$this->app->loadClass($route->action, "action");
|
||||
if (!is_a($route->action, "\\Crispage\\Response\\APIPermissions", true)) {
|
||||
http_response_code(500);
|
||||
header("Content-Type: application/json");
|
||||
@ -103,7 +103,7 @@
|
||||
|
||||
$this->app->route = $route;
|
||||
$this->app->page->template->setLayout(
|
||||
$route->data["layout"] ?? "api"
|
||||
$route->data["layout"] ?? "api",
|
||||
$route->data["template"] ?? "default"
|
||||
);
|
||||
$this->app->page->setAction(
|
||||
|
@ -54,7 +54,7 @@
|
||||
// If classname given, create the module
|
||||
$component = strval($this->app->request->params["component"] ?? "");
|
||||
if (!empty($component)) {
|
||||
$this->app->loadClass($component, "\\Crispage\\Framework\\Component");
|
||||
$this->app->loadClass($component, "component");
|
||||
if (!is_a($component, "\Crispage\Framework\ModuleComponent", true)) {
|
||||
$this->app->page->setPersistentMessage(
|
||||
"invalid_module_component",
|
||||
|
27
core/app/ApplicationConfig.php
Normal file
27
core/app/ApplicationConfig.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
Crispage CMS
|
||||
crispycat <the@crispy.cat>
|
||||
https://crispy.cat/software/crispage
|
||||
|
||||
Crispage is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
*/
|
||||
|
||||
namespace Crispage;
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
define("CONFIG_PATH", ROOT . "/config.php");
|
||||
|
||||
define("CONFIG_DATA", parse_ini_file(CONFIG_PATH, false, INI_SCANNER_TYPED));
|
||||
|
||||
class ApplicationConfig {
|
||||
public static function get(string $key, mixed $default = null): mixed {
|
||||
if (!defined("CONFIG_DATA")) return $default;
|
||||
return CONFIG_DATA[$key] ?? $default;
|
||||
}
|
||||
}
|
||||
?>
|
@ -12,7 +12,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
|
||||
use \Crispage\CrispageException;
|
||||
require_once ROOT . "/core/app/CrispageException.php";
|
||||
@ -78,6 +78,13 @@
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Crispage {
|
||||
public const FRAMEWORK_CLASSES = [
|
||||
"asset" => "\\Crispage\\Framework\\Asset",
|
||||
"action" => "\\Crispage\\Framework\\Action",
|
||||
"component" => "\\Crispage\\Framework\\Component",
|
||||
"plugin" => "\\Crispage\\Framework\\Plugin"
|
||||
];
|
||||
|
||||
public static function uriFilters(): array {
|
||||
return [
|
||||
"frontend" => function(string $uri, array $parse): string {
|
||||
@ -161,16 +168,16 @@
|
||||
}
|
||||
|
||||
public function loadDatabase(): void {
|
||||
$db = Config::DB_TYPE;
|
||||
$db = ApplicationConfig::get("crispage.database.type");
|
||||
if (!class_exists($db)) die("Invalid database type; please check config");
|
||||
$this->database = new $db([
|
||||
"location" => Config::DB_LOC,
|
||||
"port" => Config::DB_PORT,
|
||||
"username" => Config::DB_USER,
|
||||
"password" => Config::DB_PASSWD,
|
||||
"dbname" => Config::DB_NAME,
|
||||
"prefix" => Config::DB_PREFIX,
|
||||
"options" => Config::DB_OPTS
|
||||
"location" => ApplicationConfig::get("crispage.database.location"),
|
||||
"port" => ApplicationConfig::get("crispage.database.port"),
|
||||
"username" => ApplicationConfig::get("crispage.database.user"),
|
||||
"password" => ApplicationConfig::get("crispage.database.password"),
|
||||
"dbname" => ApplicationConfig::get("crispage.database.name"),
|
||||
"prefix" => ApplicationConfig::get("crispage.database.prefix"),
|
||||
"options" => ApplicationConfig::get("crispage.database.options")
|
||||
]);
|
||||
}
|
||||
|
||||
@ -222,7 +229,7 @@
|
||||
];
|
||||
|
||||
// Default scripts
|
||||
$domain = Config::SITE_DOMAIN;
|
||||
$domain = ApplicationConfig::get("crispage.site_domain");
|
||||
$wroot = WROOT;
|
||||
$version = VERSION;
|
||||
$mbase = MediaItem::uri("/");
|
||||
@ -244,14 +251,22 @@
|
||||
// Return if already loaded
|
||||
if (in_array($classname, $this->loadedClasses)) return;
|
||||
|
||||
// Assemble paths
|
||||
$classpaths = Config::CLASS_PATHS[$type] ?? null;
|
||||
if (!$classpaths) {
|
||||
if (!in_array($type, array_keys(self::FRAMEWORK_CLASSES))) {
|
||||
$this->handleException(new CrispageException(
|
||||
"Unknown class type $type", 500
|
||||
));
|
||||
}
|
||||
|
||||
$typeclass = self::FRAMEWORK_CLASSES[$type];
|
||||
|
||||
// Assemble paths
|
||||
$classpaths = ApplicationConfig::get("crispage.paths.$type") ?? [];
|
||||
if (empty($classpaths)) {
|
||||
$this->handleException(new CrispageException(
|
||||
"No paths for class type $type", 500
|
||||
));
|
||||
}
|
||||
|
||||
$name = preg_replace("/\\\\/", "/", $classname) . ".php";
|
||||
$paths = [];
|
||||
foreach ($classpaths as $cpath) $paths[] = ROOT . $cpath . $name;
|
||||
@ -267,9 +282,9 @@
|
||||
include_once $path;
|
||||
if (class_exists($classname)) {
|
||||
// Check that class is of the right type
|
||||
if (!is_a($classname, $type, true)) {
|
||||
if (!is_a($classname, $typeclass, true)) {
|
||||
$this->app->handleException(new CrispageException(
|
||||
"$classname is not a $type", 500
|
||||
"$classname is not a $typeclass", 500
|
||||
));
|
||||
}
|
||||
// Add to loaded classes
|
||||
@ -290,9 +305,9 @@
|
||||
// If module is not enabled, return null
|
||||
if (!$plugin->enabled) return null;
|
||||
|
||||
// Load class and create runnable
|
||||
$this->loadClass($plugin->runnable, "\\Crispage\\Framwork\\PluginClass");
|
||||
$runnable = new ($plugin->runnable)(
|
||||
// Load class and create classname
|
||||
$this->loadClass($plugin->classname, "plugin");
|
||||
$classname = new ($plugin->classname)(
|
||||
$this, array_merge($plugin->getOptions(), ["plugin" => $plugin])
|
||||
);
|
||||
|
||||
@ -301,19 +316,19 @@
|
||||
$inserted = false;
|
||||
foreach ($this->plugins as $ind => $plug) {
|
||||
if ($plug[0]->priority > $plugin->priority) {
|
||||
array_splice($this->plugins, $ind, 0, [[$plugin, $runnable]]);
|
||||
array_splice($this->plugins, $ind, 0, [[$plugin, $classname]]);
|
||||
$inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If no place for the new plugin was found, insert it at the end
|
||||
if (!$inserted) $this->plugins[] = [$plugin, $runnable];
|
||||
if (!$inserted) $this->plugins[] = [$plugin, $classname];
|
||||
|
||||
// Trigger event
|
||||
$this->dispatcher->trigger("crispage.plugin_loaded", [$plugin, $runnable]);
|
||||
$this->dispatcher->trigger("crispage.plugin_loaded", [$plugin, $classname]);
|
||||
|
||||
// Return
|
||||
return [$plugin, $runnable];
|
||||
return [$plugin, $classname];
|
||||
}
|
||||
|
||||
public function unloadPlugin(string $mid): ?array {
|
||||
@ -381,7 +396,7 @@
|
||||
// Handle exception
|
||||
|
||||
$err = new CrispageException(
|
||||
"Plugin Error ({$plugin[0]->runnable}\${$plugin[0]->id})",
|
||||
"Plugin Error ({$plugin[0]->classname}\${$plugin[0]->id})",
|
||||
500, $e
|
||||
);
|
||||
$this->dispatcher->trigger("crispage.plugin_error", $plugin[0], $plugin[1], $err);
|
||||
@ -435,6 +450,8 @@
|
||||
}
|
||||
|
||||
public function handleException(\Throwable $exception): void {
|
||||
if (ApplicationConfig::get("crispage.dev.disable_exception_handling", false))
|
||||
throw $exception;
|
||||
// if already handling an exception, add to the additional list
|
||||
if ($this->handlingException) {
|
||||
$this->additionalExceptions[] = $exception;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
|
||||
class CrispageException extends \Exception {
|
||||
public bool $showDebug;
|
||||
@ -24,7 +24,7 @@
|
||||
bool $showDebug = true
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->showDebug = $showDebug || Config::DEV_FORCE_ERRMSGS;
|
||||
$this->showDebug = $showDebug || ApplicationConfig::get("crispage.dev.force_errmsgs");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
// Load default asset classes
|
||||
foreach (self::CORE_CLASSES as $class)
|
||||
$this->app->loadClass($class, "\\Crispage\\Framework\\Asset", true);
|
||||
$this->app->loadClass($class, "asset", true);
|
||||
|
||||
// Automatically update routes
|
||||
$this->app->dispatcher->register(
|
||||
|
@ -135,7 +135,7 @@
|
||||
intval($Crispage->request->params["asset_id"]) ?? 0
|
||||
);
|
||||
|
||||
$Crispage->loadClass($asset->component, "\\Crispage\\Framework\\Component");
|
||||
$Crispage->loadClass($asset->component, "component");
|
||||
|
||||
$ndata = [];
|
||||
foreach ($asset->component::getModuleFields() as $name => $field)
|
||||
|
@ -117,7 +117,7 @@
|
||||
intval($Crispage->request->params["asset_id"]) ?? 0
|
||||
);
|
||||
|
||||
$Crispage->loadClass($asset->component, "\\Crispage\\Framework\\Component");
|
||||
$Crispage->loadClass($asset->component, "component");
|
||||
|
||||
$ndata = [];
|
||||
foreach ($asset->component::getPluginFields() as $name => $field)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
require_once ROOT . "/core/app/auth/CorePermissions.php";
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use \Crispage\Assets\User;
|
||||
use \Crispage\Utils\UriUtils;
|
||||
@ -71,11 +71,15 @@
|
||||
}
|
||||
|
||||
public function password_hash(string $passwd): string {
|
||||
return password_hash($passwd, Config::PASSWD_ALGO, Config::PASSWD_OPTS);
|
||||
return password_hash(
|
||||
$passwd,
|
||||
ApplicationConfig::get("crispage.security.password_algo"),
|
||||
ApplicationConfig::get("crispage.security.password_opts")
|
||||
);
|
||||
}
|
||||
|
||||
public function token(): string {
|
||||
return bin2hex(random_bytes(Config::TOKEN_BYTES));
|
||||
return bin2hex(random_bytes(ApplicationConfig::get("crispage.security.token_bytes")));
|
||||
}
|
||||
|
||||
public function startSession(User $user): int {
|
||||
@ -389,7 +393,7 @@
|
||||
$this->app->settings->get("crispage.auth.registration_enabled", 0)
|
||||
);
|
||||
|
||||
if (!Config::ENABLE_USER_REGISTRATION || !$registration_enabled)
|
||||
if (!ApplicationConfig::get("crispage.security.enable_registration") || !$registration_enabled)
|
||||
return static::ERR_REGISTER_DISABLED;
|
||||
|
||||
$username = preg_replace("/\\W/", "_", strtolower($username));
|
||||
@ -450,10 +454,10 @@
|
||||
"expire_time" => $etime
|
||||
]);
|
||||
|
||||
$sitename = $this->app->settings->get("crispage.site_name", Config::SITE_DOMAIN);
|
||||
$sitename = $this->app->settings->get("crispage.site_name", ApplicationConfig::get("crispage.site_domain"));
|
||||
|
||||
$link = UriUtils::uri(
|
||||
Config::SITE_DOMAIN, WROOT . "/confirm_account",
|
||||
ApplicationConfig::get("crispage.site_domain"), WROOT . "/confirm_account",
|
||||
($this->app->request->secure) ? "https://" : "http://",
|
||||
["user_id" => $user->id, "token" => $token]
|
||||
);
|
||||
@ -514,10 +518,10 @@
|
||||
"expire_time" => $etime
|
||||
]);
|
||||
|
||||
$sitename = $this->app->settings->get("crispage.site_name", Config::SITE_DOMAIN);
|
||||
$sitename = $this->app->settings->get("crispage.site_name", ApplicationConfig::get("crispage.site_domain"));
|
||||
|
||||
$link = UriUtils::uri(
|
||||
Config::SITE_DOMAIN, WROOT . "/reset_password",
|
||||
ApplicationConfig::get("crispage.site_domain"), WROOT . "/reset_password",
|
||||
($this->app->request->secure) ? "https://" : "http://",
|
||||
["user_id" => $user->id, "token" => $token]
|
||||
);
|
||||
@ -565,7 +569,7 @@
|
||||
$user ??= $this->currentUser;
|
||||
if (!$user) return -1;
|
||||
|
||||
if (in_array($user->slug, Config::SUPERUSERS)) return 0;
|
||||
if (in_array($user->slug, ApplicationConfig::get("crispage.dev.superusers"))) return 0;
|
||||
|
||||
// Start with lowest rank (highest number)
|
||||
$rank = PHP_INT_MAX;
|
||||
@ -585,7 +589,7 @@
|
||||
$user ??= $this->currentUser;
|
||||
if (!$user) return 0;
|
||||
|
||||
if (in_array($user->slug, Config::SUPERUSERS))
|
||||
if (in_array($user->slug, ApplicationConfig::get("crispage.superusers")))
|
||||
return CorePermissions::ALL;
|
||||
|
||||
// Start with no perms
|
||||
|
10
core/app/cache/CacheEngine.php
vendored
10
core/app/cache/CacheEngine.php
vendored
@ -16,7 +16,7 @@
|
||||
|
||||
require_once ROOT . "/core/app/cache/CacheEntry.php";
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use \Crispage\Framework\Component;
|
||||
use \Crispage\Utils\FileUtils;
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
public function __construct(\Crispage $app) {
|
||||
parent::__construct($app);
|
||||
$this->path = ROOT . Config::TEMP_PATH . "/cache";
|
||||
$this->path = ROOT . ApplicationConfig::get("crispage.paths.temp") . "/cache";
|
||||
|
||||
$this->initializeCache(false);
|
||||
}
|
||||
@ -46,7 +46,7 @@
|
||||
}
|
||||
|
||||
public function getPolicy(?int $policy, ?int $ttl): array {
|
||||
if (Config::DEV_DISABLE_CACHING)
|
||||
if (ApplicationConfig::get("crispage.dev.disable_caching"))
|
||||
return ["policy" => static::POL_NOCACHE, "ttl" => 0];
|
||||
|
||||
switch ($policy) {
|
||||
@ -94,7 +94,7 @@
|
||||
}
|
||||
|
||||
public function get(string $bucket, string $key): ?CacheEntry {
|
||||
if (Config::DEV_DISABLE_CACHING) return null;
|
||||
if (ApplicationConfig::get("crispage.dev.disable_caching")) return null;
|
||||
$this->entries[$bucket] ??= [];
|
||||
$entry = $this->entries[$bucket][md5($key)] ?? null;
|
||||
if ($entry && !$entry->expired()) return $entry;
|
||||
@ -116,7 +116,7 @@
|
||||
}
|
||||
|
||||
public function set(CacheEntry $entry): void {
|
||||
if (Config::DEV_DISABLE_CACHING) return;
|
||||
if (ApplicationConfig::get("crispage.dev.disable_caching")) return;
|
||||
$this->entries[$entry->bucket] ??= [];
|
||||
$this->entries[$entry->bucket][$entry->key] = $entry;
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Utils\FileUtils;
|
||||
use \Crispage\Utils\URIUtils;
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
public int $mtime;
|
||||
|
||||
public static function realpath(string $path): string {
|
||||
$base = realpath(ROOT . Config::MEDIA_PATH);
|
||||
$base = realpath(ROOT . ApplicationConfig::get("crispage.paths.media"));
|
||||
if ($path == "/") return $base;
|
||||
else {
|
||||
$real = realpath("$base/$path");
|
||||
@ -38,9 +38,9 @@
|
||||
}
|
||||
|
||||
public static function uri(string $path): string {
|
||||
return (Config::MEDIA_CUSTOM_PREFIX) ?
|
||||
Config::MEDIA_CUSTOM_PREFIX . $path :
|
||||
URIUtils::iuri(Config::MEDIA_PATH . $path);
|
||||
$url = ApplicationConfig::get("crispage.paths.mediaurl");
|
||||
return ($url) ? $url . $path :
|
||||
URIUtils::iuri(ApplicationConfig::get("crispage.paths.media") . $path);
|
||||
}
|
||||
|
||||
public function __construct(string $path) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use \Crispage\Utils\FileUtils;
|
||||
use \Crispage\Utils\URIUtils;
|
||||
@ -33,7 +33,7 @@
|
||||
}
|
||||
|
||||
public function writable(string $path): bool {
|
||||
foreach (Config::MEDIA_WRITABLE_PATHS as $prefix)
|
||||
foreach (ApplicationConfig::get("crispage.security.media_paths") as $prefix)
|
||||
if (!strncmp($path, $prefix, strlen($prefix))) return true;
|
||||
return false;
|
||||
}
|
||||
@ -60,7 +60,7 @@
|
||||
}
|
||||
|
||||
public function upload(array $file, MediaItem $folder): ?MediaItem {
|
||||
if (in_array(mime_content_type($file["tmp_name"]), Config::MEDIA_MIMETYPE_BLACKLIST))
|
||||
if (in_array(mime_content_type($file["tmp_name"]), ApplicationConfig::get("crispage.security.media_banned_mimes")))
|
||||
return null;
|
||||
if (!$this->writable($folder->path)) return null;
|
||||
$sn = FileUtils::sanitizeName($file["name"]);
|
||||
|
@ -68,8 +68,12 @@
|
||||
$weights[$k] ??= self::DEFAULT_FIELD_WEIGHT / $propcount;
|
||||
|
||||
$score = 0;
|
||||
foreach ($obj as $k => $v)
|
||||
$score += $this->score_str(strval($v)) * $weights[$k];
|
||||
foreach ($obj as $k => $v) {
|
||||
try {
|
||||
$score += $this->score_str(strval($v)) * $weights[$k];
|
||||
}
|
||||
catch (\Throwable $e) {}
|
||||
}
|
||||
return $score;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
|
||||
require_once ROOT . "/core/app/cms/search/SearchFilter.php";
|
||||
|
@ -73,7 +73,7 @@
|
||||
try {
|
||||
$stmt->execute($params);
|
||||
} catch (\PDOException $e) {
|
||||
if (Config::SHOW_DB_ERRORS) var_dump([$query, $params, $e]);
|
||||
if (ApplicationConfig::get("crispage.dev.db_errors")) var_dump([$query, $params, $e]);
|
||||
throw $e;
|
||||
}
|
||||
return $stmt;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use \Crispage\Utils\FileUtils;
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
}
|
||||
|
||||
public function getPath(Extension $package): string {
|
||||
return ROOT . Config::PACKAGE_PATH . "/$package->classname";
|
||||
return ROOT . ApplicationConfig::get("crispage.paths.packages") . "/$package->classname";
|
||||
}
|
||||
|
||||
public function getPackageInfo(Extension $package): array {
|
||||
@ -107,7 +107,7 @@
|
||||
public function upload(array $file): ?Extension {
|
||||
$sn = FileUtils::sanitizeName($file["name"]);
|
||||
$time = time();
|
||||
$upath = ROOT . Config::TEMP_PATH . "/pkguploads/{$time}_$sn";
|
||||
$upath = ROOT . ApplicationConfig::get("crispage.paths.temp") . "/pkguploads/{$time}_$sn";
|
||||
|
||||
if ($file["error"] != UPLOAD_ERR_OK) {
|
||||
$this->status = static::ERR_UPLOAD_FAILED;
|
||||
@ -153,7 +153,7 @@
|
||||
$this->log("Installing package $id v$version", $this::L_INFO);
|
||||
|
||||
try {
|
||||
$epath = ROOT . Config::PACKAGE_PATH . "/$id";
|
||||
$epath = ROOT . ApplicationConfig::get("crispage.paths.packages") . "/$id";
|
||||
FileUtils::emptyDirectory($epath);
|
||||
$phar->extractTo($epath);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
public function loadDefaults(): void {
|
||||
$this->pm->isSMTP();
|
||||
$this->pm->SMTPDebug = Config::SMTP_DEBUG;
|
||||
$this->pm->SMTPDebug = ApplicationConfig::get("crispage.dev.smtp_debug");
|
||||
$this->pm->Host = $this->app->settings->get(
|
||||
"crispage.mailing.smtp_host", "localhost"
|
||||
);
|
||||
@ -52,9 +52,9 @@
|
||||
$this->pm->setFrom(
|
||||
$this->app->settings->get(
|
||||
"crispage.mailing.from_addr",
|
||||
"webmaster@" . Config::SITE_DOMAIN
|
||||
"webmaster@" . ApplicationConfig::get("crispage.site_domain")
|
||||
),
|
||||
$this->app->settings->get("crispage.site_name", Config::SITE_DOMAIN)
|
||||
$this->app->settings->get("crispage.site_name", ApplicationConfig::get("crispage.site_domain"))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
use \Crispage\Response\Template;
|
||||
require_once ROOT . "/core/app/response/Template.php";
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\CrispageException;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
use \Crispage\Assets\Module;
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
public function createComponent(string $classname, array $data = []): Component {
|
||||
// Load component class
|
||||
$this->app->loadClass($classname, "\\Crispage\\Framework\\Component");
|
||||
$this->app->loadClass($classname, "component");
|
||||
// Create component
|
||||
$com = new $classname($this->app, $data);
|
||||
// Trigger event
|
||||
@ -75,7 +75,7 @@
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
// If $safe, return the execption
|
||||
if ($safe && !Config::DEV_MODULES_UNSAFE) return $e;
|
||||
if ($safe && !ApplicationConfig::get("crispage.dev.modules_unsafe")) return $e;
|
||||
// Otherwise throw it
|
||||
throw $e;
|
||||
}
|
||||
@ -125,7 +125,7 @@
|
||||
|
||||
public function setAction(string $classname, array $data = []): Action {
|
||||
// Load action class
|
||||
$this->app->loadClass($classname, "\\Crispage\\Framework\\Action");
|
||||
$this->app->loadClass($classname, "action");
|
||||
// Create and set action
|
||||
$this->action = new $classname($this->app, $data);
|
||||
// Trigger event
|
||||
@ -271,7 +271,7 @@
|
||||
|
||||
public function startBuffering(): bool {
|
||||
if (!$this->sent) return false;
|
||||
if (Config::DEV_DISABLE_OB) $this->sent = false;
|
||||
if (ApplicationConfig::get("crispage.dev.disable_buffering")) $this->sent = false;
|
||||
else $this->sent = !ob_start();
|
||||
if (!$this->sent) {
|
||||
$this->app->dispatcher->trigger("crispage.page.buffering_started");
|
||||
@ -282,7 +282,7 @@
|
||||
|
||||
public function stopBuffering(bool $render = true): bool {
|
||||
if ($this->sent) return false;
|
||||
if (Config::DEV_DISABLE_OB) $this->sent = true;
|
||||
if (ApplicationConfig::get("crispage.dev.disable_buffering")) $this->sent = true;
|
||||
else $this->sent = ($render) ? ob_end_flush() : ob_end_clean();
|
||||
if ($this->sent) {
|
||||
$this->app->dispatcher->trigger("crispage.page.buffering_stopped", $render);
|
||||
@ -310,7 +310,7 @@
|
||||
|
||||
public function setCookie(string $name, string $value, array $options = []): bool {
|
||||
$options["path"] ??= WROOT;
|
||||
$options["domain"] ??= Config::SITE_DOMAIN;
|
||||
$options["domain"] ??= ApplicationConfig::get("crispage.site_domain");
|
||||
$options["secure"] ??= $this->app->request->secure;
|
||||
$res = setcookie($name, $value, $options);
|
||||
if ($res) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\CrispageException;
|
||||
use \Crispage\Extensions\Extension;
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
}
|
||||
|
||||
private function findPath(string $template): string {
|
||||
foreach (Config::TEMPLATE_PATH as $path) {
|
||||
foreach (ApplicationConfig::get("crispage.paths.template") as $path) {
|
||||
$tpath = "$path/$template";
|
||||
if (file_exists(ROOT . $tpath)) break;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Framework\ApplicationFeature;
|
||||
|
||||
class I18n extends ApplicationFeature {
|
||||
@ -102,7 +102,7 @@
|
||||
|
||||
// Find and load files
|
||||
foreach ($this->app->extensions->getAllOfType("translation") as $ext) {
|
||||
foreach (Config::TRANSLATION_PATH as $path) {
|
||||
foreach (ApplicationConfig::get("crispage.paths.translation") as $path) {
|
||||
$transpath = ROOT . "$path/$ext->classname";
|
||||
if (file_exists($transpath)) break;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
defined("ROOT") or die();
|
||||
|
||||
use \Crispage\Config;
|
||||
use \Crispage\ApplicationConfig;
|
||||
use \Crispage\Utils\URIUtils;
|
||||
use \Crispage\Utils\FileUtils;
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
($this->app->i18n)(
|
||||
"{%UPLOADING_TO_X} {%BLACKLISTED_MIME_TYPES_X} {%MAX_FILE_SIZE_X}",
|
||||
$this->data["folder"]->path,
|
||||
implode(", ", Config::MEDIA_MIMETYPE_BLACKLIST),
|
||||
implode(", ", ApplicationConfig::get("crispage.security.media_banned_mimes")),
|
||||
FileUtils::truncateSize(FileUtils::parseSize(ini_get("upload_max_filesize")))
|
||||
);
|
||||
?>
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
public function __construct(\Crispage $app, array $data) {
|
||||
if ($data["asset"] ?? null) {
|
||||
$app->loadClass($data["asset"]->component, "\\Crispage\\Framework\\Component");
|
||||
$app->loadClass($data["asset"]->component, "component");
|
||||
$data["fields"] = $data["asset"]->component::getModuleFields();
|
||||
} else $data["fields"] = [];
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
public function __construct(\Crispage $app, array $data) {
|
||||
if ($data["asset"] ?? null) {
|
||||
$app->loadClass($data["asset"]->runnable, "\\Crispage\\Framework\\PluginClass");
|
||||
$data["fields"] = $data["asset"]->runnable::getPluginFields();
|
||||
$app->loadClass($data["asset"]->classname, "plugin");
|
||||
$data["fields"] = $data["asset"]->classname::getPluginFields();
|
||||
} else $data["fields"] = [];
|
||||
|
||||
parent::__construct($app, $data);
|
||||
|
@ -34,4 +34,6 @@
|
||||
if (!$err) return;
|
||||
\Crispage\error_handler($err["type"], $err["message"], $err["file"], $err["line"]);
|
||||
});
|
||||
|
||||
require_once ROOT . "/core/app/ApplicationConfig.php";
|
||||
?>
|
||||
|
@ -13,13 +13,12 @@
|
||||
require_once __DIR__ . "/core/init.php";
|
||||
|
||||
// Load config (or the installer)
|
||||
if (file_exists(ROOT . "/config.php")) require_once ROOT . "/config.php";
|
||||
else {
|
||||
if (!file_exists(ROOT . "/config.php")) {
|
||||
header("Location: //" . $_SERVER["SERVER_NAME"] . WROOT . "/package.php?mode=install");
|
||||
die();
|
||||
}
|
||||
|
||||
error_reporting(\Crispage\Config::ERRLVL);
|
||||
error_reporting(\Crispage\ApplicationConfig::get("crispage.dev.error_level", E_ALL));
|
||||
|
||||
// Load Crispage
|
||||
require_once ROOT . "/core/app/Crispage.php";
|
||||
|
@ -21,7 +21,7 @@
|
||||
if (IS_INSTALLED) require_once ROOT . "/config.php";
|
||||
else require_once ROOT . "/packages/crispage.core/installer_config.php";
|
||||
|
||||
error_reporting(\Crispage\Config::ERRLVL);
|
||||
error_reporting(\Crispage\ApplicationConfig::get("crispage.dev.error_level"));
|
||||
|
||||
require_once ROOT . "/core/app/Crispage.php";
|
||||
$Crispage = new \Crispage();
|
||||
|
Loading…
Reference in New Issue
Block a user