5 changed files with 294 additions and 25 deletions
@ -0,0 +1,61 @@ |
|||
<?php |
|||
@include 'conn.conn'; |
|||
$GLOBALS['conn']; |
|||
$conn = @mysqli_connect($DATAhst,$DATAusr,$DATApwd,$DATAdtb)or die("CONNECTION ERROR"); |
|||
|
|||
$content = null; |
|||
$data = json_decode(file_get_contents("php://input")); |
|||
|
|||
if(isset($data->token) && $data->token == base64_encode('admin:JohnHolmes'.date("Y-m-d"))) { |
|||
|
|||
if(isset($_GET['act']) && $_GET['act'] == 'save') { |
|||
|
|||
if(isset($data->id)) { |
|||
$q = mysqli_query($conn,"UPDATE `exhibitions` SET title = '".addslashes($data->title)."', content = '".addslashes($data->content)."', |
|||
tags = '".$data->tags."', date_from = '".$data->date_from."', date_to = '".$data->date_to."', |
|||
image = '".$data->image."', exhibitions = '".$data->exhibitions."', gallery = '".$data->gallery."', |
|||
videos = '".$data->videos."' WHERE id = ".$data->id.""); |
|||
} else { |
|||
$q = mysqli_query($conn,"INSERT INTO `exhibitions` |
|||
(`id`, `title`, `content`, `tags`, `date_from`, `date_to`, `image`, `works`, `gallery`, `videos`) |
|||
VALUES (NULL, '".addslashes($data->title)."', '".addslashes($data->content)."', '".$data->tags."', |
|||
'".$data->date_from."', '".$data->date_to."', '".$data->image."', '".$data->exhibitions."', |
|||
'".$data->gallery."', '".$data->videos."')"); |
|||
} |
|||
|
|||
$qe = mysqli_query($conn,"SELECT * FROM `exhibitions` ORDER BY id DESC"); |
|||
if(mysqli_num_rows($qe) > 0) { |
|||
$content->items = array(); |
|||
while($re = mysqli_fetch_array($qe)) { |
|||
$item = null; |
|||
$item->id = $re['id']; |
|||
$item->title = $re['title']; |
|||
$item->date_from = $re['date_from']; |
|||
$item->date_to = $re['date_to']; |
|||
$item->tags = $re['tags']; |
|||
$item->image = $re['image']; |
|||
array_push($content->items, $item); |
|||
} |
|||
} |
|||
|
|||
if($q) { |
|||
http_response_code(201); |
|||
$content->status = 201; |
|||
} else { |
|||
http_response_code(403); |
|||
$content->status = 403; |
|||
} |
|||
} |
|||
|
|||
} else { |
|||
http_response_code(401); |
|||
$content->status = 401; |
|||
} |
|||
header("Access-Control-Allow-Origin: *"); |
|||
header("Content-Type: application/json; charset=UTF-8"); |
|||
header("Access-Control-Allow-Methods: POST"); |
|||
header("Access-Control-Max-Age: 3600"); |
|||
|
|||
echo json_encode($content); |
|||
|
|||
?> |
Loading…
Reference in new issue