I’m sorry, I left out most of the pertinent information:
MODx version : 1.0.2
Version codename: rev 6066
PHP Version 5.2.12
Apache Version Apache/2.0.52 (Red Hat)
MySQL Client API version 5.0.83
Javascript is located in ’assets/templates/nhpets/js/’
CSS Stylesheets are located in ’assets/templates/nhpets/styles/’
Imagefunctions is located in ’assets/templates/nhpets/ajax/’
Here is the code for my imagefuntions.php:
<?php
/*******************************************************************************
Filename : imagefunctions.php
Called by :
Created : 30 March 2004 (16:59:40)
Created by : Rick Holmes/NinthVector LLC
QueryString Collection :
Form Collection :
Session Variables :
Database Tables :
Stored Procedures :
Include Files :
Comments : provides AJAX 'back end' for image gallery for NHpets.com
*******************************************************************************/
class DirectoryItems {
public $filearray = array();
private $directory;
private $imagetypes = array('jpg', 'jpeg', 'gif', 'png');
function __construct($directory) {
$this->directory = $directory;
$this->getDirectoryItems();
}
private function getDirectoryItems() {
if (is_dir($this->directory)) {
$d = opendir($this->directory) or die("Failed to open $this->directory");
while (false !== ($f = readdir($d))) {
if (is_file($this->directory . $f)) {
$ext = substr($f, strpos($f, ".") + 1);
if (in_array($ext, $this->imagetypes)) {
array_push($this->filearray, $f);
}
}
}
}
}
public function encodeJSON() {
return json_encode($this->filearray);
}
}
// get directory name from Ajax request
if (isset($_GET['page'])) {
$page = $_GET['page'];
$directory = "../photos/$page/";
$files = new DirectoryItems($directory);
echo $files->encodeJSON();
}
// check directory for image files
// return JSON string of image names
?>