Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario 2017-12-27 16:45:33 +01:00
commit 4a71fb0831
5 changed files with 40 additions and 10 deletions

View File

@ -691,7 +691,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
} }
$prefix = ''; $prefix = '';
$suffix = ''; $suffix = ' order by is_dir desc, filename asc ';
$r = q("select $prefix id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, created, edited from attach where folder = '%s' and uid = %d $perms $suffix", $r = q("select $prefix id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, created, edited from attach where folder = '%s' and uid = %d $perms $suffix",
dbesc($folder), dbesc($folder),

View File

@ -32,12 +32,18 @@ class Video {
fclose($ostream); fclose($ostream);
} }
/*
* Note: imagick convert may try to call 'ffmpeg' (or other conversion utilities) under
* the covers for this particular operation. If this is not installed or not in the path
* for the web server user, errors may be reported in the web server logs.
*/
$imagick_path = get_config('system','imagick_convert_path'); $imagick_path = get_config('system','imagick_convert_path');
if($imagick_path && @file_exists($imagick_path)) { if($imagick_path && @file_exists($imagick_path)) {
$cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile);
// logger('imagick thumbnail command: ' . $cmd); // logger('imagick thumbnail command: ' . $cmd);
exec($cmd); @exec($cmd);
if(! file_exists($outfile)) { if(! file_exists($outfile)) {
logger('imagick scale failed.'); logger('imagick scale failed.');

View File

@ -550,6 +550,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$type = $f['type']; $type = $f['type'];
} else { } else {
if(! x($_FILES,'userfile')) { if(! x($_FILES,'userfile')) {
logger('No source file');
$ret['message'] = t('No source file.'); $ret['message'] = t('No source file.');
return $ret; return $ret;
} }
@ -590,6 +591,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
intval($channel_id) intval($channel_id)
); );
if(! $x) { if(! $x) {
logger('update file source not found');
$ret['message'] = t('Cannot locate file to revise/update'); $ret['message'] = t('Cannot locate file to revise/update');
return $ret; return $ret;
} }
@ -731,6 +733,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$maxfilesize = get_config('system','maxfilesize'); $maxfilesize = get_config('system','maxfilesize');
if(($maxfilesize) && ($filesize > $maxfilesize)) { if(($maxfilesize) && ($filesize > $maxfilesize)) {
logger('quota_exceeded');
$ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize); $ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize);
if($remove_when_processed) if($remove_when_processed)
@unlink($src); @unlink($src);
@ -751,6 +754,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
intval($channel['channel_account_id']) intval($channel['channel_account_id'])
); );
if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) {
logger('service_class limit exceeded');
$ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000); $ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000);
if($remove_when_processed) if($remove_when_processed)
@unlink($src); @unlink($src);
@ -783,8 +787,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$os_path = $os_relpath; $os_path = $os_relpath;
$display_path = ltrim($pathname . '/' . $filename,'/'); $display_path = ltrim($pathname . '/' . $filename,'/');
if($src) if($src) {
@file_put_contents($os_basepath . $os_relpath,@file_get_contents($src)); $istream = @fopen($src,'rb');
$ostream = @fopen($os_basepath . $os_relpath,'wb');
if($istream && $ostream) {
pipe_streams($istream,$ostream,65535);
fclose($istream);
fclose($ostream);
}
}
if(array_key_exists('created', $arr)) if(array_key_exists('created', $arr))
$created = $arr['created']; $created = $arr['created'];

View File

@ -313,12 +313,25 @@ function dir_tagadelic($count = 0) {
$count = intval($count); $count = intval($count);
// Fetch tags $dirmode = get_config('system','directory_mode');
$r = q("select xtag_term as term, count(xtag_term) as total from xtag where xtag_flags = 0
group by xtag_term order by total desc %s",
((intval($count)) ? "limit $count" : '')
);
if($dirmode == DIRECTORY_MODE_STANDALONE) {
// Fetch tags
$r = q("select xtag_term as term, count(xtag_term) as total from xtag
left join hubloc on xtag_hash = hubloc_hash
where xtag_flags = 0 and hubloc_url = '%s'
group by xtag_term order by total desc %s",
dbesc(z_root()),
((intval($count)) ? "limit $count" : '')
);
}
else {
// Fetch tags
$r = q("select xtag_term as term, count(xtag_term) as total from xtag where xtag_flags = 0
group by xtag_term order by total desc %s",
((intval($count)) ? "limit $count" : '')
);
}
if(! $r) if(! $r)
return array(); return array();

View File

@ -14,7 +14,7 @@ require_once('include/attach.php');
cli_startup(); cli_startup();
if($argc <= 3) { if($argc < 3) {
echo "Usage: " . $argv[0] . ' src dstdir' . "\n"; echo "Usage: " . $argv[0] . ' src dstdir' . "\n";
echo 'Always run from the toplevel web directory.' . "\n"; echo 'Always run from the toplevel web directory.' . "\n";
echo 'destination should begin with store/$nickname/desired/path or $nickname/desired/path' . "\n"; echo 'destination should begin with store/$nickname/desired/path or $nickname/desired/path' . "\n";