261 lines
7.1 KiB
PHP
261 lines
7.1 KiB
PHP
<?
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
// Yuba RTC Browser
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
$browser_version = "0.3.8";
|
|
|
|
?>
|
|
|
|
<html>
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, user-scalable=no" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
|
<script src="https://raw.githubusercontent.com/bd808/php-unserialize-js/master/phpUnserialize.js"></script>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
$("a").contextmenu(function() {
|
|
window.location.href=$(this).attr('title');
|
|
return false;
|
|
})
|
|
})
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
body { margin: 20px; font-family: helvetica; font-size: 11px; }
|
|
*:focus { outline: none !important }
|
|
a { color: black; }
|
|
|
|
div.container { display: flex; flex-flow: row wrap; justify-content: center; }
|
|
div.flexfill { width: 220px; height: 1px; }
|
|
div.item { width: 180px; height: 220px; padding: 20px; }
|
|
div.item img { margin-bottom: 20px; padding: 10px; border: 1px solid grey; }
|
|
|
|
span.material { display: block; word-break:break-all; }
|
|
span.materialsub { display: block; color: #bdbdbd; }
|
|
i { font-style: normal; color: red; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<?
|
|
|
|
function array_unserialize($array) {
|
|
foreach ($array as $key => $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 "<div class='container'>";
|
|
$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<div class='item'>";
|
|
echo "\n<a href='?db=".basename($file,".sqlite3")."&view=".$view."'><img src='".$icon."' title='".$row[0]['stats']."' width='128' height='128'></a>";
|
|
$parts = explode("_",basename($file, ".sqlite3"));
|
|
echo "\n<span class='material'>".$parts[2]." (".$parts[0].")</a></span>";
|
|
echo "\n<span class='materialsub'>".$dbo->query("SELECT Count(*) FROM files")->fetch()['Count(*)']." Files";
|
|
if ($dbo->query("SELECT status FROM _walkwalk")->fetch()[0] == "aborted") {
|
|
echo " <i>(Aborted)</i>";
|
|
}
|
|
echo "\n</span>";
|
|
echo "\n</div>";
|
|
}
|
|
|
|
} 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 "<table width='100%'><tr><td>";
|
|
|
|
$crumb = breadcrumbs($dbo, $myview['Pathname']);
|
|
foreach ($crumb as $myparts) {
|
|
if ($crumb[count($crumb)-1] != $myparts) {
|
|
echo "\n<a href='finder.php?db=".$db."&id=".$myparts[0]."&view=".$view."'>".$myparts[1]."</a>";
|
|
echo " > ";
|
|
} else {
|
|
echo $myparts[1];
|
|
}
|
|
}
|
|
|
|
echo "</td><td width='200'>";
|
|
|
|
if ($view == "icon") {
|
|
echo "icon | <a href='finder.php?db=".$db."&id=".$id."&view=list'>list</a>";
|
|
} else {
|
|
echo "<a href='finder.php?db=".$db."&id=".$id."&view=icon'>icon</a> | list";
|
|
}
|
|
|
|
echo "</td></tr></table>";
|
|
|
|
echo "<hr>";
|
|
|
|
echo "<div class='container'>";
|
|
|
|
// directory view
|
|
|
|
if ($type == "dir") {
|
|
|
|
$items = $dbo->query("SELECT * FROM files WHERE (parent=".$id.")")->fetchAll();
|
|
|
|
if ($view == "icon") {
|
|
|
|
foreach ($items as $item) {
|
|
echo "\n<div class='item'>";
|
|
echo "\n<a href='finder.php?db=".$db."&id=".$item['id']."&view=".$view."' title='launch.php?db=".$db."&id=".$item['id']."'>";
|
|
if ($item['Type'] == "dir") {
|
|
|
|
echo "<img src='/icons/directory.png' width='128' height='128'></a>";
|
|
|
|
} elseif (isset($item['tinfo'])) {
|
|
|
|
list ($twidth, $theight) = unserialize($item['tinfo']);
|
|
echo "<img src='/image.php?db=".$db."&id=".$item['id']."' width='".($twidth/2)."' height='".($theight/2)."'>";
|
|
|
|
} else {
|
|
|
|
echo "<img src='/icons/null.png' width='128' height='128'>";
|
|
|
|
}
|
|
|
|
echo "</a>";
|
|
echo "\n<span class='material'>".$item['Filename'];
|
|
if ($item['Type'] == "dir") {
|
|
echo " (".count($dbo->query("SELECT * FROM files WHERE (parent=".$item['id'].")")->fetchAll())." Items)";
|
|
}
|
|
echo "\n</span>";
|
|
echo "\n<span class='materialsub'>".human_filesize($item['Size'])."</span>";
|
|
echo "\n</div>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "list";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// file view
|
|
|
|
echo "<pre>";
|
|
|
|
$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 "<h1>".$fdeep['Pathname']."</h1><hr>";
|
|
|
|
if (isset($fdeep['tinfo'])) {
|
|
echo "<img src='/image.php?db=".$db."&id=".$id."' width='".$twidth."' height='".$theight."'><br>";
|
|
} else {
|
|
echo "<img src='/icons/null.png' width='128' height='128'><br>";
|
|
}
|
|
|
|
echo dumpme(array_unserialize($fdeep));
|
|
echo "<h1>Spotlight</h1><hr>";
|
|
echo dumpme(array_unserialize($sdeep));
|
|
echo "<h1>Mediainfo</h1><hr>";
|
|
echo dumpme(array_unserialize($mdeep));
|
|
|
|
echo "</pre>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo str_repeat("<div class='flexfill'></div>", 100);
|
|
|
|
?>
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|