From bae448657b0b133413c60d485caa9acbef52e6b0 Mon Sep 17 00:00:00 2001 From: profiteroles Date: Mon, 3 Sep 2018 03:40:31 -0700 Subject: [PATCH] 0.7.4 --- Yuba.php | 105 ++++++----- functions.php | 0 web/lib/debug.php | 451 ++++++++++++++++++++++++++++++++++++++++++++++ web/rtc.php | 185 ++++++++++++++----- web/rtc_patch.php | 85 --------- 5 files changed, 647 insertions(+), 179 deletions(-) mode change 100644 => 100755 Yuba.php mode change 100644 => 100755 functions.php create mode 100644 web/lib/debug.php delete mode 100644 web/rtc_patch.php diff --git a/Yuba.php b/Yuba.php old mode 100644 new mode 100755 index 7ed32e0..e99d531 --- a/Yuba.php +++ b/Yuba.php @@ -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,15 +338,20 @@ $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 + + if ($splFileInfo->getType() != "link") { + $stx[$i] = array( $splFileInfo->getATime(), + $splFileInfo->getMTime(), + $splFileInfo->getCTime() ); + } - //$family[$key]['parents'] = getParents($zpath, $pathname); + 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,8 +601,15 @@ 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)); + } } @@ -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; diff --git a/functions.php b/functions.php old mode 100644 new mode 100755 diff --git a/web/lib/debug.php b/web/lib/debug.php new file mode 100644 index 0000000..4597274 --- /dev/null +++ b/web/lib/debug.php @@ -0,0 +1,451 @@ +\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 .= "".$key.''; + } + else + { + $result .= ''.$key.''; + } + } + if (is_object($value) || (is_array($value) && count($value)>0)) + { + if (is_object($value)) + { + if ($plain) + { + $result .= " (".get_class($value).")"; + } + else + { + $result .= " ".get_class($value).""; + } + } + else + { + if ($plain) + { + $result .= " (array)"; + } + else + { + $result .= " array"; + } + } + if ($plain) + { + $result .= "\n"; + } + else + { + $collapse = !($level+1<=1 || $title===true || (is_string($title) && substr($title,0,1)=='*')); + $collapse = false; // hack + $result .= "\n
\n
".($collapse?'+':'-')."
"; + } + $result .= debug ($value, $title, $plain, $limit, $level+1); + if ($plain) + { + $result .= ""; + } + else + { + $result .= "
\n"; + } + + } + else + { + $result .= " : "; + if ($value===null) + { + if ($plain) + { + $result .= $color_cyan."null".$color_clear; + } + else + { + $result .= "null"; + } + } + else if (is_bool($value)) + { + if ($value) + { + if ($plain) + { + $result .= $color_purple_light."true".$color_clear; + } + else + { + + $result .= "true"; + } + } + else + { + if ($plain) + { + $result .= $color_purple_light."false".$color_clear; + } + else + { + $result .= "false"; + } + } + } + else if (is_integer($value) || is_float($value)) + { + if ($plain) + { + $result .= $color_red_light.$value.$color_clear; + } + else + { + $result .= "".$value.""; + } + } + else if (is_array($value)) + { + if ($plain) + { + $result .= "[]"; + } + else + { + $result .= "[]"; + } + } + else + { + if ($plain) + { + $result .= $color_green_light."\"".$value."\"".$color_clear; + } + else + { + $result .= "\"".htmlspecialchars ($value,ENT_NOQUOTES,'UTF-8')."\""; + } + } + if ($plain) + { + $result .= "\n"; + } + else + { + $result .= "
\n"; + } + } + } + if ($level>0) + { + return $result; + } + } + else + { + if ($object===null) + { + if ($plain) + { + $result = $color_cyan."null".$color_clear; + } + else + { + $result = "null"; + } + } + else if (is_bool($object)) + { + if ($object) + { + if ($plain) + { + $result = $color_purple_light."true".$color_clear; + } + else + { + + $result = "true"; + } + } + else + { + if ($plain) + { + $result = $color_purple_light."false".$color_clear; + } + else + { + $result = "false"; + } + } + } + else if (is_integer($object) || is_float($object)) + { + if ($plain) + { + $result = $color_red_light.$object.$color_clear; + } + else + { + $result = "".$object.""; + } + } + else if (is_array($object)) + { + if ($plain) + { + $result = "[]"; + } + else + { + $result = "[]"; + } + } + else + { + if ($plain) + { + $result = $color_green_light."\"".$object."\"".$color_clear; + } + else + { + $result = "\"".htmlspecialchars ($object,ENT_NOQUOTES,'UTF-8')."\""; + } + } + if ($plain) + { + $result .= "\n"; + } + else + { + $result .= "
\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 = "
"; + foreach ($trace as $key => $value) + { + if (isset($value['file']) && $value['line']) + { + $debug .= "".$value['file']." [".$value['line']."] ".$value['function']."
"; + } + else + { + $debug .= "".$value['function']."
"; + } + } + $debug .= "
"; + echo "
\n"; + echo "
".(($title && !is_bool($title))?$title:$type)."
\n"; + echo $result; + echo "
\n"; + } + } + +?> \ No newline at end of file diff --git a/web/rtc.php b/web/rtc.php index c3c346e..733cf7e 100644 --- a/web/rtc.php +++ b/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;