This commit is contained in:
2018-09-02 11:21:24 -07:00
parent 547eb3f4fa
commit d2ed189d2b
4 changed files with 172 additions and 192 deletions

293
Yuba.php
View File

@@ -3,7 +3,7 @@
// Yuba // Yuba
// // // //
////////////////////////////////////////// //////////////////////////////////////////
$version = "0.7.2"; $version = "0.7.2.5";
ini_set('memory_limit', '4096M'); ini_set('memory_limit', '4096M');
date_default_timezone_set("America/Los_Angeles"); date_default_timezone_set("America/Los_Angeles");
@@ -22,6 +22,8 @@ $p = unserialize(file_get_contents("prefs.php"));
// Path & application variables // Path & application variables
////////////////////////////////////////// //////////////////////////////////////////
$stamp = date("Y-m-d_H-i-s", time());
if (!isset($argv[1])) { echo "Input error"; die; } if (!isset($argv[1])) { echo "Input error"; die; }
$zpath = realpath(@$argv[1]); $zpath = realpath(@$argv[1]);
if (@$argv[2]) { $bdest = realpath($argv[2]); } else { $bdest = realpath($p['bdest']); } if (@$argv[2]) { $bdest = realpath($argv[2]); } else { $bdest = realpath($p['bdest']); }
@@ -75,10 +77,11 @@ $bin_qlthumb = __DIR__."/bin/ql-thumbnail";
// Logfile // Logfile
$error_log_file = $bpath."/".$stamp."_error.log";
error_reporting(E_ALL); error_reporting(E_ALL);
ini_set("display_errors", TRUE); ini_set("display_errors", TRUE);
ini_set("log_errors", TRUE); ini_set("log_errors", TRUE);
ini_set("error_log", $bpath."/php.log"); ini_set("error_log", $error_log_file);
// Banner // Banner
////////////////////////////////////////// //////////////////////////////////////////
@@ -99,6 +102,7 @@ $df_device = shell_exec("df ".$zpath." | tail -n 1 | cut -d' ' -f1");
$mdutil = shell_exec("mdutil -s ".$df_volume); $mdutil = shell_exec("mdutil -s ".$df_volume);
if (strpos($mdutil,"disabled")) { if (strpos($mdutil,"disabled")) {
echo "Warning: spotlight indexing is disabled\n"; echo "Warning: spotlight indexing is disabled\n";
$p['spotlight'] = false;
} }
if (substr($zpath, 0, 9) != "/Volumes/") { if (substr($zpath, 0, 9) != "/Volumes/") {
@@ -156,8 +160,6 @@ $sysvers = shell_exec("sw_vers 2>&1");
echo "Building database...\n"; echo "Building database...\n";
$stamp = date("Y-m-d_H-i-s", time());
$dbo = new PDO("sqlite:".$bpath."/".$stamp.".sqlite3"); $dbo = new PDO("sqlite:".$bpath."/".$stamp.".sqlite3");
$dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -169,7 +171,7 @@ $dbo->query("PRAGMA synchronous = NORMAL");
$dbo->query("PRAGMA journal_mode = WAL"); $dbo->query("PRAGMA journal_mode = WAL");
*/ */
$dbo->exec("CREATE TABLE _walkwalk ( $dbo->exec("CREATE TABLE _skim (
version TEXT, version TEXT,
opts TEXT, opts TEXT,
host TEXT, host TEXT,
@@ -215,8 +217,8 @@ $dbo->exec("CREATE TABLE files (
Perms INTEGER, Perms INTEGER,
Owner TEXT, Owner TEXT,
ATime INTEGER, ATime INTEGER,
CTime INTEGER,
MTime INTEGER, MTime INTEGER,
CTime INTEGER,
LinkTarget TEXT, LinkTarget TEXT,
RealPath TEXT, RealPath TEXT,
stat TEXT, stat TEXT,
@@ -234,23 +236,6 @@ $dbo->exec("CREATE TABLE files (
Origin TEXT, Origin TEXT,
GPS TEXT, GPS TEXT,
Author TEXT, Author TEXT,
spotlight TEXT,
kMDItemDateAdded INTEGER,
kMDItemLastUsedDate INTEGER,
kMDItemUseCount INTEGER,
kMDItemContentModificationDate INTEGER,
kMDItemContentType TEXT,
kMDItemCreator TEXT,
kMDItemFSCreatorCode TEXT,
kMDItemKind TEXT,
kMDItemFSTypeCode TEXT,
kMDItemUserTags TEXT,
kMDItemFSInvisible INTEGER,
kMDItemNumberOfPages INTEGER,
kMDItemPageHeight INTEGER,
kMDItemPageWidth INTEGER,
kMDItemWhereFroms TEXT,
kMDItemEncodingApplications TEXT,
has_exif INTEGER, has_exif INTEGER,
has_mediainfo INTEGER, has_mediainfo INTEGER,
has_hash INTEGER, has_hash INTEGER,
@@ -269,7 +254,7 @@ $dbo->exec("CREATE TABLE files (
Bitrate INTEGER Bitrate INTEGER
)"); )");
$stmt = $dbo->prepare("INSERT INTO _walkwalk VALUES (:version, :opts, :host, :uid, :zpath, :bpath, :type, :passed_file, :passed_dir, :passed_link, :passed_total, :nodescended, :ignored, :dupes, :stats, :qlmanage, :sysvers, :diskutil, :disks, :df, :df_device, :df_volume, :mdutil, :profile, :status)"); $stmt = $dbo->prepare("INSERT INTO _skim VALUES (:version, :opts, :host, :uid, :zpath, :bpath, :type, :passed_file, :passed_dir, :passed_link, :passed_total, :nodescended, :ignored, :dupes, :stats, :qlmanage, :sysvers, :diskutil, :disks, :df, :df_device, :df_volume, :mdutil, :profile, :status)");
$stmt->BindValue(":version",$version); $stmt->BindValue(":version",$version);
$stmt->BindValue(":opts",serialize($p)); $stmt->BindValue(":opts",serialize($p));
$stmt->BindValue(":host",$host); $stmt->BindValue(":host",$host);
@@ -346,6 +331,11 @@ $files = new RecursiveIteratorIterator(
foreach ($files as $null) { } foreach ($files as $null) { }
$first_run = 0; $first_run = 0;
if (!$passed_total) {
echo "Nothing was found, exiting";
die;
}
// Permissions & Stat // Permissions & Stat
////////////////////////////////////////// //////////////////////////////////////////
@@ -488,7 +478,7 @@ echo ProgressBar::finish();
unset($dx, $dxo, $dupes); unset($dx, $dxo, $dupes);
// stats // stats
$stmt = "UPDATE _walkwalk SET "; $stmt = "UPDATE _skim SET ";
$stmt .= "passed_file=".$passed_file.", "; $stmt .= "passed_file=".$passed_file.", ";
$stmt .= "passed_dir=".$passed_dir.", "; $stmt .= "passed_dir=".$passed_dir.", ";
$stmt .= "passed_link=".$passed_link.", "; $stmt .= "passed_link=".$passed_link.", ";
@@ -504,6 +494,9 @@ $dbo->exec($stmt);
if ($p['contents']) { if ($p['contents']) {
echo "DO CONTENTS HERE\n"; echo "DO CONTENTS HERE\n";
// make a dir in the bundle called contents (similar to db)
// match files smaller than x and with file extension of txt etc
// copy files to hash dirs in bundle (like db dir)
} }
@@ -669,6 +662,98 @@ if ($p['hash']) {
} }
// Spotlight
//////////////////////////////////////////
$mb['i'] = array( "PixelWidth",
"PixelHeight",
"Latitude",
"Longitude",
"DurationSeconds",
"UseCount",
"FSInvisible",
"NumberOfPages",
"PageHeight",
"PageWidth" );
$mb['t'] = array( "Title",
"ContentType",
"Creator",
"FSCreatorCode",
"Kind",
"FSTypeCode" );
$mb['a'] = array( "UserTags",
"WhereFroms",
"EncodingApplications" );
$mb['d'] = array( "DateAdded",
"LastUsedDate",
"ContentModificationDate",
"ContentCreationDate" );
$ibuild[] = ":pid, :spotlight";
$cbuild[] = "pid TEXT, spotlight TEXT";
foreach (array_merge($mb['i'],$mb['d']) as $item) {
$cbuild[] = $item." INTEGER";
$ibuild[] = ":".$item;
}
foreach (array_merge($mb['t'],$mb['a']) as $item) {
$cbuild[] = $item." TEXT";
$ibuild[] = ":".$item;
}
$p['spotlight'] = 1;
if ($p['spotlight']) {
echo ProgressBar::start($passed_total,"Spotlight");
$dbo->exec("CREATE TABLE mdls (".implode(",",$cbuild).")");
foreach ($files as $splFileInfo) {
$pid = md5($splFileInfo->getPathname());
$shellpath = escapeshellarg($splFileInfo->getPathname());
$mdls = shell_exec("mdls -plist - ".$shellpath." 2>&1");
if (substr_count(@$mdls,"\n") < 2) { continue; }
$parser = new plistParser();
$spotlight = $parser->parseString($mdls);
$stmt = $dbo->prepare("INSERT INTO mdls VALUES (".implode(",",$ibuild).")");
foreach ($mb as $key => $list) {
foreach ($list as $item) {
if (@$spotlight["kMDItem".$item]) {
$stmt->BindValue(":pid",$pid);
$stmt->BindValue(":spotlight",$mdls);
switch($key) {
case "i":
case "t":
$stmt->BindValue(":".$item,$spotlight["kMDItem".$item]);
break;
case "a":
$stmt->BindValue(":".$item,serialize($spotlight["kMDItem".$item]));
break;
case "d":
$stmt->BindValue(":".$item,strtotime($spotlight["kMDItem".$item]));
break;
}
}
}
}
$stmt->execute();
echo ProgressBar::next();
}
echo ProgressBar::finish();
}
// Files // Files
////////////////////////////////////////// //////////////////////////////////////////
@@ -682,7 +767,7 @@ foreach ($files as $splFileInfo) {
// DB // DB
$stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Inode, :Perms, :Owner, :ATime, :CTime, :MTime, :LinkTarget, :RealPath, :stat, :items, :newest, :gfi_type, :gfi_attr, :gfi_created, :Size, :Title, :PixelWidth, :PixelHeight, :Duration, :DateTimeOriginal, :Origin, :GPS, :Author, :spotlight, :kMDItemDateAdded, :kMDItemLastUsedDate, :kMDItemUseCount, :kMDItemContentModificationDate, :kMDItemContentType, :kMDItemCreator, :kMDItemFSCreatorCode, :kMDItemKind, :kMDItemFSTypeCode, :kMDItemUserTags, :kMDItemFSInvisible, :kMDItemNumberOfPages, :kMDItemPageHeight, :kMDItemPageWidth, :kMDItemWhereFroms, :kMDItemEncodingApplications, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :ProfileDescription, :BitDepth, :Compression, :Orientation, :LensType, :VideoFormat, :AudioFormat, :Tracks, :Profile, :Bitrate)"); $stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Inode, :Perms, :Owner, :ATime, :CTime, :MTime, :LinkTarget, :RealPath, :stat, :items, :newest, :gfi_type, :gfi_attr, :gfi_created, :Size, :Title, :PixelWidth, :PixelHeight, :Duration, :DateTimeOriginal, :Origin, :GPS, :Author, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :ProfileDescription, :BitDepth, :Compression, :Orientation, :LensType, :VideoFormat, :AudioFormat, :Tracks, :Profile, :Bitrate)");
// Identify dir, file, link or bundle dir // Identify dir, file, link or bundle dir
@@ -728,7 +813,7 @@ foreach ($files as $splFileInfo) {
} }
echo shortlabel($pathname,50,1); echo shortlabel($pathname,50);
// ------------------------------------------------ // // ------------------------------------------------ //
@@ -754,7 +839,6 @@ foreach ($files as $splFileInfo) {
$size = null; $size = null;
} }
$stmt->BindValue(":Size",@$size); $stmt->BindValue(":Size",@$size);
stringPrint(floor($size/1024)."k");
// ------------------------------------------------ // // ------------------------------------------------ //
@@ -763,10 +847,8 @@ foreach ($files as $splFileInfo) {
if ($type == "dir" || $type == "bundle" ) { if ($type == "dir" || $type == "bundle" ) {
$items = chop(@shell_exec("find ".$shellpath." \( ! -regex '.*/\..*' \) | wc -l 2>&1"))-1; $items = chop(@shell_exec("find ".$shellpath." \( ! -regex '.*/\..*' \) | wc -l 2>&1"))-1;
$stmt->BindValue(":items",@$items); $stmt->BindValue(":items",@$items);
stringPrint($items ? "ITEMS" : "items");
} else { } else {
$items = null; $items = null;
stringPrint(" ");
} }
// ------------------------------------------------ // // ------------------------------------------------ //
@@ -776,10 +858,8 @@ foreach ($files as $splFileInfo) {
if ($type == "dir") { if ($type == "dir") {
$newest = @filemtime(chop(shell_exec("find ".$shellpath." -type f -not -path '*/\.*' -print0 | xargs -0 stat -f \"%m %N\" | sort -rn 2>&1 | head -1 | cut -f2- -d\" \""))); $newest = @filemtime(chop(shell_exec("find ".$shellpath." -type f -not -path '*/\.*' -print0 | xargs -0 stat -f \"%m %N\" | sort -rn 2>&1 | head -1 | cut -f2- -d\" \"")));
$stmt->BindValue(":newest",@$newest); $stmt->BindValue(":newest",@$newest);
stringPrint($newest ? "NEWEST" : "newest");
} else { } else {
$newest = null; $newest = null;
stringPrint(" ");
} }
// ------------------------------------------------ // // ------------------------------------------------ //
@@ -801,63 +881,6 @@ foreach ($files as $splFileInfo) {
$stmt->BindValue(":gfi_attr",@$gfi['attributes']); $stmt->BindValue(":gfi_attr",@$gfi['attributes']);
$stmt->BindValue(":gfi_created",strtotime($gfi['created'])); $stmt->BindValue(":gfi_created",strtotime($gfi['created']));
stringPrint("GFI");
// ------------------------------------------------ //
// Spotlight
$mdls = null;
$mdls = shell_exec("mdls -plist - ".$shellpath." 2>&1");
if ($mdls != $pathname.": could not find ".$pathname.".\n") {
$parser = new plistParser();
$spotlight = $parser->parseString($mdls);
//$stmt->BindValue(":spotlight",serialize($spotlight));
$stmt->BindValue(":spotlight",$mdls);
} else {
$spotlight = array();
$stmt->BindValue(":spotlight",null);
}
stringPrint($mdls ? "MDLS" : "mdls");
unset($breakout, $schema, $item, $ready);
$breakout[] = array ("kMDItemDateAdded", "date");
$breakout[] = array ("kMDItemLastUsedDate", "date");
$breakout[] = array ("kMDItemUseCount", 0);
$breakout[] = array ("kMDItemContentModificationDate", "date");
$breakout[] = array ("kMDItemContentType", 0);
$breakout[] = array ("kMDItemCreator", 0);
$breakout[] = array ("kMDItemFSCreatorCode", 0);
$breakout[] = array ("kMDItemKind", 0);
$breakout[] = array ("kMDItemFSTypeCode", 0);
$breakout[] = array ("kMDItemUserTags", "array");
$breakout[] = array ("kMDItemFSInvisible", 0);
$breakout[] = array ("kMDItemNumberOfPages", 0);
$breakout[] = array ("kMDItemPageHeight", 0);
$breakout[] = array ("kMDItemPageWidth", 0);
$breakout[] = array ("kMDItemWhereFroms", "array");
$breakout[] = array ("kMDItemEncodingApplications", "array");
foreach ($breakout as $schema) {
if (!isset($spotlight[$schema[0]])) {
$stmt->BindValue(":".$schema[0],null);
continue;
}
if ($schema[1] === "date") {
$ready = strtotime($spotlight[$schema[0]]);
} elseif ($schema[1] === "array") {
$ready = serialize($spotlight[$schema[0]]);
} else {
$ready = $spotlight[$schema[0]];
}
$stmt->BindValue(":".$schema[0],$ready);
}
unset($breakout);
// ------------------------------------------------ // // ------------------------------------------------ //
// Pool // Pool
@@ -869,119 +892,47 @@ foreach ($files as $splFileInfo) {
$fetch_exif = @unserialize($dbp->query("SELECT tags FROM exiftool WHERE fid='".$fid."'")->fetch()[0]); $fetch_exif = @unserialize($dbp->query("SELECT tags FROM exiftool WHERE fid='".$fid."'")->fetch()[0]);
is_array($fetch_exif) ? $yes_exif = 1 : $yes_exif = 0; is_array($fetch_exif) ? $yes_exif = 1 : $yes_exif = 0;
$stmt->BindValue(":has_exif",$yes_exif); $stmt->BindValue(":has_exif",$yes_exif);
stringPrint($yes_exif ? "EXIF" : "exif");
$fetch_media = @unserialize($dbp->query("SELECT info FROM mediainfo WHERE fid='".$fid."'")->fetch()[0]); $fetch_media = @unserialize($dbp->query("SELECT info FROM mediainfo WHERE fid='".$fid."'")->fetch()[0]);
is_array($fetch_media) ? $yes_media = 1 : $yes_media = 0; is_array($fetch_media) ? $yes_media = 1 : $yes_media = 0;
$stmt->BindValue(":has_mediainfo",$yes_media); $stmt->BindValue(":has_mediainfo",$yes_media);
stringPrint($yes_media ? "MEDIA" : "media");
$yes_hash = $dbp->query("SELECT EXISTS(SELECT 1 FROM md5 WHERE fid='".$fid."')")->fetch()[0]; $yes_hash = $dbp->query("SELECT EXISTS(SELECT 1 FROM md5 WHERE fid='".$fid."')")->fetch()[0];
$stmt->BindValue(":has_hash",$yes_hash); $stmt->BindValue(":has_hash",$yes_hash);
stringPrint($yes_hash ? "HASH" : "hash");
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$fid."'")->fetch(); $fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$fid."'")->fetch();
if (@$fetch_thumb['relative_path']) { if (@$fetch_thumb['relative_path']) {
$stmt->BindValue(":thumb_filename",$fetch_thumb['relative_path']); $stmt->BindValue(":thumb_filename",$fetch_thumb['relative_path']);
$stmt->BindValue(":thumb_width",$fetch_thumb['width']); $stmt->BindValue(":thumb_width",$fetch_thumb['width']);
$stmt->BindValue(":thumb_height",$fetch_thumb['height']); $stmt->BindValue(":thumb_height",$fetch_thumb['height']);
stringPrint("THUMB");
} else { } else {
$stmt->BindValue(":thumb_filename",null); $stmt->BindValue(":thumb_filename",null);
stringPrint("thumb");
} }
$breakout[] = "ProfileDescription";
$breakout[] = "BitDepth_BitsPerSample";
$breakout[] = "Compression";
$breakout[] = "Aperture,LightSource,WhiteBalance";
$breakout[] = "Orientation";
$breakout[] = "LensType,FocalLength";
$breakout['profile'] = "ProfileDescription";
$breakout['bits'] = "BitDepth_BitsPerSample";
$breakout['compression'] = "Compression";
$breakout[] = "Aperture,LightSource,WhiteBalance";
$breakout[] = "Orientation";
$breakout[] = "LensType,FocalLength";
/*
function parseConditionalItem($data, $item) {
if (strpos($item, "_")) {
$list = explode("_", $item);
foreach ($list as $piece) {
// left off here
} }
}
// ------------------------------------------------ //
// Breakouts
function parseItem($data, $item) {
if (strpos($item, ",")) {
$list = explode(",", $item);
foreach ($list as $piece) {
$cleared[] = parseConditionalItem($piece);
}
} else {
$cleared[] = parseConditionalItem($item);
}
foreach ($cleared as $check) {
if (isset($data[$check])) {
$ready[] = $data[$check];
}
}
if (@count($ready) > 1) {
return implode(", ",$ready);
} elseif (@count($ready) == 1) {
return $ready[0];
} else {
return null;
}
}
// left off here
foreach ($breakout as $item) {
unset($ready);
if (strpos($item, ",")) {
$list = explode(",", $item) {
foreach ($list as $multi) {
if (isset($fetch_exif[$multi])) {
$ready[] = $fetch_exif[$multi];
}
}
} elseif (strpos($item, "_")) {
$list = explode("_", $item) {
foreach ($list as $multi) {
if (isset($ready) {
continue;
}
if (isset($fetch_exif[$multi])) {
$ready[] = $fetch_exif[$multi];
}
*/
unset($breakout);
//print_r($fetch_exif);
//print_r($fetch_media);
}
// ------------------------------------------------ //
// Write to DB // Write to DB
$stmt->execute(); $stmt->execute();
stringPrint("->DB");
// Set fileatime back to original value // Set fileatime back to original value
//if ($type != "link" && is_writable($pathname) && $p['fixatimes']) { //if ($type != "link" && is_writable($pathname) && $p['fixatimes']) {
// exec("touch -at `date -r ".$atime." +%Y%m%d%H%M.%S` ".$shellpath." 2>&1"); // exec("touch -at `date -r ".$atime." +%Y%m%d%H%M.%S` ".$shellpath." 2>&1");
// stringPrint("touch");
// } // }
// Double check stat for file against pre-run value // Double check stat for file against pre-run value
@@ -1016,7 +967,7 @@ function parseItem($data, $item) {
$message[] = "CTIME"; $message[] = "CTIME";
} }
if (count($message)) { stringPrint("Changed: ".implode(", ", $message)); } if (count($message)) { echo "\nChanged: ".implode(", ", $message)."\n"; }
} }
@@ -1033,8 +984,10 @@ echo ProgressBar::finish();
echo "\n"; echo "\n";
if (file_exists($error_log_file)) { echo file_get_contents($error_log_file); }
$seconds = floor($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"]); $seconds = floor($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"]);
$dbo->exec("UPDATE _walkwalk SET status='completed_in_".$seconds."'"); $dbo->exec("UPDATE _skim SET status='completed_in_".$seconds."'");
echo "Finished in ".$seconds." seconds\n\n"; echo "Finished in ".$seconds." seconds\n\n";
unset($dbo, $dbp, $files, $family, $fx); unset($dbo, $dbp, $files, $family, $fx);

View File

@@ -11,7 +11,7 @@ class ProgressBar {
public static function display($message = null) { public static function display($message = null) {
$string = "PROGRESS:".round((self::$done/self::$total)*100,2); $string = "PROGRESS:".round((self::$done/self::$total)*100,2);
if ($message) { if ($message) {
return "\t".$string."\n".$message; return "\n".$string."\n".$message;
} elseif (!strpos(__FILE__,".app")) { } elseif (!strpos(__FILE__,".app")) {
return "\r\033[K\r".$string; return "\r\033[K\r".$string;
} else { } else {

View File

@@ -3,9 +3,9 @@
<style> <style>
div.container { display: flex; flex-flow: row wrap; justify-content: center; } div.container { display: flex; flex-flow: row wrap; justify-content: center; }
div.flexfill { width: 220px; height: 1px; } div.item { width: 99px; height: 99px; padding: 20px; }
div.item { width: 190px; height: 220px; padding: 20px; } div.item { font-family: Helvetica; font-size: 11px; }
img { width: 128px; height: 128px; } img { width: 64px; height: 64px; }
</style> </style>
</head> </head>
@@ -14,6 +14,12 @@ img { width: 128px; height: 128px; }
<? <?
////////////////////////////////////////////////
// Yuba RTC Browser
////////////////////////////////////////////////
// Functions
function findicon($filename) { function findicon($filename) {
$ext = pathinfo($filename)['extension']; $ext = pathinfo($filename)['extension'];
if (!$ext) { if (!$ext) {
@@ -29,47 +35,67 @@ function findicon($filename) {
return $good; return $good;
} }
////////////////////////////////////////////////
$db_file = $_GET['db']; $db_file = $_GET['db'];
if ($db_file) { if ($db_file) {
echo "<div class='container'>"; // Show a view
if (!is_readable($db_file)) { echo "can't read db file"; die; } if (!is_readable($db_file)) { echo "can't read db file"; die; }
echo "<a href='?db='><-</a>"; echo "<a href='?db='>index</a>";
echo "<hr>";
$dbo = new PDO("sqlite:".$db_file); $dbo = new PDO("sqlite:".$db_file);
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$array = $dbo->query("SELECT children FROM family WHERE (rowid=2)")->fetch()['children']; $array = $dbo->query("SELECT children FROM family WHERE (rowid=2)")->fetch()['children'];
$array = unserialize($array); $children = unserialize($array);
//echo "<pre>"; print_r($array); echo "</pre>"; //echo "<pre>"; print_r($array); echo "</pre>";
foreach ($array as $key => $item) {
$row = $dbo->query("SELECT * FROM files WHERE (pid='".$item."')")->fetchAll()[0]; echo "<hr>";
//echo "<pre>"; print_r($row); echo "</pre>";
$icon = "<img src='".findicon($row['Filename'])."'>"; echo "\n<div class='container'>";
echo "<div class='item'>".$icon."<br>".$row['Filename']."</div>"; foreach ($children as $key => $item) {
$row_a = $dbo->query("SELECT * FROM files WHERE (pid='".$item."')")->fetchAll()[0];
//$row_b = $dbo->query("SELECT * FROM mdls WHERE (pid='".$item."')")->fetchAll()[0];
//$row_c = $dbo->query("SELECT * FROM milk WHERE (pid='".$item."')")->fetchAll()[0];
$icon = "<img src='".findicon($row_a['Filename'])."'>";
echo "\n<div class='item'>".$icon."<br>".htmlentities($row_a['Filename'])."</div>";
echo "<br>"; echo "<br>";
} }
echo "</div>"; echo "\n</div>";
} else { } else {
foreach (glob("skim/*.bundle") as $skim) { // DB List
$dbs = glob($skim."/*.sqlite3");
foreach ($dbs as $db) { $bundles = glob("skim/*.bundle");
if (!strpos($db,"pool")) { foreach ($bundles as $bundle) {
echo "<a href='?db=".$db."'>".$db."</a><br>"; echo "<h2>".pathinfo($bundle)['filename']."</h2>";
$dbs = glob($bundle."/*.sqlite3");
foreach ($dbs as $db_file) {
if (!strpos($db_file,"pool")) {
echo "<a href='?db=".$db_file."'>".pathinfo($db_file)['filename']."</a>&nbsp;";
$dbo = new PDO("sqlite:".$db_file);
echo $dbo->query("SELECT type FROM _skim WHERE (rowid=1)")->fetch()['type'].", ";
echo $dbo->query("SELECT passed_total FROM _skim WHERE (rowid=1)")->fetch()['passed_total']." files, ";
echo $dbo->query("SELECT status FROM _skim WHERE (rowid=1)")->fetch()['status'];
echo "<br>";
} }
} }
} }

View File

@@ -7,6 +7,7 @@
$browser_version = "0.4.5"; $browser_version = "0.4.5";
require_once("togggle.php");
date_default_timezone_set("America/Los_Angeles"); date_default_timezone_set("America/Los_Angeles");
$method = "id"; $method = "id";