Skip to content

Instantly share code, notes, and snippets.

@benmills
Created December 10, 2009 15:56
Show Gist options
  • Save benmills/253410 to your computer and use it in GitHub Desktop.
Save benmills/253410 to your computer and use it in GitHub Desktop.
<?php
$dir = "pics";
if (is_dir($dir) && $scan_dir = scandir($dir)) echo count($scan_dir);
?>
<?php
$dir = "pics";
function contents($dir, $path = null) {
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
echo "<ul>";
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != ".." && $file != "index.php") {
echo "<li>".$file."</li>";
}
}
echo "</ul>";
closedir($dh);
}
}
}
// Open a known directory, and proceed to read its contents
contents($dir);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>index</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Ben Mills">
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
count = 0;
function get_files() {
$.ajax({
type: 'get',
url: 'get_files.php',
success: function(data){
$("#files").html(data);
},
});
};
function get_count() {
$.ajax({
type: 'get',
url: 'file_count.php',
success: function(data){
console.log('getting count... '+data);
if (count != data) {
get_files();
}
count = data;
},
});
};
$(document).ready(function(){
setInterval("get_count()", 1000);
});
</script>
<!-- Date: 2009-12-10 -->
</head>
<body>
<div id="files">
<?php include('get_files.php'); ?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment