From 756ea17f99833a2745a8a81aec41941f92195760 Mon Sep 17 00:00:00 2001 From: profiteroles Date: Sat, 27 Apr 2019 00:48:25 -0700 Subject: [PATCH] 0.7.10.3 --- Yuba.php | 61 ++++++++----- filetypes.php | 16 +++- functions.php | 6 +- web/handle_zip.php | 27 ++++++ web/rtc.php | 220 ++++++++++++++++++++++++++++++++++++--------- 5 files changed, 263 insertions(+), 67 deletions(-) create mode 100644 web/handle_zip.php diff --git a/Yuba.php b/Yuba.php index 0e302a2..7166e0b 100755 --- a/Yuba.php +++ b/Yuba.php @@ -3,9 +3,9 @@ // Yuba // // ////////////////////////////////////////// -$version = "0.7.9.3"; +$version = "0.7.10.3"; -ini_set('memory_limit', '4096M'); +ini_set('memory_limit', '10240M'); date_default_timezone_set("America/Los_Angeles"); // Includes & Prefs @@ -62,6 +62,7 @@ foreach ($p['bundles'] as $bundle) { // Ignore matching files and directories $p['ignore'] = array( ".DS_Store", + ".Trashes", ".DocumentRevisions-V100", ".Spotlight-V100", ".TemporaryItems", @@ -116,7 +117,6 @@ $vdisks_parsed = $parser->parseString(utf8_for_xml($vdisks)); //print_r($vdisks_parsed); $df = shell_exec("df 2>&1"); - // old method, new method is to parse plist //$df_volume = trim(shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | rev | cut -d' ' -f1 | rev")); //$df_device = trim(shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | cut -d' ' -f1")); @@ -124,7 +124,7 @@ $df = shell_exec("df 2>&1"); $df_volume = $diskutil_parsed['MountPoint']; $df_device = "/dev/".$diskutil_parsed['ParentWholeDisk']; -$mdutil = shell_exec("mdutil -s ".$df_volume); +$mdutil = shell_exec("mdutil -sv ".$df_volume); if (strpos($mdutil,"disabled")) { echo msg("Warning: spotlight indexing is disabled"); $p['spotlight'] = false; @@ -268,6 +268,7 @@ $dbo->exec("CREATE TABLE files ( stat TEXT, items INTEGER, newest INTEGER, + fkind TEXT, gfi_type TEXT, gfi_attr TEXT, gfi_created TEXT, @@ -767,7 +768,8 @@ $mb['i'] = array( "PixelWidth", "FSInvisible", "NumberOfPages", "PageHeight", - "PageWidth" ); + "PageWidth", + "TotalBitRate" ); $mb['t'] = array( "Title", "ContentType", @@ -863,7 +865,7 @@ foreach ($files as $splFileInfo) { // DB - $stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Size, :Inode, :Perms, :Owner, :ATime, :MTime, :CTime, :LinkTarget, :RealPath, :stat, :items, :newest, :gfi_type, :gfi_attr, :gfi_created, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :contents_filename)"); + $stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Size, :Inode, :Perms, :Owner, :ATime, :MTime, :CTime, :LinkTarget, :RealPath, :stat, :items, :newest, :fkind, :gfi_type, :gfi_attr, :gfi_created, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :contents_filename)"); // Identify dir, file, link or bundle dir @@ -972,6 +974,17 @@ foreach ($files as $splFileInfo) { $stmt->BindValue(":gfi_type",$writegfitype); $stmt->BindValue(":gfi_attr",@$gfi['attributes']); $stmt->BindValue(":gfi_created",strtotime(@$gfi['created'])); + + // ------------------------------------------------ // + + // Kind + + unset($fkind); + + if ($type == "file") { + $fkind = trim(shell_exec("file -b -p ".$shellpath." | cut -f1 -d,")); + $stmt->BindValue(":fkind",@$fkind); + } // ------------------------------------------------ // @@ -1046,29 +1059,30 @@ echo ProgressBar::finish(); // Milk ////////////////////////////////////////// -$milk['t*Title'] = ["e^Title","k^Title","m^Track_name"]; +$milk['t*DocTitle'] = ["e^Title","k^Title","m^Track_name"]; $milk['t*Format'] = ["m^Format","e^Compression","e^MIMEType"]; -$milk['t*Dimensions'] = ["k^PixelWidth.k^PixelHeight","e^PixelWidth.e^PixelHeight","m^SkimDims"]; +$milk['t*Dimensions'] = ["k^PixelWidth.k^PixelHeight","e^PixelWidth.e^PixelHeight","m^SkimDims","k^SkimPageDims"]; $milk['s*Seconds'] = ["k^DurationSeconds","e^Duration","m^Duration"]; $milk['d*DateTime'] = ["e^DateTimeOriginal","m^EncodedDate","e^CreateDate","e^MediaCreateDate","k^ContentCreationDate"]; $milk['t*Origin'] = ["e^CameraModelName","e^Producer","e^CreatorTool","e^WriterName","e^Software","e^Encoder","k^Creator"]; $milk['t*GPS'] = ["k^Latitude.k^Longitude","e^GPSPosition"]; -$milk['t*Author'] = ["e^Author","e^Artist","e^Creator","e^By-line"]; +$milk['t*Author'] = ["e^Author","e^Artist","e^Creator","e^By-line","k^Copyright"]; -$milk['i*Tracks'] = ["m^SkimTrackCount"]; +$milk['i*Tracks'] = ["m^SkimTrackCount","k^NumberOfPages"]; $milk['t*Writer'] = ["m^Writing_application.m^Writing_library"]; -$milk['t*Bitrate'] = ["m^Overall_bit_rate"]; +$milk['t*Bitrate'] = ["m^Overall_bit_rate","e^AvgBitrate","k^TotalBitRate"]; -$milk['i*Orientation'] = ["e^Orientation"]; -$milk['t*Profile'] = ["e^Profile"]; -$milk['i*BitDepth'] = ["e^BitDepth"]; -$milk['t*LensType'] = ["e^LensType"]; -$milk['t*FocalLength'] = ["e^FocalLength"]; -$milk['t*Aperture'] = ["e^Aperture"]; -$milk['t*LightSource'] = ["e^LightSource"]; -$milk['t*WhiteBalance'] = ["e^WhiteBalance"]; +//$milk['i*Orientation'] = ["e^Orientation"]; +//$milk['t*Profile'] = ["e^Profile"]; +//$milk['i*BitDepth'] = ["e^BitDepth"]; +//$milk['t*LensType'] = ["e^LensType"]; +//$milk['t*FocalLength'] = ["e^FocalLength"]; +//$milk['t*Aperture'] = ["e^Aperture"]; +//$milk['t*LightSource'] = ["e^LightSource"]; +//$milk['t*WhiteBalance'] = ["e^WhiteBalance"]; $delimiter = ","; +$display_delimiter = " x "; // Build DB @@ -1102,6 +1116,13 @@ while ($row_a = $loop->fetch()) { $row_b = @$dbo->query("SELECT * FROM mdls WHERE (rowid='".$row_a['rowid']."')")->fetch(); if (count(@$row_b) > 1) { $m['k'] = $row_b; + + //custom values + + if ($m['k']['PageWidth'] && $m['k']['PageHeight']) { + $m['k']['SkimPageDims'] = round($m['k']['PageWidth']/72,2)."in".$display_delimiter.round($m['k']['PageHeight']/72,2)."in"; + } + } else { $m['k'] = null; } @@ -1125,7 +1146,7 @@ while ($row_a = $loop->fetch()) { foreach (@$decoded['File']['track'] as $track) { if (!@$m['m']['SkimDims'] && @$track['Width'] && @$track['Height']) { - $m['m']['SkimDims'] = sanitize($track['Width'],"i").$delimiter.sanitize($track['Height'],"i"); + $m['m']['SkimDims'] = sanitize($track['Width'],"i").$display_delimiter.sanitize($track['Height'],"i"); } } diff --git a/filetypes.php b/filetypes.php index 926303b..aede80a 100755 --- a/filetypes.php +++ b/filetypes.php @@ -1,8 +1,19 @@ parse_array(); break; case 'dict': return $this->parse_dict(); break; - default: throw new Exception(sprintf("Not a valid plist. %s is not a valid type", $this->name), 4); - } + // why the fuck cant this plist parser handle the plist generated from an hdiutil list with no dimgs attached? + //default: throw new Exception(sprintf("Not a valid plist. %s is not a valid type", $this->name), 4); + } } private function parse_dict() { $array = array(); $this->nextOfType(XMLReader::ELEMENT); diff --git a/web/handle_zip.php b/web/handle_zip.php new file mode 100644 index 0000000..5f8964e --- /dev/null +++ b/web/handle_zip.php @@ -0,0 +1,27 @@ +open($_GET['file']); +$stat = $zip->statIndex(0); + +if (!$mime = $types[pathinfo($stat['name'],PATHINFO_EXTENSION)]) { + $mime = "text/plain"; + } + +header("Content-Type: ".$mime); +header("Content-Length: ".$stat['size']); +echo $zip->getFromIndex(0); + +?> \ No newline at end of file diff --git a/web/rtc.php b/web/rtc.php index 388c456..988b31b 100644 --- a/web/rtc.php +++ b/web/rtc.php @@ -4,14 +4,14 @@ // Yuba RTC Browser ///////////////////////////////////////////////////////////////// -$browser_version = "0.7.9.2"; +$browser_version = "0.7.10.3"; require "togggle.php"; require "lib/debug.php"; -$db_dir = "skim"; -$icon_size = 64; -$pad = 28; +$db_dir = "data/skim"; +$icon_size = 96; +$pad = 40; ?> @@ -25,10 +25,16 @@ html { font-family: Helvetica; word-wrap: break-word; } div#exectime { position: absolute; right: 8px; top: 8px; } div.container { display: flex; flex-flow: row wrap; justify-content: center; } -div.item { width: px; height: px; padding: px; } +div.item { width: px; height: px; padding-bottom: } div.item { font-size: 11px; } -div.flexfill { width: px; height: 1px; } +div.flexfill { width: px; height: 1px; } div.aborted { text-decoration: line-through; } +.slider, .slow_slider { position: absolute !important; top: 50px; right: 10px; width: 200px; } +.controls { position: absolute !important; top: 85px; right: 10px; width: 30px; } +form { margin-block-end: 0em !important; } + +.arrow { font-size: 8px; opacity: .7; } +img.tiny { vertical-align: middle; width: 18px; height: 18px; margin: 0px 4px 0px 0px; } .red { background-color: #ea6c60; } .green { background-color: #9cde70; } @@ -66,9 +72,85 @@ a.hidden img { opacity: .3; } iframe { width: 425px; height: 550px; padding: 6px; border: 1px solid black; } +div.dblist { display: none; } + - + + + + + + + @@ -151,7 +233,7 @@ class plistParser extends XMLReader { case 'false': return false; break; case 'array': return $this->parse_array(); break; case 'dict': return $this->parse_dict(); break; - default: throw new Exception(sprintf("Not a valid plist. %s is not a valid type", $this->name), 4); + //default: throw new Exception(sprintf("Not a valid plist. %s is not a valid type", $this->name), 4); } } private function parse_dict() { @@ -191,9 +273,12 @@ function breadcrumbs($zpath, $pathname) { } function shortlabel($filename, $max = 40) { - $suffix = "(...).".pathinfo($filename)['extension']; - if (strlen($filename) > $max) { - $return = substr($filename, 0, ($max-strlen($suffix))).$suffix; + if (mb_strlen($filename, mb_detect_encoding($filename)) > $max) { + // more work is needed to figure out what is going on with non EN chars + //echo "(-) "; + $prefix = mb_substr($filename, 0, floor($max*.66), mb_detect_encoding($filename)); + $suffix = substr($filename, -floor($max*.33)); + $return = $prefix."...".$suffix; } else { $return = $filename; } @@ -219,9 +304,6 @@ $search = $_POST['query']; $parser = new plistParser(); if ($db_file) { - - echo "db list"; - echo "
"; if (!is_readable($db_file)) { echo "can't read db file"; die; } @@ -237,9 +319,10 @@ if ($db_file) { // Check for initial view + $view = $dbo->query("SELECT * FROM _skim")->fetch(); + if (!$pid) { $pid = $dbo->query("SELECT pid FROM family WHERE (rowid=2)")->fetch()['pid']; - $view = $dbo->query("SELECT * FROM _skim")->fetch(); // handle special strings $view['opts'] = unserialize($view['opts']); $view['qlmanage'] = "hidden"; //array($view['qlmanage']); @@ -264,6 +347,7 @@ if ($db_file) { if ($view['hdiutil']) { $view['hdiutil'] = $parser->parseString(utf8_for_xml($view['hdiutil'])); } + $view['Type'] = "dir"; } else { $view = $dbo->query("SELECT rowid, * FROM files WHERE (pid='".$pid."')")->fetch(); if (is_serial($view['stat'])) { @@ -271,6 +355,22 @@ if ($db_file) { } $dirmdls = $dbo->query("SELECT rowid, * FROM mdls WHERE (rowid='".$view['rowid']."')")->fetch(); } + + // Header + + echo "Home "; + $dbs = glob(pathinfo($_GET['db'],PATHINFO_DIRNAME)."/????-??-??_??-??-??.sqlite3"); + rsort($dbs); + echo ""; + echo "
"; // Breadcrumbs @@ -279,9 +379,14 @@ if ($db_file) { foreach ($crumb as $myparts) { if ($myparts[0] === null) { - $xc .= $myparts[1]; + if ($view['Type'] == "dir") { + $myicon = "icons/directory.png"; + } else { + $myicon = "icons/null.png"; + } + $xc .= "".$myparts[1]; } else { - $xc .= "".$myparts[1]." > "; + $xc .= "".$myparts[1]." "; } } if (!$search) { echo $xc; echo "
"; } @@ -450,29 +555,42 @@ if ($db_file) { } elseif (!$search) { + if (count($children) > 3000) { + echo "
"; + } else { + echo "
"; + } + + echo "
info
"; + echo "
"; echo "
"; - foreach ($children as $item) { + $spotlight_status = $dbo->query("SELECT mdutil FROM _skim")->fetch()['mdutil']; + + $sql = "SELECT mdls.*, files.*, milk.* FROM files "; + $sql .= "LEFT JOIN mdls ON (files.rowid = mdls.rowid) "; + $sql .= "LEFT JOIN milk ON (files.rowid = milk.rowid) "; + $sql .= "WHERE files.rowid IN (".implode(",",$children).") "; + $sql .= "ORDER BY files.Filename COLLATE NOCASE"; + + $rows = $dbo->query($sql)->fetchAll(); + + foreach ($rows as $item) { + //print_r($item); + + $myname = $item['Filename']; echo "
"; - - ///////////////////////// - $row_a = $dbo->query("SELECT rowid, * FROM files WHERE (rowid='".$item."')")->fetch(); - $row_b = $dbo->query("SELECT rowid, * FROM mdls WHERE (rowid='".$item."')")->fetch(); - //$row_c = $dbo->query("SELECT * FROM milk WHERE (rowid='".$item."')")->fetch(); - - ///////////////////////// - - if ($row_b['FSInvisible']) { + if ($item['FSInvisible'] | substr($item['Filename'],0,1) == ".") { $visibility = "hidden"; } else { $visibility = "unhidden"; } - if ($row_a['thumb_filename']) { - $aspect = $row_a['thumb_width']/$row_a['thumb_height']; + if ($item['thumb_filename']) { + $aspect = $item['thumb_width']/$item['thumb_height']; if ($aspect > 1) { $width = $icon_size; $height = $icon_size/$aspect; @@ -480,35 +598,35 @@ if ($db_file) { $width = $icon_size*$aspect; $height = $icon_size; } - $realfile = dirname($db_file).$row_a['thumb_filename']; - $icon = ""; - } elseif ($row_a['Type'] == "dir") { - $icon = ""; + $realfile = dirname($db_file).$item['thumb_filename']; + $icon = ""; + } elseif ($item['Type'] == "dir") { + $icon = ""; } else { - $icon = ""; + $icon = ""; } - echo "\n".$icon.""; + echo "\n".$icon.""; echo "
"; - if ($row_b['UserTags']) { - foreach (unserialize($row_b['UserTags']) as $tag) { + if ($item['UserTags']) { + foreach (unserialize($item['UserTags']) as $tag) { echo ""; } echo " "; } - echo htmlentities(shortlabel($row_a['Filename'])); + echo htmlentities(shortlabel($item['Filename'])); echo "
"; - if ($row_a['Size']) { - echo "
".human_filesize($row_a['Size'])."
"; + if ($item['Size']) { + echo "
".human_filesize($item['Size'])."
"; } - if ($row_a['Type'] == "dir" && $row_a['items']) { - echo "
".number_format($row_a['items'])." items
"; + if ($item['Type'] == "dir" && $item['items']) { + echo "
".number_format($item['items'])." items
"; } echo "
"; @@ -518,7 +636,7 @@ if ($db_file) { echo str_repeat("
", 100); echo "
"; - echo "
"; + echo "