add mime type
This commit is contained in:
parent
5834a92a3f
commit
08098b5417
@ -47,17 +47,22 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "getcontent"){
|
if ($action == "getcontent"){
|
||||||
$stmt4 = $mysqli->prepare("SELECT `ContentID`, `Content` FROM Content");
|
$stmt4 = $mysqli->prepare("SELECT `ContentID`, `Type`, `Content` FROM Content");
|
||||||
$stmt4->bind_result ($contentid, $content);
|
$stmt4->bind_result ($contentid, $type, $content);
|
||||||
$stmt4->execute();
|
$stmt4->execute();
|
||||||
$stmt4->store_result();
|
$stmt4->store_result();
|
||||||
$out = "<table><tbody><tr><th>Content ID</th><th>Content</th><th>Button</th></tr>";
|
$out = "<table><tbody><tr><th>Content ID</th><th>Content</th><th>Button</th></tr>";
|
||||||
while ($stmt4->fetch()) {
|
while ($stmt4->fetch()) {
|
||||||
$id = htmlspecialchars($contentid);
|
$id = htmlspecialchars($contentid);
|
||||||
|
if(empty($type)){
|
||||||
$content = htmlspecialchars($content);
|
$content = htmlspecialchars($content);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$content = "Binary data";
|
||||||
|
}
|
||||||
$out = $out . "<tr><td>$id</td><td>$content</td><td><button onclick=\"delcthis('$id')\">Delete</button></td></tr>";
|
$out = $out . "<tr><td>$id</td><td>$content</td><td><button onclick=\"delcthis('$id')\">Delete</button></td></tr>";
|
||||||
}
|
}
|
||||||
$out = $out . "<tr><td><input id=\"addidc\" placeholder=\"Content ID\"></td><td><textarea id=\"addcontentc\" placeholder=\"Content\"></textarea></td><td><button id=\"contentadder\" onclick=\"justaddc()\">Add</button></td></tr>";
|
$out = $out . "<tr><td><input id=\"addidc\" placeholder=\"Content ID\"></td><td><textarea id=\"addcontentc\" placeholder=\"Content\"></textarea></td><td><input id=\"addtypec\" placeholder=\"MIME Type(when set the data must be Base64)\"></td></td><td><button id=\"contentadder\" onclick=\"justaddc()\">Add</button></td></tr>";
|
||||||
$out = $out . "</tbody></table>";
|
$out = $out . "</tbody></table>";
|
||||||
echo $out;
|
echo $out;
|
||||||
}
|
}
|
||||||
@ -70,8 +75,14 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "setcontent" && !empty($_POST["id"]) && !empty($_POST["content"])){
|
if ($action == "setcontent" && !empty($_POST["id"]) && !empty($_POST["content"])){
|
||||||
$stmt6 = $mysqli->prepare("INSERT INTO Content (`ContentID`, `Content`) VALUES (?, ?);");
|
$stmt6 = $mysqli->prepare("INSERT INTO Content (`ContentID`, `Type`, `Content`) VALUES (?, ?, ?);");
|
||||||
$stmt6->bind_param('ss', $_POST["id"], $_POST["content"]);
|
if (!empty($_POST["type"])){
|
||||||
|
$decoded = base64_decode($_POST["content"]);
|
||||||
|
$stmt6->bind_param('sss', $_POST["id"], $_POST["type"], $decoded);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$stmt6->bind_param('sss', $_POST["id"], "", $_POST["content"]);
|
||||||
|
}
|
||||||
$stmt6->execute();
|
$stmt6->execute();
|
||||||
$stmt6->store_result();
|
$stmt6->store_result();
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,15 @@
|
|||||||
function justaddc(){
|
function justaddc(){
|
||||||
let id = $("#addidc").val();
|
let id = $("#addidc").val();
|
||||||
let content = $("#addcontentc").val();
|
let content = $("#addcontentc").val();
|
||||||
|
let type = "normal";
|
||||||
|
type = $("#addtypec").val();
|
||||||
$.post("api.php",
|
$.post("api.php",
|
||||||
{
|
{
|
||||||
action: "setcontent",
|
action: "setcontent",
|
||||||
password: password,
|
password: password,
|
||||||
id: id,
|
id: id,
|
||||||
content: content,
|
content: content,
|
||||||
|
type: type,
|
||||||
}, function( data ) {
|
}, function( data ) {
|
||||||
getcontents();
|
getcontents();
|
||||||
});
|
});
|
||||||
|
@ -19,9 +19,9 @@ if (!empty($idcko)){
|
|||||||
die("Nonexistent link");
|
die("Nonexistent link");
|
||||||
}
|
}
|
||||||
while ($stmt1->fetch()) {
|
while ($stmt1->fetch()) {
|
||||||
$stmt2 = $mysqli->prepare("SELECT `Content` FROM Content WHERE `ContentID` = ?");
|
$stmt2 = $mysqli->prepare("SELECT `Type`, `Content` FROM Content WHERE `ContentID` = ?");
|
||||||
$stmt2->bind_param("s", $contentid);
|
$stmt2->bind_param("s", $contentid);
|
||||||
$stmt2->bind_result ($content);
|
$stmt2->bind_result ($type, $content);
|
||||||
$stmt2->execute();
|
$stmt2->execute();
|
||||||
$stmt2->store_result();
|
$stmt2->store_result();
|
||||||
if ($stmt2->num_rows() < 1) {
|
if ($stmt2->num_rows() < 1) {
|
||||||
@ -33,6 +33,10 @@ if (!empty($idcko)){
|
|||||||
$stmt3->bind_param('ssssss', $action, $idcko, $contentid, $curdate, $nickname, $ipcka);
|
$stmt3->bind_param('ssssss', $action, $idcko, $contentid, $curdate, $nickname, $ipcka);
|
||||||
$stmt3->execute();
|
$stmt3->execute();
|
||||||
$stmt3->store_result();
|
$stmt3->store_result();
|
||||||
|
if ($type == 1){
|
||||||
|
|
||||||
|
}
|
||||||
|
header("Content-Type: $type");
|
||||||
echo $content;
|
echo $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user