From 15c99a4e0c2063806e7a3f3773b37b6913de21c7 Mon Sep 17 00:00:00 2001
From: Jonas Leder <git@jonasled.de>
Date: Mon, 12 Apr 2021 20:36:45 +0200
Subject: [PATCH] move new comment in API dor

---
 js/customElements/newComment.js |  2 +-
 public/{ => API}/newComment.php |  3 ++-
 public/index.php                |  1 -
 public/internal/mysql.php       | 11 -----------
 public/post.php                 |  1 -
 5 files changed, 3 insertions(+), 15 deletions(-)
 rename public/{ => API}/newComment.php (94%)
 delete mode 100644 public/internal/mysql.php

diff --git a/js/customElements/newComment.js b/js/customElements/newComment.js
index 2d1e8c3..92a6e27 100644
--- a/js/customElements/newComment.js
+++ b/js/customElements/newComment.js
@@ -8,7 +8,7 @@ class newComment extends HTMLElement {
         let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
 
         this.innerHTML = ` 
-            <form action="/newComment.php" method="post">
+            <form action="/API/newComment.php" method="post">
                 <label for="name">Name:</label><br>
                 <input type="text" id="name" name="name"><br><br>
         
diff --git a/public/newComment.php b/public/API/newComment.php
similarity index 94%
rename from public/newComment.php
rename to public/API/newComment.php
index acb7b49..860a81b 100644
--- a/public/newComment.php
+++ b/public/API/newComment.php
@@ -1,5 +1,6 @@
 <?php
-include("./internal/mysql.php");
+include("./lib/config.php");
+include("./lib/mysql.php");
 
 $data = array(
     'secret' => $secretkey,
diff --git a/public/index.php b/public/index.php
index 74bfda6..19fec50 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,7 +1,6 @@
 <?php
 include "internal/header.php";
 include "internal/footer.php";
-include "internal/mysql.php";
 
 getHeader("Jonas Leder", "home");
 ?>
diff --git a/public/internal/mysql.php b/public/internal/mysql.php
deleted file mode 100644
index 5c1d19b..0000000
--- a/public/internal/mysql.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-include "config.php";
-
-$conn = new mysqli($mysqlServer, $mysqlUser, $mysqlPassword, $mysqlDatabase);
-// Check connection
-if ($conn->connect_error) {
-    include "500.php";
-
-    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
-    die(getError500());
-}
diff --git a/public/post.php b/public/post.php
index e89af9d..ffc7ad0 100644
--- a/public/post.php
+++ b/public/post.php
@@ -1,5 +1,4 @@
 <?php
-include "internal/mysql.php";
 include "internal/header.php";
 include "internal/footer.php";
 
-- 
GitLab