11 changed files with 179 additions and 41 deletions
@ -0,0 +1,59 @@ |
|||
<?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 `works` SET title = '".addslashes($data->title)."', content = '".addslashes($data->content)."', |
|||
type = '".$data->type."', tags = '".$data->tags."', image = '".$data->image."', |
|||
exhibitions = '".$data->exhibitions."', gallery = '".$data->gallery."', videos = '".$data->videos."' |
|||
WHERE id = ".$data->id.""); |
|||
} else { |
|||
$q = mysqli_query($conn,"INSERT INTO `works` (`id`, `title`, `content`, `type`, `tags`, `image`, `exhibitions`, `gallery`, `videos`) |
|||
VALUES (NULL, '".addslashes($data->title)."', '".addslashes($data->content)."', '".$data->type."', |
|||
'".$data->tags."', '".$data->image."', '".$data->exhibitions."', '".$data->gallery."', |
|||
'".$data->videos."')"); |
|||
} |
|||
|
|||
$qe = mysqli_query($conn,"SELECT * FROM `works` 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->type = $re['type']; |
|||
$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); |
|||
|
|||
?> |
After Width: | Height: | Size: 432 B |
Loading…
Reference in new issue