Here it is (thanks!):
<?php
if(isset($_REQUEST['action'])){ $action = $_REQUEST['action']; } else { echo 'ERROR'; exit; }
if($action == 'MORE_IMAGES'){
if(isset($_REQUEST['ids'])){ $ids = explode(',', $_REQUEST['ids']); } else { echo 'ERROR'; exit; }
if(isset($_REQUEST['category'])){ $category = $_REQUEST['category']; } else { echo 'ERROR'; exit; }
if(isset($_REQUEST['category_id'])){ $category_id = $_REQUEST['category_id']; } else { echo 'ERROR'; exit; }
if(isset($_REQUEST['from'])){ $from = $_REQUEST['from']; } else { echo 'ERROR'; exit; }
$list = new Images($category);
$list->query_list($ids);
$list->reset();
$i = $from;
while(list($id, $obj) = $list->each()){
echo '<img id="thumbnail-'.$i++.'" class="thumbnail" src="'.$obj->tsrc().'" title="'.$obj->artist().'" data-id="'.$obj->id().'"/>';
}
} else if($action == 'IMAGE_DATA'){
if(isset($_REQUEST['id'])){ $id = $_REQUEST['id']; } else { echo 'ERROR'; exit; }
$sql = '
SELECT nb_artist.nb_artist_name as name, '.sql_clean_href('nb_artist.nb_artist_name').' as href
FROM nb_artist LEFT JOIN nb_image_artist USING (nb_artist_id) WHERE nb_image_id = "'.$id.'"
';
$rows = $GLOBALS['IDB']->get_results($sql, ARRAY_A);
$artist = '<a href="/'.$rows[0]['href'].'">'.$rows[0]['name'].'</a>';
$data = '';
$styles = new Styles();
$sql = '
SELECT nb_style.nb_style_name as name, '.sql_clean_href('nb_style.nb_style_name').' as href
FROM nb_style LEFT JOIN nb_image_style USING (nb_style_id) WHERE nb_image_id = "'.$id.'"
';
$rows = $GLOBALS['IDB']->get_results($sql, ARRAY_A);
foreach($rows as $row){
if($styles->exists_by_href($row['href'])){
$data .= '<li><a href="/'.$row['href'].'">'.$row['name'].'</a></li>';
}
}
$subjects = new Subjects();
$sql = '
SELECT nb_subject.nb_subject_name as name, '.sql_clean_href('nb_subject.nb_subject_name').' as href
FROM nb_subject LEFT JOIN nb_image_subject USING (nb_subject_id) WHERE nb_image_id = "'.$id.'"
';
$rows = $GLOBALS['IDB']->get_results($sql, ARRAY_A);
foreach($rows as $row){
if($subjects->exists_by_href($row['href'])){
$data .= '<li><a href="/'.$row['href'].'">'.$row['name'].'</a></li>';
}
}
$obj = new Image($id);
echo '
<img id="prev-image" src="/wp-content/themes/nb/css/bg/arrow-previous.png">
<img id="next-image" src="/wp-content/themes/nb/css/bg/arrow-next.png">
<figure>
<img src="'.$obj->src().'" title="'.$obj->artist().'" style="max-width:'.$obj->width().'px;"/>
<figcaption class="clearfix">© '.date('Y').' '.$artist.'</figcaption>
</figure>
<div class="keywords">
<strong>See also</strong>
<ul class="clearfix">'.$data.'</ul>
<p id="logged-in-image-link">http://www.nbillustration.co.uk/image/'.$id.'/</p>
</div>';
} else if($action == 'IMAGE_DATA_SHORT'){
if(isset($_REQUEST['id'])){ $id = $_REQUEST['id']; } else { echo 'ERROR'; exit; }
$obj = new Image($id);
echo '
<figure>
<img src="'.$obj->src().'" title="'.$obj->artist().'" style="max-width:'.$obj->width().'px;"/>
<figcaption class="clearfix">© '.date('Y').' '.$obj->artist().'</figcaption>
</figure>';
}
?>