0.7.12
This commit is contained in:
53
Yuba.php
53
Yuba.php
@@ -3,7 +3,7 @@
|
||||
// Yuba
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
$version = "0.7.11.5";
|
||||
$version = file_get_contents(__DIR__."/version.txt");
|
||||
|
||||
ini_set('memory_limit', '10240M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
@@ -11,7 +11,9 @@ date_default_timezone_set("America/Los_Angeles");
|
||||
// Includes & Prefs
|
||||
//////////////////////////////////////////
|
||||
|
||||
$p = unserialize(file_get_contents("prefs.php"));
|
||||
$p = unserialize(file_get_contents(__DIR__."/prefs.php"));
|
||||
|
||||
$p['phpbin'] = "/usr/bin/php";
|
||||
|
||||
require("functions.php");
|
||||
require("filetypes.php");
|
||||
@@ -21,6 +23,33 @@ $wopt_currstep = 1;
|
||||
|
||||
$parser = new plistParser();
|
||||
|
||||
// Menu options
|
||||
//////////////////////////////////////////
|
||||
|
||||
// Preferences
|
||||
|
||||
if (@$argv[1] == "Preferences...") {
|
||||
exec($p['phpbin']." ".__DIR__."/YubaPrefs.php 2>&1");
|
||||
die;
|
||||
}
|
||||
|
||||
// Version check
|
||||
|
||||
if (@$argv[1] == "Check for Updates...") {
|
||||
|
||||
$curr_version = file_get_contents("http://git.profiteroles.org/profiteroles/Yuba/raw/branch/master/version.txt");
|
||||
if ($curr_version > $version) {
|
||||
if(askMulti("Yuba ".$curr_version." is available (you have ".$version.")", array("Cancel","Download")) == 1) {
|
||||
exec("open http://git.profiteroles.org/profiteroles/Yuba");
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
alert($version." is the latest version","Up-to-date");
|
||||
die;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Path & application variables
|
||||
//////////////////////////////////////////
|
||||
|
||||
@@ -28,8 +57,8 @@ $stamp = date("Y-m-d_H-i-s", time());
|
||||
|
||||
if (!isset($argv[1])) { echo "No input"; die; }
|
||||
$zpath = realpath(@$argv[1]);
|
||||
if (@$argv[2]) { $bdest = realpath($argv[2]); } else { $bdest = realpath($p['bdest']); }
|
||||
if (!is_dir($zpath) | !is_dir($bdest)) { echo "Filepath error"; die; }
|
||||
if ($p['bdest']) { $bdest = realpath($p['bdest']); } else { $bdest = "/Users/".get_current_user()."/Documents/Yuba/"; }
|
||||
if (!is_dir($bdest)) { if (!mkdir($bdest)) { echo "Error creating directory: ".$bdest; die; } }
|
||||
|
||||
// Check for bundle
|
||||
if ($zpath == "/") { $blabel = "root"; } else { $blabel = preg_replace("/[^A-Za-z0-9\.]/", "_", basename($zpath)); }
|
||||
@@ -48,7 +77,6 @@ $bin_ffmpeg = __DIR__."/bin/ffmpeg";
|
||||
$bin_qlthumb = __DIR__."/bin/ql-thumbnail";
|
||||
|
||||
// Logfile
|
||||
|
||||
$messages_log_file = $bpath."/".$stamp."_messages.log";
|
||||
$error_log_file = $bpath."/".$stamp."_error.log";
|
||||
error_reporting(E_ALL);
|
||||
@@ -59,6 +87,8 @@ ini_set("error_log", $error_log_file);
|
||||
// Banner
|
||||
//////////////////////////////////////////
|
||||
|
||||
if (!is_dir($zpath) | !is_dir($bdest)) { echo "Filepath error"; die; }
|
||||
|
||||
$banner = "Yuba: ".$zpath." -> ".$bpath;
|
||||
echo msg($banner."\n".str_repeat("-", strlen($banner)));
|
||||
|
||||
@@ -509,9 +539,7 @@ if ($p['thumbs']) {
|
||||
if (!is_dir($tpath)) { mkdir($tpath); }
|
||||
$tfile = $tpath."/".$fid.".jpg";
|
||||
|
||||
// HACK for ql-thumbnail bug
|
||||
$t_skip = array("emlx","flac");
|
||||
if (count($t_skip) && in_array($ext, $t_skip)) {
|
||||
if (count($p['t_skip']) && in_array($ext, $p['t_skip'])) {
|
||||
echo ProgressBar::next("Skipping ".shortlabel($pathname));
|
||||
continue;
|
||||
}
|
||||
@@ -589,7 +617,8 @@ if ($p['contents']) {
|
||||
$cfile = $cpath."/".$fid.".zip";
|
||||
if (in_array($ext, $p['c_files'])) {
|
||||
if (!is_dir($cpath)) { mkdir($cpath); }
|
||||
if (!file_exists($cfile) && filesize($pathname) < 25000) {
|
||||
$max_size = $p['contents_limit'] * 1000;
|
||||
if (!file_exists($cfile) && filesize($pathname) < $max_size) {
|
||||
|
||||
msg("Zipping ".$pathname);
|
||||
|
||||
@@ -972,7 +1001,7 @@ foreach ($files as $splFileInfo) {
|
||||
$yes_contents = $dbp->query("SELECT relative_path FROM contents WHERE fid='".$fid."'")->fetch()[0];
|
||||
$stmt->BindValue(":contents_filename",$yes_contents);
|
||||
|
||||
if (!in_array($extension, $t_skip)) {
|
||||
if (!in_array($extension, $p['t_skip'])) {
|
||||
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$fid."'")->fetch();
|
||||
}
|
||||
if (@$fetch_thumb['relative_path']) {
|
||||
@@ -1188,7 +1217,7 @@ $dbo->exec("UPDATE _skim SET status='completed_in_".$seconds."'");
|
||||
|
||||
// rsync
|
||||
|
||||
if ($p['rsync_dest']) {
|
||||
if ($p['postflight'] == 2 && $p['rsync_dest']) {
|
||||
echo msg("rsync...");
|
||||
$command = "rsync -avv -e ssh ".$bpath." ".$p['rsync_dest'];
|
||||
$count = trim(shell_exec("find ".escapeshellarg($bpath)." | wc -l"));
|
||||
@@ -1197,6 +1226,8 @@ if ($p['rsync_dest']) {
|
||||
while(fgets($pipe, 2048)) { echo ProgressBar::next(true); }
|
||||
pclose($pipe);
|
||||
echo ProgressBar::finish();
|
||||
} elseif ($p['postflight'] == 1) {
|
||||
exec("open -R ".escapeshellarg($bpath));
|
||||
}
|
||||
|
||||
$done = "Finished ".$zpath." in ".$seconds." seconds";
|
||||
|
||||
Reference in New Issue
Block a user