mirror of
https://git.sr.ht/~iwakuralain/text0Nly
synced 2025-07-27 07:30:31 +00:00
debugging...
This commit is contained in:
parent
4d3ee3ab7d
commit
14cc0ec57a
10
README.txt
10
README.txt
@ -13,6 +13,9 @@ Installation:
|
||||
CentOS:
|
||||
yum install httpd php php-mysqlnd mariadb-server
|
||||
cp configs/apache.conf.centos /etc/httpd/conf.d/text0nly.conf
|
||||
cp configs/php.ini /etc/php.ini
|
||||
chown -R apache:apache /var/www/html/main
|
||||
chmod -R 755 /var/www/html/main
|
||||
systemctl start mariadb
|
||||
systemctl enable mariadb
|
||||
systemctl start httpd
|
||||
@ -21,6 +24,9 @@ CentOS:
|
||||
Alpine:
|
||||
apk add apache2 php php-mysql mariadb
|
||||
cp configs/apache.conf.debian /etc/apache2/sites-available/text0nly.conf
|
||||
cp configs/php.ini /etc/php/php.ini
|
||||
chown -R www-data:www-data /var/www/html/main
|
||||
chmod -R 755 /var/www/html/main
|
||||
ln -s /etc/apache2/sites-available/text0nly.conf /etc/apache2/sites-enabled/
|
||||
rc-update add mariadb default
|
||||
rc-update add apache2 default
|
||||
@ -30,6 +36,9 @@ Alpine:
|
||||
Debian:
|
||||
apt install apache2 php mariadb-server
|
||||
cp configs/apache.conf.debian /etc/apache2/sites-available/text0nly.conf
|
||||
cp configs/php.ini /etc/php/php.ini
|
||||
chown -R www-data:www-data /var/www/html/main
|
||||
chmod -R 755 /var/www/html/main
|
||||
a2ensite text0nly.conf
|
||||
systemctl start mariadb
|
||||
systemctl enable mariadb
|
||||
@ -41,6 +50,7 @@ Files:
|
||||
configs/ - Server configs
|
||||
configs/apache.conf.centos - Apache config for CentOS
|
||||
configs/apache.conf.debian - Apache config for Debian/Alpine
|
||||
configs/php.ini - PHP configuration
|
||||
main/db.sql - Database structure
|
||||
main/index.php - Main page
|
||||
main/register.php - Registration
|
||||
|
4
configs/php.ini
Normal file
4
configs/php.ini
Normal file
@ -0,0 +1,4 @@
|
||||
display_errors = On
|
||||
error_reporting = E_ALL
|
||||
log_errors = On
|
||||
error_log = /var/log/php_errors.log
|
@ -4,8 +4,12 @@ header('X-Frame-Options: DENY');
|
||||
header('X-XSS-Protection: 1; mode=block');
|
||||
header('Content-Security-Policy: default-src \'self\'');
|
||||
|
||||
$db = new PDO('mysql:host=localhost;dbname=messenger', 'root', '');
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
try {
|
||||
$db = new PDO('mysql:host=localhost;dbname=messenger', 'root', '');
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die('Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
|
||||
@ -14,15 +18,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$is_encrypted = isset($_POST['encrypted']);
|
||||
|
||||
if ($username && $message) {
|
||||
$stmt = $db->prepare('INSERT INTO messages (username, message, signature, is_encrypted) VALUES (?, ?, ?, ?)');
|
||||
$stmt->execute([$username, $message, $signature, $is_encrypted]);
|
||||
try {
|
||||
$stmt = $db->prepare('INSERT INTO messages (username, message, signature, is_encrypted) VALUES (?, ?, ?, ?)');
|
||||
$stmt->execute([$username, $message, $signature, $is_encrypted]);
|
||||
} catch (PDOException $e) {
|
||||
die('Database error: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->query('SELECT * FROM messages ORDER BY created_at DESC LIMIT 50');
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
try {
|
||||
$stmt = $db->query('SELECT * FROM messages ORDER BY created_at DESC LIMIT 50');
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
die('Database error: ' . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user