///////////////////////////////////////////////////////////////// // Skim RTC Browser ///////////////////////////////////////////////////////////////// require "togggle.php"; require "lib/debug.php"; $db_dir = "skim"; $icon_size = 64; $pad = 28; ?>
// Functions 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]; } class plistParser extends XMLReader { public function parseString($string) { $this->XML($string); return $this->process(); } private function process() { $this->read(); if($this->nodeType !== XMLReader::DOC_TYPE || $this->name !== "plist") { throw new Exception(sprintf("Error parsing plist. nodeType: %d -- Name: %s", $this->nodeType, $this->name), 2); } if(!$this->next("plist") || $this->nodeType !== XMLReader::ELEMENT || $this->name !== "plist") { throw new Exception(sprintf("Error parsing plist. nodeType: %d -- Name: %s", $this->nodeType, $this->name), 3); } $plist = array(); while($this->read()) { if($this->nodeType == XMLReader::ELEMENT) { $plist[] = $this->parse_node(); } } if(count($plist) == 1 && $plist[0]) { return $plist[0]; } else { return $plist; } } private function parse_node() { if($this->nodeType !== XMLReader::ELEMENT) return; switch($this->name) { case 'data': return base64_decode($this->getNodeText()); break; case 'real': return floatval($this->getNodeText()); break; case 'string': return $this->getNodeText(); break; case 'integer': return intval($this->getNodeText()); break; case 'date': return $this->getNodeText(); break; case 'true': return true; break; 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); } } private function parse_dict() { $array = array(); $this->nextOfType(XMLReader::ELEMENT); do { if($this->nodeType !== XMLReader::ELEMENT || $this->name !== "key") { if(!$this->next("key")) { return $array; } } $key = $this->getNodeText(); $this->nextOfType(XMLReader::ELEMENT); $array[$key] = $this->parse_node(); $this->nextOfType(XMLReader::ELEMENT, XMLReader::END_ELEMENT); } while($this->nodeType && !$this->isNodeOfTypeName(XMLReader::END_ELEMENT, "dict")); return $array; } private function parse_array() { $array = array(); $this->nextOfType(XMLReader::ELEMENT); do { $array[] = $this->parse_node(); $this->nextOfType(XMLReader::ELEMENT, XMLReader::END_ELEMENT); } while($this->nodeType && !$this->isNodeOfTypeName(XMLReader::END_ELEMENT, "array")); return $array; } private function getNodeText() { $string = $this->readString(); $this->nextOfType(XMLReader::END_ELEMENT); return $string; } private function nextOfType() { $types = func_get_args(); $this->read(); while($this->nodeType && !(in_array($this->nodeType, $types))) { $this->read(); } } private function isNodeOfTypeName($type, $name) { return $this->nodeType === $type && $this->name === $name; } } function breadcrumbs($zpath, $pathname) { if (!$pathname) { return array(array(null,basename($zpath))); } else { $pathname_adjusted = str_replace($zpath."/", "", $pathname); $parts = explode("/", $pathname_adjusted); $i = count($parts); while ($i) { $search_path = $zpath."/".implode("/", array_slice($parts, 0, $i)); if ($i == count($parts)) { $result[] = array(null, basename($search_path)); } else { $result[] = array(md5($search_path), basename($search_path)); } $i--; } $result[] = array("",basename($zpath)); return array_reverse($result); } } function shortlabel($filename, $max = 40) { $suffix = "(...).".pathinfo($filename)['extension']; if (strlen($filename) > $max) { $return = substr($filename, 0, ($max-strlen($suffix))).$suffix; } else { $return = $filename; } return $return; } function findicon($filename) { $ext = pathinfo($filename)['extension']; if (!$ext) { $good = "icons/directory.png"; } else { $good = "icons/null.png"; } foreach (glob("icons/*.png") as $file) { if (pathinfo($file)['filename'] == $ext) { $good = $file; } } return $good; } ///////////////////////////////////////////////////////////////// $db_file = $_GET['db']; $pid = $_GET['pid']; $search = $_POST['query']; if ($db_file) { echo "db list"; echo "| ";
$row_a = $dbo->query("SELECT * FROM files WHERE (pid='".$pid."')")->fetchAll()[0];
$row_b = $dbo->query("SELECT * FROM mdls WHERE (pid='".$pid."')")->fetchAll()[0];
$row_c = $dbx->query("SELECT * FROM exiftool WHERE (fid='".$row_a['fid']."')")->fetchAll()[0];
$row_d = $dbx->query("SELECT * FROM mediainfo WHERE (fid='".$row_a['fid']."')")->fetchAll()[0];
if ($row_a['thumb_filename']) {
$width = $row_a['thumb_width'];
$height = $row_a['thumb_height'];
$realfile = dirname($db_file).$row_a['thumb_filename'];
$icon = " | ";
echo ""; debug(array($row_a),"file"); if ($row_b) { $parser = new plistParser(); $row_b['spotlight'] = $parser->parseString($row_b['spotlight']); debug(array($row_b),"mdls"); } echo " | "; if ($row_c) { debug(array(unserialize($row_c['tags'])),"exiftool"); } if ($row_d) { debug(array(json_decode(json_encode(simplexml_load_string($row_d['info'])))),"mediainfo"); } echo " | "; echo "
| ";
echo " ";
foreach ($children as $item) {
echo " ";
echo "";
/////////////////////////
$row_a = $dbo->query("SELECT * FROM files WHERE (rowid='".$item."')")->fetchAll()[0];
$row_b = $dbo->query("SELECT * FROM mdls WHERE (rowid='".$item."')")->fetchAll()[0];
//$row_c = $dbo->query("SELECT * FROM milk WHERE (pid='".$item."')")->fetchAll()[0];
/////////////////////////
if ($row_a['thumb_filename']) {
$aspect = $row_a['thumb_width']/$row_a['thumb_height'];
if ($aspect > 1) {
$width = $icon_size;
$height = $icon_size/$aspect;
} else {
$width = $icon_size*$aspect;
$height = $icon_size;
}
$realfile = dirname($db_file).$row_a['thumb_filename'];
$icon = " ";
echo "".htmlentities(shortlabel($row_a['Filename']))." ";
if ($row_a['Size']) {
echo "".human_filesize($row_a['Size'])." ";
}
if ($row_a['Type'] == "dir" && $row_a['items']) {
echo "".$row_a['items']." items ";
}
echo ""; } echo str_repeat("", 100); echo " | "; debug($view,$view['Pathname']); echo " |