Compare commits
3 commits
55ff555f46
...
e859c5d839
Author | SHA1 | Date | |
---|---|---|---|
flash | e859c5d839 | ||
flash | 227754dbff | ||
flash | d28010a293 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,5 +2,7 @@
|
|||
[Dd]esktop.ini
|
||||
.DS_Store
|
||||
/.debug
|
||||
/config/config.cfg
|
||||
/config/config.ini
|
||||
/public/robots.txt
|
||||
/vendor
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "lib/index"]
|
||||
path = lib/index
|
||||
url = https://git.flash.moe/flash/index.git
|
14
awaki.php
14
awaki.php
|
@ -1,34 +1,30 @@
|
|||
<?php
|
||||
namespace Awaki;
|
||||
|
||||
use Index\Autoloader;
|
||||
use Index\Environment;
|
||||
use Index\Data\ConnectionFailedException;
|
||||
use Index\Data\DbTools;
|
||||
use Syokuhou\SharpConfig;
|
||||
|
||||
define('AWK_STARTUP', microtime(true));
|
||||
define('AWK_ROOT', __DIR__);
|
||||
define('AWK_DEBUG', is_file(AWK_ROOT . '/.debug'));
|
||||
define('AWK_DIR_SRC', AWK_ROOT . '/src');
|
||||
define('AWK_DIR_LIB', AWK_ROOT . '/lib');
|
||||
define('AWK_DIR_PUB', AWK_ROOT . '/public');
|
||||
define('AWK_DIR_CFG', AWK_ROOT . '/config');
|
||||
define('AWK_DIR_DBM', AWK_ROOT . '/database');
|
||||
|
||||
require_once AWK_DIR_LIB . '/index/index.php';
|
||||
require_once AWK_ROOT . '/vendor/autoload.php';
|
||||
|
||||
Autoloader::addNamespace(__NAMESPACE__, AWK_DIR_SRC);
|
||||
Environment::setDebug(AWK_DEBUG);
|
||||
|
||||
$config = parse_ini_file(AWK_DIR_CFG . '/config.ini', true);
|
||||
if($config === false)
|
||||
die('Config sux.');
|
||||
$config = SharpConfig::fromFile(AWK_DIR_CFG . '/config.cfg');
|
||||
|
||||
try {
|
||||
$db = DbTools::create($config['dsn']);
|
||||
$db = DbTools::create($config->getString('dsn'));
|
||||
} catch(ConnectionFailedException $ex) {
|
||||
echo '<h3>Unable to connect to database</h3>';
|
||||
die($ex->getMessage());
|
||||
}
|
||||
|
||||
$awk = new AwakiContext($db, $config['urls']);
|
||||
$awk = new AwakiContext($db, $config->scopeTo('urls'));
|
||||
|
|
13
composer.json
Normal file
13
composer.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"flashwave/index": "dev-master",
|
||||
"flashwave/syokuhou": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Awaki\\": "src"
|
||||
}
|
||||
}
|
||||
}
|
107
composer.lock
generated
Normal file
107
composer.lock
generated
Normal file
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "d909826a501788db19148054e389ec5f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "flashwave/index",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.flash.moe/flash/index.git",
|
||||
"reference": "82a350a5c719cc83aa22382201683a68a2629f2a"
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mysqli": "Support for the Index\\Data\\MariaDB namespace (both mysqlnd and libmysql are supported).",
|
||||
"ext-sqlite3": "Support for the Index\\Data\\SQLite namespace."
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"index.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Index\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"bsd-3-clause-clear"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "flashwave",
|
||||
"email": "packagist@flash.moe",
|
||||
"homepage": "https://flash.moe",
|
||||
"role": "mom"
|
||||
}
|
||||
],
|
||||
"description": "Composer package for the common library for my projects.",
|
||||
"homepage": "https://railgun.sh/index",
|
||||
"time": "2023-09-15T22:44:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "flashwave/syokuhou",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.flash.moe/flash/syokuhou.git",
|
||||
"reference": "b3470ad8605b0484294c73cd95be6e7ba4551e5a"
|
||||
},
|
||||
"require": {
|
||||
"flashwave/index": "dev-master",
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^10.4"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Syokuhou\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"bsd-3-clause-clear"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "flashwave",
|
||||
"email": "packagist@flash.moe",
|
||||
"homepage": "https://flash.moe",
|
||||
"role": "mom"
|
||||
}
|
||||
],
|
||||
"description": "Configuration library for PHP.",
|
||||
"homepage": "https://railgun.sh/syokuhou",
|
||||
"time": "2023-10-20T21:26:38+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"flashwave/index": 20,
|
||||
"flashwave/syokuhou": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 99a4e0c3027a7b29c58e0e0164cb831a03461527
|
|
@ -8,6 +8,7 @@ use Index\Data\Migration\FsDbMigrationRepo;
|
|||
use Index\Http\HttpFx;
|
||||
use Index\Http\HttpRequest;
|
||||
use Index\Routing\IRouter;
|
||||
use Syokuhou\IConfig;
|
||||
|
||||
// theme colours: #99403d, #592824, #d18c83
|
||||
// totally didn't just eyedrop musujime
|
||||
|
@ -17,9 +18,9 @@ class AwakiContext {
|
|||
|
||||
private IDbConnection $dbConn;
|
||||
private HttpFx $router;
|
||||
private array $urls;
|
||||
private IConfig $urls;
|
||||
|
||||
public function __construct(IDbConnection $dbConn, array $urls) {
|
||||
public function __construct(IDbConnection $dbConn, IConfig $urls) {
|
||||
$this->dbConn = $dbConn;
|
||||
$this->urls = $urls;
|
||||
$dbConn->execute(self::DB_INIT);
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
namespace Awaki;
|
||||
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\DbType;
|
||||
use Index\Routing\IRouter;
|
||||
use Syokuhou\IConfig;
|
||||
|
||||
final class RedirectorRoutes {
|
||||
private IDbConnection $dbConn;
|
||||
private array $urls;
|
||||
private IConfig $urls;
|
||||
|
||||
public function __construct(IRouter $router, IDbConnection $dbConn, array $urls) {
|
||||
public function __construct(IRouter $router, IDbConnection $dbConn, IConfig $urls) {
|
||||
$this->dbConn = $dbConn;
|
||||
$this->urls = $urls;
|
||||
|
||||
|
@ -48,8 +48,8 @@ final class RedirectorRoutes {
|
|||
|
||||
public function redirectDatabase($response, $request, $id) {
|
||||
$getInfo = $this->dbConn->prepare('SELECT redir_id, redir_url FROM awk_redirects WHERE redir_id = ? OR redir_vanity = ?');
|
||||
$getInfo->addParameter(1, $id, DbType::INTEGER);
|
||||
$getInfo->addParameter(2, $id, DbType::STRING);
|
||||
$getInfo->addParameter(1, $id);
|
||||
$getInfo->addParameter(2, $id);
|
||||
$getInfo->execute();
|
||||
$info = $getInfo->getResult();
|
||||
|
||||
|
@ -57,7 +57,7 @@ final class RedirectorRoutes {
|
|||
return 404;
|
||||
|
||||
$incClicks = $this->dbConn->prepare('UPDATE awk_redirects SET redir_clicks = redir_clicks + 1 WHERE redir_id = ?');
|
||||
$incClicks->addParameter(1, $info->getInteger(0), DbType::INTEGER);
|
||||
$incClicks->addParameter(1, $info->getInteger(0));
|
||||
$incClicks->execute();
|
||||
|
||||
$this->redirect($response, $request, $info->getString(1));
|
||||
|
@ -72,18 +72,18 @@ final class RedirectorRoutes {
|
|||
}
|
||||
|
||||
public function redirectProfile($response, $request, string $userId) {
|
||||
$this->redirectSimple($response, $request, $this->urls['user_profile'], $userId);
|
||||
$this->redirectSimple($response, $request, $this->urls->getString('user_profile'), $userId);
|
||||
}
|
||||
|
||||
public function redirectForumCategory($response, $request, string $categoryId) {
|
||||
$this->redirectSimple($response, $request, $this->urls['forum_category'], $categoryId);
|
||||
$this->redirectSimple($response, $request, $this->urls->getString('forum_category'), $categoryId);
|
||||
}
|
||||
|
||||
public function redirectForumTopic($response, $request, string $topicId) {
|
||||
$this->redirectSimple($response, $request, $this->urls['forum_topic'], $topicId);
|
||||
$this->redirectSimple($response, $request, $this->urls->getString('forum_topic'), $topicId);
|
||||
}
|
||||
|
||||
public function redirectForumPost($response, $request, string $postId) {
|
||||
$this->redirectSimple($response, $request, $this->urls['forum_post'], $postId);
|
||||
$this->redirectSimple($response, $request, $this->urls->getString('forum_post'), $postId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue