|
|
@ -4,92 +4,114 @@ $GLOBALS['conn']; |
|
|
|
$conn=@mysqli_connect($DATAhst,$DATAusr,$DATApwd,$DATAdtb)or die("CONNECTION ERROR"); |
|
|
|
|
|
|
|
$content = null; |
|
|
|
$content->items = array(); |
|
|
|
|
|
|
|
$filter = array("portfolio", "installations", "entertainment", "performances", "workshops"); |
|
|
|
if(isset($_GET['query'])) { |
|
|
|
|
|
|
|
switch($_GET['query']) { |
|
|
|
case "portfolio": |
|
|
|
case "installations": |
|
|
|
case "entertainment": |
|
|
|
case "performances": |
|
|
|
case "workshops": |
|
|
|
if($_GET['query'] == 'portfolio') {$filter = '';} else {$filter = "WHERE type='".$_GET['query']."'";} |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `works` $filter ORDER BY id DESC"); |
|
|
|
if(mysqli_num_rows($qe) > 0) { |
|
|
|
$content = null; |
|
|
|
$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); |
|
|
|
$content->items = array(); |
|
|
|
switch($_GET['query']) { |
|
|
|
case "portfolio": |
|
|
|
case "installations": |
|
|
|
case "entertainment": |
|
|
|
case "performances": |
|
|
|
case "workshops": |
|
|
|
if($_GET['query'] == 'portfolio') {$filter = '';} else {$filter = "WHERE type='".$_GET['query']."'";} |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `works` $filter ORDER BY id DESC"); |
|
|
|
if(mysqli_num_rows($qe) > 0) { |
|
|
|
$content = null; |
|
|
|
$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); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case "exhibitions": |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `exhibitions` ORDER BY date_from DESC"); |
|
|
|
if(mysqli_num_rows($qe) > 0) { |
|
|
|
$content = null; |
|
|
|
$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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case "exhibitions": |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `exhibitions` ORDER BY date_from DESC"); |
|
|
|
if(mysqli_num_rows($qe) > 0) { |
|
|
|
$content = null; |
|
|
|
$content->items = array(); |
|
|
|
while($re = mysqli_fetch_array($qe)) { |
|
|
|
break; |
|
|
|
case "detail": |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `".$_GET['type']."` WHERE id=".$_GET['id']); |
|
|
|
if(mysqli_num_rows($qe)>0) { |
|
|
|
$content = null; |
|
|
|
$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->content = $re['content']; |
|
|
|
$item->tags = $re['tags']; |
|
|
|
$item->image = $re['image']; |
|
|
|
array_push($content->items, $item); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case "detail": |
|
|
|
$qe = mysqli_query($conn,"SELECT * FROM `".$_GET['type']."` WHERE id=".$_GET['id']); |
|
|
|
if(mysqli_num_rows($qe)>0) { |
|
|
|
$content = null; |
|
|
|
$re = mysqli_fetch_array($qe); |
|
|
|
$item = null; |
|
|
|
$item->id = $re['id']; |
|
|
|
$item->title = $re['title']; |
|
|
|
$item->content = $re['content']; |
|
|
|
$item->tags = $re['tags']; |
|
|
|
$item->image = $re['image']; |
|
|
|
if($_GET['type'] == 'exhibitions') { |
|
|
|
$item->date_from = $re['date_from']; |
|
|
|
$item->date_to = $re['date_to']; |
|
|
|
$item->works = array(); |
|
|
|
$qx = mysqli_query($conn,"SELECT id,title FROM `works` WHERE id IN (".$re['works'].")"); |
|
|
|
while($re = mysqli_fetch_array($qx)) { |
|
|
|
$ex = null; |
|
|
|
$ex->id = $re['id']; |
|
|
|
$ex->title = $re['title']; |
|
|
|
array_push($item->works, $ex); |
|
|
|
} |
|
|
|
} else if($_GET['type'] == 'works') { |
|
|
|
$item->type = $re['type']; |
|
|
|
$item->videos = $re['videos']; |
|
|
|
$item->gallery = $re['gallery']; |
|
|
|
$item->exhibitions = array(); |
|
|
|
$qx = mysqli_query($conn,"SELECT id,title FROM `exhibitions` WHERE id IN (".$re['exhibitions'].")"); |
|
|
|
while($re = mysqli_fetch_array($qx)) { |
|
|
|
$ex = null; |
|
|
|
$ex->id = $re['id']; |
|
|
|
$ex->title = $re['title']; |
|
|
|
array_push($item->exhibitions, $ex); |
|
|
|
if($_GET['type'] == 'exhibitions') { |
|
|
|
$item->date_from = $re['date_from']; |
|
|
|
$item->date_to = $re['date_to']; |
|
|
|
$item->works = array(); |
|
|
|
$qx = mysqli_query($conn,"SELECT id,title FROM `works` WHERE id IN (".$re['works'].")"); |
|
|
|
while($re = mysqli_fetch_array($qx)) { |
|
|
|
$ex = null; |
|
|
|
$ex->id = $re['id']; |
|
|
|
$ex->title = $re['title']; |
|
|
|
array_push($item->works, $ex); |
|
|
|
} |
|
|
|
} else if($_GET['type'] == 'works') { |
|
|
|
$item->type = $re['type']; |
|
|
|
$item->videos = $re['videos']; |
|
|
|
$item->gallery = $re['gallery']; |
|
|
|
$item->exhibitions = array(); |
|
|
|
$qx = mysqli_query($conn,"SELECT id,title FROM `exhibitions` WHERE id IN (".$re['exhibitions'].")"); |
|
|
|
while($re = mysqli_fetch_array($qx)) { |
|
|
|
$ex = null; |
|
|
|
$ex->id = $re['id']; |
|
|
|
$ex->title = $re['title']; |
|
|
|
array_push($item->exhibitions, $ex); |
|
|
|
} |
|
|
|
} |
|
|
|
$content->item = $item; |
|
|
|
} |
|
|
|
$content->item = $item; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} else if(isset($_GET['auth'])) { |
|
|
|
switch($_GET['auth']) { |
|
|
|
case 'auth': |
|
|
|
if($_POST['usr'] == 'admin' && $_POST['pwd'] == 'JohnHolmes') { |
|
|
|
$content->status = 200; |
|
|
|
$content->authToken = md5(date("Y-m-d")); |
|
|
|
} else { |
|
|
|
$content->status = 403; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 'check': |
|
|
|
if($_POST['token'] == md5(date("Y-m-d"))) { |
|
|
|
$content->status = 200; |
|
|
|
$content->authToken = md5(date("Y-m-d")); |
|
|
|
} else { |
|
|
|
$content->status = 403; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
header('Access-Control-Allow-Origin: *'); |
|
|
|
header('Content-Type: application/json'); |
|
|
|
header("Access-Control-Allow-Origin: *"); |
|
|
|
header("Content-Type: application/json; charset=UTF-8"); |
|
|
|
header("Access-Control-Allow-Methods: GET"); |
|
|
|
header("Access-Control-Max-Age: 3600"); |
|
|
|
echo json_encode($content); |
|
|
|
|
|
|
|
?> |
|
|
|