Update -> refactor and optimize UI , code ,...

This commit is contained in:
2026-04-10 11:35:25 +03:30
parent 3327207f05
commit 0de951fd91
20 changed files with 1085 additions and 282 deletions

View File

@@ -1,31 +1,31 @@
<?php
require __DIR__ . '/../core/security.php';
$pdo = require __DIR__ . '/../core/db.php';
require __DIR__ . '/../models/Paste.php';
require_once __DIR__ . '/../core/security.php';
$pdo = require __DIR__ . '/../core/db.php';
require_once __DIR__ . '/../models/Paste.php';
$config = require __DIR__ . '/../config/config.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: /index.php');
header('Location: /');
exit;
}
$text = $_POST['text'] ?? '';
$text = trim($_POST['text'] ?? '');
$password = $_POST['password'] ?? '';
$expire = isset($_POST['expire']) ? intval($_POST['expire']) : 0;
if (trim($text) === '') {
die('Text is required');
$expire = isset($_POST['expire']) ? (int)$_POST['expire'] : 0;
if ($text === '') {
jsonResponse(['success' => false, 'message' => 'Text cannot be empty.'], 422);
}
$id = generateId();
$enc = encryptText($text, $config['master_key']);
$id = generateId();
$enc = encryptText($text, $config['app']['master_key']);
$password_hash = $password !== '' ? password_hash($password, PASSWORD_DEFAULT) : null;
$expire_time = $expire > 0 ? time() + $expire : null;
$expire_time = $expire > 0 ? time() + $expire : null;
$paste = new Paste($pdo);
$paste->save($id, $enc['cipher'], $enc['iv'], $expire_time, $password_hash);
$paste->save($id, $enc['cipher'], $enc['iv'], $expire_time,$password_hash);
$base = rtrim($config['app']['base_url'] ?: ('http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST']), '/');
$url = $base . '/view/' . $id;
$url = "http://" . $_SERVER['HTTP_HOST'] . "/view.php?id=" . $id;
echo json_encode([
"success" => true,
"url" => $url
]);
exit;
jsonResponse(['success' => true, 'url' => $url]);