$strlen) return false; return substr($string, 0, strlen($test)) == $test; } function endswith($string, $test) { $strlen = strlen($string); $testlen = strlen($test); if ($testlen > $strlen) return false; return substr_compare(strtolower($string), strtolower($test), -$testlen) === 0; } function showSubdirs() { $d = dir("."); $name = getcwd(); $n = strrpos($name, "/resources"); echo "This is the ".substr($name, $n+1)." directory
"; echo 'Up one level
'; // show README if present if (file_exists("README")) { echo "
\n";
echo file_get_contents( "README" );
echo "\n";
}
// show subdirectories
$list = array();
while (false !== ($entry = $d->read())) {
if (is_dir($entry) && substr($entry,0,1) != '.') {
$list[] = $entry;
}
}
$d->close();
if (sizeof($list)> 0) {
echo "'."\n"; } } } function showFiles() { $listIcon = array(); $listOther = array(); $d = dir("."); while (false !== ($entry = $d->read())) { if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png") || endswith($entry, ".EPS") || endswith($entry, ".PSD") || endswith($entry, ".md") ) { $listIcon[] = $entry; } else if (! (startswith($entry, ".") || is_dir($entry) || endswith($entry, ".php") ) ) { $listOther[] = $entry; } } $d->close(); if (sizeof($listIcon)> 0) { echo "
| '.$entry.' | '."\n"; if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png") ) { // display as image // would be good to add a limiting size here echo '(download)'."\n"; } echo ''."\n"; } echo " |
| '.$entry.' | '."\n"; if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png") ) { // display as name echo '(download)'."\n"; } echo ''."\n"; } echo " |