0.7.4
This commit is contained in:
103
Yuba.php
Normal file → Executable file
103
Yuba.php
Normal file → Executable file
@@ -3,7 +3,7 @@
|
||||
// Yuba
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
$version = "0.7.3";
|
||||
$version = "0.7.4";
|
||||
|
||||
ini_set('memory_limit', '4096M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
@@ -312,7 +312,7 @@ $files = new RecursiveIteratorIterator(
|
||||
// Tally
|
||||
//////////////////////////////////////////
|
||||
|
||||
echo "Tally\n";
|
||||
echo "Counting files...\n";
|
||||
|
||||
foreach ($files as $null) { }
|
||||
$first_run = 0;
|
||||
@@ -322,45 +322,7 @@ if (!$passed_total) {
|
||||
die;
|
||||
}
|
||||
|
||||
// Permissions & Stat
|
||||
//////////////////////////////////////////
|
||||
|
||||
echo ProgressBar::start($passed_total,"Stat");
|
||||
|
||||
$i = 0;
|
||||
$noread = array();
|
||||
foreach ($files as $splFileInfo) {
|
||||
|
||||
$shellpath = escapeshellarg($splFileInfo->getPathname());
|
||||
$realpath = $splFileInfo->getRealPath();
|
||||
|
||||
if ($splFileInfo->getType() != "link") {
|
||||
$stx[$i] = array( $splFileInfo->getATime(),
|
||||
$splFileInfo->getMTime(),
|
||||
$splFileInfo->getCTime() );
|
||||
}
|
||||
$sty[$i] = chop(shell_exec("stat -x ".$shellpath." 2>&1"));
|
||||
|
||||
if ($realpath && !is_readable($realpath)) {
|
||||
$noread[] = $realpath;
|
||||
}
|
||||
|
||||
echo ProgressBar::next();
|
||||
$i++;
|
||||
|
||||
}
|
||||
|
||||
if (count($noread)) {
|
||||
foreach ($noread as $file) {
|
||||
echo "Current user (".posix_getuid().") does not have read access to ".$file."\n";
|
||||
}
|
||||
if ($p['readability']) {
|
||||
echo "Exiting...";
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
echo ProgressBar::finish();
|
||||
echo "Total files: ".$passed_total."\n";
|
||||
|
||||
// Pool DB
|
||||
//////////////////////////////////////////
|
||||
@@ -376,14 +338,19 @@ $dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, rela
|
||||
// Prescan
|
||||
//////////////////////////////////////////
|
||||
|
||||
$i = 0;
|
||||
$family = array();
|
||||
$fids = array();
|
||||
$noread = array();
|
||||
|
||||
echo ProgressBar::start($passed_total,"Prescan");
|
||||
|
||||
foreach ($files as $splFileInfo) {
|
||||
|
||||
$pathname = $splFileInfo->getPathname();
|
||||
$path = $splFileInfo->getPath();
|
||||
$pathname = $splFileInfo->getPathname();
|
||||
$shellpath = escapeshellarg($splFileInfo->getPathname());
|
||||
$realpath = $splFileInfo->getRealPath();
|
||||
|
||||
$key = md5($pathname);
|
||||
$pkey = md5($path);
|
||||
@@ -405,20 +372,51 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
}
|
||||
|
||||
// Parents
|
||||
// Cache stat values in stx array
|
||||
|
||||
//$family[$key]['parents'] = getParents($zpath, $pathname);
|
||||
if ($splFileInfo->getType() != "link") {
|
||||
$stx[$i] = array( $splFileInfo->getATime(),
|
||||
$splFileInfo->getMTime(),
|
||||
$splFileInfo->getCTime() );
|
||||
}
|
||||
|
||||
if ($p['bypass_stat']) {
|
||||
$sty[$i] = "bypass";
|
||||
} else {
|
||||
$sty[$i] = chop(shell_exec("stat -x ".$shellpath." 2>&1"));
|
||||
}
|
||||
|
||||
// Check file can be read
|
||||
|
||||
if ($realpath && !is_readable($realpath)) {
|
||||
$noread[] = $realpath;
|
||||
}
|
||||
|
||||
// Children
|
||||
|
||||
$family[$pkey]['children'][] = $key;
|
||||
//$family[$pkey]['children'][] = $key;
|
||||
$family[$pkey]['children'][] = $i+1;
|
||||
|
||||
echo ProgressBar::next();
|
||||
$i++;
|
||||
|
||||
}
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
// Thow permissions error
|
||||
|
||||
if (count($noread)) {
|
||||
"Current user (".posix_getuid().") does not have read access to the following files:";
|
||||
foreach ($noread as $file) {
|
||||
echo $file."\n";
|
||||
}
|
||||
if ($p['readability']) {
|
||||
echo "Exiting...";
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Debug record of duplicate FIDs
|
||||
|
||||
$dupes = array_filter($dx, function($a) { return count($a) > 1; });
|
||||
@@ -568,7 +566,7 @@ if ($p['thumbs']) {
|
||||
|
||||
if ($p['meta']) {
|
||||
|
||||
echo ProgressBar::start(count($fx),"Collecting external metadata");
|
||||
echo ProgressBar::start(count($fx),"Collecting external metadata...");
|
||||
|
||||
foreach ($fx as $array) {
|
||||
|
||||
@@ -576,12 +574,11 @@ if ($p['meta']) {
|
||||
$pathname = $array[1];
|
||||
$shellpath = escapeshellarg($pathname);
|
||||
$ext = pathinfo($pathname,PATHINFO_EXTENSION);
|
||||
$found = 1;
|
||||
|
||||
if (!in_array($ext, $e_files) && !in_array($ext, $m_files)) {
|
||||
echo ProgressBar::next("Not a media file: ".shortlabel($pathname));
|
||||
continue;
|
||||
} else {
|
||||
echo ProgressBar::next("Metadata: ".shortlabel($pathname));
|
||||
}
|
||||
|
||||
if (in_array($ext, $e_files)) {
|
||||
@@ -592,6 +589,7 @@ if ($p['meta']) {
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
$stmt->BindValue(":tags",serialize($rawexif[0]));
|
||||
$stmt->execute();
|
||||
$found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,9 +601,16 @@ if ($p['meta']) {
|
||||
//$stmt->BindValue(":info",serialize(parseMediaInfo(shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"))));
|
||||
$stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"));
|
||||
$stmt->execute();
|
||||
$found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
echo ProgressBar::next("Metadata found: ".shortlabel($pathname));
|
||||
} else {
|
||||
echo ProgressBar::next("Collecting metadata: ".shortlabel($pathname));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo ProgressBar::finish();
|
||||
@@ -971,7 +976,7 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
// Double check stat for file against pre-run value
|
||||
|
||||
if ($type != "link") {
|
||||
if ($p['verify_stat'] && $type != "link") {
|
||||
|
||||
$pre_access = $pre_modify = $pre_change = null;
|
||||
$post_access = $post_modify = $post_change = null;
|
||||
|
||||
0
functions.php
Normal file → Executable file
0
functions.php
Normal file → Executable file
451
web/lib/debug.php
Normal file
451
web/lib/debug.php
Normal file
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (c) 2016 hazardland
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
CHANGELOG
|
||||
|
||||
version 1.2
|
||||
----------------
|
||||
colorized output in php-cli mode
|
||||
added default plain text output in php-cli mode
|
||||
|
||||
version 1.1
|
||||
----------------
|
||||
fixed notices
|
||||
debug constant - comma separated list of allowed ip adresses to debug for (if defined)
|
||||
*/
|
||||
|
||||
/*
|
||||
HINTS
|
||||
|
||||
$title parameter
|
||||
--------------
|
||||
null/false - no title
|
||||
true - variable type as title
|
||||
"string" - custom title
|
||||
|
||||
$plain parameter
|
||||
--------------
|
||||
false - html output (default)
|
||||
true - plain text output (default in command line mode)
|
||||
"/path/to/file" - file output by append using plain mode
|
||||
|
||||
debug constant
|
||||
--------------
|
||||
if defined comma separated list of allowed ip adresses to debug for
|
||||
!defined('DEBUG') - debug for everyone
|
||||
const debug = '127.0.0.1,217.07.01.01'; - only clients from this two ips will see debug
|
||||
|
||||
|
||||
if you are logging in error log use to see nicely formated outupt:
|
||||
tail -f error_log | sed "s/\\\n/\\n/g"
|
||||
if you want just debug messages nicely formatted:
|
||||
tail -f error_log | grep --line-buffered "\n--" | sed "s/\\\n/\\n/g"
|
||||
|
||||
*/
|
||||
|
||||
function debug ($object, $title=null, $plain=false, $limit=6, $level=0)
|
||||
{
|
||||
if (defined('DEBUG') && ((isset($_SERVER['REMOTE_ADDR']) && !(debug==$_SERVER['REMOTE_ADDR'] || strpos(debug,$_SERVER['REMOTE_ADDR'].',')===0 || strpos(debug,','.$_SERVER['REMOTE_ADDR'].',')!==false || strpos(debug,','.$_SERVER['REMOTE_ADDR'])===strlen(debug)-strlen($_SERVER['REMOTE_ADDR'])-1)) || (!isset($_SERVER['REMOTE_ADDR']) && debug===false))
|
||||
)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if ($plain===false && php_sapi_name()==='cli')
|
||||
{
|
||||
$plain = true;
|
||||
}
|
||||
if (is_string($plain))
|
||||
{
|
||||
$color_black = "";
|
||||
$color_black_light = "";
|
||||
$color_red = "";
|
||||
$color_red_light = "";
|
||||
$color_green = "";
|
||||
$color_green_light = "";
|
||||
$color_yellow = "";
|
||||
$color_yellow_light = "";
|
||||
$color_blue = "";
|
||||
$color_blue_light = "";
|
||||
$color_purple = "";
|
||||
$color_purple_light = "";
|
||||
$color_cyan = "";
|
||||
$color_cyan_light = "";
|
||||
$color_gray = "";
|
||||
$color_gray_light = "";
|
||||
$color_clear = "";
|
||||
}
|
||||
else if ($plain===true)
|
||||
{
|
||||
$color_black = "\33[0;30m";
|
||||
$color_black_light = "\33[1;30m";
|
||||
$color_red = "\33[0;31m";
|
||||
$color_red_light = "\33[1;31m";
|
||||
$color_green = "\33[0;32m";
|
||||
$color_green_light = "\33[1;32m";
|
||||
$color_yellow = "\33[1;33m";
|
||||
$color_yellow_light = "\33[0;33m";
|
||||
$color_blue = "\33[0;34m";
|
||||
$color_blue_light = "\33[1;34m";
|
||||
$color_purple = "\33[0;35m";
|
||||
$color_purple_light = "\33[1;35m";
|
||||
$color_cyan = "\33[0;36m";
|
||||
$color_cyan_light = "\33[1;36m";
|
||||
$color_gray = "\33[0;37m";
|
||||
$color_gray_light = "\33[1;37m";
|
||||
$color_clear = "\033[0;39m";
|
||||
}
|
||||
$result = '';
|
||||
static $charset;
|
||||
if ($charset===null && !$plain)
|
||||
{
|
||||
echo "<meta charset=\"utf-8\">\n";
|
||||
$charset = true;
|
||||
}
|
||||
if ($level>$limit)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
return str_repeat(' ', 4*$level)."...\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
if (is_object($object) || (is_array($object) && count($object)>0))
|
||||
{
|
||||
foreach ($object as $key => $value)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= str_repeat(' ', 4*$level).$key;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($object))
|
||||
{
|
||||
$result .= "<span style='background:silver;padding-left:2px;padding-right:2px;'>".$key.'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= '<span>'.$key.'</span>';
|
||||
}
|
||||
}
|
||||
if (is_object($value) || (is_array($value) && count($value)>0))
|
||||
{
|
||||
if (is_object($value))
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= " (".get_class($value).")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:grey'> ".get_class($value)."</span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= " (array)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:grey'> array</span>";
|
||||
}
|
||||
}
|
||||
if ($plain)
|
||||
{
|
||||
$result .= "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$collapse = !($level+1<=1 || $title===true || (is_string($title) && substr($title,0,1)=='*'));
|
||||
$collapse = false; // hack
|
||||
$result .= "\n<div style='".($collapse?'height:12px':'').";margin-top:2px;margin-bottom:2px;border:1px solid grey;padding:3px;margin-left:15px;background-color:rgb(".(255-($level*10)).",".(255-($level*10)).",".(255-($level*10)).");overflow:hidden;'>\n<div id='tree' style='background-color:silver;font-size:9px;cursor:pointer;float:right;border:1px solid black;width:10px;height:10px;text-align:center;padding:0px;overflow:hidden;' onclick=\"if(this.parentNode.style.height=='12px'){this.parentNode.style.height='';this.innerHTML='-'}else{this.parentNode.style.height='12px';this.innerHTML='+'}\">".($collapse?'+':'-')."</div>";
|
||||
}
|
||||
$result .= debug ($value, $title, $plain, $limit, $level+1);
|
||||
if ($plain)
|
||||
{
|
||||
$result .= "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "</div>\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= " : ";
|
||||
if ($value===null)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= $color_cyan."null".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:blue'>null</span>";
|
||||
}
|
||||
}
|
||||
else if (is_bool($value))
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= $color_purple_light."true".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$result .= "<span style='color:green'>true</span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= $color_purple_light."false".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:red'>false</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (is_integer($value) || is_float($value))
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= $color_red_light.$value.$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:maroon'>".$value."</span>";
|
||||
}
|
||||
}
|
||||
else if (is_array($value))
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= "[]";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<span style='color:red'>[]</span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result .= $color_green_light."\"".$value."\"".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "\"".htmlspecialchars ($value,ENT_NOQUOTES,'UTF-8')."\"";
|
||||
}
|
||||
}
|
||||
if ($plain)
|
||||
{
|
||||
$result .= "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($level>0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($object===null)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = $color_cyan."null".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = "<span style='color:blue'>null</span>";
|
||||
}
|
||||
}
|
||||
else if (is_bool($object))
|
||||
{
|
||||
if ($object)
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = $color_purple_light."true".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$result = "<span style='color:green'>true</span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = $color_purple_light."false".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = "<span style='color:red'>false</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (is_integer($object) || is_float($object))
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = $color_red_light.$object.$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = "<span style='color:maroon'>".$object."</span>";
|
||||
}
|
||||
}
|
||||
else if (is_array($object))
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = "[]";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = "<span style='color:red'>[]</span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($plain)
|
||||
{
|
||||
$result = $color_green_light."\"".$object."\"".$color_clear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = "\"".htmlspecialchars ($object,ENT_NOQUOTES,'UTF-8')."\"";
|
||||
}
|
||||
}
|
||||
if ($plain)
|
||||
{
|
||||
$result .= "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= "<br>\n";
|
||||
}
|
||||
}
|
||||
if (is_null($object))
|
||||
{
|
||||
$type = 'null';
|
||||
}
|
||||
else if (is_bool($object))
|
||||
{
|
||||
$type = 'boolean';
|
||||
}
|
||||
else if (is_object($object))
|
||||
{
|
||||
$type = get_class($object);
|
||||
}
|
||||
else if (is_array($object))
|
||||
{
|
||||
$type = 'array';
|
||||
}
|
||||
else if (is_int($object))
|
||||
{
|
||||
$type = 'integer';
|
||||
}
|
||||
else if (is_float($object))
|
||||
{
|
||||
$type = 'float';
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = 'string';
|
||||
}
|
||||
if ($plain)
|
||||
{
|
||||
$header = '';
|
||||
if ($title)
|
||||
{
|
||||
$header = $color_cyan;
|
||||
$header .= "--------------------------------------\n";
|
||||
$header .= (is_bool($title) || $title===null)?$type:$title;
|
||||
$header .= "\n--------------------------------------\n";
|
||||
$header .= $color_clear;
|
||||
}
|
||||
if (is_string($plain))
|
||||
{
|
||||
if ($plain=='error_log')
|
||||
{
|
||||
error_log ("\n".$header.$result);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_put_contents ($plain, $header.$result, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $header.$result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$trace = debug_backtrace();
|
||||
$node = reset ($trace);
|
||||
$file = basename($node['file']).":".$node['line'];
|
||||
$debug = "<div>";
|
||||
foreach ($trace as $key => $value)
|
||||
{
|
||||
if (isset($value['file']) && $value['line'])
|
||||
{
|
||||
$debug .= "<a href='subl://".str_replace('\\','/',$value['file']).":".$value['line']."' style='color:black;text-decoration:none;'>".$value['file']."</a> [".$value['line']."] <font color=maroon>".$value['function']."</font><br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$debug .= "<font color=maroon>".$value['function']."</font><br>";
|
||||
}
|
||||
}
|
||||
$debug .= "</div>";
|
||||
echo "<div style='box-shadow: 5px 5px 5px #888888;background:#f1f1f1;z-index:9999;position:relative;font-family:courier;font-size:11px;line-height:normal!important;width:550px;border:1px solid grey;padding:3px;margin:10px;'>\n";
|
||||
echo "<div style='font-weight:bold;background-color:white;padding:3px;margin-bottom:5px;border:1px solid black;height:14px;overflow:hidden;'>".(($title && !is_bool($title))?$title:$type)."</div>\n";
|
||||
echo $result;
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
181
web/rtc.php
181
web/rtc.php
@@ -4,6 +4,9 @@
|
||||
// Yuba RTC Browser
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
require "lib/debug.php";
|
||||
|
||||
$db_dir = "skim";
|
||||
$icon_size = 64;
|
||||
$pad = 28;
|
||||
|
||||
@@ -13,8 +16,9 @@ $pad = 28;
|
||||
<head>
|
||||
<style>
|
||||
|
||||
html { word-wrap: break-word; }
|
||||
div.container { display: flex; flex-flow: row wrap; justify-content: center; }
|
||||
div.item { width: <?=$icon_size+$pad;?>px; height: <?=$icon_size+$pad;?>px; padding: <?=$pad;?>px; word-wrap: break-word; }
|
||||
div.item { width: <?=$icon_size+$pad;?>px; height: <?=$icon_size+$pad;?>px; padding: <?=$pad;?>px; }
|
||||
div.item { font-family: Helvetica; font-size: 11px; }
|
||||
div.flexfill { width: <?=$icon_size+($pad*3);?>px; height: 1px; }
|
||||
img.thumb { padding: 6px; border: 1px solid gainsboro; }
|
||||
@@ -29,7 +33,41 @@ img { margin-bottom: 8px; }
|
||||
|
||||
// Functions
|
||||
|
||||
function breadcrumbs() { }
|
||||
function XML2Array(SimpleXMLElement $parent)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
foreach ($parent as $name => $element) {
|
||||
($node = & $array[$name])
|
||||
&& (1 === count($node) ? $node = array($node) : 1)
|
||||
&& $node = & $node[];
|
||||
|
||||
$node = $element->count() ? XML2Array($element) : trim($element);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
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'];
|
||||
@@ -63,83 +101,142 @@ $pid = $_GET['pid'];
|
||||
|
||||
if ($db_file) {
|
||||
|
||||
// View
|
||||
echo "<a href='?db='>db list</a>";
|
||||
echo "<hr>";
|
||||
|
||||
if (!is_readable($db_file)) { echo "can't read db file"; die; }
|
||||
|
||||
echo "<a href='?db='>db list</a>";
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$dbo = new PDO("sqlite:".$db_file);
|
||||
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
|
||||
// Get zpath
|
||||
|
||||
$zpath = $dbo->query("SELECT zpath FROM _skim")->fetch()['zpath'];
|
||||
|
||||
// Check for initial view
|
||||
|
||||
if (!$pid) {
|
||||
$array = $dbo->query("SELECT children FROM family WHERE (rowid=2)")->fetch()['children'];
|
||||
$pid = $dbo->query("SELECT pid FROM family WHERE (rowid=2)")->fetch()['pid'];
|
||||
$view = $dbo->query("SELECT * FROM _skim")->fetchAll()[0];
|
||||
// hide long strings
|
||||
$view['qlmanage'] = "hidden";
|
||||
$view['disks'] = "hidden";
|
||||
$view['diskutil'] = "hidden";
|
||||
} else {
|
||||
$array = $dbo->query("SELECT children FROM family WHERE (pid='".$pid."')")->fetch()['children'];
|
||||
$view = $dbo->query("SELECT * FROM files WHERE (pid='".$pid."')")->fetchAll()[0];
|
||||
}
|
||||
|
||||
$children = unserialize($array);
|
||||
// Breadcrumbs
|
||||
|
||||
//echo "<pre>"; print_r($array); echo "</pre>";
|
||||
$crumb = breadcrumbs($zpath,$view['Pathname']);
|
||||
|
||||
foreach ($crumb as $myparts) {
|
||||
if ($myparts[0] === null) {
|
||||
echo $myparts[1];
|
||||
} else {
|
||||
echo "<a href='?db=".$db_file."&pid=".$myparts[0]."'>".$myparts[1]."</a> > ";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
echo "\n<div class='container'>";
|
||||
dsf
|
||||
print_r($children);
|
||||
$array = $dbo->query("SELECT children FROM family WHERE (pid='".$pid."')")->fetch()['children'];
|
||||
|
||||
if (count($children) < 1) { echo "dir is empty."; die; }
|
||||
$children = unserialize($array);
|
||||
|
||||
foreach ($children as $item) {
|
||||
if (!$children) {
|
||||
|
||||
echo "<div class='item'>";
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
$row_a = $dbo->query("SELECT * FROM files WHERE (pid='".$item."')")->fetchAll()[0];
|
||||
// File view
|
||||
|
||||
//$row_b = $dbo->query("SELECT * FROM mdls WHERE (pid='".$item."')")->fetchAll()[0];
|
||||
//$row_c = $dbo->query("SELECT * FROM milk WHERE (pid='".$item."')")->fetchAll()[0];
|
||||
echo "<table><tr>";
|
||||
|
||||
echo "<td valign='top'>";
|
||||
$row_a = $dbo->query("SELECT * FROM files WHERE (pid='".$pid."')")->fetchAll()[0];
|
||||
$row_b = $dbo->query("SELECT * FROM mdls WHERE (pid='".$pid."')")->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;
|
||||
}
|
||||
$width = $row_a['thumb_width'];
|
||||
$height = $row_a['thumb_height'];
|
||||
$realfile = dirname($db_file).$row_a['thumb_filename'];
|
||||
$icon = "<img class='thumb' src='".$realfile."' width='".$width."' height='".$height."'>";
|
||||
$icon = "<img src='".$realfile."' width='".$width."' height='".$height."'>";
|
||||
} else {
|
||||
$icon = "<img class='icon' src='".findicon($row_a['Filename'])."' width='".$icon_size."' height='".$icon_size."'>";
|
||||
$icon = "<img src='".findicon($row_a['Filename'])."' width='".$icon_size."' height='".$icon_size."'>";
|
||||
}
|
||||
|
||||
$name = htmlentities(shortlabel($row_a['Filename']));
|
||||
echo $icon;
|
||||
|
||||
echo "</td>";
|
||||
|
||||
echo "<td valign='top'>";
|
||||
debug($row_a,"file");
|
||||
echo "</td>";
|
||||
|
||||
//$row_b['spotlight'] = simplexml_load_string($row_b['spotlight'],LIBXML_NSCLEAN);
|
||||
|
||||
echo "<td valign='top'>";
|
||||
debug($row_b,"mdls");
|
||||
echo "</td>";
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// Dir view
|
||||
|
||||
} else {
|
||||
|
||||
echo "<table><tr><td valign='top'>";
|
||||
echo "<div class='container'>";
|
||||
|
||||
foreach ($children as $item) {
|
||||
|
||||
echo "<div class='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];
|
||||
|
||||
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 = "<img class='thumb' src='".$realfile."' width='".$width."' height='".$height."'>";
|
||||
} else {
|
||||
$icon = "<img class='icon' src='".findicon($row_a['Filename'])."' width='".$icon_size."' height='".$icon_size."'>";
|
||||
}
|
||||
|
||||
$name = htmlentities(shortlabel($row_a['Filename']));
|
||||
|
||||
if ($row_a['Type'] == "dir") {
|
||||
echo "\n<a href='?db=".$db_file."&pid=".$row_a['pid']."'>".$icon."</a><br>".$name;
|
||||
} else {
|
||||
echo $icon."<br>".$name;
|
||||
|
||||
echo "</div>";
|
||||
echo "<br>";
|
||||
|
||||
}
|
||||
|
||||
echo str_repeat("<div class='flexfill'></div>", 100);
|
||||
echo "</div>";
|
||||
echo "<br>";
|
||||
echo "</td><td valign='top'>";
|
||||
debug($view,$view['Pathname']);
|
||||
echo "</td></tr></table>";
|
||||
|
||||
}
|
||||
|
||||
echo str_repeat("<div class='flexfill'></div>", 100);
|
||||
echo "\n</div>";
|
||||
|
||||
} else {
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// DB List
|
||||
|
||||
$bundles = glob("skim/*.bundle");
|
||||
$bundles = glob($db_dir."/*.bundle");
|
||||
foreach ($bundles as $bundle) {
|
||||
echo "<h2>".pathinfo($bundle)['filename']."</h2>";
|
||||
$dbs = glob($bundle."/*.sqlite3");
|
||||
@@ -147,9 +244,9 @@ if ($db_file) {
|
||||
if (!strpos($db_file,"pool")) {
|
||||
echo "<a href='?db=".$db_file."'>".pathinfo($db_file)['filename']."</a> ";
|
||||
$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 $dbo->query("SELECT type FROM _skim")->fetch()['type'].", ";
|
||||
echo $dbo->query("SELECT passed_total FROM _skim")->fetch()['passed_total']." files, ";
|
||||
echo $dbo->query("SELECT status FROM _skim")->fetch()['status'];
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?
|
||||
|
||||
// A viewer for older DBs that were patched with an index
|
||||
|
||||
// Functions
|
||||
|
||||
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);
|
||||
|
||||
echo "<pre>"; echo "pathname = ".$pathname; print_r($parts);
|
||||
|
||||
while ($i) {
|
||||
$search_path = $zpath."/".implode("/", array_slice($parts, 0, $i));
|
||||
$id = $dbo->query("SELECT id FROM files WHERE (Pathname='".str_replace("'", "''", $search_path)."')")->fetch()['id'];
|
||||
if ($i == count($parts)) {
|
||||
$result[] = array(null, basename($search_path));
|
||||
} else {
|
||||
$result[] = array($id, basename($search_path));
|
||||
}
|
||||
$i--;
|
||||
}
|
||||
|
||||
if ($pathname == $zpath) {
|
||||
return array(array(null,basename($zpath)));
|
||||
} else {
|
||||
$result[] = array("1",basename($zpath));
|
||||
return array_reverse($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
// View
|
||||
|
||||
$id = $_GET['id'];
|
||||
if (!$id) { $id = 1; }
|
||||
$db_file = "db/patch.sqlite3";
|
||||
|
||||
$dbo = new PDO("sqlite:".$db_file);
|
||||
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
|
||||
//echo $dbo->query("SELECT COUNT(1) FROM files")->fetch()['COUNT(1)']." files<hr>";
|
||||
|
||||
$view = $dbo->query("SELECT * FROM files WHERE (rowid=".$id.")")->fetchAll()[0];
|
||||
|
||||
print_r($view);
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$crumb = breadcrumbs($dbo, $view['Pathname']);
|
||||
|
||||
foreach ($crumb as $myparts) {
|
||||
if ($myparts[0] === null) {
|
||||
echo $myparts[1];
|
||||
} else {
|
||||
echo "<a href='?id=".$myparts[0]."'>".$myparts[1]."</a> > ";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$items = unserialize($dbo->query("SELECT children FROM patch WHERE (rowid=".$id.")")->fetch()['children']);
|
||||
|
||||
foreach ($items as $id) {
|
||||
$row_a = $dbo->query("SELECT * FROM files WHERE (rowid='".$id."')")->fetchAll()[0];
|
||||
$row_b = $dbo->query("SELECT * FROM mdls WHERE (rowid='".$id."')")->fetchAll()[0];
|
||||
$row_c = $dbo->query("SELECT * FROM metadata WHERE (rowid='".$id."')")->fetchAll()[0];
|
||||
if (!$row_a['Extension']) {
|
||||
echo "<a href='?id=".$id."'>".$row_a['Filename']."</a> ";
|
||||
} else {
|
||||
echo $row_a['Filename']." ";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
echo "<hr>".round(microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"],2)." seconds<br><hr><br>";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user