$string) { if (substr($string, 0, 2) == "a:") { $array[$key] = unserialize($string); } } return $array; } function human_filesize($bytes, $decimals = 2) { $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; } function dumpme($mixed = null) { ob_start(); var_dump($mixed); $content = ob_get_contents(); ob_end_clean(); return $content; } function breadcrumbs($dbo, $pathname) { $zpath = $dbo->query("SELECT zpath FROM _walkwalk")->fetch()['zpath']; $pathname_adjusted = str_replace($zpath."/", "", $pathname); $parts = explode("/", $pathname_adjusted); $i = count($parts); while ($i) { $search_path = $zpath."/".implode("/", array_slice($parts, 0, $i)); $id = $dbo->query("SELECT id FROM files WHERE (Pathname='".$search_path."')")->fetch()['id']; $result[] = array($id, basename($search_path)); $i--; } $home = array("0",basename($zpath)); if (basename($zpath) == $pathname) { return array($home); } else { $result[] = $home; return array_reverse($result); } } $db_dir = "db/"; $db = $_GET['db']; $id = $_GET['id']; $view = $_GET['view']; $sort = $_GET['sort']; $db_file = $db_dir.$db.".sqlite3"; if (!$view) { $view = "icon"; } // there is no db, show a list of sqlite files if (!$db) { echo "
"; $files = glob($db_dir."*.sqlite3"); rsort($files); foreach ($files as $file) { $dbo = new PDO("sqlite:".$file); $dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $row = $dbo->query("SELECT * FROM _walkwalk")->fetchAll(); if ($row[0]['type'] == "External disk") { $icon = "icons/firewire.png"; } if ($row[0]['type'] == "Startup disk") { $icon = "icons/internal.png"; } if ($row[0]['type'] == "Disk image") { $icon = "icons/image.png"; } if ($row[0]['type'] == "Folder") { $icon = "icons/directory.png"; } echo "\n
"; echo "\n"; $parts = explode("_",basename($file, ".sqlite3")); echo "\n".$parts[2]." (".$parts[0].")"; echo "\n".$dbo->query("SELECT Count(*) FROM files")->fetch()['Count(*)']." Files"; if ($dbo->query("SELECT status FROM _walkwalk")->fetch()[0] == "aborted") { echo " (Aborted)"; } echo "\n"; echo "\n
"; } } else { $dbo = new PDO("sqlite:".$db_file); $dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $zpath = $dbo->query("SELECT zpath FROM _walkwalk")->fetch()['zpath']; // there is no id, must be initial view if (!$id) { $id = 0; $type = "dir"; $myview['Pathname'] = basename($zpath); } else { $myview = $dbo->query("SELECT * FROM files WHERE (id=".$id.")")->fetchAll()[0]; $type = $myview['Type']; } echo "
"; $crumb = breadcrumbs($dbo, $myview['Pathname']); foreach ($crumb as $myparts) { if ($crumb[count($crumb)-1] != $myparts) { echo "\n".$myparts[1].""; echo " > "; } else { echo $myparts[1]; } } echo ""; if ($view == "icon") { echo "icon | list"; } else { echo "icon | list"; } echo "
"; echo "
"; echo "
"; // directory view if ($type == "dir") { $items = $dbo->query("SELECT * FROM files WHERE (parent=".$id.")")->fetchAll(); if ($view == "icon") { foreach ($items as $item) { echo "\n
"; echo "\n"; if ($item['Type'] == "dir") { echo ""; } elseif (isset($item['tinfo'])) { list ($twidth, $theight) = unserialize($item['tinfo']); echo ""; } else { echo ""; } echo ""; echo "\n".$item['Filename']; if ($item['Type'] == "dir") { echo " (".count($dbo->query("SELECT * FROM files WHERE (parent=".$item['id'].")")->fetchAll())." Items)"; } echo "\n"; echo "\n".human_filesize($item['Size']).""; echo "\n
"; } } else { echo "list"; } } else { // file view echo "
";
		
		$fdeep = $dbo->query("SELECT * FROM files WHERE (id=".$id.")")->fetchAll()[0];
		$sdeep = $mdls = $dbo->query("SELECT * FROM mdls WHERE (id=".$id.")")->fetchAll()[0];
		$mdeep = $meta = $dbo->query("SELECT * FROM metadata WHERE (id=".$id.")")->fetchAll()[0];
		
		echo "

".$fdeep['Pathname']."


"; if (isset($fdeep['tinfo'])) { echo "
"; } else { echo "
"; } echo dumpme(array_unserialize($fdeep)); echo "

Spotlight


"; echo dumpme(array_unserialize($sdeep)); echo "

Mediainfo


"; echo dumpme(array_unserialize($mdeep)); echo "
"; } } echo str_repeat("
", 100); ?>