This commit is contained in:
edsea
2025-08-07 02:01:29 +02:00
commit 8b5ba49645
22 changed files with 6487 additions and 0 deletions

11
rss/php/autoload.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
spl_autoload_register(function ($class){
$class = str_replace('App\\', '', $class);
$class = str_replace('\\', '/', $class);
$file = $_SERVER['DOCUMENT_ROOT'] . '/rss/php/class/'.$class.'.php';
if(file_exists($file)){
require_once($file);
}
});

15
rss/php/class/Main.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App;
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/autoload.php');
use PDO;
use PDOException;
use Exception;
class Main extends Sys{
public function __construct(){
}
}

26
rss/php/class/Sys.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
namespace App;
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/autoload.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/conf.php');
use PDO;
use PDOException;
use Exception;
use stdClass;
class Sys{
protected $conn;
public function __construct(){
global $conn;
$this->conn = $conn;
}
protected function createResponse($status, $message = null, $info = null){
$resp = new stdClass();
$resp->status = $status;
$resp->message = $message;
$resp->info = $info;
return $resp;
}
}

36
rss/php/conf.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/.env')){
$lines = file($_SERVER['DOCUMENT_ROOT'] . '/.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if(isset($lines) && !empty($lines)){
foreach($lines as $line){
if(strpos(trim($line), '#') === 0){
continue;
}
list($name, $value) = explode('=', $line, 2);
$name = trim($name);
$value = trim($value);
$value = trim($value, '"\'');
putenv("$name=$value");
}
}
}
try{
$db_user = getenv("DB_USER");
$db_pass = getenv("DB_PASS");
$db_server = getenv("DB_SERVER");
$db_name = getenv("DB_NAME");
$conn = new PDO("mysql:host=$db_server;dbname=$db_name;charset=utf8mb4", $db_user, $db_pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
var_dump($e);
echo json_encode('Connection exception');
exit();
}
?>

58
rss/php/handler.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/autoload.php');
use App\Main;
$classList = array(
'Main' => Main::class,
);
session_start();
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/php/conf.php')){
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/conf.php');
}
if(isset($_POST['function']) && !empty($_POST['function']) && isset($_POST['target']) && !empty($_POST['target'])){
$t_class = trim($_POST['target']);
$t_func = trim($_POST['function']);
if(array_key_exists($t_class, $classList) && class_exists($classList[$t_class])){
if(method_exists($classList[$t_class], $t_func)){
$_class = new $classList[$t_class];
if(count($_POST) > 2){
foreach($_POST as $prop => $val){
if(property_exists($classList[$t_class], $prop)){
$_class->$prop = $val;
}
}
}
if(isset($_FILES) && !empty($_FILES)){
foreach($_FILES as $prop => $val){
if(property_exists($classList[$t_class], $prop)){
$_class->$prop = $val;
}
}
}
$response = $_class->$t_func();
if($response){
$msg = $response;
}else{
$msg = new stdClass();
$msg->status = 'fail';
$msg->message = $response;
}
}else{
$msg = new stdClass();
$msg->status = 'fail';
$msg->message = 'Invalid function';
}
}else{
$msg = new stdClass();
$msg->status = 'fail';
$msg->message = 'Invalid class';
}
}
die(json_encode($msg));

View File

@@ -0,0 +1,10 @@
<?php
global $pageInfo;
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/js/' . $pageInfo['template'] . '.js')) {
echo '<script src="/rss/js/' . $pageInfo['template'] . '.js"></script>';
}
?>
<footer>
</footer>

View File

@@ -0,0 +1,77 @@
<?php
$page = isset($_GET['page']) ? basename($_GET['page']) : 'index';
$jsonFile = $_SERVER['DOCUMENT_ROOT'] . "/rss/json/pages/{$page}.json";
$pageData = file_exists($jsonFile) ? json_decode(file_get_contents($jsonFile), true) : [
'title' => 'ECUSM',
'long_desc' => '',
'robots' => 'noindex, nofollow'
];
// Set default values
$siteUrl = 'http://ecusm.local';
$pageUrl = $page === 'index' ? $siteUrl . '/' : $siteUrl . '/' . $page . '/';
$title = $pageData['title'] ?? 'ECUSM';
$description = $pageData['long_desc'] ?? '';
$keywords = '';
$robots = $pageData['robots'] ?? 'noindex, nofollow';
$currentPage = $page === 'index' ? 'Home' : ucwords(str_replace('-', ' ', $page));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Defaults -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ECUSM | <?php echo htmlspecialchars($pageData['title'], ENT_QUOTES, 'UTF-8'); ?></title>
<meta name="description" content="<?php echo htmlspecialchars($description, ENT_QUOTES, 'UTF-8'); ?>">
<meta name="author" content="ECUSM">
<meta name="keywords" content="<?php echo htmlspecialchars($keywords, ENT_QUOTES, 'UTF-8'); ?>">
<meta name="robots" content="<?php echo htmlspecialchars($robots, ENT_QUOTES, 'UTF-8'); ?>">
<link rel="canonical" href="<?php echo htmlspecialchars($pageUrl, ENT_QUOTES, 'UTF-8'); ?>">
<!-- Open Graph -->
<meta property="og:title" content="<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>">
<meta property="og:description" content="<?php echo htmlspecialchars($description, ENT_QUOTES, 'UTF-8'); ?>">
<meta property="og:type" content="website">
<meta property="og:url" content="<?php echo htmlspecialchars($pageUrl, ENT_QUOTES, 'UTF-8'); ?>">
<meta property="og:image" content="<?php echo $siteUrl; ?>/rss/img/image.png">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>">
<meta name="twitter:description" content="<?php echo htmlspecialchars($description, ENT_QUOTES, 'UTF-8'); ?>">
<meta name="twitter:image" content="<?php echo $siteUrl; ?>/rss/img/image.png">
<!-- Favicon -->
<link rel="icon" href="/rss/img/favicon/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="/rss/img/favicon/apple-touch-icon.png">
<!-- Stylesheets -->
<link rel="preload" href="/rss/css/main.css" as="style">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font/css/materialdesignicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="/rss/css/main.css">
<link rel="stylesheet" href="/rss/css/theme.css">
<!-- JavaScript -->
<script src="/rss/js/main.js" defer></script>
<!-- Structured Data (JSON-LD) -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>",
"url": "<?php echo htmlspecialchars($pageUrl, ENT_QUOTES, 'UTF-8'); ?>",
"description": "<?php echo htmlspecialchars($description, ENT_QUOTES, 'UTF-8'); ?>",
"isPartOf": {
"@type": "WebSite",
"name": "ECUSM",
"url": "<?php echo $siteUrl; ?>/"
}
}
</script>
</head>
<body>
<header>
</header>

33
rss/php/pageHandler.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/autoload.php');
// require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/conf.php');
$page = isset($_GET['page']) && !empty($_GET['page']) ? str_replace('.php', '', $_GET['page']) : 'index';
if($page == '404'){
http_response_code(404);
}
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/json/pages/' . $page . '.json')){
// Load page configuration
$jsonInfo = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/rss/json/pages/' . $page .'.json');
$pageInfo = json_decode($jsonInfo, true);
}else{
http_response_code(404);
header('location:/404');
die('Not found');
}
?>
<?php
function loadContents(){
global $pageInfo;
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/php/templates/'.$pageInfo['template'].'.php')){
include($_SERVER['DOCUMENT_ROOT'] . '/rss/php/templates/'.$pageInfo['template'].'.php');
}else{
http_response_code(404);
header('location:/404');
exit();
}
}
?>

View File

@@ -0,0 +1,3 @@
<main>
<!-- Login -->
</main>