diff --git a/admin/api.php b/admin/api.php
index d213069..a2f0864 100644
--- a/admin/api.php
+++ b/admin/api.php
@@ -15,7 +15,7 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
echo "YES";
}
- if ($action == "get"){
+ if ($action == "getlinks"){
$stmt1 = $mysqli->prepare("SELECT `LinkID`, `ContentID`, `Nickname` FROM Links");
$stmt1->bind_result($linkid, $contentid, $nickname);
$stmt1->execute();
@@ -25,21 +25,21 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
$id = htmlspecialchars($linkid);
$nickname = htmlspecialchars($nickname);
$contentid = htmlspecialchars($contentid);
- $out = $out . "
$id | $contentid | $nickname | |
";
+ $out = $out . " | | | |
";
}
$out = $out . " | | | |
";
$out = $out . "";
echo $out;
}
- if ($action == "delete" && !empty($_POST["id"])){
+ if ($action == "deletelink" && !empty($_POST["id"])){
$stmt2 = $mysqli->prepare("DELETE FROM Links WHERE `LinkID` = ?");
$stmt2->bind_param('s', $_POST["id"]);
$stmt2->execute();
$stmt2->store_result();
}
- if ($action == "set" && !empty($_POST["id"]) && !empty($_POST["contentid"]) && !empty($_POST["nickname"])){
+ if ($action == "addlink" && !empty($_POST["id"]) && !empty($_POST["contentid"]) && !empty($_POST["nickname"])){
$stmt3 = $mysqli->prepare("INSERT INTO Links (`LinkID`, `ContentID`, `Nickname`) VALUES (?, ?, ?);");
$stmt3->bind_param('sss', $_POST["id"], $_POST["contentid"], $_POST["nickname"]);
$stmt3->execute();
@@ -47,23 +47,18 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
}
if ($action == "getcontent"){
- $stmt4 = $mysqli->prepare("SELECT `ContentID`, `Type`, `Content` FROM Content");
- $stmt4->bind_result ($contentid, $type, $content);
+ $stmt4 = $mysqli->prepare("SELECT `ContentID`, `Content` FROM Content");
+ $stmt4->bind_result ($contentid, $content);
$stmt4->execute();
$stmt4->store_result();
- $out = "Content ID | Content | MIME type | Button |
";
+ $out = "";
echo $out;
}
@@ -75,21 +70,27 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
$stmt5->store_result();
}
- if ($action == "setcontent" && !empty($_POST["id"]) && !empty($_POST["content"])){
- $stmt6 = $mysqli->prepare("INSERT INTO Content (`ContentID`, `Type`, `Content`) VALUES (?, ?, ?);");
- $type = "";
- if (!empty($_POST["type"])){
- $decoded = base64_decode($_POST["content"]);
- $type = $_POST["type"];
- $stmt6->bind_param('sss', $_POST["id"], $type, $decoded);
- }
- else{
- $stmt6->bind_param('sss', $_POST["id"], $type, $_POST["content"]);
- }
+ if ($action == "addcontent" && !empty($_POST["id"]) && !empty($_POST["content"])){
+ $stmt6 = $mysqli->prepare("INSERT INTO Content (`ContentID`, `Content`) VALUES (?, ?);");
+ $stmt6->bind_param('ss', $_POST["id"], $_POST["content"]);
$stmt6->execute();
$stmt6->store_result();
}
+ if ($action == "setlink" && !empty($_POST["id"]) && !empty($_POST["contentid"]) && !empty($_POST["nickname"]) && !empty($_POST["idwhere"])){
+ $stmt9 = $mysqli->prepare("UPDATE Links SET `LinkID` = ?, `ContentID` = ?, `Nickname` = ? WHERE `LinkID` = ?;");
+ $stmt9->bind_param('ssss', $_POST["id"], $_POST["contentid"], $_POST["nickname"], $_POST["idwhere"]);
+ $stmt9->execute();
+ $stmt8->store_result();
+ }
+
+ if ($action == "setcontent" && !empty($_POST["id"]) && !empty($_POST["content"]) && !empty($_POST["idwhere"])){
+ $stmt8 = $mysqli->prepare("UPDATE Content SET `ContentID` = ?, `Content` = ? WHERE `ContentID` = ?;");
+ $stmt8->bind_param('sss', $_POST["id"], $_POST["content"], $_POST["idwhere"]);
+ $stmt8->execute();
+ $stmt8->store_result();
+ }
+
if ($action == "getlog"){
$idcko = $_POST["id"];
if (empty($idcko)||$idcko == "*"){
diff --git a/admin/index.html b/admin/index.html
index 8b1bdbb..3fc89ec 100644
--- a/admin/index.html
+++ b/admin/index.html
@@ -20,7 +20,7 @@
let nickname = $("#addnickname").val();
$.post("api.php",
{
- action: "set",
+ action: "addlink",
password: password,
id: id,
contentid: contentid,
@@ -33,15 +33,12 @@
function justaddc(){
let id = $("#addidc").val();
let content = $("#addcontentc").val();
- let type = "normal";
- type = $("#addtypec").val();
$.post("api.php",
{
- action: "setcontent",
+ action: "addcontent",
password: password,
id: id,
content: content,
- type: type,
}, function( data ) {
getcontents();
});
@@ -57,6 +54,36 @@
});
}
+ function upcthis(name){
+ let id = $("#addidc_" + name).val();
+ let contentin = $("#addcontentc_" + name).val();
+ $.post("api.php",
+ {
+ action: "setcontent",
+ idwhere: name,
+ id: id,
+ content: contentin,
+ }, function( data ) {
+ getcontents();
+ });
+ }
+
+ function uplinkthis(name){
+ let id = $("#addid_" + name).val();
+ let contentid = $("#addcontentid_" + name).val();
+ let nickname = $("#addnickname_" + name).val();
+ $.post("api.php",
+ {
+ action: "setlink",
+ idwhere: name,
+ id: id,
+ contentid: contentid,
+ nickname: nickname,
+ }, function( data ) {
+ getcontents();
+ });
+ }
+
function getcontents(){
$.post("api.php",
{
@@ -82,7 +109,7 @@
function delthis(name){
$.post("api.php",
{
- action: "delete",
+ action: "deletelink",
id: name
}, function( data ) {
getlinks();
@@ -125,7 +152,7 @@
function getlinks(){
$.post("api.php",
{
- action: "get"
+ action: "getlinks"
}, function( data ) {
$("#linkslist").html(data);
$("#addnickname").keyup(function(event) {
diff --git a/index.php b/index.php
index f990bff..73cf938 100644
--- a/index.php
+++ b/index.php
@@ -19,9 +19,9 @@ if (!empty($idcko)){
die("Nonexistent link");
}
while ($stmt1->fetch()) {
- $stmt2 = $mysqli->prepare("SELECT `Type`, `Content` FROM Content WHERE `ContentID` = ?");
+ $stmt2 = $mysqli->prepare("SELECT `Content` FROM Content WHERE `ContentID` = ?");
$stmt2->bind_param("s", $contentid);
- $stmt2->bind_result ($type, $content);
+ $stmt2->bind_result ($content);
$stmt2->execute();
$stmt2->store_result();
if ($stmt2->num_rows() < 1) {
@@ -33,10 +33,6 @@ if (!empty($idcko)){
$stmt3->bind_param('ssssss', $action, $idcko, $contentid, $curdate, $nickname, $ipcka);
$stmt3->execute();
$stmt3->store_result();
- if ($type == 1){
-
- }
- header("Content-Type: $type");
echo $content;
}