0.8.0.1
This commit is contained in:
113
helper.php
113
helper.php
@@ -4,6 +4,9 @@
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
|
||||
ini_set('memory_limit', '10240M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
|
||||
$prefs_file = "/Users/".get_current_user()."/Library/Preferences/org.profiteroles.Yuba.php";
|
||||
$p = unserialize(file_get_contents($prefs_file));
|
||||
|
||||
@@ -17,7 +20,7 @@ $dm = "";
|
||||
function dfm ($string, $flag = 0) {
|
||||
// dumb workaround for debug messages appearing out of order
|
||||
// uncomment next line to revert to instant message printing
|
||||
dm($string); return;
|
||||
//dm($string); return;
|
||||
|
||||
global $dm;
|
||||
if ($flag == 1) {
|
||||
@@ -29,13 +32,19 @@ function dfm ($string, $flag = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
$fid = $argv[1];
|
||||
$pathname = $argv[2];
|
||||
$bdone = $argv[1];
|
||||
$btotal = $argv[2];
|
||||
$fid = $argv[3];
|
||||
$pathname = $argv[4];
|
||||
$pid = md5($pathname);
|
||||
$shellpath = escapeshellarg($pathname);
|
||||
$ext = pathinfo($pathname,PATHINFO_EXTENSION);
|
||||
$file = pathinfo($pathname, PATHINFO_BASENAME);
|
||||
$bpath = $argv[3];
|
||||
$mytime = $argv[4];
|
||||
$btype = $argv[5];
|
||||
$bpath = $argv[6];
|
||||
$mytime = $argv[7];
|
||||
|
||||
$parser = new plistParser();
|
||||
|
||||
$stamp = date("Y-m-d_H-i-s", $mytime);
|
||||
$messages_log_file = $bpath."/".$stamp."_messages.log";
|
||||
@@ -43,6 +52,20 @@ $messages_log_file = $bpath."/".$stamp."_messages.log";
|
||||
$tmpdir = "/tmp/yuba/".$mytime;
|
||||
if (!is_dir($tmpdir)) { mkdir($tmpdir,0777,true); dfm("mkdir ",$tmpdir); }
|
||||
|
||||
// Main DB
|
||||
|
||||
$dbo = new PDO("sqlite:".$bpath."/".$stamp.".sqlite3");
|
||||
$dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
|
||||
//$dbo->query("PRAGMA page_size = 4096");
|
||||
//$dbo->query("PRAGMA cache_size = 10000");
|
||||
//$dbo->query("PRAGMA locking_mode = EXCLUSIVE");
|
||||
//$dbo->query("PRAGMA synchronous = NORMAL");
|
||||
$dbo->query("PRAGMA journal_mode = WAL");
|
||||
|
||||
// Pool DB
|
||||
|
||||
$dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbp->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
@@ -62,7 +85,7 @@ dfm("BATCH INIT ".$file.":".print_r($argv,true),2);
|
||||
// Thumbs //////////////////////////////////////////
|
||||
|
||||
thumbs:
|
||||
if ($p['thumbs']) {
|
||||
if ($p['thumbs'] && $btype == "file" && $ext != "DS_Store") {
|
||||
|
||||
dfm("THUMBS",1);
|
||||
|
||||
@@ -195,7 +218,7 @@ if ($p['thumbs']) {
|
||||
// Icons //////////////////////////////////////////
|
||||
|
||||
icons:
|
||||
if ($p['icons']) {
|
||||
if ($p['icons'] && ($btype == "file" || $btype == "dir") && $ext != "DS_Store") {
|
||||
|
||||
dfm("ICONS",1);
|
||||
|
||||
@@ -234,8 +257,7 @@ if ($p['icons']) {
|
||||
|
||||
}
|
||||
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
|
||||
$cmd['flacdiricon'] = $bin_flacdiricon." ".$shellpath." ".$p['icon_size']." ".$tfile;
|
||||
$cmd['flacicon'] = $bin_flacicon." ".$shellpath." ".$p['icon_size']." ".$tfile;
|
||||
$cmd['ql-icon'] = $bin_qlicon." --input=".$shellpath." --width=".$p['icon_size']." --height=".$p['icon_size']." | ".$bin_pngquant." - -o ".$tfile;
|
||||
$cmd['qltool'] = $bin_qltool." di ".$shellpath." ".$p['icon_size']." ".$p['icon_size']." | base64 --decode | ".$bin_convert." - -scale 50% - | ".$bin_pngquant." - -o ".$tfile;
|
||||
@@ -267,16 +289,25 @@ if ($p['icons']) {
|
||||
|
||||
} else {
|
||||
|
||||
if ($ext == "flac") {
|
||||
$tools = array("flacicon","ql-icon","qltool");
|
||||
if ($btype == "dir") {
|
||||
$stmt->BindValue(":fid",$pid);
|
||||
$tools = array("flacdiricon","qltool");
|
||||
} else {
|
||||
$tools = array("ql-icon","qltool");
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
if ($ext == "flac") {
|
||||
$tools = array("flacicon","ql-icon","qltool");
|
||||
} else {
|
||||
$tools = array("ql-icon","qltool");
|
||||
}
|
||||
}
|
||||
|
||||
unset($mytool);
|
||||
foreach ($tools as $tool) {
|
||||
if (!@filesize($tfile)) {
|
||||
shell_exec($cmd[$tool]." ".$redirect);
|
||||
dfm($cmd[$tool]);
|
||||
$estring .= " ->".$tool;
|
||||
$mytool = $tool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +340,7 @@ if ($p['icons']) {
|
||||
dfm("moving ".$tfile." to ".$dfile);
|
||||
$stmt->BindValue(":created",time());
|
||||
$stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));
|
||||
$stmt->BindValue(":tool",$tool);
|
||||
$stmt->BindValue(":tool",$mytool);
|
||||
$estring .= " ->use";
|
||||
|
||||
}
|
||||
@@ -317,7 +348,7 @@ if ($p['icons']) {
|
||||
} else {
|
||||
|
||||
$estring .= " ->discard";
|
||||
dfm($tool." produced a bad file (size=".$checksize.")");
|
||||
dfm($mytool." produced a bad file (size=".$checksize.")");
|
||||
|
||||
}
|
||||
|
||||
@@ -332,7 +363,7 @@ if ($p['icons']) {
|
||||
// Metadata //////////////////////////////////////////
|
||||
|
||||
meta:
|
||||
if ($p['meta']) {
|
||||
if ($p['meta'] && $btype == "file" && $ext != "DS_Store") {
|
||||
|
||||
dfm("META",1);
|
||||
|
||||
@@ -389,7 +420,7 @@ if ($p['meta']) {
|
||||
// Hash //////////////////////////////////////////
|
||||
|
||||
hashy:
|
||||
if ($p['hash']) {
|
||||
if ($p['hash'] && $btype == "file" && $ext != ".DS_Store") {
|
||||
|
||||
dfm("HASH",1);
|
||||
|
||||
@@ -423,7 +454,7 @@ if ($p['hash']) {
|
||||
// Contents //////////////////////////////////////////
|
||||
|
||||
contents:
|
||||
if ($p['contents']) {
|
||||
if ($p['contents'] && $btype == "file") {
|
||||
|
||||
dfm("CONTENTS",1);
|
||||
|
||||
@@ -463,6 +494,53 @@ if ($p['contents']) {
|
||||
}
|
||||
}
|
||||
|
||||
// Spotlight //////////////////////////////////////////
|
||||
|
||||
if ($p['spotlight']) {
|
||||
|
||||
dfm("SPOTLIGHT",1);
|
||||
$estring .= " SPOTLIGHT";
|
||||
|
||||
$cmd = "mdls -plist - ".$shellpath." ".$redirect;
|
||||
dfm($cmd);
|
||||
$mdls = shell_exec($cmd);
|
||||
|
||||
if (substr_count(@$mdls,"\n") > 1) {
|
||||
$spotlight = $parser->parseString(utf8_for_xml($mdls));
|
||||
} else {
|
||||
$spotlight = array();
|
||||
}
|
||||
|
||||
$stmt = $dbo->prepare("INSERT INTO mdls VALUES (:id,".implode(",",$ibuild).")");
|
||||
$stmt->BindValue(":id",$bdone+1);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$estring .= " ->db";
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
// Inserts //////////////////////////////////////////
|
||||
|
||||
dfm("SQL",1);
|
||||
@@ -471,5 +549,6 @@ foreach ($sbatch as $stmt) { $stmt->execute(); dfm($stmt->queryString); }
|
||||
|
||||
dm($dm);
|
||||
echo msg($estring,false);
|
||||
echo "\n"."PROGRESS:".round(($bdone/$btotal)*100,2)."\n";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user