This commit is contained in:
2017-05-03 00:39:48 -07:00
parent 604a45c736
commit e838e2617f
76 changed files with 6085 additions and 2 deletions

74
Yuba.php Executable file
View File

@@ -0,0 +1,74 @@
#!/usr/bin/php
<?php
// Yuba
$version = "0.0.1";
$time_start = microtime(true);
date_default_timezone_set("America/Los_Angeles");
print_r($argv);
$zpath = realpath($argv[1]);
$dbfile = $argv[2];
if (!$zpath | !$dbfile) {
echo "Usage: walk <path> <dbfile>";
die;
}
echo "Yuba ".$version."\n";
echo "-----------------------------------------------\n";
echo date("F jS, Y h:i:s", time())."\n";
$banner = "Walking ".$zpath." to ".$dbfile;
echo $banner."\n";
echo str_repeat("-", strlen($banner))."\n";
die;
$dir_iter = new RecursiveDirectoryIterator($zpath,
RecursiveDirectoryIterator::SKIP_DOTS
);
$iter = new RecursiveIteratorIterator($dir_iter,
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD
);
$i = 1;
foreach ($iter as $splFileInfo) {
$key[$splFileInfo->getRealPath()] = $i;
$i++;
}
$line = array();
foreach ($key as $path => $id) {
echo $path."\n";
$info = pathinfo($path);
$line[$id]['parent'] = @$key[$info['dirname']];
$line[$id]['path'] = $path;
if (is_dir($path)) {
$line[$id]['isdir'] = 1;
} else {
$line[$id]['isdir'] = 0;
}
$line[$id]['size'] = filesize($path);
$hash = md5_file($path);
$line[$id]['hash'] = $hash;
$line[$id]['perms'] = fileperms($path);
$line[$id]['owner'] = fileowner($path).":".filegroup($path);
$line[$id]['type'] = filetype($path);
$line[$id]['inode'] = fileinode($path);
$line[$id]['mtime'] = filemtime($path);
$line[$id]['atime'] = fileatime($path);
$line[$id]['ctime'] = filectime($path);
$spotlight = shell_exec("mdls \"".$path."\" 2>&1");
if ($spotlight != $path.": could not find ".$path.".\n") {
$line[$id]['mdls'] = $spotlight;
}
$thumb = "/tmp/".$hash.".png";
exec("qlmanage -t -o \"".$thumb."\" \"".$path."\"");
if (file_exists($thumb)) {
$line[$id]['thumb'] = file_get_contents($blob);
}
}
print_r($line);
?>