/** * GET method handler * * @param array parameter passing array * @return bool true on success */ function GET(&$options) { $paths = $this->paths; $pathClasses = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP; if (count($paths) > 0 && $paths[0] == 'classes' && is_dir($pathClasses)) { $fsFile = $pathClasses . $paths[1]; if (count($paths) == 2 && file_exists($fsFile)) { $content = file_get_contents($fsFile); print $content; header("Content-Type: " . mime_content_type($fsFile)); header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); header("Content-Length: " . filesize($fsFile)); return true; } } $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP; if (count($paths) > 0 && $paths[0] == 'processes' && is_dir($pathProcesses)) { if (count($paths) == 4 && $paths[2] == 'xmlforms') { $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathXmlform . $paths[3]; if (count($paths) == 4 && file_exists($fsFile)) { $content = file_get_contents($fsFile); print $content; header("Content-Type: " . mime_content_type($fsFile)); header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); header("Content-Length: " . filesize($fsFile)); return true; } } if (count($paths) == 4 && $paths[2] == 'mailTemplates') { $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathTemplates . $paths[3]; if (count($paths) == 4 && file_exists($fsFile)) { $content = file_get_contents($fsFile); print $content; header("Content-Type: " . mime_content_type($fsFile)); header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); header("Content-Length: " . filesize($fsFile)); return true; } } if (count($paths) == 4 && $paths[2] == 'public_html') { $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathPublic . $paths[3]; if (count($paths) == 4 && file_exists($fsFile)) { $content = file_get_contents($fsFile); print $content; header("Content-Type: " . mime_content_type($fsFile)); header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); header("Content-Length: " . filesize($fsFile)); return true; } } } print_r($paths); return true; if ($options["path"] == '/') { return $this->getRoot($options); } //print_r ($options); // get absolute fs path to requested resource $fspath = $this->base . $options["path"]; // sanity check if (!file_exists($fspath)) { return false; } // is this a collection? if (is_dir($fspath)) { return $this->GetDir($fspath, $options); } // detect resource type $options['mimetype'] = $this->_mimetype($fspath); // detect modification time // see rfc2518, section 13.7 // some clients seem to treat this as a reverse rule // requiering a Last-Modified header if the getlastmodified header was set $options['mtime'] = filemtime($fspath); // detect resource size $options['size'] = filesize($fspath); // no need to check result here, it is handled by the base class $options['stream'] = fopen($fspath, "r"); return true; }
function sort_file_mtime($a, $b) { $ma = file_mtime($a); $mb = file_mtime($b); if (!$ma or !$mb or $ma == $mb) { return 0; } return $ma > $mb ? -1 : 1; }